connect NLL machinery to the NiceRegionError code

This commit is contained in:
Niko Matsakis 2017-12-12 09:06:35 -05:00
parent 94e7072d0b
commit 6b39781df6
43 changed files with 144 additions and 82 deletions

View file

@ -78,7 +78,7 @@ mod note;
mod need_type_info;
mod nice_region_error;
pub mod nice_region_error;
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
pub fn note_and_explain_region(self,

View file

@ -15,11 +15,13 @@ use rustc::infer::NLLRegionVariableOrigin;
use rustc::infer::RegionObligation;
use rustc::infer::RegionVariableOrigin;
use rustc::infer::SubregionOrigin;
use rustc::infer::error_reporting::nice_region_error::NiceRegionError;
use rustc::infer::region_constraints::{GenericKind, VarOrigins};
use rustc::mir::{ClosureOutlivesRequirement, ClosureOutlivesSubject, ClosureRegionRequirements,
Local, Location, Mir};
use rustc::traits::ObligationCause;
use rustc::ty::{self, RegionVid, Ty, TypeFoldable};
use rustc::util::common::ErrorReported;
use rustc_data_structures::indexed_vec::IndexVec;
use rustc_errors::DiagnosticBuilder;
use std::fmt;
@ -230,7 +232,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
/// `num_region_variables` valid inference variables; the first N
/// of those will be constant regions representing the free
/// regions defined in `universal_regions`.
pub fn new(
pub(crate) fn new(
var_origins: VarOrigins,
universal_regions: UniversalRegions<'tcx>,
mir: &Mir<'tcx>,
@ -430,7 +432,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
self.check_type_tests(infcx, mir, outlives_requirements.as_mut());
self.check_universal_regions(infcx, mir, outlives_requirements.as_mut());
self.check_universal_regions(infcx, mir, mir_def_id, outlives_requirements.as_mut());
let outlives_requirements = outlives_requirements.unwrap_or(vec![]);
@ -807,6 +809,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
&self,
infcx: &InferCtxt<'_, 'gcx, 'tcx>,
mir: &Mir<'tcx>,
mir_def_id: DefId,
mut propagated_outlives_requirements: Option<&mut Vec<ClosureOutlivesRequirement<'gcx>>>,
) {
// The universal regions are always found in a prefix of the
@ -819,7 +822,13 @@ impl<'tcx> RegionInferenceContext<'tcx> {
// they did not grow too large, accumulating any requirements
// for our caller into the `outlives_requirements` vector.
for (fr, _) in universal_definitions {
self.check_universal_region(infcx, mir, fr, &mut propagated_outlives_requirements);
self.check_universal_region(
infcx,
mir,
mir_def_id,
fr,
&mut propagated_outlives_requirements,
);
}
}
@ -835,6 +844,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
&self,
infcx: &InferCtxt<'_, 'gcx, 'tcx>,
mir: &Mir<'tcx>,
mir_def_id: DefId,
longer_fr: RegionVid,
propagated_outlives_requirements: &mut Option<&mut Vec<ClosureOutlivesRequirement<'gcx>>>,
) {
@ -891,7 +901,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
// Note: in this case, we use the unapproximated regions
// to report the error. This gives better error messages
// in some cases.
self.report_error(infcx, mir, longer_fr, shorter_fr, blame_span);
self.report_error(infcx, mir, mir_def_id, longer_fr, shorter_fr, blame_span);
}
}
@ -907,18 +917,30 @@ impl<'tcx> RegionInferenceContext<'tcx> {
&self,
infcx: &InferCtxt<'_, '_, 'tcx>,
mir: &Mir<'tcx>,
mir_def_id: DefId,
fr: RegionVid,
outlived_fr: RegionVid,
blame_span: Span,
) {
// Obviously uncool error reporting.
let fr_string = match self.definitions[fr].external_name {
let fr_name = self.definitions[fr].external_name;
let outlived_fr_name = self.definitions[outlived_fr].external_name;
if let (Some(f), Some(o)) = (fr_name, outlived_fr_name) {
let tables = infcx.tcx.typeck_tables_of(mir_def_id);
let nice = NiceRegionError::new(infcx.tcx, blame_span, o, f, Some(tables));
if let Some(ErrorReported) = nice.try_report() {
return;
}
}
let fr_string = match fr_name {
Some(r) => format!("free region `{}`", r),
None => format!("free region `{:?}`", fr),
};
let outlived_fr_string = match self.definitions[outlived_fr].external_name {
let outlived_fr_string = match outlived_fr_name {
Some(r) => format!("free region `{}`", r),
None => format!("free region `{:?}`", outlived_fr),
};

View file

@ -445,7 +445,7 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> {
let defining_ty = self.defining_ty();
debug!("build: defining_ty={:?}", defining_ty);
let indices = self.compute_indices(fr_static, defining_ty);
let mut indices = self.compute_indices(fr_static, defining_ty);
debug!("build: indices={:?}", indices);
let bound_inputs_and_output = self.compute_inputs_and_output(&indices, defining_ty);
@ -453,8 +453,12 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> {
// "Liberate" the late-bound regions. These correspond to
// "local" free regions.
let first_local_index = self.infcx.num_region_vars();
let inputs_and_output = self.infcx
.replace_bound_regions_with_nll_infer_vars(FR, &bound_inputs_and_output);
let inputs_and_output = self.infcx.replace_bound_regions_with_nll_infer_vars(
FR,
self.mir_def_id,
&bound_inputs_and_output,
&mut indices,
);
let fr_fn_body = self.infcx.next_nll_region_var(FR).to_region_vid();
let num_universals = self.infcx.num_region_vars();
@ -717,7 +721,7 @@ impl UniversalRegionRelations {
}
}
pub(crate) trait InferCtxtExt<'tcx> {
trait InferCtxtExt<'tcx> {
fn replace_free_regions_with_nll_infer_vars<T>(
&self,
origin: NLLRegionVariableOrigin,
@ -729,7 +733,9 @@ pub(crate) trait InferCtxtExt<'tcx> {
fn replace_bound_regions_with_nll_infer_vars<T>(
&self,
origin: NLLRegionVariableOrigin,
all_outlive_scope: DefId,
value: &ty::Binder<T>,
indices: &mut UniversalRegionIndices<'tcx>,
) -> T
where
T: TypeFoldable<'tcx>;
@ -752,18 +758,38 @@ impl<'cx, 'gcx, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'cx, 'gcx, 'tcx> {
fn replace_bound_regions_with_nll_infer_vars<T>(
&self,
origin: NLLRegionVariableOrigin,
all_outlive_scope: DefId,
value: &ty::Binder<T>,
indices: &mut UniversalRegionIndices<'tcx>,
) -> T
where
T: TypeFoldable<'tcx>,
{
let (value, _map) = self.tcx
.replace_late_bound_regions(value, |_br| self.next_nll_region_var(origin));
let (value, _map) = self.tcx.replace_late_bound_regions(value, |br| {
let liberated_region = self.tcx.mk_region(ty::ReFree(ty::FreeRegion {
scope: all_outlive_scope,
bound_region: br,
}));
let region_vid = self.next_nll_region_var(origin);
indices.insert_late_bound_region(liberated_region, region_vid.to_region_vid());
region_vid
});
value
}
}
impl<'tcx> UniversalRegionIndices<'tcx> {
/// Initially, the `UniversalRegionIndices` map contains only the
/// early-bound regions in scope. Once that is all setup, we come
/// in later and instantiate the late-bound regions, and then we
/// insert the `ReFree` version of those into the map as
/// well. These are used for error reporting.
fn insert_late_bound_region(&mut self, r: ty::Region<'tcx>,
vid: ty::RegionVid)
{
self.indices.insert(r, vid);
}
/// Converts `r` into a local inference variable: `r` can either
/// by a `ReVar` (i.e., already a reference to an inference
/// variable) or it can be `'static` or some early-bound

View file

@ -45,7 +45,7 @@ fn bar<'a>(x: &'a u32) -> &'static u32 {
// as part of checking the `ReifyFnPointer`.
let f: fn(_) -> _ = foo;
//~^ WARNING not reporting region error due to -Znll
//~| ERROR free region `'_#1r` does not outlive free region `'static`
//~| ERROR free region `'a` does not outlive free region `'static`
f(x)
}

View file

@ -17,7 +17,7 @@ fn bar<'a>(input: &'a u32, f: fn(&'a u32) -> &'a u32) -> &'static u32 {
// in `g`. These are related via the `UnsafeFnPointer` cast.
let g: unsafe fn(_) -> _ = f;
//~^ WARNING not reporting region error due to -Znll
//~| ERROR free region `'_#1r` does not outlive free region `'static`
//~| ERROR free region `'a` does not outlive free region `'static`
unsafe { g(input) }
}

View file

@ -16,7 +16,7 @@
use std::fmt::Debug;
fn bar<'a>(x: &'a u32) -> &'static dyn Debug {
//~^ ERROR free region `'_#1r` does not outlive free region `'static`
//~^ ERROR free region `'a` does not outlive free region `'static`
x
//~^ WARNING not reporting region error due to -Znll
}

View file

@ -21,7 +21,7 @@ where
fn bar<'a, 'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) {
foo(x, y)
//~^ ERROR free region `'_#1r` does not outlive free region `'_#2r`
//~^ ERROR lifetime mismatch [E0623]
//~| WARNING not reporting region error due to -Znll
}

