upcasting traits requires only that things become more general
Revert the code that states that upcasting traits requires full equality and change to require that the source type is a subtype of the target type, as one would expect. As the comment states, this was an old bug that we didn't want to fix yet as it interacted poorly with the old leak-check. This fixes the old-lub-glb-object test, which was previously reporting too many errors (i.e., in the previous commit).
This commit is contained in:
parent
5a7a850753
commit
1e00e1b6de
4 changed files with 12 additions and 40 deletions
|
|
@ -1,22 +1,17 @@
|
|||
// Test that we give a note when the old LUB/GLB algorithm would have
|
||||
// succeeded but the new code (which is stricter) gives an error.
|
||||
|
||||
trait Foo<T, U> { }
|
||||
trait Foo<T, U> {}
|
||||
|
||||
fn foo(
|
||||
x: &dyn for<'a, 'b> Foo<&'a u8, &'b u8>,
|
||||
y: &dyn for<'a> Foo<&'a u8, &'a u8>,
|
||||
) {
|
||||
fn foo(x: &dyn for<'a, 'b> Foo<&'a u8, &'b u8>, y: &dyn for<'a> Foo<&'a u8, &'a u8>) {
|
||||
let z = match 22 {
|
||||
//~^ ERROR mismatched types
|
||||
0 => x,
|
||||
_ => y, //~ ERROR `match` arms have incompatible types
|
||||
_ => y,
|
||||
};
|
||||
}
|
||||
|
||||
fn bar(
|
||||
x: &dyn for<'a, 'b> Foo<&'a u8, &'b u8>,
|
||||
y: &dyn for<'a> Foo<&'a u8, &'a u8>,
|
||||
) {
|
||||
fn bar(x: &dyn for<'a, 'b> Foo<&'a u8, &'b u8>, y: &dyn for<'a> Foo<&'a u8, &'a u8>) {
|
||||
// Accepted with explicit case:
|
||||
let z = match 22 {
|
||||
0 => x as &dyn for<'a> Foo<&'a u8, &'a u8>,
|
||||
|
|
@ -24,5 +19,4 @@ fn bar(
|
|||
};
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/old-lub-glb-object.rs:10:13
|
||||
--> $DIR/old-lub-glb-object.rs:7:13
|
||||
|
|
||||
LL | let z = match 22 {
|
||||
| _____________^
|
||||
LL | |
|
||||
LL | | 0 => x,
|
||||
LL | | _ => y,
|
||||
LL | | };
|
||||
|
|
@ -11,15 +12,6 @@ LL | | };
|
|||
= note: expected trait object `dyn for<'a, 'b> Foo<&'a u8, &'b u8>`
|
||||
found trait object `dyn for<'a> Foo<&'a u8, &'a u8>`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/old-lub-glb-object.rs:22:14
|
||||
|
|
||||
LL | 0 => x as &dyn for<'a> Foo<&'a u8, &'a u8>,
|
||||
| ^ one type is more general than the other
|
||||
|
|
||||
= note: expected trait object `dyn for<'a> Foo<&'a u8, &'a u8>`
|
||||
found trait object `dyn for<'a, 'b> Foo<&'a u8, &'b u8>`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue