Skip to content

Commit 0b2d21e

Browse files
committed
Make impl-trait ciclical reference error point to def_span
1 parent aabb604 commit 0b2d21e

File tree

2 files changed

+8
-20
lines changed

2 files changed

+8
-20
lines changed

src/librustc/ty/maps/plumbing.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
8686
"unsupported cyclic reference between types/traits detected");
8787
err.span_label(span, "cyclic reference");
8888

89-
err.span_note(stack[0].0, &format!("the cycle begins when {}...",
90-
stack[0].1.describe(self)));
89+
err.span_note(self.sess.codemap().def_span(stack[0].0),
90+
&format!("the cycle begins when {}...", stack[0].1.describe(self)));
9191

9292
for &(span, ref query) in &stack[1..] {
93-
err.span_note(span, &format!("...which then requires {}...",
94-
query.describe(self)));
93+
err.span_note(self.sess.codemap().def_span(span),
94+
&format!("...which then requires {}...", query.describe(self)));
9595
}
9696

9797
err.note(&format!("...which then again requires {}, completing the cycle.",

src/test/ui/impl-trait/auto-trait-leak.stderr

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,8 @@ error[E0391]: unsupported cyclic reference between types/traits detected
3535
note: the cycle begins when processing `cycle1`...
3636
--> $DIR/auto-trait-leak.rs:52:1
3737
|
38-
52 | / fn cycle1() -> impl Clone {
39-
53 | | //~^ ERROR unsupported cyclic reference between types/traits detected
40-
54 | | //~| cyclic reference
41-
55 | | //~| NOTE the cycle begins when processing `cycle1`...
42-
... |
43-
60 | | Rc::new(Cell::new(5))
44-
61 | | }
45-
| |_^
38+
52 | fn cycle1() -> impl Clone {
39+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
4640
note: ...which then requires processing `cycle2::{{impl-Trait}}`...
4741
--> $DIR/auto-trait-leak.rs:63:16
4842
|
@@ -51,14 +45,8 @@ note: ...which then requires processing `cycle2::{{impl-Trait}}`...
5145
note: ...which then requires processing `cycle2`...
5246
--> $DIR/auto-trait-leak.rs:63:1
5347
|
54-
63 | / fn cycle2() -> impl Clone {
55-
64 | | //~^ NOTE ...which then requires processing `cycle2::{{impl-Trait}}`...
56-
65 | | //~| NOTE ...which then requires processing `cycle2`...
57-
66 | | send(cycle1().clone());
58-
67 | |
59-
68 | | Rc::new(String::from("foo"))
60-
69 | | }
61-
| |_^
48+
63 | fn cycle2() -> impl Clone {
49+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
6250
note: ...which then requires processing `cycle1::{{impl-Trait}}`...
6351
--> $DIR/auto-trait-leak.rs:52:16
6452
|

0 commit comments

Comments
 (0)