Skip to content

Commit 2e4224a

Browse files
committed
Region inference error messages no longer start with 'free region'
1 parent f44807a commit 2e4224a

File tree

8 files changed

+15
-14
lines changed

8 files changed

+15
-14
lines changed

src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,13 @@ enum ConstraintCategory {
3939

4040
impl fmt::Display for ConstraintCategory {
4141
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
42+
// Must end with a space. Allows for empty names to be provided.
4243
match self {
43-
ConstraintCategory::Assignment => write!(f, "assignment"),
44-
ConstraintCategory::Return => write!(f, "return"),
45-
ConstraintCategory::Cast => write!(f, "cast"),
46-
ConstraintCategory::CallArgument => write!(f, "argument"),
47-
_ => write!(f, "free region"),
44+
ConstraintCategory::Assignment => write!(f, "assignment "),
45+
ConstraintCategory::Return => write!(f, "return "),
46+
ConstraintCategory::Cast => write!(f, "cast "),
47+
ConstraintCategory::CallArgument => write!(f, "argument "),
48+
_ => write!(f, ""),
4849
}
4950
}
5051
}
@@ -421,7 +422,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
421422
},
422423
_ => {
423424
diag.span_label(span, format!(
424-
"{} requires that `{}` must outlive `{}`",
425+
"{}requires that `{}` must outlive `{}`",
425426
category, fr_name, outlived_fr_name,
426427
));
427428
},

src/test/ui/error-codes/E0621-does-not-trigger-for-closures.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ error: unsatisfied lifetime constraints
1010
LL | invoke(&x, |a, b| if a > b { a } else { b }); //~ ERROR E0495
1111
| ----------^^^^^-----------------
1212
| | | |
13-
| | | free region requires that `'1` must outlive `'2`
13+
| | | requires that `'1` must outlive `'2`
1414
| | has type `&'1 i32`
1515
| lifetime `'2` appears in return type
1616

src/test/ui/impl-trait/static-return-lifetime-infered.nll.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ error: unsatisfied lifetime constraints
1616
LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> {
1717
| - let's call the lifetime of this reference `'1`
1818
LL | self.x.iter().map(|a| a.0)
19-
| ^^^^^^^^^^^^^ free region requires that `'1` must outlive `'static`
19+
| ^^^^^^^^^^^^^ requires that `'1` must outlive `'static`
2020

2121
error: unsatisfied lifetime constraints
2222
--> $DIR/static-return-lifetime-infered.rs:21:9
2323
|
2424
LL | self.x.iter().map(|a| a.0)
25-
| ^^^^^^^^^^^^^ free region requires that `'a` must outlive `'static`
25+
| ^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
2626

2727
error: aborting due to 2 previous errors
2828

src/test/ui/issue-10291.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ error: unsatisfied lifetime constraints
88
--> $DIR/issue-10291.rs:12:5
99
|
1010
LL | drop::<Box<for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| {
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ free region requires that `'x` must outlive `'static`
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'x` must outlive `'static`
1212

1313
error: aborting due to previous error
1414

src/test/ui/issue-40510-3.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LL | || || {
99
| ||_________^
1010
LL | ||| x.push(())
1111
LL | ||| }
12-
| |||_________^ free region requires that `'1` must outlive `'2`
12+
| |||_________^ requires that `'1` must outlive `'2`
1313
LL | || };
1414
| || -
1515
| ||_____|

src/test/ui/issue-52213.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ error: unsatisfied lifetime constraints
88
--> $DIR/issue-52213.rs:13:11
99
|
1010
LL | ((u,),) => u,
11-
| ^ free region requires that `'a` must outlive `'b`
11+
| ^ requires that `'a` must outlive `'b`
1212

1313
error: aborting due to previous error
1414

src/test/ui/nll/closure-requirements/escape-argument-callee.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ error: unsatisfied lifetime constraints
88
--> $DIR/escape-argument-callee.rs:36:45
99
|
1010
LL | let mut closure = expect_sig(|p, y| *p = y);
11-
| - - ^^^^^^ free region requires that `'1` must outlive `'2`
11+
| - - ^^^^^^ requires that `'1` must outlive `'2`
1212
| | |
1313
| | has type `&'1 i32`
1414
| has type `&mut &'2 i32`

src/test/ui/nll/closure-requirements/region-lbr-named-does-not-outlive-static.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ error: unsatisfied lifetime constraints
88
--> $DIR/region-lbr-named-does-not-outlive-static.rs:19:5
99
|
1010
LL | &*x
11-
| ^^^ free region requires that `'a` must outlive `'static`
11+
| ^^^ requires that `'a` must outlive `'static`
1212

1313
error: aborting due to previous error
1414

0 commit comments

Comments
 (0)