Skip to content

Commit 5460b88

Browse files
committed
Remove export_name query
Part of rust-lang#47320
1 parent 97b30f0 commit 5460b88

File tree

11 files changed

+38
-64
lines changed

11 files changed

+38
-64
lines changed

src/librustc/dep_graph/dep_node.rs

-1
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,6 @@ define_dep_nodes!( <'tcx>
627627
[input] AllCrateNums,
628628
[] ExportedSymbols(CrateNum),
629629
[eval_always] CollectAndPartitionTranslationItems,
630-
[] ExportName(DefId),
631630
[] ContainsExternIndicator(DefId),
632631
[] IsTranslatedItem(DefId),
633632
[] CodegenUnit(InternedString),

src/librustc/hir/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -2216,6 +2216,7 @@ pub fn provide(providers: &mut Providers) {
22162216
pub struct TransFnAttrs {
22172217
pub flags: TransFnAttrFlags,
22182218
pub inline: InlineAttr,
2219+
pub export_name: Option<Symbol>,
22192220
}
22202221

22212222
bitflags! {
@@ -2234,6 +2235,7 @@ impl TransFnAttrs {
22342235
TransFnAttrs {
22352236
flags: TransFnAttrFlags::empty(),
22362237
inline: InlineAttr::None,
2238+
export_name: None,
22372239
}
22382240
}
22392241

src/librustc/ich/impls_hir.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1147,10 +1147,12 @@ impl<'hir> HashStable<StableHashingContext<'hir>> for hir::TransFnAttrs
11471147
let hir::TransFnAttrs {
11481148
flags,
11491149
inline,
1150+
export_name,
11501151
} = *self;
11511152

11521153
flags.hash_stable(hcx, hasher);
11531154
inline.hash_stable(hcx, hasher);
1155+
export_name.hash_stable(hcx, hasher);
11541156
}
11551157
}
11561158

src/librustc/ty/maps/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,6 @@ define_maps! { <'tcx>
363363
[] fn collect_and_partition_translation_items:
364364
collect_and_partition_translation_items_node(CrateNum)
365365
-> (Arc<DefIdSet>, Arc<Vec<Arc<CodegenUnit<'tcx>>>>),
366-
[] fn export_name: ExportName(DefId) -> Option<Symbol>,
367366
[] fn contains_extern_indicator: ContainsExternIndicator(DefId) -> bool,
368367
[] fn symbol_export_level: GetSymbolExportLevel(DefId) -> SymbolExportLevel,
369368
[] fn is_translated_item: IsTranslatedItem(DefId) -> bool,

src/librustc/ty/maps/plumbing.rs

-1
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,6 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
926926
DepKind::CollectAndPartitionTranslationItems => {
927927
force!(collect_and_partition_translation_items, LOCAL_CRATE);
928928
}
929-
DepKind::ExportName => { force!(export_name, def_id!()); }
930929
DepKind::ContainsExternIndicator => {
931930
force!(contains_extern_indicator, def_id!());
932931
}

src/librustc_trans_utils/diagnostics.rs

-38
This file was deleted.

src/librustc_trans_utils/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ extern crate rustc;
3737
extern crate rustc_back;
3838
extern crate rustc_mir;
3939
extern crate rustc_incremental;
40-
#[macro_use]
4140
extern crate syntax;
4241
extern crate syntax_pos;
4342
extern crate rustc_data_structures;
@@ -46,7 +45,6 @@ pub extern crate rustc as __rustc;
4645

4746
use rustc::ty::TyCtxt;
4847

49-
pub mod diagnostics;
5048
pub mod link;
5149
pub mod trans_crate;
5250
pub mod symbol_names;

src/librustc_trans_utils/symbol_names.rs

+2-20
Original file line numberDiff line numberDiff line change
@@ -120,27 +120,9 @@ pub fn provide(providers: &mut Providers) {
120120
def_symbol_name,
121121
symbol_name,
122122

123-
export_name: |tcx, id| {
124-
tcx.get_attrs(id).iter().fold(None, |ia, attr| {
125-
if attr.check_name("export_name") {
126-
if let s @ Some(_) = attr.value_str() {
127-
s
128-
} else {
129-
struct_span_err!(tcx.sess, attr.span, E0558,
130-
"export_name attribute has invalid format")
131-
.span_label(attr.span, "did you mean #[export_name=\"*\"]?")
132-
.emit();
133-
None
134-
}
135-
} else {
136-
ia
137-
}
138-
})
139-
},
140-
141123
contains_extern_indicator: |tcx, id| {
142124
attr::contains_name(&tcx.get_attrs(id), "no_mangle") ||
143-
tcx.export_name(id).is_some()
125+
tcx.trans_fn_attrs(id).export_name.is_some()
144126
},
145127

146128
..*providers
@@ -287,7 +269,7 @@ fn compute_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance
287269
return tcx.item_name(def_id).to_string();
288270
}
289271

290-
if let Some(name) = tcx.export_name(def_id) {
272+
if let Some(name) = tcx.trans_fn_attrs(def_id).export_name {
291273
// Use provided name
292274
return name.to_string();
293275
}

src/librustc_trans_utils/trans_crate.rs

-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ impl TransCrate for MetadataOnlyTransCrate {
233233
MonoItem::Fn(inst) => {
234234
let def_id = inst.def_id();
235235
if def_id.is_local() {
236-
let _ = tcx.export_name(def_id);
237236
let _ = tcx.contains_extern_indicator(def_id);
238237
let _ = inst.def.is_inline(tcx);
239238
let _ = tcx.trans_fn_attrs(def_id);

src/librustc_typeck/collect.rs

+9
Original file line numberDiff line numberDiff line change
@@ -1777,6 +1777,15 @@ fn trans_fn_attrs<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: DefId) -> TransFnAt
17771777
_ => ia,
17781778
}
17791779
});
1780+
} else if attr.check_name("export_name") {
1781+
if let s @ Some(_) = attr.value_str() {
1782+
trans_fn_attrs.export_name = s;
1783+
} else {
1784+
struct_span_err!(tcx.sess, attr.span, E0558,
1785+
"export_name attribute has invalid format")
1786+
.span_label(attr.span, "did you mean #[export_name=\"*\"]?")
1787+
.emit();
1788+
}
17801789
}
17811790
}
17821791

src/librustc_typeck/diagnostics.rs

+23
Original file line numberDiff line numberDiff line change
@@ -3774,6 +3774,29 @@ For more information about the inline attribute, https:
37743774
read://doc.rust-lang.org/reference.html#inline-attributes
37753775
"##,
37763776

3777+
E0558: r##"
3778+
The `export_name` attribute was malformed.
3779+
3780+
Erroneous code example:
3781+
3782+
```ignore (error-emitted-at-codegen-which-cannot-be-handled-by-compile_fail)
3783+
#[export_name] // error: export_name attribute has invalid format
3784+
pub fn something() {}
3785+
3786+
fn main() {}
3787+
```
3788+
3789+
The `export_name` attribute expects a string in order to determine the name of
3790+
the exported symbol. Example:
3791+
3792+
```
3793+
#[export_name = "some_function"] // ok!
3794+
pub fn something() {}
3795+
3796+
fn main() {}
3797+
```
3798+
"##,
3799+
37773800
E0559: r##"
37783801
An unknown field was specified into an enum's structure variant.
37793802

0 commit comments

Comments
 (0)