Skip to content

Commit

Permalink
Use find_export_name_attr instead of string literal
Browse files Browse the repository at this point in the history
  • Loading branch information
arcnmx committed Feb 11, 2016
1 parent 32328ac commit a141c52
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
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(ccx.sess().diagnostic(), attrs) {
match attr::find_export_name_attr(Some(ccx.sess().diagnostic()), attrs) {
// Use provided name
Some(name) => name.to_string(),
_ => {
Expand Down
8 changes: 4 additions & 4 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: &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 {
Expand All @@ -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)]
Expand Down

0 comments on commit a141c52

Please sign in to comment.