Use find_export_name_attr instead of string literal

This commit is contained in:
arcnmx 2016-01-12 15:55:59 -05:00
parent 32328ac6ff
commit a141c52816
2 changed files with 5 additions and 5 deletions

View File

@ -2727,7 +2727,7 @@ fn exported_name<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
None => {}
}
match attr::find_export_name_attr(ccx.sess().diagnostic(), attrs) {
match attr::find_export_name_attr(Some(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: &Handler, attrs: &[Attribute]) -> Option<InternedString> {
pub fn find_export_name_attr(diag: Option<&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.struct_span_err(attr.span,
diag.map(|d| d.struct_span_err(attr.span,
"export_name attribute has invalid format")
.help("use #[export_name=\"*\"]")
.emit();
.emit());
None
}
} else {
@ -318,7 +318,7 @@ pub fn find_export_name_attr(diag: &Handler, attrs: &[Attribute]) -> Option<Inte
pub fn contains_extern_indicator(attrs: &[Attribute]) -> bool {
contains_name(attrs, "no_mangle") ||
contains_name(attrs, "export_name")
find_export_name_attr(None, attrs).is_some()
}
#[derive(Copy, Clone, PartialEq)]