summaryrefslogtreecommitdiffstats
path: root/tests/ui/traits/suggest-fully-qualified-path-without-adjustment.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
commit218caa410aa38c29984be31a5229b9fa717560ee (patch)
treec54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/ui/traits/suggest-fully-qualified-path-without-adjustment.rs
parentReleasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz
rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/traits/suggest-fully-qualified-path-without-adjustment.rs')
-rw-r--r--tests/ui/traits/suggest-fully-qualified-path-without-adjustment.rs64
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/ui/traits/suggest-fully-qualified-path-without-adjustment.rs b/tests/ui/traits/suggest-fully-qualified-path-without-adjustment.rs
new file mode 100644
index 000000000..da640c8c8
--- /dev/null
+++ b/tests/ui/traits/suggest-fully-qualified-path-without-adjustment.rs
@@ -0,0 +1,64 @@
+use std::ops::{Deref, DerefMut};
+
+struct Thing;
+
+trait Method<T> {
+ fn method(&self) -> T;
+ fn mut_method(&mut self) -> T;
+}
+
+impl Method<i32> for Thing {
+ fn method(&self) -> i32 { 0 }
+ fn mut_method(&mut self) -> i32 { 0 }
+}
+
+impl Method<u32> for Thing {
+ fn method(&self) -> u32 { 0 }
+ fn mut_method(&mut self) -> u32 { 0 }
+}
+
+trait MethodRef<T> {
+ fn by_self(self);
+}
+impl MethodRef<i32> for &Thing {
+ fn by_self(self) {}
+}
+impl MethodRef<u32> for &Thing {
+ fn by_self(self) {}
+}
+
+struct DerefsTo<T>(T);
+impl<T> Deref for DerefsTo<T> {
+ type Target = T;
+ fn deref(&self) -> &Self::Target {
+ &self.0
+ }
+}
+impl<T> DerefMut for DerefsTo<T> {
+ fn deref_mut(&mut self) -> &mut Self::Target {
+ &mut self.0
+ }
+}
+
+fn main() {
+ let mut ref_thing = &Thing;
+ ref_thing.method();
+ //~^ ERROR type annotations needed
+ //~| ERROR type annotations needed
+ ref_thing.by_self(); //~ ERROR type annotations needed
+
+ let mut mut_thing = &mut Thing;
+ mut_thing.method(); //~ ERROR type annotations needed
+ mut_thing.mut_method(); //~ ERROR type annotations needed
+ mut_thing.by_self(); //~ ERROR type annotations needed
+
+ let mut deref_to = &DerefsTo(Thing);
+ deref_to.method(); //~ ERROR type annotations needed
+ deref_to.mut_method(); //~ ERROR type annotations needed
+ deref_to.by_self(); //~ ERROR type annotations needed
+
+ let mut deref_deref_to = &DerefsTo(DerefsTo(Thing));
+ deref_deref_to.method(); //~ ERROR type annotations needed
+ deref_deref_to.mut_method(); //~ ERROR type annotations needed
+ deref_deref_to.by_self(); //~ ERROR type annotations needed
+}