Skip to content

Commit

Permalink
Rollup merge of #32970 - taralx:patch-2, r=alexcrichton
Browse files Browse the repository at this point in the history
Accommodate the case where dup lang items are entirely external.

Fixes #32961
  • Loading branch information
Manishearth committed Apr 15, 2016
2 parents 9873771 + 37e59b9 commit 00d4ac3
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/librustc/middle/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,19 @@ impl<'a, 'tcx> LanguageItemCollector<'a, 'tcx> {
match self.items.items[item_index] {
Some(original_def_id) if original_def_id != item_def_id => {
let cstore = &self.session.cstore;
let span = self.ast_map.span_if_local(item_def_id)
.expect("we should have found local duplicate earlier");
let mut err = struct_span_err!(self.session,
span,
E0152,
"duplicate lang item found: `{}`.",
LanguageItems::item_name(item_index));
let name = LanguageItems::item_name(item_index);
let mut err = match self.ast_map.span_if_local(item_def_id) {
Some(span) => struct_span_err!(
self.session,
span,
E0152,
"duplicate lang item found: `{}`.",
name),
None => self.session.struct_err(&format!(
"duplicate lang item in crate `{}`: `{}`.",
cstore.crate_name(item_def_id.krate),
name)),
};
if let Some(span) = self.ast_map.span_if_local(original_def_id) {
span_note!(&mut err, span,
"first defined here.");
Expand Down

0 comments on commit 00d4ac3

Please sign in to comment.