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).
This commit is contained in:
Jonathan Turner 2016-08-11 06:34:02 -07:00 committed by GitHub
commit cdedad530f
6 changed files with 6 additions and 0 deletions

View File

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

View File

@ -9,6 +9,7 @@
// except according to those terms.
struct ListNode { //~ ERROR E0072
//~| NOTE recursive type has infinite size
head: u8,
tail: Option<ListNode>,
}

View File

@ -13,6 +13,7 @@
enum foo { foo_(bar) }
struct bar { x: bar }
//~^ ERROR E0072
//~| NOTE recursive type has infinite size
fn main() {
}

View File

@ -13,6 +13,7 @@
// too big.
enum Expr { //~ ERROR E0072
//~| NOTE recursive type has infinite size
Plus(Expr, Expr),
Literal(i64),
}

View File

@ -9,6 +9,7 @@
// except according to those terms.
struct S { //~ ERROR E0072
//~| NOTE recursive type has infinite size
element: Option<S>
}

View File

@ -9,6 +9,7 @@
// except according to those terms.
struct t1 { //~ ERROR E0072
//~| NOTE recursive type has infinite size
foo: isize,
foolish: t1
}