Pass through diagnostic handler instead

This commit is contained in:
arcnmx 2016-01-15 14:43:14 -05:00
parent a141c52816
commit 0ff055ad66
4 changed files with 11 additions and 8 deletions

View File

@ -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);
}
}

View File

@ -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
}

View File

@ -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(),
_ => {

View File

@ -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 {
@ -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)]