summaryrefslogtreecommitdiffstats
path: root/src/test/ui/span/issue-7575.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/test/ui/span/issue-7575.rs
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/span/issue-7575.rs')
-rw-r--r--src/test/ui/span/issue-7575.rs75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/test/ui/span/issue-7575.rs b/src/test/ui/span/issue-7575.rs
new file mode 100644
index 000000000..eddd158ae
--- /dev/null
+++ b/src/test/ui/span/issue-7575.rs
@@ -0,0 +1,75 @@
+// Test the mechanism for warning about possible missing `self` declarations.
+trait CtxtFn {
+ fn f8(self, _: usize) -> usize;
+ fn f9(_: usize) -> usize;
+}
+
+trait OtherTrait {
+ fn f9(_: usize) -> usize;
+}
+
+// Note: this trait is not implemented, but we can't really tell
+// whether or not an impl would match anyhow without a self
+// declaration to match against, so we wind up prisizeing it as a
+// candidate. This seems not unreasonable -- perhaps the user meant to
+// implement it, after all.
+trait UnusedTrait {
+ fn f9(_: usize) -> usize;
+}
+
+impl CtxtFn for usize {
+ fn f8(self, i: usize) -> usize {
+ i * 4
+ }
+
+ fn f9(i: usize) -> usize {
+ i * 4
+ }
+}
+
+impl OtherTrait for usize {
+ fn f9(i: usize) -> usize {
+ i * 8
+ }
+}
+
+struct Myisize(isize);
+
+impl Myisize {
+ fn fff(i: isize) -> isize {
+ i
+ }
+}
+
+trait ManyImplTrait {
+ fn is_str() -> bool {
+ false
+ }
+}
+
+impl ManyImplTrait for String {
+ fn is_str() -> bool {
+ true
+ }
+}
+
+impl ManyImplTrait for usize {}
+impl ManyImplTrait for isize {}
+impl ManyImplTrait for char {}
+impl ManyImplTrait for Myisize {}
+
+fn no_param_bound(u: usize, m: Myisize) -> usize {
+ u.f8(42) + u.f9(342) + m.fff(42)
+ //~^ ERROR no method named `f9` found
+ //~| ERROR no method named `fff` found
+
+
+}
+
+fn param_bound<T: ManyImplTrait>(t: T) -> bool {
+ t.is_str()
+ //~^ ERROR no method named `is_str` found
+}
+
+fn main() {
+}