View file

@ -21,7 +21,7 @@ struct Foo<'a: 'b, 'b> {
fn bar<'a, 'b>(x: Cell<&'a u32>, y: Cell<&'b u32>) {
Foo { x, y };
//~^ ERROR free region `'_#1r` does not outlive free region `'_#2r`
//~^ ERROR lifetime mismatch [E0623]
//~| WARNING not reporting region error due to -Znll
}

View file

@ -24,10 +24,10 @@ fn static_id_wrong_way<'a>(t: &'a ()) -> &'static () where 'static: 'a {
fn error(u: &(), v: &()) {
static_id(&u); //[ll]~ ERROR cannot infer an appropriate lifetime
//[nll]~^ WARNING not reporting region error due to -Znll
//[nll]~| ERROR free region `'_#1r` does not outlive free region `'static`
//[nll]~| ERROR free region `` does not outlive free region `'static`
static_id_indirect(&v); //[ll]~ ERROR cannot infer an appropriate lifetime
//[nll]~^ WARNING not reporting region error due to -Znll
//[nll]~| ERROR free region `'_#2r` does not outlive free region `'static`
//[nll]~| ERROR free region `` does not outlive free region `'static`
}
fn main() {}

View file

@ -34,7 +34,7 @@ fn test() {
{
let y = 22;
let mut closure = expect_sig(|p, y| *p = y);
//~^ ERROR free region `'_#4r` does not outlive free region `'_#3r`
//~^ ERROR does not outlive free region
//~| WARNING not reporting region error due to -Znll
closure(&mut p, &y);
}

View file

@ -4,7 +4,7 @@ warning: not reporting region error due to -Znll
36 | let mut closure = expect_sig(|p, y| *p = y);
| ^
error: free region `'_#4r` does not outlive free region `'_#3r`
error: free region `ReFree(DefId(0/1:9 ~ escape_argument_callee[317d]::test[0]::{{closure}}[0]), BrAnon(3))` does not outlive free region `ReFree(DefId(0/1:9 ~ escape_argument_callee[317d]::test[0]::{{closure}}[0]), BrAnon(2))`
--> $DIR/escape-argument-callee.rs:36:45
|
36 | let mut closure = expect_sig(|p, y| *p = y);

View file

@ -54,7 +54,7 @@ fn supply<'a, 'b, 'c>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>, cell_c: Cell
// Only works if 'x: 'y:
let p = x.get();
//~^ WARN not reporting region error due to -Znll
//~| ERROR free region `'_#5r` does not outlive free region `'_#6r`
//~| ERROR does not outlive free region
demand_y(x, y, p)
},
);

