Skip to content

Commit 4fce59f

Browse files
committed
remove unnecessary blame_span from report_region_errors
1 parent 52c94e9 commit 4fce59f

22 files changed

+76
-61
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -199,19 +199,10 @@ impl<'tcx> RegionInferenceContext<'tcx> {
199199
mir_def_id: DefId,
200200
fr: RegionVid,
201201
outlived_fr: RegionVid,
202-
blame_span: Span,
203202
errors_buffer: &mut Vec<Diagnostic>,
204203
) {
205204
debug!("report_error(fr={:?}, outlived_fr={:?})", fr, outlived_fr);
206205

207-
if let (Some(f), Some(o)) = (self.to_error_region(fr), self.to_error_region(outlived_fr)) {
208-
let tables = infcx.tcx.typeck_tables_of(mir_def_id);
209-
let nice = NiceRegionError::new_from_span(infcx.tcx, blame_span, o, f, Some(tables));
210-
if let Some(_error_reported) = nice.try_report() {
211-
return;
212-
}
213-
}
214-
215206
// Find all paths
216207
let constraint_paths = self.find_constraint_paths_between_regions(fr, |r| r == outlived_fr);
217208
debug!("report_error: constraint_paths={:#?}", constraint_paths);
@@ -233,6 +224,15 @@ impl<'tcx> RegionInferenceContext<'tcx> {
233224
// Get a span
234225
let (category, span) = categorized_path.first().unwrap();
235226

227+
// Check if we can use one of the "nice region errors".
228+
if let (Some(f), Some(o)) = (self.to_error_region(fr), self.to_error_region(outlived_fr)) {
229+
let tables = infcx.tcx.typeck_tables_of(mir_def_id);
230+
let nice = NiceRegionError::new_from_span(infcx.tcx, *span, o, f, Some(tables));
231+
if let Some(_error_reported) = nice.try_report() {
232+
return;
233+
}
234+
}
235+
236236
let category = match (
237237
category,
238238
self.universal_regions.is_local_free_region(fr),

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
921921
// to report the error. This gives better error messages
922922
// in some cases.
923923
self.report_error(
924-
mir, infcx, mir_def_id, longer_fr, shorter_fr, blame_span, errors_buffer);
924+
mir, infcx, mir_def_id, longer_fr, shorter_fr, errors_buffer);
925925
}
926926
}
927927
}

src/test/ui/issue-40288-2.nll.stderr

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,22 @@ LL | let mut out = Struct { head: x, _tail: [()] };
3535
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3636

3737
error[E0621]: explicit lifetime required in the type of `y`
38-
--> $DIR/issue-40288-2.rs:14:9
38+
--> $DIR/issue-40288-2.rs:16:31
3939
|
4040
LL | fn lifetime_transmute_slice<'a, T: ?Sized>(x: &'a T, y: &T) -> &'a T {
4141
| - consider changing the type of `y` to `&'a T`
42-
LL | let mut out = [x];
43-
| ^^^^^^^ lifetime `'a` required
42+
...
43+
LL | let slice: &mut [_] = &mut out;
44+
| ^^^^^^^^ lifetime `'a` required
4445

4546
error[E0621]: explicit lifetime required in the type of `y`
46-
--> $DIR/issue-40288-2.rs:29:9
47+
--> $DIR/issue-40288-2.rs:31:41
4748
|
4849
LL | fn lifetime_transmute_struct<'a, T: ?Sized>(x: &'a T, y: &T) -> &'a T {
4950
| - consider changing the type of `y` to `&'a T`
50-
LL | let mut out = Struct { head: x, _tail: [()] };
51-
| ^^^^^^^ lifetime `'a` required
51+
...
52+
LL | let dst: &mut Struct<_, [()]> = &mut out;
53+
| ^^^^^^^^ lifetime `'a` required
5254

5355
error: aborting due to 2 previous errors
5456

src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-3.nll.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ LL | if x > y { x } else { y } //~ ERROR explicit lifetime
55
| ^
66

77
error[E0621]: explicit lifetime required in parameter type
8-
--> $DIR/ex1-return-one-existing-name-if-else-3.rs:11:13
8+
--> $DIR/ex1-return-one-existing-name-if-else-3.rs:11:16
99
|
1010
LL | fn foo<'a>((x, y): (&'a i32, &i32)) -> &'a i32 {
11-
| -^----
12-
| ||
13-
| |lifetime `'a` required
11+
| ----^-
12+
| | |
13+
| | lifetime `'a` required
1414
| consider changing type to `(&'a i32, &'a i32)`
1515

