]> git.lizzy.rs Git - rust.git/blobdiff - src/libsyntax/attr.rs
Use find_export_name_attr instead of string literal
[rust.git] / src / libsyntax / attr.rs
index c3e3042eff08b996c999a60be9348a86f55bb1ae..fca659e63b582da4ac079aef288c26e8ec5378ec 100644 (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)]