Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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).
- Loading branch information
1 parent
5a7a850
commit 1e00e1b
Showing
4 changed files
with
12 additions
and
40 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 |
---|---|---|
@@ -1,28 +1,22 @@ | ||
// 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>, | ||
_ => y, | ||
}; | ||
} | ||
|
||
fn main() { | ||
} | ||
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