diff options
| author | moxian <moxian@users.noreply.github.com> | 2025-05-01 14:34:04 -0700 |
|---|---|---|
| committer | moxian <moxian@users.noreply.github.com> | 2025-05-02 11:46:31 -0700 |
| commit | dcee18b3b8cd23e6cd3ed20805d97515526852f7 (patch) | |
| tree | d6754579ba5745f802f423a94343d83bebb62d7e | |
| parent | 1b8ab72680f36e783af84c1a3c4f8508572bd9f9 (diff) | |
| download | rust-dcee18b3b8cd23e6cd3ed20805d97515526852f7.tar.gz rust-dcee18b3b8cd23e6cd3ed20805d97515526852f7.zip | |
Add a regression test
for #140545
| -rw-r--r-- | tests/ui/impl-trait/non-defining-uses/double-wrap-with-defining-use.rs | 12 | ||||
| -rw-r--r-- | tests/ui/impl-trait/non-defining-uses/double-wrap-with-defining-use.stderr | 17 |
2 files changed, 29 insertions, 0 deletions
diff --git a/tests/ui/impl-trait/non-defining-uses/double-wrap-with-defining-use.rs b/tests/ui/impl-trait/non-defining-uses/double-wrap-with-defining-use.rs new file mode 100644 index 00000000000..339277fec37 --- /dev/null +++ b/tests/ui/impl-trait/non-defining-uses/double-wrap-with-defining-use.rs @@ -0,0 +1,12 @@ +// Regression test for ICE from issue #140545 +// The error message is confusing and wrong, but that's a different problem (#139350) +//@ edition:2018 + +trait Foo {} +fn a(x: impl Foo) -> impl Foo { + if true { x } else { a(a(x)) } + //~^ ERROR: expected generic type parameter, found `impl Foo` [E0792] + //~| ERROR: type parameter `impl Foo` is part of concrete type but not used in parameter list for the `impl Trait` type alias +} + +fn main(){} diff --git a/tests/ui/impl-trait/non-defining-uses/double-wrap-with-defining-use.stderr b/tests/ui/impl-trait/non-defining-uses/double-wrap-with-defining-use.stderr new file mode 100644 index 00000000000..1b02811e31b --- /dev/null +++ b/tests/ui/impl-trait/non-defining-uses/double-wrap-with-defining-use.stderr @@ -0,0 +1,17 @@ +error[E0792]: expected generic type parameter, found `impl Foo` + --> $DIR/double-wrap-with-defining-use.rs:7:26 + | +LL | fn a(x: impl Foo) -> impl Foo { + | -------- this generic parameter must be used with a generic type parameter +LL | if true { x } else { a(a(x)) } + | ^^^^^^^ + +error: type parameter `impl Foo` is part of concrete type but not used in parameter list for the `impl Trait` type alias + --> $DIR/double-wrap-with-defining-use.rs:7:26 + | +LL | if true { x } else { a(a(x)) } + | ^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0792`. |
