Skip to content

Commit 6bd4abb

Browse files
committed
add tests for fixed issues
1 parent bb64a34 commit 6bd4abb

3 files changed

Lines changed: 72 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//@compile-flags: -Znext-solver
2+
3+
// Regression test for #151308
4+
5+
#![feature(lazy_type_alias)]
6+
trait Trait {
7+
type Associated;
8+
}
9+
10+
trait Generic<T> {}
11+
12+
type TraitObject = dyn Generic<<i32 as Trait>::Associated>;
13+
//~^ ERROR: the trait bound `i32: Trait` is not satisfied
14+
15+
struct Wrap(TraitObject);
16+
//~^ ERROR: the trait bound `i32: Trait` is not satisfied
17+
18+
fn cast(x: *mut Wrap) {
19+
x as *mut Wrap;
20+
}
21+
22+
fn main() {}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
error[E0277]: the trait bound `i32: Trait` is not satisfied
2+
--> $DIR/dont-ice-on-normalization-failure.rs:12:32
3+
|
4+
LL | type TraitObject = dyn Generic<<i32 as Trait>::Associated>;
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `i32`
6+
|
7+
help: this trait has no implementations, consider adding one
8+
--> $DIR/dont-ice-on-normalization-failure.rs:6:1
9+
|
10+
LL | trait Trait {
11+
| ^^^^^^^^^^^
12+
13+
error[E0277]: the trait bound `i32: Trait` is not satisfied
14+
--> $DIR/dont-ice-on-normalization-failure.rs:15:13
15+
|
16+
LL | struct Wrap(TraitObject);
17+
| ^^^^^^^^^^^ the trait `Trait` is not implemented for `i32`
18+
|
19+
help: this trait has no implementations, consider adding one
20+
--> $DIR/dont-ice-on-normalization-failure.rs:6:1
21+
|
22+
LL | trait Trait {
23+
| ^^^^^^^^^^^
24+
25+
error: aborting due to 2 previous errors
26+
27+
For more information about this error, try `rustc --explain E0277`.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//@compile-flags: -Znext-solver
2+
//@check-pass
3+
4+
// Regression test for the first variant of trait-system-refactor-initiative#191
5+
6+
trait Indir<T>: FnOnce(T) -> Self::Ret {
7+
type Ret;
8+
}
9+
impl<F, T, R> Indir<T> for F where F: FnOnce(T) -> R {
10+
type Ret = R;
11+
}
12+
13+
trait Mirror {
14+
type Assoc<'a>;
15+
}
16+
17+
fn needs<T: Mirror>(_: impl for<'a> Indir<T::Assoc<'a>>) {}
18+
19+
fn test<T>() where for<'a> T: Mirror<Assoc<'a> = i32> {
20+
needs::<T>(|x| { x.to_string(); });
21+
}
22+
23+
fn main() {}

0 commit comments

Comments
 (0)