Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions tests/ui/traits/ice-normalize-erasing-regions-132767.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Regression test for #132767
// This used to ICE with "maybe try to call `try_normalize_erasing_regions`"
// when using associated types with fn pointers and impl Trait.
// Now it correctly reports a trait bound error.

use std::hint::black_box;

trait Func {
type Ret: Id;
}
trait Id {
type Assoc;
}
impl Id for i32 {
type Assoc = i32;
}
impl<F: FnOnce() -> R, R: Id> Func for F {
type Ret = R;
}
fn bar() -> impl Copy + Id {
//~^ ERROR the trait bound `u32: Id` is not satisfied
0u32
}
struct Foo<T: Func> {
_func: T,
value: Option<<<T as Func>::Ret as Id>::Assoc>,
}
fn main() {
let mut fn_def = black_box(Foo {
_func: bar,
value: None,
});
let fn_ptr = black_box(Foo {
_func: bar as fn() -> _,
value: None,
});
fn_def.value = fn_ptr.value;
black_box(fn_def);
}
18 changes: 18 additions & 0 deletions tests/ui/traits/ice-normalize-erasing-regions-132767.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
error[E0277]: the trait bound `u32: Id` is not satisfied
--> $DIR/ice-normalize-erasing-regions-132767.rs:20:13
|
LL | fn bar() -> impl Copy + Id {
| ^^^^^^^^^^^^^^ the trait `Id` is not implemented for `u32`
LL |
LL | 0u32
| ---- return type was inferred to be `u32` here
|
help: the trait `Id` is implemented for `i32`
--> $DIR/ice-normalize-erasing-regions-132767.rs:14:1
|
LL | impl Id for i32 {
| ^^^^^^^^^^^^^^^

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0277`.
Loading