Skip to content

Commit cdedad5

Browse files
author
Jonathan Turner
authored
Rollup merge of #35576 - circuitfox:E0072-update-error-format, r=jonathandturner
E0072 update error format Part of #35233 Fixes #35506 r? @jonathandturner The bonus for this issue currently seems to be impossible to do reliably, as the compiler seems to lack span information for item names alone, like `Foo` in `struct Foo { ... }`. It would be possible to hack something together by computing span offsets, but that seems like a solution that would be begging for trouble. A proper solution to this would, of course, be to add span information to the right place (seems to be `rustc::hir::Item::name` but I may be wrong).
2 parents 0e92c5e + c5f9feb commit cdedad5

File tree

6 files changed

+6
-0
lines changed

6 files changed

+6
-0
lines changed

src/librustc/traits/error_reporting.rs

+1
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
654654
let mut err = struct_span_err!(self.sess, span, E0072,
655655
"recursive type `{}` has infinite size",
656656
self.item_path_str(type_def_id));
657+
err.span_label(span, &format!("recursive type has infinite size"));
657658
err.help(&format!("insert indirection (e.g., a `Box`, `Rc`, or `&`) \
658659
at some point to make `{}` representable",
659660
self.item_path_str(type_def_id)));

src/test/compile-fail/E0072.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
struct ListNode { //~ ERROR E0072
12+
//~| NOTE recursive type has infinite size
1213
head: u8,
1314
tail: Option<ListNode>,
1415
}

src/test/compile-fail/issue-3008-2.rs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
enum foo { foo_(bar) }
1414
struct bar { x: bar }
1515
//~^ ERROR E0072
16+
//~| NOTE recursive type has infinite size
1617

1718
fn main() {
1819
}

src/test/compile-fail/issue-32326.rs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// too big.
1414

1515
enum Expr { //~ ERROR E0072
16+
//~| NOTE recursive type has infinite size
1617
Plus(Expr, Expr),
1718
Literal(i64),
1819
}

src/test/compile-fail/issue-3779.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
struct S { //~ ERROR E0072
12+
//~| NOTE recursive type has infinite size
1213
element: Option<S>
1314
}
1415

src/test/compile-fail/type-recursive.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
struct t1 { //~ ERROR E0072
12+
//~| NOTE recursive type has infinite size
1213
foo: isize,
1314
foolish: t1
1415
}

0 commit comments

Comments
 (0)