File tree Expand file tree Collapse file tree 4 files changed +47
-0
lines changed Expand file tree Collapse file tree 4 files changed +47
-0
lines changed Original file line number Diff line number Diff line change 11// Test that we cannot create objects from unsized types.
2+ //@ revisions: current next
3+ //@ ignore-compare-mode-next-solver (explicit revisions)
4+ //@[next] compile-flags: -Znext-solver
25
36trait Foo { fn foo ( & self ) { } }
47impl Foo for str { }
Original file line number Diff line number Diff line change 1+ //@ check-pass
2+ //@ revisions: current next
3+ //@ ignore-compare-mode-next-solver (explicit revisions)
4+ //@[next] compile-flags: -Znext-solver
5+ // Test from trait-system-refactor-initiative#241:
6+ // Used to ICE in mir typeck because of ambiguity in the new solver.
7+ // The wrong (first) trait bound was selected.
8+ // This is fixed with new logic for unsizing coercions
9+ // that's independent from that of the old solver, which this test verifies.
10+
11+ trait Super < T > { }
12+ trait Trait < T > : Super < T > + for < ' hr > Super < & ' hr ( ) > { }
13+
14+ fn foo < ' a > ( x : Box < dyn Trait < & ' a ( ) > > ) -> Box < dyn Super < & ' a ( ) > > {
15+ x
16+ }
17+
18+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ //@ check-pass
2+ //@ revisions: current next
3+ //@ ignore-compare-mode-next-solver (explicit revisions)
4+ //@[next] compile-flags: -Znext-solver
5+ // Test from trait-system-refactor-initiative#241:
6+ // Used to ICE in mir typeck because of ambiguity in the new solver.
7+ // The wrong (first) trait bound was selected.
8+ // This is fixed with new logic for unsizing coercions
9+ // that's independent from that of the old solver, which this test verifies.
10+
11+ trait Super < ' a > { }
12+ trait Trait < ' a > : Super < ' a > + for < ' hr > Super < ' hr > { }
13+
14+ fn foo < ' a > ( x : Box < dyn Trait < ' a > > ) -> Box < dyn Super < ' a > > {
15+ x
16+ //~^ ERROR type annotations needed: cannot satisfy `dyn Trait<'_>: Unsize<dyn Super<'_>>
17+ }
18+
19+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ //@ compile-flags: -Znext-solver
2+ #![ recursion_limit = "8" ]
3+
4+ fn main ( ) {
5+ let _: Box < dyn Send > = Box :: new ( & & & & & & & 1 ) ;
6+ //~^ ERROR overflow evaluating the requirement `Box<&&&&&&&i32>: CoerceUnsized<Box<dyn Send>>
7+ }
You can’t perform that action at this time.
0 commit comments