Use find_export_name_attr instead of string literal
This commit is contained in:
@@ -2727,7 +2727,7 @@ fn exported_name<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||||||
None => {}
|
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
|
// Use provided name
|
||||||
Some(name) => name.to_string(),
|
Some(name) => name.to_string(),
|
||||||
_ => {
|
_ => {
|
||||||
|
|||||||
@@ -298,16 +298,16 @@ pub fn find_crate_name(attrs: &[Attribute]) -> Option<InternedString> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Find the value of #[export_name=*] attribute and check its validity.
|
/// 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| {
|
attrs.iter().fold(None, |ia,attr| {
|
||||||
if attr.check_name("export_name") {
|
if attr.check_name("export_name") {
|
||||||
if let s@Some(_) = attr.value_str() {
|
if let s@Some(_) = attr.value_str() {
|
||||||
s
|
s
|
||||||
} else {
|
} else {
|
||||||
diag.struct_span_err(attr.span,
|
diag.map(|d| d.struct_span_err(attr.span,
|
||||||
"export_name attribute has invalid format")
|
"export_name attribute has invalid format")
|
||||||
.help("use #[export_name=\"*\"]")
|
.help("use #[export_name=\"*\"]")
|
||||||
.emit();
|
.emit());
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
} else {
|
} 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 {
|
pub fn contains_extern_indicator(attrs: &[Attribute]) -> bool {
|
||||||
contains_name(attrs, "no_mangle") ||
|
contains_name(attrs, "no_mangle") ||
|
||||||
contains_name(attrs, "export_name")
|
find_export_name_attr(None, attrs).is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
|
|||||||
Reference in New Issue
Block a user