parent
97b30f0961
commit
5460b88774
11 changed files with 38 additions and 64 deletions
|
@ -627,7 +627,6 @@ define_dep_nodes!( <'tcx>
|
||||||
[input] AllCrateNums,
|
[input] AllCrateNums,
|
||||||
[] ExportedSymbols(CrateNum),
|
[] ExportedSymbols(CrateNum),
|
||||||
[eval_always] CollectAndPartitionTranslationItems,
|
[eval_always] CollectAndPartitionTranslationItems,
|
||||||
[] ExportName(DefId),
|
|
||||||
[] ContainsExternIndicator(DefId),
|
[] ContainsExternIndicator(DefId),
|
||||||
[] IsTranslatedItem(DefId),
|
[] IsTranslatedItem(DefId),
|
||||||
[] CodegenUnit(InternedString),
|
[] CodegenUnit(InternedString),
|
||||||
|
|
|
@ -2216,6 +2216,7 @@ pub fn provide(providers: &mut Providers) {
|
||||||
pub struct TransFnAttrs {
|
pub struct TransFnAttrs {
|
||||||
pub flags: TransFnAttrFlags,
|
pub flags: TransFnAttrFlags,
|
||||||
pub inline: InlineAttr,
|
pub inline: InlineAttr,
|
||||||
|
pub export_name: Option<Symbol>,
|
||||||
}
|
}
|
||||||
|
|
||||||
bitflags! {
|
bitflags! {
|
||||||
|
@ -2234,6 +2235,7 @@ impl TransFnAttrs {
|
||||||
TransFnAttrs {
|
TransFnAttrs {
|
||||||
flags: TransFnAttrFlags::empty(),
|
flags: TransFnAttrFlags::empty(),
|
||||||
inline: InlineAttr::None,
|
inline: InlineAttr::None,
|
||||||
|
export_name: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1147,10 +1147,12 @@ impl<'hir> HashStable<StableHashingContext<'hir>> for hir::TransFnAttrs
|
||||||
let hir::TransFnAttrs {
|
let hir::TransFnAttrs {
|
||||||
flags,
|
flags,
|
||||||
inline,
|
inline,
|
||||||
|
export_name,
|
||||||
} = *self;
|
} = *self;
|
||||||
|
|
||||||
flags.hash_stable(hcx, hasher);
|
flags.hash_stable(hcx, hasher);
|
||||||
inline.hash_stable(hcx, hasher);
|
inline.hash_stable(hcx, hasher);
|
||||||
|
export_name.hash_stable(hcx, hasher);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -363,7 +363,6 @@ define_maps! { <'tcx>
|
||||||
[] fn collect_and_partition_translation_items:
|
[] fn collect_and_partition_translation_items:
|
||||||
collect_and_partition_translation_items_node(CrateNum)
|
collect_and_partition_translation_items_node(CrateNum)
|
||||||
-> (Arc<DefIdSet>, Arc<Vec<Arc<CodegenUnit<'tcx>>>>),
|
-> (Arc<DefIdSet>, Arc<Vec<Arc<CodegenUnit<'tcx>>>>),
|
||||||
[] fn export_name: ExportName(DefId) -> Option<Symbol>,
|
|
||||||
[] fn contains_extern_indicator: ContainsExternIndicator(DefId) -> bool,
|
[] fn contains_extern_indicator: ContainsExternIndicator(DefId) -> bool,
|
||||||
[] fn symbol_export_level: GetSymbolExportLevel(DefId) -> SymbolExportLevel,
|
[] fn symbol_export_level: GetSymbolExportLevel(DefId) -> SymbolExportLevel,
|
||||||
[] fn is_translated_item: IsTranslatedItem(DefId) -> bool,
|
[] fn is_translated_item: IsTranslatedItem(DefId) -> bool,
|
||||||
|
|
|
@ -926,7 +926,6 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
|
||||||
DepKind::CollectAndPartitionTranslationItems => {
|
DepKind::CollectAndPartitionTranslationItems => {
|
||||||
force!(collect_and_partition_translation_items, LOCAL_CRATE);
|
force!(collect_and_partition_translation_items, LOCAL_CRATE);
|
||||||
}
|
}
|
||||||
DepKind::ExportName => { force!(export_name, def_id!()); }
|
|
||||||
DepKind::ContainsExternIndicator => {
|
DepKind::ContainsExternIndicator => {
|
||||||
force!(contains_extern_indicator, def_id!());
|
force!(contains_extern_indicator, def_id!());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
#![allow(non_snake_case)]
|
|
||||||
|
|
||||||
register_long_diagnostics! {
|
|
||||||
|
|
||||||
E0558: r##"
|
|
||||||
The `export_name` attribute was malformed.
|
|
||||||
|
|
||||||
Erroneous code example:
|
|
||||||
|
|
||||||
```ignore (error-emitted-at-codegen-which-cannot-be-handled-by-compile_fail)
|
|
||||||
#[export_name] // error: export_name attribute has invalid format
|
|
||||||
pub fn something() {}
|
|
||||||
|
|
||||||
fn main() {}
|
|
||||||
```
|
|
||||||
|
|
||||||
The `export_name` attribute expects a string in order to determine the name of
|
|
||||||
the exported symbol. Example:
|
|
||||||
|
|
||||||
```
|
|
||||||
#[export_name = "some_function"] // ok!
|
|
||||||
pub fn something() {}
|
|
||||||
|
|
||||||
fn main() {}
|
|
||||||
```
|
|
||||||
"##,
|
|
||||||
|
|
||||||
}
|
|
|
@ -37,7 +37,6 @@ extern crate rustc;
|
||||||
extern crate rustc_back;
|
extern crate rustc_back;
|
||||||
extern crate rustc_mir;
|
extern crate rustc_mir;
|
||||||
extern crate rustc_incremental;
|
extern crate rustc_incremental;
|
||||||
#[macro_use]
|
|
||||||
extern crate syntax;
|
extern crate syntax;
|
||||||
extern crate syntax_pos;
|
extern crate syntax_pos;
|
||||||
extern crate rustc_data_structures;
|
extern crate rustc_data_structures;
|
||||||
|
@ -46,7 +45,6 @@ pub extern crate rustc as __rustc;
|
||||||
|
|
||||||
use rustc::ty::TyCtxt;
|
use rustc::ty::TyCtxt;
|
||||||
|
|
||||||
pub mod diagnostics;
|
|
||||||
pub mod link;
|
pub mod link;
|
||||||
pub mod trans_crate;
|
pub mod trans_crate;
|
||||||
pub mod symbol_names;
|
pub mod symbol_names;
|
||||||
|
|
|
@ -120,27 +120,9 @@ pub fn provide(providers: &mut Providers) {
|
||||||
def_symbol_name,
|
def_symbol_name,
|
||||||
symbol_name,
|
symbol_name,
|
||||||
|
|
||||||
export_name: |tcx, id| {
|
|
||||||
tcx.get_attrs(id).iter().fold(None, |ia, attr| {
|
|
||||||
if attr.check_name("export_name") {
|
|
||||||
if let s @ Some(_) = attr.value_str() {
|
|
||||||
s
|
|
||||||
} else {
|
|
||||||
struct_span_err!(tcx.sess, attr.span, E0558,
|
|
||||||
"export_name attribute has invalid format")
|
|
||||||
.span_label(attr.span, "did you mean #[export_name=\"*\"]?")
|
|
||||||
.emit();
|
|
||||||
None
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ia
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
contains_extern_indicator: |tcx, id| {
|
contains_extern_indicator: |tcx, id| {
|
||||||
attr::contains_name(&tcx.get_attrs(id), "no_mangle") ||
|
attr::contains_name(&tcx.get_attrs(id), "no_mangle") ||
|
||||||
tcx.export_name(id).is_some()
|
tcx.trans_fn_attrs(id).export_name.is_some()
|
||||||
},
|
},
|
||||||
|
|
||||||
..*providers
|
..*providers
|
||||||
|
@ -287,7 +269,7 @@ fn compute_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance
|
||||||
return tcx.item_name(def_id).to_string();
|
return tcx.item_name(def_id).to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(name) = tcx.export_name(def_id) {
|
if let Some(name) = tcx.trans_fn_attrs(def_id).export_name {
|
||||||
// Use provided name
|
// Use provided name
|
||||||
return name.to_string();
|
return name.to_string();
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,7 +233,6 @@ impl TransCrate for MetadataOnlyTransCrate {
|
||||||
MonoItem::Fn(inst) => {
|
MonoItem::Fn(inst) => {
|
||||||
let def_id = inst.def_id();
|
let def_id = inst.def_id();
|
||||||
if def_id.is_local() {
|
if def_id.is_local() {
|
||||||
let _ = tcx.export_name(def_id);
|
|
||||||
let _ = tcx.contains_extern_indicator(def_id);
|
let _ = tcx.contains_extern_indicator(def_id);
|
||||||
let _ = inst.def.is_inline(tcx);
|
let _ = inst.def.is_inline(tcx);
|
||||||
let _ = tcx.trans_fn_attrs(def_id);
|
let _ = tcx.trans_fn_attrs(def_id);
|
||||||
|
|
|
@ -1777,6 +1777,15 @@ fn trans_fn_attrs<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: DefId) -> TransFnAt
|
||||||
_ => ia,
|
_ => ia,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else if attr.check_name("export_name") {
|
||||||
|
if let s @ Some(_) = attr.value_str() {
|
||||||
|
trans_fn_attrs.export_name = s;
|
||||||
|
} else {
|
||||||
|
struct_span_err!(tcx.sess, attr.span, E0558,
|
||||||
|
"export_name attribute has invalid format")
|
||||||
|
.span_label(attr.span, "did you mean #[export_name=\"*\"]?")
|
||||||
|
.emit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3774,6 +3774,29 @@ For more information about the inline attribute, https:
|
||||||
read://doc.rust-lang.org/reference.html#inline-attributes
|
read://doc.rust-lang.org/reference.html#inline-attributes
|
||||||
"##,
|
"##,
|
||||||
|
|
||||||
|
E0558: r##"
|
||||||
|
The `export_name` attribute was malformed.
|
||||||
|
|
||||||
|
Erroneous code example:
|
||||||
|
|
||||||
|
```ignore (error-emitted-at-codegen-which-cannot-be-handled-by-compile_fail)
|
||||||
|
#[export_name] // error: export_name attribute has invalid format
|
||||||
|
pub fn something() {}
|
||||||
|
|
||||||
|
fn main() {}
|
||||||
|
```
|
||||||
|
|
||||||
|
The `export_name` attribute expects a string in order to determine the name of
|
||||||
|
the exported symbol. Example:
|
||||||
|
|
||||||
|
```
|
||||||
|
#[export_name = "some_function"] // ok!
|
||||||
|
pub fn something() {}
|
||||||
|
|
||||||
|
fn main() {}
|
||||||
|
```
|
||||||
|
"##,
|
||||||
|
|
||||||
E0559: r##"
|
E0559: r##"
|
||||||
An unknown field was specified into an enum's structure variant.
|
An unknown field was specified into an enum's structure variant.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue