]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #35576 - circuitfox:E0072-update-error-format, r=jonathandturner
authorJonathan Turner <jonathandturner@users.noreply.github.com>
Thu, 11 Aug 2016 13:34:02 +0000 (06:34 -0700)
committerGitHub <noreply@github.com>
Thu, 11 Aug 2016 13:34:02 +0000 (06:34 -0700)
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).

1  2 
src/librustc/traits/error_reporting.rs

index 4725272d2b69ae51d762663297639665d3c46d3a,80f1559fefce50f737867a989bd558575bd85aaf..62a31133a5499b33a21ba1898a01e9d0cfde226d
@@@ -654,6 -654,7 +654,7 @@@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, '
          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)));
          let mut err = match warning_node_id {
              Some(_) => None,
              None => {
 -                Some(struct_span_err!(
 -                    self.sess, span, E0038,
 -                    "the trait `{}` cannot be made into an object",
 -                    self.item_path_str(trait_def_id)))
 +                let trait_str = self.item_path_str(trait_def_id);
 +                let mut db = struct_span_err!(
 +                            self.sess, span, E0038,
 +                            "the trait `{}` cannot be made into an object",
 +                            trait_str);
 +                db.span_label(span,
 +                              &format!("the trait `{}` cannot be made \
 +                              into an object", trait_str));
 +                Some(db)
              }
          };