Skip to content

Commit b9e1806

Browse files
committed
Use def_span for external requirements.
1 parent d85dff7 commit b9e1806

24 files changed

+137
-421
lines changed

compiler/rustc_borrowck/src/nll.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,9 @@ pub(super) fn dump_annotation<'a, 'tcx>(
389389
// viewing the intraprocedural state, the -Zdump-mir output is
390390
// better.
391391

392+
let def_span = tcx.def_span(body.source.def_id());
392393
let mut err = if let Some(closure_region_requirements) = closure_region_requirements {
393-
let mut err = tcx.sess.diagnostic().span_note_diag(body.span, "external requirements");
394+
let mut err = tcx.sess.diagnostic().span_note_diag(def_span, "external requirements");
394395

395396
regioncx.annotate(tcx, &mut err);
396397

@@ -409,7 +410,7 @@ pub(super) fn dump_annotation<'a, 'tcx>(
409410

410411
err
411412
} else {
412-
let mut err = tcx.sess.diagnostic().span_note_diag(body.span, "no external requirements");
413+
let mut err = tcx.sess.diagnostic().span_note_diag(def_span, "no external requirements");
413414
regioncx.annotate(tcx, &mut err);
414415

415416
err

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

+3-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ note: no external requirements
22
--> $DIR/escape-argument-callee.rs:26:38
33
|
44
LL | let mut closure = expect_sig(|p, y| *p = y);
5-
| ^^^^^^^^^^^^^
5+
| ^^^^^^
66
|
77
= note: defining type: test::{closure#0} with closure substs [
88
i16,
@@ -22,14 +22,8 @@ LL | let mut closure = expect_sig(|p, y| *p = y);
2222
note: no external requirements
2323
--> $DIR/escape-argument-callee.rs:20:1
2424
|
25-
LL | / fn test() {
26-
LL | | let x = 44;
27-
LL | | let mut p = &x;
28-
LL | |
29-
... |
30-
LL | | deref(p);
31-
LL | | }
32-
| |_^
25+
LL | fn test() {
26+
| ^^^^^^^^^
3327
|
3428
= note: defining type: test
3529

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

+3-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ note: no external requirements
22
--> $DIR/escape-argument.rs:26:38
33
|
44
LL | let mut closure = expect_sig(|p, y| *p = y);
5-
| ^^^^^^^^^^^^^
5+
| ^^^^^^
66
|
77
= note: defining type: test::{closure#0} with closure substs [
88
i16,
@@ -13,14 +13,8 @@ LL | let mut closure = expect_sig(|p, y| *p = y);
1313
note: no external requirements
1414
--> $DIR/escape-argument.rs:20:1
1515
|
16-
LL | / fn test() {
17-
LL | | let x = 44;
18-
LL | | let mut p = &x;
19-
LL | |
20-
... |
21-
LL | | deref(p);
22-
LL | | }
23-
| |_^
16+
LL | fn test() {
17+
| ^^^^^^^^^
2418
|
2519
= note: defining type: test
2620

src/test/ui/nll/closure-requirements/escape-upvar-nested.stderr

+5-15
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ note: external requirements
22
--> $DIR/escape-upvar-nested.rs:21:32
33
|
44
LL | let mut closure1 = || p = &y;
5-
| ^^^^^^^^^
5+
| ^^
66
|
77
= note: defining type: test::{closure#0}::{closure#0} with closure substs [
88
i16,
@@ -15,12 +15,8 @@ LL | let mut closure1 = || p = &y;
1515
note: external requirements
1616
--> $DIR/escape-upvar-nested.rs:20:27
1717
|
18-
LL | let mut closure = || {
19-
| ___________________________^
20-
LL | | let mut closure1 = || p = &y;
21-
LL | | closure1();
22-
LL | | };
23-
| |_________^
18+
LL | let mut closure = || {
19+
| ^^
2420
|
2521
= note: defining type: test::{closure#0} with closure substs [
2622
i16,
@@ -33,14 +29,8 @@ LL | | };
3329
note: no external requirements
3430
--> $DIR/escape-upvar-nested.rs:13:1
3531
|
36-
LL | / fn test() {
37-
LL | | let x = 44;
38-
LL | | let mut p = &x;
39-
LL | |
40-
... |
41-
LL | | deref(p);
42-
LL | | }
43-
| |_^
32+
LL | fn test() {
33+
| ^^^^^^^^^
4434
|
4535
= note: defining type: test
4636

src/test/ui/nll/closure-requirements/escape-upvar-ref.stderr

+3-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ note: external requirements
22
--> $DIR/escape-upvar-ref.rs:23:27
33
|
44
LL | let mut closure = || p = &y;
5-
| ^^^^^^^^^
5+
| ^^
66
|
77
= note: defining type: test::{closure#0} with closure substs [
88
i16,
@@ -15,14 +15,8 @@ LL | let mut closure = || p = &y;
1515
note: no external requirements
1616
--> $DIR/escape-upvar-ref.rs:17:1
1717
|
18-
LL | / fn test() {
19-
LL | | let x = 44;
20-
LL | | let mut p = &x;
21-
LL | |
22-
... |
23-
LL | | deref(p);
24-
LL | | }
25-
| |_^
18+
LL | fn test() {
19+
| ^^^^^^^^^
2620
|
2721
= note: defining type: test
2822

src/test/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr

+4-14
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
note: no external requirements
22
--> $DIR/propagate-approximated-fail-no-postdom.rs:43:9
33
|
4-
LL | / |_outlives1, _outlives2, _outlives3, x, y| {
5-
LL | | // Only works if 'x: 'y:
6-
LL | | let p = x.get();
7-
LL | | demand_y(x, y, p)
8-
LL | | },
9-
| |_________^
4+
LL | |_outlives1, _outlives2, _outlives3, x, y| {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
106
|
117
= note: defining type: supply::{closure#0} with closure substs [
128
i16,
@@ -31,14 +27,8 @@ LL | demand_y(x, y, p)
3127
note: no external requirements
3228
--> $DIR/propagate-approximated-fail-no-postdom.rs:38:1
3329
|
34-
LL | / fn supply<'a, 'b, 'c>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>, cell_c: Cell<&'c u32>) {
35-
LL | | establish_relationships(
36-
LL | | cell_a,
37-
LL | | cell_b,
38-
... |
39-
LL | | );
40-
LL | | }
41-
| |_^
30+
LL | fn supply<'a, 'b, 'c>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>, cell_c: Cell<&'c u32>) {
31+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4232
|
4333
= note: defining type: supply
4434

src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr

+4-15
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
note: external requirements
22
--> $DIR/propagate-approximated-ref.rs:43:47
33
|
4-
LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
5-
| _______________________________________________^
6-
LL | | // Only works if 'x: 'y:
7-
LL | | demand_y(x, y, x.get())
8-
LL | |
9-
LL | | });
10-
| |_____^
4+
LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
116
|
127
= note: defining type: supply::{closure#0} with closure substs [
138
i16,
@@ -22,14 +17,8 @@ LL | | });
2217
note: no external requirements
2318
--> $DIR/propagate-approximated-ref.rs:42:1
2419
|
25-
LL | / fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
26-
LL | | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
27-
LL | | // Only works if 'x: 'y:
28-
LL | | demand_y(x, y, x.get())
29-
LL | |
30-
LL | | });
31-
LL | | }
32-
| |_^
20+
LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
21+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3322
|
3423
= note: defining type: supply
3524

src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr

+8-27
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
note: no external requirements
22
--> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:21:15
33
|
4-
LL | foo(cell, |cell_a, cell_x| {
5-
| _______________^
6-
LL | | cell_a.set(cell_x.get()); // forces 'x: 'a, error in closure
7-
LL | |
8-
LL | | })
9-
| |_____^
4+
LL | foo(cell, |cell_a, cell_x| {
5+
| ^^^^^^^^^^^^^^^^
106
|
117
= note: defining type: case1::{closure#0} with closure substs [
128
i32,
@@ -27,25 +23,16 @@ LL | cell_a.set(cell_x.get()); // forces 'x: 'a, error in closure
2723
note: no external requirements
2824
--> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:18:1
2925
|
30-
LL | / fn case1() {
31-
LL | | let a = 0;
32-
LL | | let cell = Cell::new(&a);
33-
LL | | foo(cell, |cell_a, cell_x| {
34-
... |
35-
LL | | })
36-
LL | | }
37-
| |_^
26+
LL | fn case1() {
27+
| ^^^^^^^^^^
3828
|
3929
= note: defining type: case1
4030

4131
note: external requirements
4232
--> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:35:15
4333
|
44-
LL | foo(cell, |cell_a, cell_x| {
45-
| _______________^
46-
LL | | cell_x.set(cell_a.get()); // forces 'a: 'x, implies 'a = 'static -> borrow error
47-
LL | | })
48-
| |_____^
34+
LL | foo(cell, |cell_a, cell_x| {
35+
| ^^^^^^^^^^^^^^^^
4936
|
5037
= note: defining type: case2::{closure#0} with closure substs [
5138
i32,
@@ -58,14 +45,8 @@ LL | | })
5845
note: no external requirements
5946
--> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:28:1
6047
|
61-
LL | / fn case2() {
62-
LL | | let a = 0;
63-
LL | | let cell = Cell::new(&a);
64-
LL | |
65-
... |
66-
LL | | })
67-
LL | | }
68-
| |_^
48+
LL | fn case2() {
49+
| ^^^^^^^^^^
6950
|
7051
= note: defining type: case2
7152

src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr

+4-16
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
note: external requirements
22
--> $DIR/propagate-approximated-shorter-to-static-no-bound.rs:32:47
33
|
4-
LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
5-
| _______________________________________________^
6-
LL | |
7-
LL | |
8-
LL | | // Only works if 'x: 'y:
9-
LL | | demand_y(x, y, x.get())
10-
LL | | });
11-
| |_____^
4+
LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
5+
| ^^^^^^^^^^^^^^^^^
126
|
137
= note: defining type: supply::{closure#0} with closure substs [
148
i16,
@@ -23,14 +17,8 @@ LL | | });
2317
note: no external requirements
2418
--> $DIR/propagate-approximated-shorter-to-static-no-bound.rs:31:1
2519
|
26-
LL | / fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
27-
LL | | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
28-
LL | |
29-
LL | |
30-
... |
31-
LL | | });
32-
LL | | }
33-
| |_^
20+
LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
21+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3422
|
3523
= note: defining type: supply
3624

src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr

+4-16
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
note: external requirements
22
--> $DIR/propagate-approximated-shorter-to-static-wrong-bound.rs:35:47
33
|
4-
LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
5-
| _______________________________________________^
6-
LL | |
7-
LL | |
8-
LL | | // Only works if 'x: 'y:
9-
LL | | demand_y(x, y, x.get())
10-
LL | | });
11-
| |_____^
4+
LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
126
|
137
= note: defining type: supply::{closure#0} with closure substs [
148
i16,
@@ -23,14 +17,8 @@ LL | | });
2317
note: no external requirements
2418
--> $DIR/propagate-approximated-shorter-to-static-wrong-bound.rs:34:1
2519
|
26-
LL | / fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
27-
LL | | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
28-
LL | |
29-
LL | |
30-
... |
31-
LL | | });
32-
LL | | }
33-
| |_^
20+
LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
21+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3422
|
3523
= note: defining type: supply
3624

