Skip to content

Commit 5f9330c

Browse files
authored
Rollup merge of #140568 - moxian:reg-140545, r=compiler-errors
Add regression test for #140545 Closes #140545 I am not very knowledgable about the typesystem internals, so I couldn't come up with a good name for the test. But I'm happy to move it to a more appropriate place if there is one (`tests/ui/impl-trait/non-defining-uses` maybe?) r? types (or reroll as appropriate if this is not actually a T-types issue; i'm clueless)
2 parents 422dfe6 + dcee18b commit 5f9330c

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Regression test for ICE from issue #140545
2+
// The error message is confusing and wrong, but that's a different problem (#139350)
3+
//@ edition:2018
4+
5+
trait Foo {}
6+
fn a(x: impl Foo) -> impl Foo {
7+
if true { x } else { a(a(x)) }
8+
//~^ ERROR: expected generic type parameter, found `impl Foo` [E0792]
9+
//~| ERROR: type parameter `impl Foo` is part of concrete type but not used in parameter list for the `impl Trait` type alias
10+
}
11+
12+
fn main(){}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0792]: expected generic type parameter, found `impl Foo`
2+
--> $DIR/double-wrap-with-defining-use.rs:7:26
3+
|
4+
LL | fn a(x: impl Foo) -> impl Foo {
5+
| -------- this generic parameter must be used with a generic type parameter
6+
LL | if true { x } else { a(a(x)) }
7+
| ^^^^^^^
8+
9+
error: type parameter `impl Foo` is part of concrete type but not used in parameter list for the `impl Trait` type alias
10+
--> $DIR/double-wrap-with-defining-use.rs:7:26
11+
|
12+
LL | if true { x } else { a(a(x)) }
13+
| ^^^^^^^
14+
15+
error: aborting due to 2 previous errors
16+
17+
For more information about this error, try `rustc --explain E0792`.

0 commit comments

Comments
 (0)