View file

@ -4,7 +4,7 @@ warning: not reporting region error due to -Znll
55 | let p = x.get();
| ^^^^^^^
error: free region `'_#5r` does not outlive free region `'_#6r`
error: free region `ReFree(DefId(0/1:20 ~ propagate_approximated_fail_no_postdom[317d]::supply[0]::{{closure}}[0]), BrAnon(1))` does not outlive free region `ReFree(DefId(0/1:20 ~ propagate_approximated_fail_no_postdom[317d]::supply[0]::{{closure}}[0]), BrAnon(2))`
--> $DIR/propagate-approximated-fail-no-postdom.rs:55:17
|
55 | let p = x.get();
@ -17,7 +17,7 @@ note: No external requirements
54 | | // Only works if 'x: 'y:
55 | | let p = x.get();
56 | | //~^ WARN not reporting region error due to -Znll
57 | | //~| ERROR free region `'_#5r` does not outlive free region `'_#6r`
57 | | //~| ERROR does not outlive free region
58 | | demand_y(x, y, p)
59 | | },
| |_________^

View file

@ -51,7 +51,7 @@ fn demand_y<'x, 'y>(_cell_x: &Cell<&'x u32>, _cell_y: &Cell<&'y u32>, _y: &'y u3
#[rustc_regions]
fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
//~^ ERROR free region `'_#1r` does not outlive free region `'_#2r`
//~^ ERROR lifetime mismatch
// Only works if 'x: 'y:
demand_y(x, y, x.get()) //~ WARNING not reporting region error due to -Znll

View file

@ -9,7 +9,7 @@ note: External requirements
|
53 | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
| _______________________________________________^
54 | | //~^ ERROR free region `'_#1r` does not outlive free region `'_#2r`
54 | | //~^ ERROR lifetime mismatch
55 | |
56 | | // Only works if 'x: 'y:
57 | | demand_y(x, y, x.get()) //~ WARNING not reporting region error due to -Znll
@ -23,18 +23,22 @@ note: External requirements
= note: number of external vids: 3
= note: where '_#1r: '_#2r
error: free region `'_#1r` does not outlive free region `'_#2r`
error[E0623]: lifetime mismatch
--> $DIR/propagate-approximated-ref.rs:53:29
|
52 | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
| ------- -------
| |
| these two types are declared with different lifetimes...
53 | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
| ^^^^^^^
| ^^^^^^^ ...but data from `cell_a` flows into `cell_b` here
note: No external requirements
--> $DIR/propagate-approximated-ref.rs:52:1
|
52 | / fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
53 | | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
54 | | //~^ ERROR free region `'_#1r` does not outlive free region `'_#2r`
54 | | //~^ ERROR lifetime mismatch
55 | |
... |
58 | | });

View file

@ -31,7 +31,7 @@ fn case1() {
foo(cell, |cell_a, cell_x| {
//~^ WARNING not reporting region error due to -Znll
cell_a.set(cell_x.get()); // forces 'x: 'a, error in closure
//~^ ERROR free region `'_#2r` does not outlive free region `'_#1r`
//~^ ERROR does not outlive free region
})
}

View file

@ -4,7 +4,7 @@ warning: not reporting region error due to -Znll
31 | foo(cell, |cell_a, cell_x| {
| ^^^
error: free region `'_#2r` does not outlive free region `'_#1r`
error: free region `ReFree(DefId(0/1:12 ~ propagate_approximated_shorter_to_static_comparing_against_free[317d]::case1[0]::{{closure}}[0]), BrAnon(1))` does not outlive free region `'_#1r`
--> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:33:9
|
33 | cell_a.set(cell_x.get()); // forces 'x: 'a, error in closure
@ -17,7 +17,7 @@ note: No external requirements
| _______________^
32 | | //~^ WARNING not reporting region error due to -Znll
33 | | cell_a.set(cell_x.get()); // forces 'x: 'a, error in closure
34 | | //~^ ERROR free region `'_#2r` does not outlive free region `'_#1r`
34 | | //~^ ERROR does not outlive free region
35 | | })
| |_____^
|

View file

@ -43,7 +43,7 @@ fn demand_y<'x, 'y>(_cell_x: &Cell<&'x u32>, _cell_y: &Cell<&'y u32>, _y: &'y u3
#[rustc_regions]
fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
//~^ ERROR free region `'_#1r` does not outlive free region `ReStatic`
//~^ ERROR does not outlive free region
// Only works if 'x: 'y:
demand_y(x, y, x.get()) //~ WARNING not reporting region error due to -Znll

View file

@ -9,7 +9,7 @@ note: External requirements
|
45 | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
| _______________________________________________^
46 | | //~^ ERROR free region `'_#1r` does not outlive free region `ReStatic`
46 | | //~^ ERROR does not outlive free region
47 | |
48 | | // Only works if 'x: 'y:
49 | | demand_y(x, y, x.get()) //~ WARNING not reporting region error due to -Znll
@ -23,12 +23,12 @@ note: External requirements
= note: number of external vids: 2
= note: where '_#1r: '_#0r
error: free region `'_#1r` does not outlive free region `ReStatic`
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:47
|
45 | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
| _______________________________________________^
46 | | //~^ ERROR free region `'_#1r` does not outlive free region `ReStatic`
46 | | //~^ ERROR does not outlive free region
47 | |
48 | | // Only works if 'x: 'y:
49 | | demand_y(x, y, x.get()) //~ WARNING not reporting region error due to -Znll
@ -40,7 +40,7 @@ note: No external requirements
|
44 | / fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
45 | | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
46 | | //~^ ERROR free region `'_#1r` does not outlive free region `ReStatic`
46 | | //~^ ERROR does not outlive free region
47 | |
... |
50 | | });

View file

@ -46,7 +46,7 @@ fn demand_y<'x, 'y>(_cell_x: &Cell<&'x u32>, _cell_y: &Cell<&'y u32>, _y: &'y u3
#[rustc_regions]
fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
//~^ ERROR free region `'_#1r` does not outlive free region `ReStatic`
//~^ ERROR does not outlive free region
// Only works if 'x: 'y:
demand_y(x, y, x.get())
//~^ WARNING not reporting region error due to -Znll

View file

@ -9,7 +9,7 @@ note: External requirements
|
48 | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
| _______________________________________________^
49 | | //~^ ERROR free region `'_#1r` does not outlive free region `ReStatic`
49 | | //~^ ERROR does not outlive free region
50 | | // Only works if 'x: 'y:
51 | | demand_y(x, y, x.get())
52 | | //~^ WARNING not reporting region error due to -Znll
@ -23,12 +23,12 @@ note: External requirements
= note: number of external vids: 3
= note: where '_#1r: '_#0r
error: free region `'_#1r` does not outlive free region `ReStatic`
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:47
|
48 | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
| _______________________________________________^
49 | | //~^ ERROR free region `'_#1r` does not outlive free region `ReStatic`
49 | | //~^ ERROR does not outlive free region
50 | | // Only works if 'x: 'y:
51 | | demand_y(x, y, x.get())
52 | | //~^ WARNING not reporting region error due to -Znll
@ -40,7 +40,7 @@ note: No external requirements
|
47 | / fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
48 | | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
49 | | //~^ ERROR free region `'_#1r` does not outlive free region `ReStatic`
49 | | //~^ ERROR does not outlive free region
50 | | // Only works if 'x: 'y:
... |
53 | | });

View file

@ -44,7 +44,7 @@ fn demand_y<'x, 'y>(_outlives1: Cell<&&'x u32>, _outlives2: Cell<&'y &u32>, _y:
#[rustc_regions]
fn test<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| {
//~^ ERROR free region `'_#1r` does not outlive free region `'_#2r`
//~^ ERROR lifetime mismatch
// Only works if 'x: 'y:
demand_y(outlives1, outlives2, x.get()) //~ WARNING not reporting region error due to -Znll

View file

@ -9,7 +9,7 @@ note: External requirements
|
46 | establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| {
| _____________________________________________^
47 | | //~^ ERROR free region `'_#1r` does not outlive free region `'_#2r`
47 | | //~^ ERROR lifetime mismatch
48 | |
49 | | // Only works if 'x: 'y:
50 | | demand_y(outlives1, outlives2, x.get()) //~ WARNING not reporting region error due to -Znll
@ -23,18 +23,22 @@ note: External requirements
= note: number of external vids: 3
= note: where '_#1r: '_#2r
error: free region `'_#1r` does not outlive free region `'_#2r`
error[E0623]: lifetime mismatch
--> $DIR/propagate-approximated-val.rs:46:29
|
45 | fn test<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
| ------- -------
| |
| these two types are declared with different lifetimes...
46 | establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| {
| ^^^^^^
| ^^^^^^ ...but data from `cell_a` flows into `cell_b` here
note: No external requirements
--> $DIR/propagate-approximated-val.rs:45:1
|
45 | / fn test<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
46 | | establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| {
47 | | //~^ ERROR free region `'_#1r` does not outlive free region `'_#2r`
47 | | //~^ ERROR lifetime mismatch
48 | |
... |
51 | | });

View file

@ -46,7 +46,7 @@ fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
// Only works if 'x: 'y:
demand_y(x, y, x.get())
//~^ WARN not reporting region error due to -Znll
//~| ERROR free region `'_#6r` does not outlive free region `'_#4r`
//~| ERROR does not outlive free region
});
}

View file

@ -4,7 +4,7 @@ warning: not reporting region error due to -Znll
47 | demand_y(x, y, x.get())
| ^^^^^^^^^^^^^^^^^^^^^^^
error: free region `'_#6r` does not outlive free region `'_#4r`
error: free region `ReFree(DefId(0/1:18 ~ propagate_fail_to_approximate_longer_no_bounds[317d]::supply[0]::{{closure}}[0]), BrAnon(4))` does not outlive free region `ReFree(DefId(0/1:18 ~ propagate_fail_to_approximate_longer_no_bounds[317d]::supply[0]::{{closure}}[0]), BrAnon(2))`
--> $DIR/propagate-fail-to-approximate-longer-no-bounds.rs:47:18
|
47 | demand_y(x, y, x.get())
@ -18,7 +18,7 @@ note: No external requirements
46 | | // Only works if 'x: 'y:
47 | | demand_y(x, y, x.get())
48 | | //~^ WARN not reporting region error due to -Znll
49 | | //~| ERROR free region `'_#6r` does not outlive free region `'_#4r`
49 | | //~| ERROR does not outlive free region
50 | | });
| |_____^
|

View file

@ -50,7 +50,7 @@ fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
// Only works if 'x: 'y:
demand_y(x, y, x.get())
//~^ WARN not reporting region error due to -Znll
//~| ERROR free region `'_#5r` does not outlive free region `'_#7r`
//~| ERROR does not outlive free region
});
}

View file

@ -4,7 +4,7 @@ warning: not reporting region error due to -Znll
51 | demand_y(x, y, x.get())
| ^^^^^^^^^^^^^^^^^^^^^^^
error: free region `'_#5r` does not outlive free region `'_#7r`
error: free region `ReFree(DefId(0/1:18 ~ propagate_fail_to_approximate_longer_wrong_bounds[317d]::supply[0]::{{closure}}[0]), BrAnon(2))` does not outlive free region `ReFree(DefId(0/1:18 ~ propagate_fail_to_approximate_longer_wrong_bounds[317d]::supply[0]::{{closure}}[0]), BrAnon(4))`
--> $DIR/propagate-fail-to-approximate-longer-wrong-bounds.rs:51:18
|
51 | demand_y(x, y, x.get())
@ -18,7 +18,7 @@ note: No external requirements
50 | | // Only works if 'x: 'y:
51 | | demand_y(x, y, x.get())
52 | | //~^ WARN not reporting region error due to -Znll
53 | | //~| ERROR free region `'_#5r` does not outlive free region `'_#7r`
53 | | //~| ERROR does not outlive free region
54 | | });
| |_____^
|

View file

@ -18,7 +18,7 @@
fn foo(x: &u32) -> &'static u32 {
&*x
//~^ WARN not reporting region error due to -Znll
//~| ERROR free region `'_#1r` does not outlive free region `ReStatic`
//~| ERROR does not outlive free region
}
fn main() { }

View file

@ -4,7 +4,7 @@ warning: not reporting region error due to -Znll
19 | &*x
| ^^^
error: free region `'_#1r` does not outlive free region `ReStatic`
error: free region `ReFree(DefId(0/0:3 ~ region_lbr_anon_does_not_outlive_static[317d]::foo[0]), BrAnon(0))` does not outlive free region `ReStatic`
--> $DIR/region-lbr-anon-does-not-outlive-static.rs:19:5
|
19 | &*x

View file

@ -18,7 +18,7 @@
fn foo<'a>(x: &'a u32) -> &'static u32 {
&*x
//~^ WARN not reporting region error due to -Znll
//~| ERROR free region `'_#1r` does not outlive free region `ReStatic`
//~| ERROR does not outlive free region
}
fn main() { }

View file

@ -4,7 +4,7 @@ warning: not reporting region error due to -Znll
19 | &*x
| ^^^
error: free region `'_#1r` does not outlive free region `ReStatic`
error: free region `ReFree(DefId(0/0:3 ~ region_lbr_named_does_not_outlive_static[317d]::foo[0]), BrNamed(crate0:DefIndex(1:9), 'a))` does not outlive free region `ReStatic`
--> $DIR/region-lbr-named-does-not-outlive-static.rs:19:5
|
19 | &*x

View file

@ -18,7 +18,7 @@
fn foo<'a, 'b>(x: &'a u32, y: &'b u32) -> &'b u32 {
&*x
//~^ WARN not reporting region error due to -Znll
//~| ERROR free region `'_#1r` does not outlive free region `'_#2r`
//~| ERROR lifetime mismatch
}
fn main() { }

View file

