-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check allow instantiating object trait binder when upcasting and in n…
…ew solver
- Loading branch information
1 parent
0399709
commit 8de3078
Showing
8 changed files
with
69 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//@ check-pass | ||
//@ revisions: current next | ||
//@ ignore-compare-mode-next-solver (explicit revisions) | ||
//@[next] compile-flags: -Znext-solver | ||
|
||
// Verify that the unsize goal can cast a higher-ranked trait goal to | ||
// a non-higer-ranked instantiation. | ||
|
||
#![feature(unsize)] | ||
|
||
use std::marker::Unsize; | ||
|
||
fn test<T: ?Sized, U: ?Sized>() | ||
where | ||
T: Unsize<U>, | ||
{ | ||
} | ||
|
||
fn main() { | ||
test::<dyn for<'a> Fn(&'a ()) -> &'a (), dyn Fn(&'static ()) -> &'static ()>(); | ||
|
||
trait Foo<'a, 'b> {} | ||
test::<dyn for<'a, 'b> Foo<'a, 'b>, dyn for<'a> Foo<'a, 'a>>(); | ||
|
||
trait Bar<'a> {} | ||
test::<dyn for<'a> Bar<'a>, dyn Bar<'_>>(); | ||
} |
22 changes: 0 additions & 22 deletions
22
tests/ui/traits/trait-upcasting/higher-ranked-upcasting-ok.current.stderr
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
tests/ui/traits/trait-upcasting/higher-ranked-upcasting-ok.next.stderr
This file was deleted.
Oops, something went wrong.
10 changes: 6 additions & 4 deletions
10
tests/ui/traits/trait-upcasting/higher-ranked-upcasting-ok.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
//@ revisions: current next | ||
//@ ignore-compare-mode-next-solver (explicit revisions) | ||
//@[next] compile-flags: -Znext-solver | ||
//@ check-pass | ||
|
||
// We should be able to instantiate a binder during trait upcasting. | ||
// This test could be `check-pass`, but we should make sure that we | ||
// do so in both trait solvers. | ||
|
||
#![feature(trait_upcasting)] | ||
#![crate_type = "rlib"] | ||
trait Supertrait<'a, 'b> {} | ||
|
||
trait Supertrait<'a, 'b> {} | ||
trait Subtrait<'a, 'b>: Supertrait<'a, 'b> {} | ||
|
||
impl<'a> Supertrait<'a, 'a> for () {} | ||
impl<'a> Subtrait<'a, 'a> for () {} | ||
fn ok(x: &dyn for<'a, 'b> Subtrait<'a, 'b>) -> &dyn for<'a> Supertrait<'a, 'a> { | ||
x //~ ERROR mismatched types | ||
//[current]~^ ERROR mismatched types | ||
x | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//@ check-pass | ||
//@ revisions: current next | ||
//@ ignore-compare-mode-next-solver (explicit revisions) | ||
//@[next] compile-flags: -Znext-solver | ||
|
||
// Verify that the unsize goal can cast a higher-ranked trait goal to | ||
// a non-higer-ranked instantiation. | ||
|
||
#![feature(unsize)] | ||
|
||
use std::marker::Unsize; | ||
|
||
fn test<T: ?Sized, U: ?Sized>() | ||
where | ||
T: Unsize<U>, | ||
{ | ||
} | ||
|
||
fn main() { | ||
test::<dyn for<'a> Fn(&'a ()) -> &'a (), dyn FnOnce(&'static ()) -> &'static ()>(); | ||
|
||
trait Foo: for<'a> Bar<'a> {} | ||
trait Bar<'a> {} | ||
test::<dyn Foo, dyn Bar<'static>>(); | ||
test::<dyn Foo, dyn Bar<'_>>(); | ||
} |