Skip to content

Commit c6a5c87

Browse files
author
Ariel Ben-Yehuda
committed
---
yaml --- r: 223235 b: refs/heads/auto c: 612760b h: refs/heads/master i: 223233: f31f7ca 223231: 66187ed v: v3
1 parent 34823c4 commit c6a5c87

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
@@ -8,7 +8,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
88
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
99
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1010
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
11-
refs/heads/auto: c533f963d9f7f6c665c4d6e9c8c02c5a2d62c9e6
11+
refs/heads/auto: 612760bea06e55dc4cb7bf7cdf430e8b1ba8d8e7
1212
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1313
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
1414
refs/tags/0.2: 1754d02027f2924bed83b0160ee340c7f41d5ea1

branches/auto/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)