Skip to content

Commit c6036e2

Browse files
author
Ariel Ben-Yehuda
committed
---
yaml --- r: 224884 b: refs/heads/tmp c: 612760b h: refs/heads/master v: v3
1 parent 11465de commit c6036e2

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
2626
refs/heads/beta: 83dee3dfbb452a7558193f3ce171b3c60bf4a499
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
28-
refs/heads/tmp: c533f963d9f7f6c665c4d6e9c8c02c5a2d62c9e6
28+
refs/heads/tmp: 612760bea06e55dc4cb7bf7cdf430e8b1ba8d8e7
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: e58601ab085591c71a27ae82137fc313222c2270
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828

branches/tmp/src/librustc_typeck/check/dropck.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use util::nodemap::FnvHashSet;
1818

1919
use syntax::ast;
2020
use syntax::codemap::{self, Span};
21+
use syntax::parse::token::special_idents;
2122

2223
/// check_drop_impl confirms that the Drop implementation identfied by
2324
/// `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>
286287
// was somehow on the root.
287288
}
288289
TypeContext::ADT { def_id, variant, field, field_index } => {
289-
// FIXME (pnkfelix): eventually lookup arg_name
290-
// for the given index on struct variants.
291-
// TODO: be saner
292-
if let ty::ADTKind::Enum = tcx.lookup_adt_def(def_id).adt_kind() {
293-
span_note!(
294-
rcx.tcx().sess,
295-
span,
296-
"overflowed on enum {} variant {} argument {} type: {}",
297-
tcx.item_path_str(def_id),
298-
variant,
299-
field_index,
300-
detected_on_typ);
290+
let adt = tcx.lookup_adt_def(def_id);
291+
let variant_name = match adt.adt_kind() {
292+
ty::ADTKind::Enum => format!("enum {} variant {}",
293+
tcx.item_path_str(def_id),
294+
variant),
295+
ty::ADTKind::Struct => format!("struct {}",
296+
tcx.item_path_str(def_id))
297+
};
298+
let field_name = if field == special_idents::unnamed_field.name {
299+
format!("#{}", field_index)
301300
} else {
302-
span_note!(
303-
rcx.tcx().sess,
304-
span,
305-
"overflowed on struct {} field {} type: {}",
306-
tcx.item_path_str(def_id),
307-
field,
308-
detected_on_typ);
309-
}
301+
format!("`{}`", field)
302+
};
303+
span_note!(
304+
rcx.tcx().sess,
305+
span,
306+
"overflowed on {} field {} type: {}",
307+
variant_name,
308+
field_name,
309+
detected_on_typ);
310310
}
311311
}
312312
}

0 commit comments

Comments
 (0)