about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-12-16 14:02:18 +0100
committerGitHub <noreply@github.com>2022-12-16 14:02:18 +0100
commitcc04e97cfbc3946a5b4a28ba07f47438e34ea99a (patch)
tree3f3f19ce139eb0320158f2b12540f0d3487dcc72 /src
parent3b9aea967f69fd96fce7a2861d953fe10004ef5f (diff)
parent605f77b7d0cb991f2f63c02ceb9dfea72091f398 (diff)
downloadrust-cc04e97cfbc3946a5b4a28ba07f47438e34ea99a.tar.gz
rust-cc04e97cfbc3946a5b4a28ba07f47438e34ea99a.zip
Rollup merge of #105747 - chenyukang:yukang/fix-105732-auto-trait, r=compiler-errors
Fix ICE calling method on auto trait

Fixes #105732
r? `@compiler-errors`
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/methods/issues/issue-105732.rs13
-rw-r--r--src/test/ui/methods/issues/issue-105732.stderr28
2 files changed, 41 insertions, 0 deletions
diff --git a/src/test/ui/methods/issues/issue-105732.rs b/src/test/ui/methods/issues/issue-105732.rs
new file mode 100644
index 00000000000..98b7a8d0d04
--- /dev/null
+++ b/src/test/ui/methods/issues/issue-105732.rs
@@ -0,0 +1,13 @@
+#![feature(auto_traits)]
+
+auto trait Foo {
+    fn g(&self); //~ ERROR auto traits cannot have associated items
+}
+
+trait Bar {
+    fn f(&self) {
+        self.g(); //~ ERROR the method `g` exists for reference `&Self`, but its trait bounds were not satisfied
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/methods/issues/issue-105732.stderr b/src/test/ui/methods/issues/issue-105732.stderr
new file mode 100644
index 00000000000..fb2bdf47de7
--- /dev/null
+++ b/src/test/ui/methods/issues/issue-105732.stderr
@@ -0,0 +1,28 @@
+error[E0380]: auto traits cannot have associated items
+  --> $DIR/issue-105732.rs:4:8
+   |
+LL | auto trait Foo {
+   |            --- auto trait cannot have associated items
+LL |     fn g(&self);
+   |     ---^-------- help: remove these associated items
+
+error[E0599]: the method `g` exists for reference `&Self`, but its trait bounds were not satisfied
+  --> $DIR/issue-105732.rs:9:14
+   |
+LL |         self.g();
+   |              ^
+   |
+   = note: the following trait bounds were not satisfied:
+           `Self: Foo`
+           which is required by `&Self: Foo`
+           `&Self: Foo`
+   = help: items from traits can only be used if the type parameter is bounded by the trait
+help: the following trait defines an item `g`, perhaps you need to add a supertrait for it:
+   |
+LL | trait Bar: Foo {
+   |          +++++
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0380, E0599.
+For more information about an error, try `rustc --explain E0380`.