1616
error: aborting due to previous error

src/test/ui/lifetime-errors/ex2a-push-one-existing-name-2.nll.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ error[E0621]: explicit lifetime required in the type of `x`
1010
LL | fn foo<'a>(x: Ref<i32>, y: &mut Vec<Ref<'a, i32>>) {
1111
| - consider changing the type of `x` to `Ref<'a, i32>`
1212
LL | y.push(x); //~ ERROR explicit lifetime
13-
| ^ lifetime `'a` required
13+
| ^^^^^^^^^ lifetime `'a` required
1414

1515
error: aborting due to previous error
1616

src/test/ui/lifetime-errors/ex2a-push-one-existing-name.nll.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ error[E0621]: explicit lifetime required in the type of `y`
1010
LL | fn foo<'a>(x: &mut Vec<Ref<'a, i32>>, y: Ref<i32>) {
1111
| - consider changing the type of `y` to `Ref<'a, i32>`
1212
LL | x.push(y); //~ ERROR explicit lifetime
13-
| ^ lifetime `'a` required
13+
| ^^^^^^^^^ lifetime `'a` required
1414

1515
error: aborting due to previous error
1616

src/test/ui/lifetime-errors/ex2b-push-no-existing-names.nll.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ error[E0623]: lifetime mismatch
1010
LL | fn foo(x: &mut Vec<Ref<i32>>, y: Ref<i32>) {
1111
| -------- -------- these two types are declared with different lifetimes...
1212
LL | x.push(y); //~ ERROR lifetime mismatch
13-
| ^ ...but data from `y` flows into `x` here
13+
| ^^^^^^^^^ ...but data from `y` flows into `x` here
1414

1515
error: aborting due to previous error
1616

src/test/ui/lifetime-errors/ex2c-push-inference-variable.nll.stderr

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ LL | let z = Ref { data: y.data };
55
| ^^^
66

77
error[E0623]: lifetime mismatch
8-
--> $DIR/ex2c-push-inference-variable.rs:16:9
8+
--> $DIR/ex2c-push-inference-variable.rs:17:5
99
|
1010
LL | fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) {
1111
| ------------ ------------ these two types are declared with different lifetimes...
1212
LL | let z = Ref { data: y.data };
13-
| ^ ...but data from `y` flows into `x` here
13+
LL | x.push(z); //~ ERROR lifetime mismatch
14+
| ^^^^^^^^^ ...but data from `y` flows into `x` here
1415

1516
error: aborting due to previous error
1617

src/test/ui/lifetime-errors/ex2d-push-inference-variable-2.nll.stderr

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ LL | let b = Ref { data: y.data };
55
| ^^^
66

77
error[E0623]: lifetime mismatch
8-
--> $DIR/ex2d-push-inference-variable-2.rs:16:9
8+
--> $DIR/ex2d-push-inference-variable-2.rs:18:5
99
|
1010
LL | fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) {
1111
| ------------ ------------ these two types are declared with different lifetimes...
12-
LL | let a: &mut Vec<Ref<i32>> = x; //~ ERROR lifetime mismatch
13-
| ^ ...but data from `y` flows into `x` here
12+
...
13+
LL | a.push(b);
14+
| ^^^^^^^^^ ...but data from `y` flows into `x` here
1415

1516
error: aborting due to previous error
1617

src/test/ui/lifetime-errors/ex2e-push-inference-variable-3.nll.stderr

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ LL | let b = Ref { data: y.data };
55
| ^^^
66

77
error[E0623]: lifetime mismatch
8-
--> $DIR/ex2e-push-inference-variable-3.rs:16:9
8+
--> $DIR/ex2e-push-inference-variable-3.rs:18:5
99
|
1010
LL | fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) {
1111
| ------------ ------------ these two types are declared with different lifetimes...
12-
LL | let a: &mut Vec<Ref<i32>> = x; //~ ERROR lifetime mismatch
13-
| ^ ...but data from `y` flows into `x` here
12+
...
13+
LL | Vec::push(a, b);
14+
| ^^^^^^^^^^^^^^^ ...but data from `y` flows into `x` here
1415

1516
error: aborting due to previous error
1617

0 commit comments

Comments
 (0)