Skip to content

Commit a141c52

Browse files
committed
Use find_export_name_attr instead of string literal
1 parent 32328ac commit a141c52

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/librustc_trans/trans/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2727,7 +2727,7 @@ fn exported_name<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
27272727
None => {}
27282728
}
27292729

2730-
match attr::find_export_name_attr(ccx.sess().diagnostic(), attrs) {
2730+
match attr::find_export_name_attr(Some(ccx.sess().diagnostic()), attrs) {
27312731
// Use provided name
27322732
Some(name) => name.to_string(),
27332733
_ => {

src/libsyntax/attr.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -298,16 +298,16 @@ pub fn find_crate_name(attrs: &[Attribute]) -> Option<InternedString> {
298298
}
299299

300300
/// Find the value of #[export_name=*] attribute and check its validity.
301-
pub fn find_export_name_attr(diag: &Handler, attrs: &[Attribute]) -> Option<InternedString> {
301+
pub fn find_export_name_attr(diag: Option<&Handler>, attrs: &[Attribute]) -> Option<InternedString> {
302302
attrs.iter().fold(None, |ia,attr| {
303303
if attr.check_name("export_name") {
304304
if let s@Some(_) = attr.value_str() {
305305
s
306306
} else {
307-
diag.struct_span_err(attr.span,
307+
diag.map(|d| d.struct_span_err(attr.span,
308308
"export_name attribute has invalid format")
309309
.help("use #[export_name=\"*\"]")
310-
.emit();
310+
.emit());
311311
None
312312
}
313313
} else {
@@ -318,7 +318,7 @@ pub fn find_export_name_attr(diag: &Handler, attrs: &[Attribute]) -> Option<Inte
318318

319319
pub fn contains_extern_indicator(attrs: &[Attribute]) -> bool {
320320
contains_name(attrs, "no_mangle") ||
321-
contains_name(attrs, "export_name")
321+
find_export_name_attr(None, attrs).is_some()
322322
}
323323

324324
#[derive(Copy, Clone, PartialEq)]

0 commit comments

Comments
 (0)