From 53dda8e915e54bc65b41599738245d62dbe3e6df Mon Sep 17 00:00:00 2001 From: David Wood Date: Mon, 23 Jul 2018 13:09:30 +0200 Subject: Added fully elaborated type label for inferred arguments. --- src/test/ui/issue-52533.nll.stderr | 17 +++++++++++++++++ src/test/ui/issue-52533.rs | 17 +++++++++++++++++ src/test/ui/issue-52533.stderr | 20 ++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 src/test/ui/issue-52533.nll.stderr create mode 100644 src/test/ui/issue-52533.rs create mode 100644 src/test/ui/issue-52533.stderr (limited to 'src/test/ui') diff --git a/src/test/ui/issue-52533.nll.stderr b/src/test/ui/issue-52533.nll.stderr new file mode 100644 index 00000000000..7931bc320b1 --- /dev/null +++ b/src/test/ui/issue-52533.nll.stderr @@ -0,0 +1,17 @@ +warning: not reporting region error due to nll + --> $DIR/issue-52533.rs:15:16 + | +LL | foo(|a, b| b) + | ^ + +error: unsatisfied lifetime constraints + --> $DIR/issue-52533.rs:15:16 + | +LL | foo(|a, b| b) + | - - ^ free region requires that `'1` must outlive `'2` + | | | + | | lifetime `'1` appears in this argument + | lifetime `'2` appears in this argument + +error: aborting due to previous error + diff --git a/src/test/ui/issue-52533.rs b/src/test/ui/issue-52533.rs new file mode 100644 index 00000000000..08f2805cefd --- /dev/null +++ b/src/test/ui/issue-52533.rs @@ -0,0 +1,17 @@ +// Copyright 2018 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn foo(_: impl for<'a> FnOnce(&'a u32, &u32) -> &'a u32) { +} + +fn main() { + foo(|a, b| b) + //~^ ERROR lifetime of reference outlives lifetime of borrowed content... +} diff --git a/src/test/ui/issue-52533.stderr b/src/test/ui/issue-52533.stderr new file mode 100644 index 00000000000..76a2470a2e0 --- /dev/null +++ b/src/test/ui/issue-52533.stderr @@ -0,0 +1,20 @@ +error[E0312]: lifetime of reference outlives lifetime of borrowed content... + --> $DIR/issue-52533.rs:15:16 + | +LL | foo(|a, b| b) + | ^ + | +note: ...the reference is valid for the anonymous lifetime #2 defined on the body at 15:9... + --> $DIR/issue-52533.rs:15:9 + | +LL | foo(|a, b| b) + | ^^^^^^^^ +note: ...but the borrowed content is only valid for the anonymous lifetime #3 defined on the body at 15:9 + --> $DIR/issue-52533.rs:15:9 + | +LL | foo(|a, b| b) + | ^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0312`. -- cgit 1.4.1-3-g733a5 From 5282d7d060a37e419c2d829b085c4429064bab5b Mon Sep 17 00:00:00 2001 From: David Wood Date: Mon, 23 Jul 2018 16:27:24 +0200 Subject: Update affected tests. --- .../ui/error-codes/E0621-does-not-trigger-for-closures.nll.stderr | 2 +- src/test/ui/issue-40510-1.nll.stderr | 2 +- src/test/ui/issue-52213.nll.stderr | 6 +++--- src/test/ui/issue-52533.nll.stderr | 6 +++--- src/test/ui/nll/closure-requirements/escape-argument-callee.stderr | 4 ++-- .../propagate-approximated-fail-no-postdom.stderr | 6 +++--- .../propagate-fail-to-approximate-longer-no-bounds.stderr | 6 +++--- .../propagate-fail-to-approximate-longer-wrong-bounds.stderr | 6 +++--- .../ui/nll/closure-requirements/return-wrong-bound-region.stderr | 6 +++--- 9 files changed, 22 insertions(+), 22 deletions(-) (limited to 'src/test/ui') diff --git a/src/test/ui/error-codes/E0621-does-not-trigger-for-closures.nll.stderr b/src/test/ui/error-codes/E0621-does-not-trigger-for-closures.nll.stderr index 9c7e3db67a6..77f0ab5d6bd 100644 --- a/src/test/ui/error-codes/E0621-does-not-trigger-for-closures.nll.stderr +++ b/src/test/ui/error-codes/E0621-does-not-trigger-for-closures.nll.stderr @@ -11,7 +11,7 @@ LL | invoke(&x, |a, b| if a > b { a } else { b }); //~ ERROR E0495 | ----------^^^^^----------------- | | | | | | | free region requires that `'1` must outlive `'2` - | | lifetime `'1` appears in this argument + | | has type `&'1i32` | lifetime `'2` appears in return type error: aborting due to previous error diff --git a/src/test/ui/issue-40510-1.nll.stderr b/src/test/ui/issue-40510-1.nll.stderr index 73a8d58290d..312ec6e742e 100644 --- a/src/test/ui/issue-40510-1.nll.stderr +++ b/src/test/ui/issue-40510-1.nll.stderr @@ -6,7 +6,7 @@ LL | || { | |_____| | || LL | || &mut x - | || ^^^^^^ free region requires that `'1` must outlive `'2` + | || ^^^^^^ return requires that `'1` must outlive `'2` LL | || }; | || - | ||_____| diff --git a/src/test/ui/issue-52213.nll.stderr b/src/test/ui/issue-52213.nll.stderr index c288cf9ed82..fb5da7d7a19 100644 --- a/src/test/ui/issue-52213.nll.stderr +++ b/src/test/ui/issue-52213.nll.stderr @@ -5,10 +5,10 @@ LL | match (&t,) { //~ ERROR cannot infer an appropriate lifetime | ^^^^^ error: unsatisfied lifetime constraints - --> $DIR/issue-52213.rs:13:11 + --> $DIR/issue-52213.rs:12:11 | -LL | ((u,),) => u, - | ^ free region requires that `'a` must outlive `'b` +LL | match (&t,) { //~ ERROR cannot infer an appropriate lifetime + | ^^^^^ free region requires that `'a` must outlive `'b` error: aborting due to previous error diff --git a/src/test/ui/issue-52533.nll.stderr b/src/test/ui/issue-52533.nll.stderr index 7931bc320b1..365ef2bac39 100644 --- a/src/test/ui/issue-52533.nll.stderr +++ b/src/test/ui/issue-52533.nll.stderr @@ -8,10 +8,10 @@ error: unsatisfied lifetime constraints --> $DIR/issue-52533.rs:15:16 | LL | foo(|a, b| b) - | - - ^ free region requires that `'1` must outlive `'2` + | - - ^ closure was supposed to return data with lifetime `'1` but it is returning data with lifetime `'2` | | | - | | lifetime `'1` appears in this argument - | lifetime `'2` appears in this argument + | | has type `&'1u32` + | has type `&'2u32` error: aborting due to previous error diff --git a/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr b/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr index d6f54218360..c7fdbe1685c 100644 --- a/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr +++ b/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr @@ -10,8 +10,8 @@ error: unsatisfied lifetime constraints LL | let mut closure = expect_sig(|p, y| *p = y); | - - ^^^^^^ free region requires that `'1` must outlive `'2` | | | - | | lifetime `'1` appears in this argument - | lifetime `'2` appears in this argument + | | has type `&'1 i32` + | has type `&'2 mut &'3 i32` note: No external requirements --> $DIR/escape-argument-callee.rs:36:38 diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr index a7a50a3a029..6882b08f330 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr @@ -8,12 +8,12 @@ error: unsatisfied lifetime constraints --> $DIR/propagate-approximated-fail-no-postdom.rs:57:13 | LL | |_outlives1, _outlives2, _outlives3, x, y| { - | ---------- ---------- lifetime `'2` appears in this argument + | ---------- ---------- has type `std::cell::Cell<&'3 &'4 u32>` | | - | lifetime `'1` appears in this argument + | has type `std::cell::Cell<&'1 &'2 u32>` ... LL | demand_y(x, y, p) //~ ERROR - | ^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2` + | ^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'3` note: No external requirements --> $DIR/propagate-approximated-fail-no-postdom.rs:53:9 diff --git a/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr b/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr index fb98c506c7d..771d1df2df0 100644 --- a/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr @@ -8,12 +8,12 @@ error: unsatisfied lifetime constraints --> $DIR/propagate-fail-to-approximate-longer-no-bounds.rs:47:9 | LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { - | --------- - lifetime `'1` appears in this argument + | --------- - has type `&'1 std::cell::Cell<&'2 u32>` | | - | lifetime `'2` appears in this argument + | has type `&'3 std::cell::Cell<&'4 &'5 u32>` LL | // Only works if 'x: 'y: LL | demand_y(x, y, x.get()) - | ^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2` + | ^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'3` note: No external requirements --> $DIR/propagate-fail-to-approximate-longer-no-bounds.rs:45:47 diff --git a/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr b/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr index 73d39a8502b..1ac52e5e560 100644 --- a/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr @@ -8,12 +8,12 @@ error: unsatisfied lifetime constraints --> $DIR/propagate-fail-to-approximate-longer-wrong-bounds.rs:51:9 | LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { - | ---------- ---------- lifetime `'2` appears in this argument + | ---------- ---------- has type `&'4 std::cell::Cell<&'5 &'6 u32>` | | - | lifetime `'1` appears in this argument + | has type `&'1 std::cell::Cell<&'2 &'3 u32>` LL | // Only works if 'x: 'y: LL | demand_y(x, y, x.get()) - | ^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2` + | ^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'4` note: No external requirements --> $DIR/propagate-fail-to-approximate-longer-wrong-bounds.rs:49:47 diff --git a/src/test/ui/nll/closure-requirements/return-wrong-bound-region.stderr b/src/test/ui/nll/closure-requirements/return-wrong-bound-region.stderr index 5724cdbd8c9..d6d1645ceea 100644 --- a/src/test/ui/nll/closure-requirements/return-wrong-bound-region.stderr +++ b/src/test/ui/nll/closure-requirements/return-wrong-bound-region.stderr @@ -8,10 +8,10 @@ error: unsatisfied lifetime constraints --> $DIR/return-wrong-bound-region.rs:21:23 | LL | expect_sig(|a, b| b); // ought to return `a` - | - - ^ free region requires that `'1` must outlive `'2` + | - - ^ closure was supposed to return data with lifetime `'1` but it is returning data with lifetime `'2` | | | - | | lifetime `'1` appears in this argument - | lifetime `'2` appears in this argument + | | has type `&'1 i32` + | has type `&'2 i32` note: No external requirements --> $DIR/return-wrong-bound-region.rs:21:16 -- cgit 1.4.1-3-g733a5 From 055aaaf765eee0eb951b55898d943ff7dde3d4ae Mon Sep 17 00:00:00 2001 From: David Wood Date: Mon, 23 Jul 2018 17:41:18 +0200 Subject: Fixed missing whitespace on some elaborated types. --- .../borrow_check/nll/region_infer/error_reporting/region_name.rs | 6 +++--- .../ui/error-codes/E0621-does-not-trigger-for-closures.nll.stderr | 2 +- src/test/ui/issue-52533.nll.stderr | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/test/ui') diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs index 6c400278b70..f3b437c38d8 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs @@ -238,8 +238,8 @@ impl<'tcx> RegionInferenceContext<'tcx> { // Need to make the `end_index` relative to the full string. let end_index = start_index + end_index; // `start_index + 1` skips the `&`. - // `end_index` goes until the space after the region. - type_name.replace_range(start_index + 1..end_index, ""); + // `end_index + 1` goes to (including) the space after the region. + type_name.replace_range(start_index + 1..end_index + 1, ""); } } debug!("give_name_if_we_cannot_match_hir_ty: type_name={:?}", type_name); @@ -255,7 +255,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { // Compute the index of the character after `&` in the original string. index = next_index + index + 1; - type_name.insert_str(index, &format!("{}", region_name)); + type_name.insert_str(index, &format!("{} ", region_name)); } let (_, span) = self.get_argument_name_and_span_for_region(mir, argument_index); diff --git a/src/test/ui/error-codes/E0621-does-not-trigger-for-closures.nll.stderr b/src/test/ui/error-codes/E0621-does-not-trigger-for-closures.nll.stderr index 77f0ab5d6bd..14d889dca73 100644 --- a/src/test/ui/error-codes/E0621-does-not-trigger-for-closures.nll.stderr +++ b/src/test/ui/error-codes/E0621-does-not-trigger-for-closures.nll.stderr @@ -11,7 +11,7 @@ LL | invoke(&x, |a, b| if a > b { a } else { b }); //~ ERROR E0495 | ----------^^^^^----------------- | | | | | | | free region requires that `'1` must outlive `'2` - | | has type `&'1i32` + | | has type `&'1 i32` | lifetime `'2` appears in return type error: aborting due to previous error diff --git a/src/test/ui/issue-52533.nll.stderr b/src/test/ui/issue-52533.nll.stderr index 365ef2bac39..a13b06e3204 100644 --- a/src/test/ui/issue-52533.nll.stderr +++ b/src/test/ui/issue-52533.nll.stderr @@ -10,8 +10,8 @@ error: unsatisfied lifetime constraints LL | foo(|a, b| b) | - - ^ closure was supposed to return data with lifetime `'1` but it is returning data with lifetime `'2` | | | - | | has type `&'1u32` - | has type `&'2u32` + | | has type `&'1 u32` + | has type `&'2 u32` error: aborting due to previous error -- cgit 1.4.1-3-g733a5 From b377e7bbfbf584de4c1a775fd41b957cbd2e057b Mon Sep 17 00:00:00 2001 From: David Wood Date: Tue, 24 Jul 2018 16:22:41 +0200 Subject: Change label from closure to function where appropriate. --- .../nll/region_infer/error_reporting/mod.rs | 32 ++++++++++++---------- .../static-return-lifetime-infered.nll.stderr | 12 ++++---- .../ui/in-band-lifetimes/impl/dyn-trait.nll.stderr | 6 ++-- src/test/ui/issue-16683.nll.stderr | 6 ++-- src/test/ui/issue-17758.nll.stderr | 6 ++-- src/test/ui/issue-52213.nll.stderr | 6 ++-- ...-approximated-shorter-to-static-no-bound.stderr | 6 ++-- ...proximated-shorter-to-static-wrong-bound.stderr | 6 ++-- src/test/ui/nll/issue-50716.stderr | 6 ++-- src/test/ui/nll/mir_check_cast_reify.stderr | 6 ++-- src/test/ui/nll/mir_check_cast_unsafe_fn.stderr | 6 ++-- 11 files changed, 49 insertions(+), 49 deletions(-) (limited to 'src/test/ui') diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs index cef6ab311a3..c88259d5e8f 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs @@ -324,8 +324,8 @@ impl<'tcx> RegionInferenceContext<'tcx> { match (category, fr_is_local, outlived_fr_is_local) { (ConstraintCategory::Assignment, true, false) | (ConstraintCategory::CallArgument, true, false) => - self.report_escapes_closure_error(mir, infcx, mir_def_id, fr, outlived_fr, - category, span, errors_buffer), + self.report_escaping_data_error(mir, infcx, mir_def_id, fr, outlived_fr, + category, span, errors_buffer), _ => self.report_general_error(mir, infcx, mir_def_id, fr, fr_is_local, outlived_fr, outlived_fr_is_local, @@ -333,7 +333,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { }; } - fn report_escapes_closure_error( + fn report_escaping_data_error( &self, mir: &Mir<'tcx>, infcx: &InferCtxt<'_, '_, 'tcx>, @@ -348,22 +348,23 @@ impl<'tcx> RegionInferenceContext<'tcx> { let outlived_fr_name_and_span = self.get_var_name_and_span_for_region(infcx.tcx, mir, outlived_fr); + let escapes_from = if infcx.tcx.is_closure(mir_def_id) { "closure" } else { "function" }; + if fr_name_and_span.is_none() && outlived_fr_name_and_span.is_none() { return self.report_general_error(mir, infcx, mir_def_id, fr, true, outlived_fr, false, category, span, errors_buffer); } - let mut diag = infcx - .tcx - .sess - .struct_span_err(span, &format!("borrowed data escapes outside of closure")); + let mut diag = infcx.tcx.sess.struct_span_err( + span, &format!("borrowed data escapes outside of {}", escapes_from), + ); if let Some((outlived_fr_name, outlived_fr_span)) = outlived_fr_name_and_span { if let Some(name) = outlived_fr_name { diag.span_label( outlived_fr_span, - format!("`{}` is declared here, outside of the closure body", name), + format!("`{}` is declared here, outside of the {} body", name, escapes_from), ); } } @@ -372,13 +373,12 @@ impl<'tcx> RegionInferenceContext<'tcx> { if let Some(name) = fr_name { diag.span_label( fr_span, - format!( - "`{}` is a reference that is only valid in the closure body", - name - ), + format!("`{}` is a reference that is only valid in the {} body", + name, escapes_from), ); - diag.span_label(span, format!("`{}` escapes the closure body here", name)); + diag.span_label(span, format!("`{}` escapes the {} body here", + name, escapes_from)); } } @@ -409,12 +409,14 @@ impl<'tcx> RegionInferenceContext<'tcx> { let outlived_fr_name = self.give_region_a_name( infcx, mir, mir_def_id, outlived_fr, counter, &mut diag); + let mir_def_name = if infcx.tcx.is_closure(mir_def_id) { "closure" } else { "function" }; + match (category, outlived_fr_is_local, fr_is_local) { (ConstraintCategory::Return, true, _) => { diag.span_label(span, format!( - "closure was supposed to return data with lifetime `{}` but it is returning \ + "{} was supposed to return data with lifetime `{}` but it is returning \ data with lifetime `{}`", - fr_name, outlived_fr_name, + mir_def_name, fr_name, outlived_fr_name, )); }, _ => { diff --git a/src/test/ui/impl-trait/static-return-lifetime-infered.nll.stderr b/src/test/ui/impl-trait/static-return-lifetime-infered.nll.stderr index c6f8d2e519c..123a93636d2 100644 --- a/src/test/ui/impl-trait/static-return-lifetime-infered.nll.stderr +++ b/src/test/ui/impl-trait/static-return-lifetime-infered.nll.stderr @@ -10,21 +10,19 @@ warning: not reporting region error due to nll LL | self.x.iter().map(|a| a.0) | ^^^^ -error: borrowed data escapes outside of closure +error: unsatisfied lifetime constraints --> $DIR/static-return-lifetime-infered.rs:17:9 | LL | fn iter_values_anon(&self) -> impl Iterator { - | ----- `self` is a reference that is only valid in the closure body + | - let's call the lifetime of this reference `'1` LL | self.x.iter().map(|a| a.0) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `self` escapes the closure body here + | ^^^^^^^^^^^^^ free region requires that `'1` must outlive `'static` -error: borrowed data escapes outside of closure +error: unsatisfied lifetime constraints --> $DIR/static-return-lifetime-infered.rs:21:9 | -LL | fn iter_values<'a>(&'a self) -> impl Iterator { - | -------- `self` is a reference that is only valid in the closure body LL | self.x.iter().map(|a| a.0) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `self` escapes the closure body here + | ^^^^^^^^^^^^^ free region requires that `'a` must outlive `'static` error: aborting due to 2 previous errors diff --git a/src/test/ui/in-band-lifetimes/impl/dyn-trait.nll.stderr b/src/test/ui/in-band-lifetimes/impl/dyn-trait.nll.stderr index e26b1956d5e..f5d98e04ad8 100644 --- a/src/test/ui/in-band-lifetimes/impl/dyn-trait.nll.stderr +++ b/src/test/ui/in-band-lifetimes/impl/dyn-trait.nll.stderr @@ -4,13 +4,13 @@ warning: not reporting region error due to nll LL | static_val(x); //~ ERROR cannot infer | ^ -error: borrowed data escapes outside of closure +error: borrowed data escapes outside of function --> $DIR/dyn-trait.rs:32:5 | LL | fn with_dyn_debug_static<'a>(x: Box) { - | - `x` is a reference that is only valid in the closure body + | - `x` is a reference that is only valid in the function body LL | static_val(x); //~ ERROR cannot infer - | ^^^^^^^^^^^^^ `x` escapes the closure body here + | ^^^^^^^^^^^^^ `x` escapes the function body here error: aborting due to previous error diff --git a/src/test/ui/issue-16683.nll.stderr b/src/test/ui/issue-16683.nll.stderr index f9dda27da09..890bb426441 100644 --- a/src/test/ui/issue-16683.nll.stderr +++ b/src/test/ui/issue-16683.nll.stderr @@ -10,13 +10,13 @@ warning: not reporting region error due to nll LL | self.a(); //~ ERROR cannot infer | ^ -error: borrowed data escapes outside of closure +error: borrowed data escapes outside of function --> $DIR/issue-16683.rs:14:9 | LL | fn b(&self) { - | ----- `self` is a reference that is only valid in the closure body + | ----- `self` is a reference that is only valid in the function body LL | self.a(); //~ ERROR cannot infer - | ^^^^^^^^ `self` escapes the closure body here + | ^^^^^^^^ `self` escapes the function body here error: aborting due to previous error diff --git a/src/test/ui/issue-17758.nll.stderr b/src/test/ui/issue-17758.nll.stderr index 5775135aefc..c51a72f885d 100644 --- a/src/test/ui/issue-17758.nll.stderr +++ b/src/test/ui/issue-17758.nll.stderr @@ -10,13 +10,13 @@ warning: not reporting region error due to nll LL | self.foo(); | ^^^ -error: borrowed data escapes outside of closure +error: borrowed data escapes outside of function --> $DIR/issue-17758.rs:17:9 | LL | fn bar(&self) { - | ----- `self` is a reference that is only valid in the closure body + | ----- `self` is a reference that is only valid in the function body LL | self.foo(); - | ^^^^^^^^^^ `self` escapes the closure body here + | ^^^^^^^^^^ `self` escapes the function body here error: aborting due to previous error diff --git a/src/test/ui/issue-52213.nll.stderr b/src/test/ui/issue-52213.nll.stderr index fb5da7d7a19..c288cf9ed82 100644 --- a/src/test/ui/issue-52213.nll.stderr +++ b/src/test/ui/issue-52213.nll.stderr @@ -5,10 +5,10 @@ LL | match (&t,) { //~ ERROR cannot infer an appropriate lifetime | ^^^^^ error: unsatisfied lifetime constraints - --> $DIR/issue-52213.rs:12:11 + --> $DIR/issue-52213.rs:13:11 | -LL | match (&t,) { //~ ERROR cannot infer an appropriate lifetime - | ^^^^^ free region requires that `'a` must outlive `'b` +LL | ((u,),) => u, + | ^ free region requires that `'a` must outlive `'b` error: aborting due to previous error diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr index 3177cd7c28f..33e4240736f 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr @@ -23,18 +23,18 @@ LL | | }); = note: number of external vids: 2 = note: where '_#1r: '_#0r -error: borrowed data escapes outside of closure +error: borrowed data escapes outside of function --> $DIR/propagate-approximated-shorter-to-static-no-bound.rs:45:5 | LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { - | ------ `cell_a` is a reference that is only valid in the closure body + | ------ `cell_a` is a reference that is only valid in the function body LL | / establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { LL | | //~^ ERROR LL | | LL | | // Only works if 'x: 'y: LL | | demand_y(x, y, x.get()) //~ WARNING not reporting region error due to nll LL | | }); - | |______^ `cell_a` escapes the closure body here + | |______^ `cell_a` escapes the function body here note: No external requirements --> $DIR/propagate-approximated-shorter-to-static-no-bound.rs:44:1 diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr index 089c88abcdd..5f98a0fd36d 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr @@ -23,18 +23,18 @@ LL | | }); = note: number of external vids: 3 = note: where '_#1r: '_#0r -error: borrowed data escapes outside of closure +error: borrowed data escapes outside of function --> $DIR/propagate-approximated-shorter-to-static-wrong-bound.rs:48:5 | LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { - | ------ `cell_a` is a reference that is only valid in the closure body + | ------ `cell_a` is a reference that is only valid in the function body LL | / establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { LL | | //~^ ERROR LL | | // Only works if 'x: 'y: LL | | demand_y(x, y, x.get()) LL | | //~^ WARNING not reporting region error due to nll LL | | }); - | |______^ `cell_a` escapes the closure body here + | |______^ `cell_a` escapes the function body here note: No external requirements --> $DIR/propagate-approximated-shorter-to-static-wrong-bound.rs:47:1 diff --git a/src/test/ui/nll/issue-50716.stderr b/src/test/ui/nll/issue-50716.stderr index 8acf2ef51ec..f12ab9b4f96 100644 --- a/src/test/ui/nll/issue-50716.stderr +++ b/src/test/ui/nll/issue-50716.stderr @@ -1,11 +1,11 @@ -error: borrowed data escapes outside of closure +error: borrowed data escapes outside of function --> $DIR/issue-50716.rs:25:14 | LL | fn foo<'a, T: 'static>(s: Box<<&'a T as A>::X>) - | - `s` is a reference that is only valid in the closure body + | - `s` is a reference that is only valid in the function body ... LL | let _x = *s; //~ ERROR - | ^^ `s` escapes the closure body here + | ^^ `s` escapes the function body here error: aborting due to previous error diff --git a/src/test/ui/nll/mir_check_cast_reify.stderr b/src/test/ui/nll/mir_check_cast_reify.stderr index 13f90e1f159..d8f186a2232 100644 --- a/src/test/ui/nll/mir_check_cast_reify.stderr +++ b/src/test/ui/nll/mir_check_cast_reify.stderr @@ -4,14 +4,14 @@ warning: not reporting region error due to nll LL | let f: fn(_) -> _ = foo; | ^^^ -error: borrowed data escapes outside of closure +error: borrowed data escapes outside of function --> $DIR/mir_check_cast_reify.rs:48:5 | LL | fn bar<'a>(x: &'a u32) -> &'static u32 { - | - `x` is a reference that is only valid in the closure body + | - `x` is a reference that is only valid in the function body ... LL | f(x) - | ^^^^ `x` escapes the closure body here + | ^^^^ `x` escapes the function body here error: aborting due to previous error diff --git a/src/test/ui/nll/mir_check_cast_unsafe_fn.stderr b/src/test/ui/nll/mir_check_cast_unsafe_fn.stderr index b08c6f32e6b..98c03e37814 100644 --- a/src/test/ui/nll/mir_check_cast_unsafe_fn.stderr +++ b/src/test/ui/nll/mir_check_cast_unsafe_fn.stderr @@ -4,14 +4,14 @@ warning: not reporting region error due to nll LL | let g: unsafe fn(_) -> _ = f; | ^ -error: borrowed data escapes outside of closure +error: borrowed data escapes outside of function --> $DIR/mir_check_cast_unsafe_fn.rs:20:14 | LL | fn bar<'a>(input: &'a u32, f: fn(&'a u32) -> &'a u32) -> &'static u32 { - | ----- `input` is a reference that is only valid in the closure body + | ----- `input` is a reference that is only valid in the function body ... LL | unsafe { g(input) } - | ^^^^^^^^ `input` escapes the closure body here + | ^^^^^^^^ `input` escapes the function body here error: aborting due to previous error -- cgit 1.4.1-3-g733a5 From f44807ae1ec15c983586077b53445bb45f083327 Mon Sep 17 00:00:00 2001 From: David Wood Date: Thu, 26 Jul 2018 12:29:58 +0200 Subject: Improved mechanism for naming regions in non-annotated types. --- src/librustc/util/ppaux.rs | 40 ++++++++++++++-- .../region_infer/error_reporting/region_name.rs | 56 +++++++++------------- src/test/ui/issue-52533-1.nll.stderr | 17 +++++++ src/test/ui/issue-52533-1.rs | 21 ++++++++ src/test/ui/issue-52533-1.stderr | 22 +++++++++ .../escape-argument-callee.stderr | 2 +- .../propagate-approximated-fail-no-postdom.stderr | 6 +-- ...ate-fail-to-approximate-longer-no-bounds.stderr | 6 +-- ...-fail-to-approximate-longer-wrong-bounds.stderr | 6 +-- 9 files changed, 127 insertions(+), 49 deletions(-) create mode 100644 src/test/ui/issue-52533-1.nll.stderr create mode 100644 src/test/ui/issue-52533-1.rs create mode 100644 src/test/ui/issue-52533-1.stderr (limited to 'src/test/ui') diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index c67453d2b20..15b5edaa3d5 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -19,7 +19,7 @@ use ty::{TyError, TyStr, TyArray, TySlice, TyFloat, TyFnDef, TyFnPtr}; use ty::{TyParam, TyRawPtr, TyRef, TyNever, TyTuple}; use ty::{TyClosure, TyGenerator, TyGeneratorWitness, TyForeign, TyProjection, TyAnon}; use ty::{TyDynamic, TyInt, TyUint, TyInfer}; -use ty::{self, Ty, TyCtxt, TypeFoldable, GenericParamCount, GenericParamDefKind}; +use ty::{self, RegionVid, Ty, TyCtxt, TypeFoldable, GenericParamCount, GenericParamDefKind}; use util::nodemap::FxHashSet; use std::cell::Cell; @@ -32,6 +32,12 @@ use syntax::ast::CRATE_NODE_ID; use syntax::symbol::{Symbol, InternedString}; use hir; +thread_local! { + /// Mechanism for highlighting of specific regions for display in NLL region inference errors. + /// Contains region to highlight and counter for number to use when highlighting. + static HIGHLIGHT_REGION: Cell> = Cell::new(None) +} + macro_rules! gen_display_debug_body { ( $with:path ) => { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { @@ -562,6 +568,19 @@ pub fn parameterized(f: &mut F, PrintContext::new().parameterized(f, substs, did, projections) } +fn get_highlight_region() -> Option<(RegionVid, usize)> { + HIGHLIGHT_REGION.with(|hr| hr.get()) +} + +pub fn with_highlight_region(r: RegionVid, counter: usize, op: impl FnOnce() -> R) -> R { + HIGHLIGHT_REGION.with(|hr| { + assert_eq!(hr.get(), None); + hr.set(Some((r, counter))); + let r = op(); + hr.set(None); + r + }) +} impl<'a, T: Print> Print for &'a T { fn print(&self, f: &mut F, cx: &mut PrintContext) -> fmt::Result { @@ -733,7 +752,7 @@ define_print! { define_print! { () ty::RegionKind, (self, f, cx) { display { - if cx.is_verbose { + if cx.is_verbose || get_highlight_region().is_some() { return self.print_debug(f, cx); } @@ -905,6 +924,15 @@ impl fmt::Debug for ty::FloatVid { impl fmt::Debug for ty::RegionVid { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + if let Some((region, counter)) = get_highlight_region() { + debug!("RegionVid.fmt: region={:?} self={:?} counter={:?}", region, self, counter); + return if *self == region { + write!(f, "'{:?}", counter) + } else { + write!(f, "'_") + } + } + write!(f, "'_#{}r", self.index()) } } @@ -1022,9 +1050,11 @@ define_print! { TyRef(r, ty, mutbl) => { write!(f, "&")?; let s = r.print_to_string(cx); - write!(f, "{}", s)?; - if !s.is_empty() { - write!(f, " ")?; + if s != "'_" { + write!(f, "{}", s)?; + if !s.is_empty() { + write!(f, " ")?; + } } ty::TypeAndMut { ty, mutbl }.print(f, cx) } diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs index f3b437c38d8..8505d8e1ef3 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs @@ -16,6 +16,7 @@ use rustc::infer::InferCtxt; use rustc::mir::Mir; use rustc::ty::subst::{Substs, UnpackedKind}; use rustc::ty::{self, RegionVid, Ty, TyCtxt}; +use rustc::util::ppaux::with_highlight_region; use rustc_errors::DiagnosticBuilder; use syntax::ast::Name; use syntax::symbol::keywords; @@ -228,40 +229,27 @@ impl<'tcx> RegionInferenceContext<'tcx> { counter: &mut usize, diag: &mut DiagnosticBuilder<'_>, ) -> Option { - let mut type_name = infcx.extract_type_name(&argument_ty); - let argument_index = self.get_argument_index_for_region(infcx.tcx, needle_fr)?; - let mut first_region_name = None; - - debug!("give_name_if_we_cannot_match_hir_ty: type_name={:?}", type_name); - while let Some(start_index) = type_name.find("&'_#") { - if let Some(end_index) = type_name[start_index..].find(' ') { - // Need to make the `end_index` relative to the full string. - let end_index = start_index + end_index; - // `start_index + 1` skips the `&`. - // `end_index + 1` goes to (including) the space after the region. - type_name.replace_range(start_index + 1..end_index + 1, ""); - } - } - debug!("give_name_if_we_cannot_match_hir_ty: type_name={:?}", type_name); - - let mut index = 0; - while let Some(next_index) = type_name[index..].find("&") { - // At this point, next_index is the index of the `&` character (starting from - // the last `&` character). - debug!("give_name_if_we_cannot_match_hir_ty: start-of-loop index={:?} type_name={:?}", - index, type_name); - let region_name = self.synthesize_region_name(counter).as_str(); - if first_region_name.is_none() { first_region_name = Some(region_name); } - - // Compute the index of the character after `&` in the original string. - index = next_index + index + 1; - type_name.insert_str(index, &format!("{} ", region_name)); - } - - let (_, span) = self.get_argument_name_and_span_for_region(mir, argument_index); - diag.span_label(span, format!("has type `{}`", type_name)); - - first_region_name.map(|s| s.as_interned_str()) + let type_name = with_highlight_region(needle_fr, *counter, || { + infcx.extract_type_name(&argument_ty) + }); + + debug!("give_name_if_we_cannot_match_hir_ty: type_name={:?} needle_fr={:?}", + type_name, needle_fr); + let assigned_region_name = if type_name.find(&format!("'{}", counter)).is_some() { + // Only add a label if we can confirm that a region was labelled. + let argument_index = self.get_argument_index_for_region(infcx.tcx, needle_fr)?; + let (_, span) = self.get_argument_name_and_span_for_region(mir, argument_index); + diag.span_label(span, format!("has type `{}`", type_name)); + + // This counter value will already have been used, so this function will increment it + // so the next value will be used next and return the region name that would have been + // used. + Some(self.synthesize_region_name(counter)) + } else { + None + }; + + assigned_region_name } /// Attempts to highlight the specific part of a type annotation diff --git a/src/test/ui/issue-52533-1.nll.stderr b/src/test/ui/issue-52533-1.nll.stderr new file mode 100644 index 00000000000..87fda1dd99c --- /dev/null +++ b/src/test/ui/issue-52533-1.nll.stderr @@ -0,0 +1,17 @@ +warning: not reporting region error due to nll + --> $DIR/issue-52533-1.rs:19:18 + | +LL | gimme(|x, y| y) + | ^ + +error: unsatisfied lifetime constraints + --> $DIR/issue-52533-1.rs:19:18 + | +LL | gimme(|x, y| y) + | - - ^ closure was supposed to return data with lifetime `'1` but it is returning data with lifetime `'2` + | | | + | | has type `&Foo<'_, '1, u32>` + | has type `&Foo<'_, '2, u32>` + +error: aborting due to previous error + diff --git a/src/test/ui/issue-52533-1.rs b/src/test/ui/issue-52533-1.rs new file mode 100644 index 00000000000..22af5a86702 --- /dev/null +++ b/src/test/ui/issue-52533-1.rs @@ -0,0 +1,21 @@ +// Copyright 2018 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(warnings)] + +struct Foo<'a, 'b, T: 'a + 'b> { x: &'a T, y: &'b T } + +fn gimme(_: impl for<'a, 'b, 'c> FnOnce(&'a Foo<'a, 'b, u32>, + &'a Foo<'a, 'c, u32>) -> &'a Foo<'a, 'b, u32>) { } + +fn main() { + gimme(|x, y| y) + //~^ ERROR mismatched types [E0308] +} diff --git a/src/test/ui/issue-52533-1.stderr b/src/test/ui/issue-52533-1.stderr new file mode 100644 index 00000000000..38deb7d66de --- /dev/null +++ b/src/test/ui/issue-52533-1.stderr @@ -0,0 +1,22 @@ +error[E0308]: mismatched types + --> $DIR/issue-52533-1.rs:19:18 + | +LL | gimme(|x, y| y) + | ^ lifetime mismatch + | + = note: expected type `&Foo<'_, '_, u32>` + found type `&Foo<'_, '_, u32>` +note: the anonymous lifetime #4 defined on the body at 19:11... + --> $DIR/issue-52533-1.rs:19:11 + | +LL | gimme(|x, y| y) + | ^^^^^^^^ +note: ...does not necessarily outlive the anonymous lifetime #3 defined on the body at 19:11 + --> $DIR/issue-52533-1.rs:19:11 + | +LL | gimme(|x, y| y) + | ^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr b/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr index c7fdbe1685c..99da2141ce9 100644 --- a/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr +++ b/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr @@ -11,7 +11,7 @@ LL | let mut closure = expect_sig(|p, y| *p = y); | - - ^^^^^^ free region requires that `'1` must outlive `'2` | | | | | has type `&'1 i32` - | has type `&'2 mut &'3 i32` + | has type `&mut &'2 i32` note: No external requirements --> $DIR/escape-argument-callee.rs:36:38 diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr index 6882b08f330..b4508824901 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr @@ -8,12 +8,12 @@ error: unsatisfied lifetime constraints --> $DIR/propagate-approximated-fail-no-postdom.rs:57:13 | LL | |_outlives1, _outlives2, _outlives3, x, y| { - | ---------- ---------- has type `std::cell::Cell<&'3 &'4 u32>` + | ---------- ---------- has type `std::cell::Cell<&'2 &u32>` | | - | has type `std::cell::Cell<&'1 &'2 u32>` + | has type `std::cell::Cell<&&'1 u32>` ... LL | demand_y(x, y, p) //~ ERROR - | ^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'3` + | ^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2` note: No external requirements --> $DIR/propagate-approximated-fail-no-postdom.rs:53:9 diff --git a/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr b/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr index 771d1df2df0..40ebda4419b 100644 --- a/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr @@ -8,12 +8,12 @@ error: unsatisfied lifetime constraints --> $DIR/propagate-fail-to-approximate-longer-no-bounds.rs:47:9 | LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { - | --------- - has type `&'1 std::cell::Cell<&'2 u32>` + | --------- - has type `&std::cell::Cell<&'1 u32>` | | - | has type `&'3 std::cell::Cell<&'4 &'5 u32>` + | has type `&std::cell::Cell<&'2 &u32>` LL | // Only works if 'x: 'y: LL | demand_y(x, y, x.get()) - | ^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'3` + | ^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2` note: No external requirements --> $DIR/propagate-fail-to-approximate-longer-no-bounds.rs:45:47 diff --git a/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr b/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr index 1ac52e5e560..37ea6103976 100644 --- a/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr @@ -8,12 +8,12 @@ error: unsatisfied lifetime constraints --> $DIR/propagate-fail-to-approximate-longer-wrong-bounds.rs:51:9 | LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { - | ---------- ---------- has type `&'4 std::cell::Cell<&'5 &'6 u32>` + | ---------- ---------- has type `&std::cell::Cell<&'2 &u32>` | | - | has type `&'1 std::cell::Cell<&'2 &'3 u32>` + | has type `&std::cell::Cell<&'1 &u32>` LL | // Only works if 'x: 'y: LL | demand_y(x, y, x.get()) - | ^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'4` + | ^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2` note: No external requirements --> $DIR/propagate-fail-to-approximate-longer-wrong-bounds.rs:49:47 -- cgit 1.4.1-3-g733a5 From 2e4224a9983cacf6ef1a2787c0084d743abb27e1 Mon Sep 17 00:00:00 2001 From: David Wood Date: Thu, 26 Jul 2018 15:36:41 +0200 Subject: Region inference error messages no longer start with 'free region' --- .../borrow_check/nll/region_infer/error_reporting/mod.rs | 13 +++++++------ .../E0621-does-not-trigger-for-closures.nll.stderr | 2 +- .../ui/impl-trait/static-return-lifetime-infered.nll.stderr | 4 ++-- src/test/ui/issue-10291.nll.stderr | 2 +- src/test/ui/issue-40510-3.nll.stderr | 2 +- src/test/ui/issue-52213.nll.stderr | 2 +- .../nll/closure-requirements/escape-argument-callee.stderr | 2 +- .../region-lbr-named-does-not-outlive-static.stderr | 2 +- 8 files changed, 15 insertions(+), 14 deletions(-) (limited to 'src/test/ui') diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs index c88259d5e8f..c2c5c6771b0 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs @@ -39,12 +39,13 @@ enum ConstraintCategory { impl fmt::Display for ConstraintCategory { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + // Must end with a space. Allows for empty names to be provided. match self { - ConstraintCategory::Assignment => write!(f, "assignment"), - ConstraintCategory::Return => write!(f, "return"), - ConstraintCategory::Cast => write!(f, "cast"), - ConstraintCategory::CallArgument => write!(f, "argument"), - _ => write!(f, "free region"), + ConstraintCategory::Assignment => write!(f, "assignment "), + ConstraintCategory::Return => write!(f, "return "), + ConstraintCategory::Cast => write!(f, "cast "), + ConstraintCategory::CallArgument => write!(f, "argument "), + _ => write!(f, ""), } } } @@ -421,7 +422,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { }, _ => { diag.span_label(span, format!( - "{} requires that `{}` must outlive `{}`", + "{}requires that `{}` must outlive `{}`", category, fr_name, outlived_fr_name, )); }, diff --git a/src/test/ui/error-codes/E0621-does-not-trigger-for-closures.nll.stderr b/src/test/ui/error-codes/E0621-does-not-trigger-for-closures.nll.stderr index 14d889dca73..0ac295c54bc 100644 --- a/src/test/ui/error-codes/E0621-does-not-trigger-for-closures.nll.stderr +++ b/src/test/ui/error-codes/E0621-does-not-trigger-for-closures.nll.stderr @@ -10,7 +10,7 @@ error: unsatisfied lifetime constraints LL | invoke(&x, |a, b| if a > b { a } else { b }); //~ ERROR E0495 | ----------^^^^^----------------- | | | | - | | | free region requires that `'1` must outlive `'2` + | | | requires that `'1` must outlive `'2` | | has type `&'1 i32` | lifetime `'2` appears in return type diff --git a/src/test/ui/impl-trait/static-return-lifetime-infered.nll.stderr b/src/test/ui/impl-trait/static-return-lifetime-infered.nll.stderr index 123a93636d2..bbc63e6feca 100644 --- a/src/test/ui/impl-trait/static-return-lifetime-infered.nll.stderr +++ b/src/test/ui/impl-trait/static-return-lifetime-infered.nll.stderr @@ -16,13 +16,13 @@ error: unsatisfied lifetime constraints LL | fn iter_values_anon(&self) -> impl Iterator { | - let's call the lifetime of this reference `'1` LL | self.x.iter().map(|a| a.0) - | ^^^^^^^^^^^^^ free region requires that `'1` must outlive `'static` + | ^^^^^^^^^^^^^ requires that `'1` must outlive `'static` error: unsatisfied lifetime constraints --> $DIR/static-return-lifetime-infered.rs:21:9 | LL | self.x.iter().map(|a| a.0) - | ^^^^^^^^^^^^^ free region requires that `'a` must outlive `'static` + | ^^^^^^^^^^^^^ requires that `'a` must outlive `'static` error: aborting due to 2 previous errors diff --git a/src/test/ui/issue-10291.nll.stderr b/src/test/ui/issue-10291.nll.stderr index 1358fe010b4..6de00ffd48c 100644 --- a/src/test/ui/issue-10291.nll.stderr +++ b/src/test/ui/issue-10291.nll.stderr @@ -8,7 +8,7 @@ error: unsatisfied lifetime constraints --> $DIR/issue-10291.rs:12:5 | LL | drop:: FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ free region requires that `'x` must outlive `'static` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'x` must outlive `'static` error: aborting due to previous error diff --git a/src/test/ui/issue-40510-3.nll.stderr b/src/test/ui/issue-40510-3.nll.stderr index 4133c69f031..eb44850e639 100644 --- a/src/test/ui/issue-40510-3.nll.stderr +++ b/src/test/ui/issue-40510-3.nll.stderr @@ -9,7 +9,7 @@ LL | || || { | ||_________^ LL | ||| x.push(()) LL | ||| } - | |||_________^ free region requires that `'1` must outlive `'2` + | |||_________^ requires that `'1` must outlive `'2` LL | || }; | || - | ||_____| diff --git a/src/test/ui/issue-52213.nll.stderr b/src/test/ui/issue-52213.nll.stderr index c288cf9ed82..7dd513d1b71 100644 --- a/src/test/ui/issue-52213.nll.stderr +++ b/src/test/ui/issue-52213.nll.stderr @@ -8,7 +8,7 @@ error: unsatisfied lifetime constraints --> $DIR/issue-52213.rs:13:11 | LL | ((u,),) => u, - | ^ free region requires that `'a` must outlive `'b` + | ^ requires that `'a` must outlive `'b` error: aborting due to previous error diff --git a/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr b/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr index 99da2141ce9..ccf116e640d 100644 --- a/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr +++ b/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr @@ -8,7 +8,7 @@ error: unsatisfied lifetime constraints --> $DIR/escape-argument-callee.rs:36:45 | LL | let mut closure = expect_sig(|p, y| *p = y); - | - - ^^^^^^ free region requires that `'1` must outlive `'2` + | - - ^^^^^^ requires that `'1` must outlive `'2` | | | | | has type `&'1 i32` | has type `&mut &'2 i32` diff --git a/src/test/ui/nll/closure-requirements/region-lbr-named-does-not-outlive-static.stderr b/src/test/ui/nll/closure-requirements/region-lbr-named-does-not-outlive-static.stderr index d012dca2527..b0562711627 100644 --- a/src/test/ui/nll/closure-requirements/region-lbr-named-does-not-outlive-static.stderr +++ b/src/test/ui/nll/closure-requirements/region-lbr-named-does-not-outlive-static.stderr @@ -8,7 +8,7 @@ error: unsatisfied lifetime constraints --> $DIR/region-lbr-named-does-not-outlive-static.rs:19:5 | LL | &*x - | ^^^ free region requires that `'a` must outlive `'static` + | ^^^ requires that `'a` must outlive `'static` error: aborting due to previous error -- cgit 1.4.1-3-g733a5