fix SCCs containing mixture of universes
And add a test showing a universe violation getting caught.
This commit is contained in:
parent
f0e3a09bb8
commit
fced2b1200
3 changed files with 61 additions and 28 deletions
17
src/test/ui/nll/relate_tys/universe-violation.rs
Normal file
17
src/test/ui/nll/relate_tys/universe-violation.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// Test that the NLL `relate_tys` code correctly deduces that a
|
||||
// function returning either argument CANNOT be upcast to one
|
||||
// that returns always its first argument.
|
||||
//
|
||||
// compile-flags:-Zno-leak-check
|
||||
|
||||
#![feature(nll)]
|
||||
|
||||
fn make_it() -> fn(&'static u32) -> &'static u32 {
|
||||
panic!()
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let a: fn(_) -> _ = make_it();
|
||||
let b: fn(&u32) -> &u32 = a;
|
||||
drop(a);
|
||||
}
|
||||
14
src/test/ui/nll/relate_tys/universe-violation.stderr
Normal file
14
src/test/ui/nll/relate_tys/universe-violation.stderr
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
error: higher-ranked subtype error
|
||||
--> $DIR/universe-violation.rs:14:9
|
||||
|
|
||||
LL | let a: fn(_) -> _ = make_it();
|
||||
| ^
|
||||
|
||||
error: higher-ranked subtype error
|
||||
--> $DIR/universe-violation.rs:15:9
|
||||
|
|
||||
LL | let b: fn(&u32) -> &u32 = a;
|
||||
| ^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue