summaryrefslogtreecommitdiffstats
path: root/src/test/ui/rust-2021/inherent-dyn-collision.fixed
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
commit64d98f8ee037282c35007b64c2649055c56af1db (patch)
tree5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /src/test/ui/rust-2021/inherent-dyn-collision.fixed
parentAdding debian version 1.67.1+dfsg1-1. (diff)
downloadrustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz
rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/rust-2021/inherent-dyn-collision.fixed')
-rw-r--r--src/test/ui/rust-2021/inherent-dyn-collision.fixed53
1 files changed, 0 insertions, 53 deletions
diff --git a/src/test/ui/rust-2021/inherent-dyn-collision.fixed b/src/test/ui/rust-2021/inherent-dyn-collision.fixed
deleted file mode 100644
index 5789a9039..000000000
--- a/src/test/ui/rust-2021/inherent-dyn-collision.fixed
+++ /dev/null
@@ -1,53 +0,0 @@
-// Test case where the method we want is an inherent method on a
-// dyn Trait. In that case, the fix is to insert `*` on the receiver.
-//
-// check-pass
-// run-rustfix
-// edition:2018
-
-#![warn(rust_2021_prelude_collisions)]
-
-trait TryIntoU32 {
- fn try_into(&self) -> Result<u32, ()>;
-}
-
-impl TryIntoU32 for u8 {
- // note: &self
- fn try_into(&self) -> Result<u32, ()> {
- Ok(22)
- }
-}
-
-mod inner {
- use super::get_dyn_trait;
-
- // note: this does nothing, but is copying from ffishim's problem of
- // having a struct of the same name as the trait in-scope, while *also*
- // implementing the trait for that struct but **without** importing the
- // trait itself into scope
- struct TryIntoU32;
-
- impl super::TryIntoU32 for TryIntoU32 {
- fn try_into(&self) -> Result<u32, ()> {
- Ok(0)
- }
- }
-
- // this is where the gross part happens. since `get_dyn_trait` returns
- // a Box<dyn Trait>, it can still call the method for `dyn Trait` without
- // `Trait` being in-scope. it might even be possible to make the trait itself
- // entirely unreference-able from the callsite?
- pub fn test() -> u32 {
- (&*get_dyn_trait()).try_into().unwrap()
- //~^ WARNING trait method `try_into` will become ambiguous
- //~| WARNING this is accepted in the current edition
- }
-}
-
-fn get_dyn_trait() -> Box<dyn TryIntoU32> {
- Box::new(3u8) as Box<dyn TryIntoU32>
-}
-
-fn main() {
- dbg!(inner::test());
-}