src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr

+4-15
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
note: external requirements
22
--> $DIR/propagate-approximated-val.rs:36:45
33
|
4-
LL | establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| {
5-
| _____________________________________________^
6-
LL | | // Only works if 'x: 'y:
7-
LL | | demand_y(outlives1, outlives2, x.get())
8-
LL | |
9-
LL | | });
10-
| |_____^
4+
LL | establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
116
|
127
= note: defining type: test::{closure#0} with closure substs [
138
i16,
@@ -22,14 +17,8 @@ LL | | });
2217
note: no external requirements
2318
--> $DIR/propagate-approximated-val.rs:35:1
2419
|
25-
LL | / fn test<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
26-
LL | | establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| {
27-
LL | | // Only works if 'x: 'y:
28-
LL | | demand_y(outlives1, outlives2, x.get())
29-
LL | |
30-
LL | | });
31-
LL | | }
32-
| |_^
20+
LL | fn test<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
21+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3322
|
3423
= note: defining type: test
3524

Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
note: external requirements
22
--> $DIR/propagate-despite-same-free-region.rs:42:9
33
|
4-
LL | / |_outlives1, _outlives2, x, y| {
5-
LL | | // Only works if 'x: 'y:
6-
LL | | let p = x.get();
7-
LL | | demand_y(x, y, p)
8-
LL | | },
9-
| |_________^
4+
LL | |_outlives1, _outlives2, x, y| {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
106
|
117
= note: defining type: supply::{closure#0} with closure substs [
128
i16,
@@ -20,14 +16,8 @@ LL | | },
2016
note: no external requirements
2117
--> $DIR/propagate-despite-same-free-region.rs:39:1
2218
|
23-
LL | / fn supply<'a>(cell_a: Cell<&'a u32>) {
24-
LL | | establish_relationships(
25-
LL | | cell_a,
26-
LL | | |_outlives1, _outlives2, x, y| {
27-
... |
28-
LL | | );
29-
LL | | }
30-
| |_^
19+
LL | fn supply<'a>(cell_a: Cell<&'a u32>) {
20+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3121
|
3222
= note: defining type: supply
3323

0 commit comments

Comments
 (0)