Auto merge of #51139 - vakaras:issue-50716, r=nikomatsakis

Fix NLL issue 50716 and add a regression test.

Fix for NLL issue #50716.

r? @nikomatsakis
This commit is contained in:
bors 2018-06-27 21:32:44 +00:00
commit cd494c1f09
8 changed files with 117 additions and 7 deletions

View file

@ -24,15 +24,16 @@ LL | | });
= note: where '_#1r: '_#0r
error: free region `ReFree(DefId(0/0:6 ~ propagate_approximated_shorter_to_static_no_bound[317d]::supply[0]), BrNamed(crate0:DefIndex(1:16), 'a))` does not outlive free region `ReStatic`
--> $DIR/propagate-approximated-shorter-to-static-no-bound.rs:45:5
--> $DIR/propagate-approximated-shorter-to-static-no-bound.rs:45:47
|
LL | / establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
| _______________________________________________^
LL | | //~^ ERROR does not outlive free region
LL | |
LL | | // Only works if 'x: 'y:
LL | | demand_y(x, y, x.get()) //~ WARNING not reporting region error due to nll
LL | | });
| |______^
| |_____^
note: No external requirements
--> $DIR/propagate-approximated-shorter-to-static-no-bound.rs:44:1

View file

@ -24,15 +24,16 @@ LL | | });
= note: where '_#1r: '_#0r
error: free region `ReFree(DefId(0/0:6 ~ propagate_approximated_shorter_to_static_wrong_bound[317d]::supply[0]), BrNamed(crate0:DefIndex(1:16), 'a))` does not outlive free region `ReStatic`
--> $DIR/propagate-approximated-shorter-to-static-wrong-bound.rs:48:5
--> $DIR/propagate-approximated-shorter-to-static-wrong-bound.rs:48:47
|
LL | / establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
| _______________________________________________^
LL | | //~^ ERROR does not outlive free region
LL | | // Only works if 'x: 'y:
LL | | demand_y(x, y, x.get())
LL | | //~^ WARNING not reporting region error due to nll
LL | | });
| |______^
| |_____^
note: No external requirements
--> $DIR/propagate-approximated-shorter-to-static-wrong-bound.rs:47:1

View file

@ -0,0 +1,23 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//
// An additional regression test for the issue #50716 “NLL ignores lifetimes
// bounds derived from `Sized` requirements” that checks that the fixed compiler
// accepts this code fragment with both AST and MIR borrow checkers.
//
// revisions: ast mir
//
// compile-pass
#![cfg_attr(mir, feature(nll))]
struct Qey<Q: ?Sized>(Q);
fn main() {}

View file

@ -0,0 +1,28 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//
// Regression test for the issue #50716: NLL ignores lifetimes bounds
// derived from `Sized` requirements
#![feature(nll)]
trait A {
type X: ?Sized;
}
fn foo<'a, T: 'static>(s: Box<<&'a T as A>::X>)
where
for<'b> &'b T: A,
<&'static T as A>::X: Sized
{
let _x = *s; //~ ERROR free region `'a` does not outlive free region `'static`
}
fn main() {}

View file

@ -0,0 +1,8 @@
error: free region `'a` does not outlive free region `'static`
--> $DIR/issue-50716.rs:25:14
|
LL | let _x = *s; //~ ERROR free region `'a` does not outlive free region `'static`
| ^^
error: aborting due to previous error