about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorFabian Wolff <fabian.wolff@alumni.ethz.ch>2021-09-12 22:05:52 +0200
committerFabian Wolff <fabian.wolff@alumni.ethz.ch>2021-09-12 22:05:52 +0200
commit3f0e69591934bdc90577f2af41c0981ea2d1651b (patch)
tree24d4e7bc562dd34653d65b77d36a294b583c6eaa /src
parentc7dbe7a830100c70d59994fd940bf75bb6e39b39 (diff)
Improve error message for missing trait in trait impl
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/issues/issue-56031.stderr10
-rw-r--r--src/test/ui/parser/issue-88818.rs10
-rw-r--r--src/test/ui/parser/issue-88818.stderr18
3 files changed, 38 insertions, 0 deletions
diff --git a/src/test/ui/issues/issue-56031.stderr b/src/test/ui/issues/issue-56031.stderr
index 3d7acee0a56..7ee5bc6ec61 100644
--- a/src/test/ui/issues/issue-56031.stderr
+++ b/src/test/ui/issues/issue-56031.stderr
@@ -3,6 +3,16 @@ error: missing trait in a trait impl
    |
 LL | impl for T {}
    |     ^
+   |
+help: add a trait here
+   |
+LL | impl Trait for T {}
+   |      +++++
+help: for an inherent impl, drop this `for`
+   |
+LL - impl for T {}
+LL + impl T {}
+   | 
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/parser/issue-88818.rs b/src/test/ui/parser/issue-88818.rs
new file mode 100644
index 00000000000..b9233ca8339
--- /dev/null
+++ b/src/test/ui/parser/issue-88818.rs
@@ -0,0 +1,10 @@
+// Regression test for #88818 (improve error message for missing trait
+// in `impl for X`).
+
+struct S { }
+impl for S { }
+//~^ ERROR: missing trait in a trait impl
+//~| HELP: add a trait here
+//~| HELP: for an inherent impl, drop this `for`
+
+fn main() {}
diff --git a/src/test/ui/parser/issue-88818.stderr b/src/test/ui/parser/issue-88818.stderr
new file mode 100644
index 00000000000..d30990ae582
--- /dev/null
+++ b/src/test/ui/parser/issue-88818.stderr
@@ -0,0 +1,18 @@
+error: missing trait in a trait impl
+  --> $DIR/issue-88818.rs:5:5
+   |
+LL | impl for S { }
+   |     ^
+   |
+help: add a trait here
+   |
+LL | impl Trait for S { }
+   |      +++++
+help: for an inherent impl, drop this `for`
+   |
+LL - impl for S { }
+LL + impl S { }
+   | 
+
+error: aborting due to previous error
+