diff options
| author | Ariel Ben-Yehuda <arielb1@mail.tau.ac.il> | 2015-08-06 17:43:08 +0300 |
|---|---|---|
| committer | Ariel Ben-Yehuda <arielb1@mail.tau.ac.il> | 2015-08-06 18:07:00 +0300 |
| commit | 612760bea06e55dc4cb7bf7cdf430e8b1ba8d8e7 (patch) | |
| tree | 42cd717da2fb302a685c7f80a1e1786f36696c05 | |
| parent | c533f963d9f7f6c665c4d6e9c8c02c5a2d62c9e6 (diff) | |
| download | rust-612760bea06e55dc4cb7bf7cdf430e8b1ba8d8e7.tar.gz rust-612760bea06e55dc4cb7bf7cdf430e8b1ba8d8e7.zip | |
fix dropck overflow error message
Perf numbers: Before this patchset: 572.70user 5.52system 7:33.21elapsed 127%CPU (0avgtext+0avgdata 1173368maxresident)k llvm-time: 385.858 After this patch: 557.84user 5.73system 7:22.10elapsed 127%CPU (0avgtext+0avgdata 1142848maxresident)k llvm-time: 385.834 nice 2.5% perf improvement
| -rw-r--r-- | src/librustc_typeck/check/dropck.rs | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/src/librustc_typeck/check/dropck.rs b/src/librustc_typeck/check/dropck.rs index 57f2f063c71..4ae65a15c26 100644 --- a/src/librustc_typeck/check/dropck.rs +++ b/src/librustc_typeck/check/dropck.rs @@ -18,6 +18,7 @@ use util::nodemap::FnvHashSet; use syntax::ast; use syntax::codemap::{self, Span}; +use syntax::parse::token::special_idents; /// check_drop_impl confirms that the Drop implementation identfied by /// `drop_impl_did` is not any more specialized than the type it is @@ -286,27 +287,26 @@ pub fn check_safety_of_destructor_if_necessary<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx> // was somehow on the root. } TypeContext::ADT { def_id, variant, field, field_index } => { - // FIXME (pnkfelix): eventually lookup arg_name - // for the given index on struct variants. - // TODO: be saner - if let ty::ADTKind::Enum = tcx.lookup_adt_def(def_id).adt_kind() { - span_note!( - rcx.tcx().sess, - span, - "overflowed on enum {} variant {} argument {} type: {}", - tcx.item_path_str(def_id), - variant, - field_index, - detected_on_typ); + let adt = tcx.lookup_adt_def(def_id); + let variant_name = match adt.adt_kind() { + ty::ADTKind::Enum => format!("enum {} variant {}", + tcx.item_path_str(def_id), + variant), + ty::ADTKind::Struct => format!("struct {}", + tcx.item_path_str(def_id)) + }; + let field_name = if field == special_idents::unnamed_field.name { + format!("#{}", field_index) } else { - span_note!( - rcx.tcx().sess, - span, - "overflowed on struct {} field {} type: {}", - tcx.item_path_str(def_id), - field, - detected_on_typ); - } + format!("`{}`", field) + }; + span_note!( + rcx.tcx().sess, + span, + "overflowed on {} field {} type: {}", + variant_name, + field_name, + detected_on_typ); } } } |
