diff options
author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-05-14 08:21:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-14 08:21:39 +0200 |
commit | d7f742532a16ec3a2db3b47e02fdbd6bbbbf9521 (patch) | |
tree | e2914700b1046ac7c003ace870c62ae5150988ce /tests | |
parent | 0b8f2bfe5f9f405162cfeaea9753c020885f2efb (diff) | |
parent | 7fe83345ef0204eedd8ac3847a527466f6853c0b (diff) | |
download | rust-d7f742532a16ec3a2db3b47e02fdbd6bbbbf9521.tar.gz |
Rollup merge of #111477 - y21:extra-impl-in-trait-impl, r=compiler-errors
better diagnostics for `impl<..> impl Trait for Type`
Fixes #109963
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ui/impl-trait/extra-impl-in-trait-impl.fixed | 19 | ||||
-rw-r--r-- | tests/ui/impl-trait/extra-impl-in-trait-impl.rs | 19 | ||||
-rw-r--r-- | tests/ui/impl-trait/extra-impl-in-trait-impl.stderr | 26 |
3 files changed, 64 insertions, 0 deletions
diff --git a/tests/ui/impl-trait/extra-impl-in-trait-impl.fixed b/tests/ui/impl-trait/extra-impl-in-trait-impl.fixed new file mode 100644 index 00000000000..cd4f2610d3f --- /dev/null +++ b/tests/ui/impl-trait/extra-impl-in-trait-impl.fixed @@ -0,0 +1,19 @@ +// run-rustfix + +struct S<T>(T); +struct S2; + +impl<T: Default> Default for S<T> { + //~^ ERROR: unexpected `impl` keyword + //~| HELP: remove the extra `impl` + fn default() -> Self { todo!() } +} + +impl Default for S2 { + //~^ ERROR: unexpected `impl` keyword + //~| HELP: remove the extra `impl` + fn default() -> Self { todo!() } +} + + +fn main() {} diff --git a/tests/ui/impl-trait/extra-impl-in-trait-impl.rs b/tests/ui/impl-trait/extra-impl-in-trait-impl.rs new file mode 100644 index 00000000000..024b703e6f2 --- /dev/null +++ b/tests/ui/impl-trait/extra-impl-in-trait-impl.rs @@ -0,0 +1,19 @@ +// run-rustfix + +struct S<T>(T); +struct S2; + +impl<T: Default> impl Default for S<T> { + //~^ ERROR: unexpected `impl` keyword + //~| HELP: remove the extra `impl` + fn default() -> Self { todo!() } +} + +impl impl Default for S2 { + //~^ ERROR: unexpected `impl` keyword + //~| HELP: remove the extra `impl` + fn default() -> Self { todo!() } +} + + +fn main() {} diff --git a/tests/ui/impl-trait/extra-impl-in-trait-impl.stderr b/tests/ui/impl-trait/extra-impl-in-trait-impl.stderr new file mode 100644 index 00000000000..5aafc8b64d4 --- /dev/null +++ b/tests/ui/impl-trait/extra-impl-in-trait-impl.stderr @@ -0,0 +1,26 @@ +error: unexpected `impl` keyword + --> $DIR/extra-impl-in-trait-impl.rs:6:18 + | +LL | impl<T: Default> impl Default for S<T> { + | ^^^^^ help: remove the extra `impl` + | +note: this is parsed as an `impl Trait` type, but a trait is expected at this position + --> $DIR/extra-impl-in-trait-impl.rs:6:18 + | +LL | impl<T: Default> impl Default for S<T> { + | ^^^^^^^^^^^^ + +error: unexpected `impl` keyword + --> $DIR/extra-impl-in-trait-impl.rs:12:6 + | +LL | impl impl Default for S2 { + | ^^^^^ help: remove the extra `impl` + | +note: this is parsed as an `impl Trait` type, but a trait is expected at this position + --> $DIR/extra-impl-in-trait-impl.rs:12:6 + | +LL | impl impl Default for S2 { + | ^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + |