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,
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;
/// `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>,
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![]);
&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
// 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,
+ );
}
}
&self,
infcx: &InferCtxt<'_, 'gcx, 'tcx>,
mir: &Mir<'tcx>,
+ mir_def_id: DefId,
longer_fr: RegionVid,
propagated_outlives_requirements: &mut Option<&mut Vec<ClosureOutlivesRequirement<'gcx>>>,
) {
// 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);
}
}
&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),
};
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);
// "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();
}
}
-pub(crate) trait InferCtxtExt<'tcx> {
+trait InferCtxtExt<'tcx> {
fn replace_free_regions_with_nll_infer_vars<T>(
&self,
origin: NLLRegionVariableOrigin,
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>;
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
// 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)
}
// 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) }
}
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
}
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
}
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
}
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() {}
{
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);
}
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);
// 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)
},
);
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();
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 | | },
| |_________^
#[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
|
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
= 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 | | });
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
})
}
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
| _______________^
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 | | })
| |_____^
|
#[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
|
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
= 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
|
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 | | });
#[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
|
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
= 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
|
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 | | });
#[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
|
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
= 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 | | });
// 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
});
}
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())
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 | | });
| |_____^
|
// 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
});
}
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())
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 | | });
| |_____^
|
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() { }
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
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() { }
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
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() { }
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
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
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`
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 | | }
| |_^
|
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() {}
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
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]
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]
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));
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 | | }
| |_^
|
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 | | }
| |_^
|
{
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]
{
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]
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]
= 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));
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 | | }
| |_^
|
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 | | }
| |_^
|
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 | | }
| |_^
|
{
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]
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));
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 | | }
| |_^
|