Skip to content

Commit

Permalink
Use def_span for external requirements.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Sep 1, 2022
1 parent d85dff7 commit b9e1806
Show file tree
Hide file tree
Showing 24 changed files with 137 additions and 421 deletions.
5 changes: 3 additions & 2 deletions compiler/rustc_borrowck/src/nll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,9 @@ pub(super) fn dump_annotation<'a, 'tcx>(
// viewing the intraprocedural state, the -Zdump-mir output is
// better.

let def_span = tcx.def_span(body.source.def_id());
let mut err = if let Some(closure_region_requirements) = closure_region_requirements {
let mut err = tcx.sess.diagnostic().span_note_diag(body.span, "external requirements");
let mut err = tcx.sess.diagnostic().span_note_diag(def_span, "external requirements");

regioncx.annotate(tcx, &mut err);

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

err
} else {
let mut err = tcx.sess.diagnostic().span_note_diag(body.span, "no external requirements");
let mut err = tcx.sess.diagnostic().span_note_diag(def_span, "no external requirements");
regioncx.annotate(tcx, &mut err);

err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ note: no external requirements
--> $DIR/escape-argument-callee.rs:26:38
|
LL | let mut closure = expect_sig(|p, y| *p = y);
| ^^^^^^^^^^^^^
| ^^^^^^
|
= note: defining type: test::{closure#0} with closure substs [
i16,
Expand All @@ -22,14 +22,8 @@ LL | let mut closure = expect_sig(|p, y| *p = y);
note: no external requirements
--> $DIR/escape-argument-callee.rs:20:1
|
LL | / fn test() {
LL | | let x = 44;
LL | | let mut p = &x;
LL | |
... |
LL | | deref(p);
LL | | }
| |_^
LL | fn test() {
| ^^^^^^^^^
|
= note: defining type: test

Expand Down
12 changes: 3 additions & 9 deletions src/test/ui/nll/closure-requirements/escape-argument.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ note: no external requirements
--> $DIR/escape-argument.rs:26:38
|
LL | let mut closure = expect_sig(|p, y| *p = y);
| ^^^^^^^^^^^^^
| ^^^^^^
|
= note: defining type: test::{closure#0} with closure substs [
i16,
Expand All @@ -13,14 +13,8 @@ LL | let mut closure = expect_sig(|p, y| *p = y);
note: no external requirements
--> $DIR/escape-argument.rs:20:1
|
LL | / fn test() {
LL | | let x = 44;
LL | | let mut p = &x;
LL | |
... |
LL | | deref(p);
LL | | }
| |_^
LL | fn test() {
| ^^^^^^^^^
|
= note: defining type: test

Expand Down
20 changes: 5 additions & 15 deletions src/test/ui/nll/closure-requirements/escape-upvar-nested.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ note: external requirements
--> $DIR/escape-upvar-nested.rs:21:32
|
LL | let mut closure1 = || p = &y;
| ^^^^^^^^^
| ^^
|
= note: defining type: test::{closure#0}::{closure#0} with closure substs [
i16,
Expand All @@ -15,12 +15,8 @@ LL | let mut closure1 = || p = &y;
note: external requirements
--> $DIR/escape-upvar-nested.rs:20:27
|
LL | let mut closure = || {
| ___________________________^
LL | | let mut closure1 = || p = &y;
LL | | closure1();
LL | | };
| |_________^
LL | let mut closure = || {
| ^^
|
= note: defining type: test::{closure#0} with closure substs [
i16,
Expand All @@ -33,14 +29,8 @@ LL | | };
note: no external requirements
--> $DIR/escape-upvar-nested.rs:13:1
|
LL | / fn test() {
LL | | let x = 44;
LL | | let mut p = &x;
LL | |
... |
LL | | deref(p);
LL | | }
| |_^
LL | fn test() {
| ^^^^^^^^^
|
= note: defining type: test

Expand Down
12 changes: 3 additions & 9 deletions src/test/ui/nll/closure-requirements/escape-upvar-ref.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ note: external requirements
--> $DIR/escape-upvar-ref.rs:23:27
|
LL | let mut closure = || p = &y;
| ^^^^^^^^^
| ^^
|
= note: defining type: test::{closure#0} with closure substs [
i16,
Expand All @@ -15,14 +15,8 @@ LL | let mut closure = || p = &y;
note: no external requirements
--> $DIR/escape-upvar-ref.rs:17:1
|
LL | / fn test() {
LL | | let x = 44;
LL | | let mut p = &x;
LL | |
... |
LL | | deref(p);
LL | | }
| |_^
LL | fn test() {
| ^^^^^^^^^
|
= note: defining type: test

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
note: no external requirements
--> $DIR/propagate-approximated-fail-no-postdom.rs:43:9
|
LL | / |_outlives1, _outlives2, _outlives3, x, y| {
LL | | // Only works if 'x: 'y:
LL | | let p = x.get();
LL | | demand_y(x, y, p)
LL | | },
| |_________^
LL | |_outlives1, _outlives2, _outlives3, x, y| {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: supply::{closure#0} with closure substs [
i16,
Expand All @@ -31,14 +27,8 @@ LL | demand_y(x, y, p)
note: no external requirements
--> $DIR/propagate-approximated-fail-no-postdom.rs:38:1
|
LL | / fn supply<'a, 'b, 'c>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>, cell_c: Cell<&'c u32>) {
LL | | establish_relationships(
LL | | cell_a,
LL | | cell_b,
... |
LL | | );
LL | | }
| |_^
LL | fn supply<'a, 'b, 'c>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>, cell_c: Cell<&'c u32>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: supply

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
note: external requirements
--> $DIR/propagate-approximated-ref.rs:43:47
|
LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
| _______________________________________________^
LL | | // Only works if 'x: 'y:
LL | | demand_y(x, y, x.get())
LL | |
LL | | });
| |_____^
LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: supply::{closure#0} with closure substs [
i16,
Expand All @@ -22,14 +17,8 @@ LL | | });
note: no external requirements
--> $DIR/propagate-approximated-ref.rs:42:1
|
LL | / fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
LL | | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
LL | | // Only works if 'x: 'y:
LL | | demand_y(x, y, x.get())
LL | |
LL | | });
LL | | }
| |_^
LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: supply

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
note: no external requirements
--> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:21:15
|
LL | foo(cell, |cell_a, cell_x| {
| _______________^
LL | | cell_a.set(cell_x.get()); // forces 'x: 'a, error in closure
LL | |
LL | | })
| |_____^
LL | foo(cell, |cell_a, cell_x| {
| ^^^^^^^^^^^^^^^^
|
= note: defining type: case1::{closure#0} with closure substs [
i32,
Expand All @@ -27,25 +23,16 @@ LL | cell_a.set(cell_x.get()); // forces 'x: 'a, error in closure
note: no external requirements
--> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:18:1
|
LL | / fn case1() {
LL | | let a = 0;
LL | | let cell = Cell::new(&a);
LL | | foo(cell, |cell_a, cell_x| {
... |
LL | | })
LL | | }
| |_^
LL | fn case1() {
| ^^^^^^^^^^
|
= note: defining type: case1

note: external requirements
--> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:35:15
|
LL | foo(cell, |cell_a, cell_x| {
| _______________^
LL | | cell_x.set(cell_a.get()); // forces 'a: 'x, implies 'a = 'static -> borrow error
LL | | })
| |_____^
LL | foo(cell, |cell_a, cell_x| {
| ^^^^^^^^^^^^^^^^
|
= note: defining type: case2::{closure#0} with closure substs [
i32,
Expand All @@ -58,14 +45,8 @@ LL | | })
note: no external requirements
--> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:28:1
|
LL | / fn case2() {
LL | | let a = 0;
LL | | let cell = Cell::new(&a);
LL | |
... |
LL | | })
LL | | }
| |_^
LL | fn case2() {
| ^^^^^^^^^^
|
= note: defining type: case2

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
note: external requirements
--> $DIR/propagate-approximated-shorter-to-static-no-bound.rs:32:47
|
LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
| _______________________________________________^
LL | |
LL | |
LL | | // Only works if 'x: 'y:
LL | | demand_y(x, y, x.get())
LL | | });
| |_____^
LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
| ^^^^^^^^^^^^^^^^^
|
= note: defining type: supply::{closure#0} with closure substs [
i16,
Expand All @@ -23,14 +17,8 @@ LL | | });
note: no external requirements
--> $DIR/propagate-approximated-shorter-to-static-no-bound.rs:31:1
|
LL | / fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
LL | | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
LL | |
LL | |
... |
LL | | });
LL | | }
| |_^
LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: supply

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
note: external requirements
--> $DIR/propagate-approximated-shorter-to-static-wrong-bound.rs:35:47
|
LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
| _______________________________________________^
LL | |
LL | |
LL | | // Only works if 'x: 'y:
LL | | demand_y(x, y, x.get())
LL | | });
| |_____^
LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: supply::{closure#0} with closure substs [
i16,
Expand All @@ -23,14 +17,8 @@ LL | | });
note: no external requirements
--> $DIR/propagate-approximated-shorter-to-static-wrong-bound.rs:34:1
|
LL | / fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
LL | | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
LL | |
LL | |
... |
LL | | });
LL | | }
| |_^
LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: supply

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
note: external requirements
--> $DIR/propagate-approximated-val.rs:36:45
|
LL | establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| {
| _____________________________________________^
LL | | // Only works if 'x: 'y:
LL | | demand_y(outlives1, outlives2, x.get())
LL | |
LL | | });
| |_____^
LL | establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: test::{closure#0} with closure substs [
i16,
Expand All @@ -22,14 +17,8 @@ LL | | });
note: no external requirements
--> $DIR/propagate-approximated-val.rs:35:1
|
LL | / fn test<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
LL | | establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| {
LL | | // Only works if 'x: 'y:
LL | | demand_y(outlives1, outlives2, x.get())
LL | |
LL | | });
LL | | }
| |_^
LL | fn test<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: test

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
note: external requirements
--> $DIR/propagate-despite-same-free-region.rs:42:9
|
LL | / |_outlives1, _outlives2, x, y| {
LL | | // Only works if 'x: 'y:
LL | | let p = x.get();
LL | | demand_y(x, y, p)
LL | | },
| |_________^
LL | |_outlives1, _outlives2, x, y| {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: supply::{closure#0} with closure substs [
i16,
Expand All @@ -20,14 +16,8 @@ LL | | },
note: no external requirements
--> $DIR/propagate-despite-same-free-region.rs:39:1
|
LL | / fn supply<'a>(cell_a: Cell<&'a u32>) {
LL | | establish_relationships(
LL | | cell_a,
LL | | |_outlives1, _outlives2, x, y| {
... |
LL | | );
LL | | }
| |_^
LL | fn supply<'a>(cell_a: Cell<&'a u32>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: supply

Loading

0 comments on commit b9e1806

Please sign in to comment.