fix SCCs containing mixture of universes

And add a test showing a universe violation getting caught.
This commit is contained in:
Niko Matsakis 2018-09-05 09:38:06 -04:00
parent f0e3a09bb8
commit fced2b1200
3 changed files with 61 additions and 28 deletions

View 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);
}

View 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