@ -4,11 +4,15 @@ warning: not reporting region error due to -Znll
19 | &*x
| ^^^
error: free region `'_#1r` does not outlive free region `'_#2r`
error[E0623]: lifetime mismatch
--> $DIR/region-lbr1-does-not-outlive-ebr2.rs:19:5
|
18 | fn foo<'a, 'b>(x: &'a u32, y: &'b u32) -> &'b u32 {
| ------- -------
| |
| this parameter and the return type are declared with different lifetimes...
19 | &*x
| ^^^
| ^^^ ...but data from `x` is returned here
error: aborting due to previous error

View file

@ -20,7 +20,7 @@
fn test() {
expect_sig(|a, b| b); // ought to return `a`
//~^ WARN not reporting region error due to -Znll
//~| ERROR free region `'_#3r` does not outlive free region `'_#2r`
//~| ERROR does not outlive free region
}
fn expect_sig<F>(f: F) -> F

View file

@ -4,7 +4,7 @@ warning: not reporting region error due to -Znll
21 | expect_sig(|a, b| b); // ought to return `a`
| ^
error: free region `'_#3r` does not outlive free region `'_#2r`
error: free region `ReFree(DefId(0/1:9 ~ return_wrong_bound_region[317d]::test[0]::{{closure}}[0]), BrAnon(2))` does not outlive free region `ReFree(DefId(0/1:9 ~ return_wrong_bound_region[317d]::test[0]::{{closure}}[0]), BrAnon(1))`
--> $DIR/return-wrong-bound-region.rs:21:23
|
21 | expect_sig(|a, b| b); // ought to return `a`
@ -27,7 +27,7 @@ note: No external requirements
20 | / fn test() {
21 | | expect_sig(|a, b| b); // ought to return `a`
22 | | //~^ WARN not reporting region error due to -Znll
23 | | //~| ERROR free region `'_#3r` does not outlive free region `'_#2r`
23 | | //~| ERROR does not outlive free region
24 | | }
| |_^
|

View file

@ -21,7 +21,7 @@ impl<'a, T> Foo<'a> for T { }
fn foo<'a, T>(x: &T) -> impl Foo<'a> {
x
//~^ WARNING not reporting region error due to -Znll
//~| ERROR free region `'_#2r` does not outlive free region `ReEarlyBound(0, 'a)`
//~| ERROR explicit lifetime required in the type of `x` [E0621]
}
fn main() {}

View file

@ -4,11 +4,13 @@ warning: not reporting region error due to -Znll
22 | x
| ^
error: free region `'_#2r` does not outlive free region `ReEarlyBound(0, 'a)`
error[E0621]: explicit lifetime required in the type of `x`
--> $DIR/impl-trait-captures.rs:22:5
|
21 | fn foo<'a, T>(x: &T) -> impl Foo<'a> {
| - consider changing the type of `x` to `&ReEarlyBound(0, 'a) T`
22 | x
| ^
| ^ lifetime `ReEarlyBound(0, 'a)` required
error: aborting due to previous error

View file

@ -56,7 +56,7 @@ where
with_signature(cell, t, |cell, t| require(cell, t));
//~^ WARNING not reporting region error due to -Znll
//~| ERROR `T` does not outlive
//~| ERROR free region `ReEarlyBound(0, 'b)` does not outlive free region `'_#2r`
//~| ERROR does not outlive free region
}
#[rustc_regions]
@ -68,7 +68,7 @@ where
with_signature(cell, t, |cell, t| require(cell, t));
//~^ WARNING not reporting region error due to -Znll
//~| ERROR `T` does not outlive
//~| ERROR free region `ReEarlyBound(1, 'b)` does not outlive free region `ReEarlyBound(0, 'a)`
//~| ERROR does not outlive free region
}
#[rustc_regions]

View file

@ -89,7 +89,7 @@ error: `T` does not outlive `'_#5r`
56 | with_signature(cell, t, |cell, t| require(cell, t));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: free region `ReEarlyBound(0, 'b)` does not outlive free region `'_#2r`
error: free region `ReEarlyBound(0, 'b)` does not outlive free region `ReFree(DefId(0/0:8 ~ projection_one_region_closure[317d]::no_relationships_late[0]), BrNamed(crate0:DefIndex(1:17), 'a))`
--> $DIR/projection-one-region-closure.rs:56:20
|
56 | with_signature(cell, t, |cell, t| require(cell, t));
@ -103,7 +103,7 @@ note: No external requirements
54 | | T: Anything<'b>,
55 | | {
... |
59 | | //~| ERROR free region `ReEarlyBound(0, 'b)` does not outlive free region `'_#2r`
59 | | //~| ERROR does not outlive free region
60 | | }
| |_^
|
@ -132,7 +132,7 @@ note: No external requirements
65 | | T: Anything<'b>,
66 | | 'a: 'a,
... |
71 | | //~| ERROR free region `ReEarlyBound(1, 'b)` does not outlive free region `ReEarlyBound(0, 'a)`
71 | | //~| ERROR does not outlive free region
72 | | }
| |_^
|

