Skip to content

Commit

Permalink
Pass through diagnostic handler instead
Browse files Browse the repository at this point in the history
  • Loading branch information
arcnmx committed Feb 11, 2016
1 parent a141c52 commit 0ff055a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/librustc/middle/reachable.rs
Expand Up @@ -237,7 +237,9 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
} else {
false
};
if reachable || attr::contains_extern_indicator(&item.attrs) {
let is_extern = attr::contains_extern_indicator(&self.tcx.sess.diagnostic(),
&item.attrs);
if reachable || is_extern {
self.reachable_symbols.insert(search_item);
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_metadata/decoder.rs
Expand Up @@ -1586,7 +1586,8 @@ pub fn is_extern_item(cdata: Cmd, id: DefIndex, tcx: &ty::ctxt) -> bool {
};

if applicable {
attr::contains_extern_indicator(&get_attributes(item_doc))
attr::contains_extern_indicator(tcx.sess.diagnostic(),
&get_attributes(item_doc))
} else {
false
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/trans/base.rs
Expand Up @@ -2727,7 +2727,7 @@ fn exported_name<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
None => {}
}

match attr::find_export_name_attr(Some(ccx.sess().diagnostic()), attrs) {
match attr::find_export_name_attr(ccx.sess().diagnostic(), attrs) {
// Use provided name
Some(name) => name.to_string(),
_ => {
Expand Down
10 changes: 5 additions & 5 deletions src/libsyntax/attr.rs
Expand Up @@ -298,16 +298,16 @@ pub fn find_crate_name(attrs: &[Attribute]) -> Option<InternedString> {
}

/// Find the value of #[export_name=*] attribute and check its validity.
pub fn find_export_name_attr(diag: Option<&Handler>, attrs: &[Attribute]) -> Option<InternedString> {
pub fn find_export_name_attr(diag: &Handler, attrs: &[Attribute]) -> Option<InternedString> {
attrs.iter().fold(None, |ia,attr| {
if attr.check_name("export_name") {
if let s@Some(_) = attr.value_str() {
s
} else {
diag.map(|d| d.struct_span_err(attr.span,
diag.struct_span_err(attr.span,
"export_name attribute has invalid format")
.help("use #[export_name=\"*\"]")
.emit());
.emit();
None
}
} else {
Expand All @@ -316,9 +316,9 @@ pub fn find_export_name_attr(diag: Option<&Handler>, attrs: &[Attribute]) -> Opt
})
}

pub fn contains_extern_indicator(attrs: &[Attribute]) -> bool {
pub fn contains_extern_indicator(diag: &Handler, attrs: &[Attribute]) -> bool {
contains_name(attrs, "no_mangle") ||
find_export_name_attr(None, attrs).is_some()
find_export_name_attr(diag, attrs).is_some()
}

#[derive(Copy, Clone, PartialEq)]
Expand Down

0 comments on commit 0ff055a

Please sign in to comment.