View file

@ -47,7 +47,7 @@ where
{
with_signature(cell, t, |cell, t| require(cell, t));
//~^ WARNING not reporting region error due to -Znll
//~| ERROR free region `ReEarlyBound(0, 'b)` does not outlive free region `'_#2r`
//~| ERROR does not outlive free region
}
#[rustc_regions]
@ -58,7 +58,7 @@ where
{
with_signature(cell, t, |cell, t| require(cell, t));
//~^ WARNING not reporting region error due to -Znll
//~| ERROR free region `ReEarlyBound(1, 'b)` does not outlive free region `ReEarlyBound(0, 'a)`
//~| ERROR does not outlive free region
}
#[rustc_regions]
@ -79,7 +79,7 @@ where
with_signature(cell, t, |cell, t| require(cell, t));
//~^ WARNING not reporting region error due to -Znll
//~| ERROR free region `ReEarlyBound(1, 'b)` does not outlive free region `ReEarlyBound(0, 'a)`
//~| ERROR does not outlive free region
}
#[rustc_regions]

View file

@ -94,7 +94,7 @@ note: External requirements
= note: number of external vids: 3
= note: where '_#1r: '_#2r
error: free region `ReEarlyBound(0, 'b)` does not outlive free region `'_#2r`
error: free region `ReEarlyBound(0, 'b)` does not outlive free region `ReFree(DefId(0/0:8 ~ projection_one_region_trait_bound_closure[317d]::no_relationships_late[0]), BrNamed(crate0:DefIndex(1:17), 'a))`
--> $DIR/projection-one-region-trait-bound-closure.rs:48:20
|
48 | with_signature(cell, t, |cell, t| require(cell, t));
@ -108,7 +108,7 @@ note: No external requirements
46 | | T: Anything<'b>,
47 | | {
... |
50 | | //~| ERROR free region `ReEarlyBound(0, 'b)` does not outlive free region `'_#2r`
50 | | //~| ERROR does not outlive free region
51 | | }
| |_^
|
@ -131,7 +131,7 @@ note: No external requirements
56 | | T: Anything<'b>,
57 | | 'a: 'a,
... |
61 | | //~| ERROR free region `ReEarlyBound(1, 'b)` does not outlive free region `ReEarlyBound(0, 'a)`
61 | | //~| ERROR does not outlive free region
62 | | }
| |_^
|
@ -155,7 +155,7 @@ note: No external requirements
67 | | T: Anything<'b>,
68 | | T::AssocType: 'a,
... |
82 | | //~| ERROR free region `ReEarlyBound(1, 'b)` does not outlive free region `ReEarlyBound(0, 'a)`
82 | | //~| ERROR does not outlive free region
83 | | }
| |_^
|

View file

@ -108,7 +108,7 @@ where
{
with_signature(cell, t, |cell, t| require(cell, t));
//~^ WARNING not reporting region error due to -Znll
//~| ERROR free region `ReEarlyBound(0, 'b)` does not outlive free region `'_#2r`
//~| ERROR does not outlive free region
}
#[rustc_regions]

View file

@ -264,7 +264,7 @@ note: No external requirements
T
]
error: free region `ReEarlyBound(0, 'b)` does not outlive free region `'_#2r`
error: free region `ReEarlyBound(0, 'b)` does not outlive free region `ReFree(DefId(0/0:13 ~ projection_two_region_trait_bound_closure[317d]::two_regions[0]), BrNamed(crate0:DefIndex(1:44), 'a))`
--> $DIR/projection-two-region-trait-bound-closure.rs:109:20
|
109 | with_signature(cell, t, |cell, t| require(cell, t));
@ -278,7 +278,7 @@ note: No external requirements
107 | | T: Anything<'b, 'b>,
108 | | {
... |
111 | | //~| ERROR free region `ReEarlyBound(0, 'b)` does not outlive free region `'_#2r`
111 | | //~| ERROR does not outlive free region
112 | | }
| |_^
|