rename eii-extern-target
This commit is contained in:
parent
840245e91b
commit
322bbdfaaf
35 changed files with 124 additions and 125 deletions
|
|
@ -2109,16 +2109,18 @@ pub struct MacroDef {
|
|||
/// `true` if macro was defined with `macro_rules`.
|
||||
pub macro_rules: bool,
|
||||
|
||||
/// If this is a macro used for externally implementable items,
|
||||
/// it refers to an extern item which is its "target". This requires
|
||||
/// name resolution so can't just be an attribute, so we store it in this field.
|
||||
pub eii_extern_target: Option<EiiExternTarget>,
|
||||
/// Corresponds to `#[eii_declaration(...)]`.
|
||||
/// `#[eii_declaration(...)]` is a built-in attribute macro, not a built-in attribute,
|
||||
/// because we require some name resolution to occur in the parameters of this attribute.
|
||||
/// Name resolution isn't possible in attributes otherwise, so we encode it in the AST.
|
||||
/// During ast lowering, we turn it back into an attribute again
|
||||
pub eii_declaration: Option<EiiDecl>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic, Walkable)]
|
||||
pub struct EiiExternTarget {
|
||||
pub struct EiiDecl {
|
||||
/// path to the extern item we're targeting
|
||||
pub extern_item_path: Path,
|
||||
pub foreign_item: Path,
|
||||
pub impl_unsafe: bool,
|
||||
}
|
||||
|
||||
|
|
@ -3824,7 +3826,7 @@ pub struct EiiImpl {
|
|||
///
|
||||
/// This field is that shortcut: we prefill the extern target to skip a name resolution step,
|
||||
/// making sure it never fails. It'd be awful UX if we fail name resolution in code invisible to the user.
|
||||
pub known_eii_macro_resolution: Option<EiiExternTarget>,
|
||||
pub known_eii_macro_resolution: Option<EiiDecl>,
|
||||
pub impl_safety: Safety,
|
||||
pub span: Span,
|
||||
pub inner_span: Span,
|
||||
|
|
|
|||
|
|
@ -489,7 +489,7 @@ macro_rules! common_visitor_and_walkers {
|
|||
WhereEqPredicate,
|
||||
WhereRegionPredicate,
|
||||
YieldKind,
|
||||
EiiExternTarget,
|
||||
EiiDecl,
|
||||
EiiImpl,
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use rustc_abi::ExternAbi;
|
|||
use rustc_ast::visit::AssocCtxt;
|
||||
use rustc_ast::*;
|
||||
use rustc_errors::{E0570, ErrorGuaranteed, struct_span_code_err};
|
||||
use rustc_hir::attrs::{AttributeKind, EiiDecl, EiiImplResolution};
|
||||
use rustc_hir::attrs::{AttributeKind, EiiImplResolution};
|
||||
use rustc_hir::def::{DefKind, PerNS, Res};
|
||||
use rustc_hir::def_id::{CRATE_DEF_ID, LocalDefId};
|
||||
use rustc_hir::{
|
||||
|
|
@ -134,16 +134,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||
}
|
||||
}
|
||||
|
||||
fn lower_eii_extern_target(
|
||||
fn lower_eii_decl(
|
||||
&mut self,
|
||||
id: NodeId,
|
||||
eii_name: Ident,
|
||||
EiiExternTarget { extern_item_path, impl_unsafe }: &EiiExternTarget,
|
||||
) -> Option<EiiDecl> {
|
||||
self.lower_path_simple_eii(id, extern_item_path).map(|did| EiiDecl {
|
||||
eii_extern_target: did,
|
||||
name: Ident,
|
||||
EiiDecl { foreign_item, impl_unsafe }: &EiiDecl,
|
||||
) -> Option<hir::attrs::EiiDecl> {
|
||||
self.lower_path_simple_eii(id, foreign_item).map(|did| hir::attrs::EiiDecl {
|
||||
foreign_item: did,
|
||||
impl_unsafe: *impl_unsafe,
|
||||
name: eii_name,
|
||||
name,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -160,7 +160,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||
}: &EiiImpl,
|
||||
) -> hir::attrs::EiiImpl {
|
||||
let resolution = if let Some(target) = known_eii_macro_resolution
|
||||
&& let Some(decl) = self.lower_eii_extern_target(
|
||||
&& let Some(decl) = self.lower_eii_decl(
|
||||
*node_id,
|
||||
// the expect is ok here since we always generate this path in the eii macro.
|
||||
eii_macro_path.segments.last().expect("at least one segment").ident,
|
||||
|
|
@ -196,9 +196,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||
eii_impls.iter().map(|i| self.lower_eii_impl(i)).collect(),
|
||||
))]
|
||||
}
|
||||
ItemKind::MacroDef(name, MacroDef { eii_extern_target: Some(target), .. }) => self
|
||||
.lower_eii_extern_target(id, *name, target)
|
||||
.map(|decl| vec![hir::Attribute::Parsed(AttributeKind::EiiExternTarget(decl))])
|
||||
ItemKind::MacroDef(name, MacroDef { eii_declaration: Some(target), .. }) => self
|
||||
.lower_eii_decl(id, *name, target)
|
||||
.map(|decl| vec![hir::Attribute::Parsed(AttributeKind::EiiDeclaration(decl))])
|
||||
.unwrap_or_default(),
|
||||
|
||||
ItemKind::ExternCrate(..)
|
||||
|
|
@ -242,10 +242,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||
vis_span,
|
||||
span: self.lower_span(i.span),
|
||||
has_delayed_lints: !self.delayed_lints.is_empty(),
|
||||
eii: find_attr!(
|
||||
attrs,
|
||||
AttributeKind::EiiImpls(..) | AttributeKind::EiiExternTarget(..)
|
||||
),
|
||||
eii: find_attr!(attrs, AttributeKind::EiiImpls(..) | AttributeKind::EiiDeclaration(..)),
|
||||
};
|
||||
self.arena.alloc(item)
|
||||
}
|
||||
|
|
@ -539,7 +536,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||
);
|
||||
hir::ItemKind::TraitAlias(constness, ident, generics, bounds)
|
||||
}
|
||||
ItemKind::MacroDef(ident, MacroDef { body, macro_rules, eii_extern_target: _ }) => {
|
||||
ItemKind::MacroDef(ident, MacroDef { body, macro_rules, eii_declaration: _ }) => {
|
||||
let ident = self.lower_ident(*ident);
|
||||
let body = Box::new(self.lower_delim_args(body));
|
||||
let def_id = self.local_def_id(id);
|
||||
|
|
@ -553,7 +550,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||
let macro_def = self.arena.alloc(ast::MacroDef {
|
||||
body,
|
||||
macro_rules: *macro_rules,
|
||||
eii_extern_target: None,
|
||||
eii_declaration: None,
|
||||
});
|
||||
hir::ItemKind::Macro(ident, macro_def, macro_kinds)
|
||||
}
|
||||
|
|
@ -693,7 +690,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||
has_delayed_lints: !this.delayed_lints.is_empty(),
|
||||
eii: find_attr!(
|
||||
attrs,
|
||||
AttributeKind::EiiImpls(..) | AttributeKind::EiiExternTarget(..)
|
||||
AttributeKind::EiiImpls(..) | AttributeKind::EiiDeclaration(..)
|
||||
),
|
||||
};
|
||||
hir::OwnerNode::Item(this.arena.alloc(item))
|
||||
|
|
|
|||
|
|
@ -865,10 +865,10 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
|
|||
sp: Span,
|
||||
print_visibility: impl FnOnce(&mut Self),
|
||||
) {
|
||||
if let Some(eii_extern_target) = ¯o_def.eii_extern_target {
|
||||
self.word("#[eii_extern_target(");
|
||||
self.print_path(&eii_extern_target.extern_item_path, false, 0);
|
||||
if eii_extern_target.impl_unsafe {
|
||||
if let Some(eii_decl) = ¯o_def.eii_declaration {
|
||||
self.word("#[eii_declaration(");
|
||||
self.print_path(&eii_decl.foreign_item, false, 0);
|
||||
if eii_decl.impl_unsafe {
|
||||
self.word(",");
|
||||
self.space();
|
||||
self.word("unsafe");
|
||||
|
|
|
|||
|
|
@ -151,9 +151,9 @@ builtin_macros_derive_path_args_value = traits in `#[derive(...)]` don't accept
|
|||
|
||||
builtin_macros_duplicate_macro_attribute = duplicated attribute
|
||||
|
||||
builtin_macros_eii_extern_target_expected_list = `#[eii_extern_target(...)]` expects a list of one or two elements
|
||||
builtin_macros_eii_extern_target_expected_macro = `#[eii_extern_target(...)]` is only valid on macros
|
||||
builtin_macros_eii_extern_target_expected_unsafe = expected this argument to be "unsafe"
|
||||
builtin_macros_eii_declaration_expected_list = `#[eii_declaration(...)]` expects a list of one or two elements
|
||||
builtin_macros_eii_declaration_expected_macro = `#[eii_declaration(...)]` is only valid on macros
|
||||
builtin_macros_eii_declaration_expected_unsafe = expected this argument to be "unsafe"
|
||||
.note = the second argument is optional
|
||||
|
||||
builtin_macros_eii_only_once = `#[{$name}]` can only be specified once
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use rustc_ast::token::{Delimiter, TokenKind};
|
||||
use rustc_ast::tokenstream::{DelimSpacing, DelimSpan, Spacing, TokenStream, TokenTree};
|
||||
use rustc_ast::{
|
||||
Attribute, DUMMY_NODE_ID, EiiExternTarget, EiiImpl, ItemKind, MetaItem, Path, Stmt, StmtKind,
|
||||
Attribute, DUMMY_NODE_ID, EiiDecl, EiiImpl, ItemKind, MetaItem, Path, Stmt, StmtKind,
|
||||
Visibility, ast,
|
||||
};
|
||||
use rustc_ast_pretty::pprust::path_to_string;
|
||||
|
|
@ -30,7 +30,7 @@ use crate::errors::{
|
|||
/// }
|
||||
///
|
||||
/// #[rustc_builtin_macro(eii_shared_macro)]
|
||||
/// #[eii_extern_target(panic_handler)]
|
||||
/// #[eii_declaration(panic_handler)]
|
||||
/// macro panic_handler() {}
|
||||
/// ```
|
||||
pub(crate) fn eii(
|
||||
|
|
@ -210,8 +210,8 @@ fn generate_default_impl(
|
|||
},
|
||||
span: eii_attr_span,
|
||||
is_default: true,
|
||||
known_eii_macro_resolution: Some(ast::EiiExternTarget {
|
||||
extern_item_path: ecx.path(
|
||||
known_eii_macro_resolution: Some(ast::EiiDecl {
|
||||
foreign_item: ecx.path(
|
||||
foreign_item_name.span,
|
||||
// prefix super to escape the `dflt` module generated below
|
||||
vec![Ident::from_str_and_span("super", foreign_item_name.span), foreign_item_name],
|
||||
|
|
@ -349,7 +349,7 @@ fn generate_foreign_item(
|
|||
/// // This attribute tells the compiler that
|
||||
/// #[builtin_macro(eii_shared_macro)]
|
||||
/// // the metadata to link this macro to the generated foreign item.
|
||||
/// #[eii_extern_target(<related_reign_item>)]
|
||||
/// #[eii_declaration(<related_foreign_item>)]
|
||||
/// macro macro_name { () => {} }
|
||||
/// ```
|
||||
fn generate_attribute_macro_to_implement(
|
||||
|
|
@ -401,9 +401,9 @@ fn generate_attribute_macro_to_implement(
|
|||
]),
|
||||
}),
|
||||
macro_rules: false,
|
||||
// #[eii_extern_target(foreign_item_ident)]
|
||||
eii_extern_target: Some(ast::EiiExternTarget {
|
||||
extern_item_path: ast::Path::from_ident(foreign_item_name),
|
||||
// #[eii_declaration(foreign_item_ident)]
|
||||
eii_declaration: Some(ast::EiiDecl {
|
||||
foreign_item: ast::Path::from_ident(foreign_item_name),
|
||||
impl_unsafe,
|
||||
}),
|
||||
},
|
||||
|
|
@ -412,7 +412,7 @@ fn generate_attribute_macro_to_implement(
|
|||
})
|
||||
}
|
||||
|
||||
pub(crate) fn eii_extern_target(
|
||||
pub(crate) fn eii_declaration(
|
||||
ecx: &mut ExtCtxt<'_>,
|
||||
span: Span,
|
||||
meta_item: &ast::MetaItem,
|
||||
|
|
@ -461,7 +461,7 @@ pub(crate) fn eii_extern_target(
|
|||
false
|
||||
};
|
||||
|
||||
d.eii_extern_target = Some(EiiExternTarget { extern_item_path, impl_unsafe });
|
||||
d.eii_declaration = Some(EiiDecl { foreign_item: extern_item_path, impl_unsafe });
|
||||
|
||||
// Return the original item and the new methods.
|
||||
vec![item]
|
||||
|
|
|
|||
|
|
@ -1010,21 +1010,21 @@ pub(crate) struct CfgSelectUnreachable {
|
|||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(builtin_macros_eii_extern_target_expected_macro)]
|
||||
#[diag(builtin_macros_eii_declaration_expected_macro)]
|
||||
pub(crate) struct EiiExternTargetExpectedMacro {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(builtin_macros_eii_extern_target_expected_list)]
|
||||
#[diag(builtin_macros_eii_declaration_expected_list)]
|
||||
pub(crate) struct EiiExternTargetExpectedList {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(builtin_macros_eii_extern_target_expected_unsafe)]
|
||||
#[diag(builtin_macros_eii_declaration_expected_unsafe)]
|
||||
pub(crate) struct EiiExternTargetExpectedUnsafe {
|
||||
#[primary_span]
|
||||
#[note]
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) {
|
|||
derive: derive::Expander { is_const: false },
|
||||
derive_const: derive::Expander { is_const: true },
|
||||
eii: eii::eii,
|
||||
eii_extern_target: eii::eii_extern_target,
|
||||
eii_declaration: eii::eii_declaration,
|
||||
eii_shared_macro: eii::eii_shared_macro,
|
||||
global_allocator: global_allocator::expand,
|
||||
test: test::expand_test,
|
||||
|
|
|
|||
|
|
@ -287,11 +287,11 @@ fn process_builtin_attrs(
|
|||
}
|
||||
AttributeKind::EiiImpls(impls) => {
|
||||
for i in impls {
|
||||
let extern_item = match i.resolution {
|
||||
let foreign_item = match i.resolution {
|
||||
EiiImplResolution::Macro(def_id) => {
|
||||
let Some(extern_item) = find_attr!(
|
||||
tcx.get_all_attrs(def_id),
|
||||
AttributeKind::EiiExternTarget(target) => target.eii_extern_target
|
||||
AttributeKind::EiiDeclaration(target) => target.foreign_item
|
||||
) else {
|
||||
tcx.dcx().span_delayed_bug(
|
||||
i.span,
|
||||
|
|
@ -301,7 +301,7 @@ fn process_builtin_attrs(
|
|||
};
|
||||
extern_item
|
||||
}
|
||||
EiiImplResolution::Known(decl) => decl.eii_extern_target,
|
||||
EiiImplResolution::Known(decl) => decl.foreign_item,
|
||||
EiiImplResolution::Error(_eg) => continue,
|
||||
};
|
||||
|
||||
|
|
@ -316,13 +316,13 @@ fn process_builtin_attrs(
|
|||
// iterate over all implementations *in the current crate*
|
||||
// (this is ok since we generate codegen fn attrs in the local crate)
|
||||
// if any of them is *not default* then don't emit the alias.
|
||||
&& tcx.externally_implementable_items(LOCAL_CRATE).get(&extern_item).expect("at least one").1.iter().any(|(_, imp)| !imp.is_default)
|
||||
&& tcx.externally_implementable_items(LOCAL_CRATE).get(&foreign_item).expect("at least one").1.iter().any(|(_, imp)| !imp.is_default)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
codegen_fn_attrs.foreign_item_symbol_aliases.push((
|
||||
extern_item,
|
||||
foreign_item,
|
||||
if i.is_default { Linkage::LinkOnceAny } else { Linkage::External },
|
||||
Visibility::Default,
|
||||
));
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ pub struct EiiImpl {
|
|||
|
||||
#[derive(Copy, Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)]
|
||||
pub struct EiiDecl {
|
||||
pub eii_extern_target: DefId,
|
||||
pub foreign_item: DefId,
|
||||
/// whether or not it is unsafe to implement this EII
|
||||
pub impl_unsafe: bool,
|
||||
pub name: Ident,
|
||||
|
|
@ -744,10 +744,10 @@ pub enum AttributeKind {
|
|||
Dummy,
|
||||
|
||||
/// Implementation detail of `#[eii]`
|
||||
EiiExternItem,
|
||||
EiiDeclaration(EiiDecl),
|
||||
|
||||
/// Implementation detail of `#[eii]`
|
||||
EiiExternTarget(EiiDecl),
|
||||
EiiExternItem,
|
||||
|
||||
/// Implementation detail of `#[eii]`
|
||||
EiiImpls(ThinVec<EiiImpl>),
|
||||
|
|
|
|||
|
|
@ -47,8 +47,8 @@ impl AttributeKind {
|
|||
Doc(_) => Yes,
|
||||
DocComment { .. } => Yes,
|
||||
Dummy => No,
|
||||
EiiDeclaration(_) => Yes,
|
||||
EiiExternItem => No,
|
||||
EiiExternTarget(_) => Yes,
|
||||
EiiImpls(..) => No,
|
||||
ExportName { .. } => Yes,
|
||||
ExportStable => No,
|
||||
|
|
|
|||
|
|
@ -1205,7 +1205,7 @@ fn check_eiis(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
|||
EiiImplResolution::Macro(def_id) => {
|
||||
// we expect this macro to have the `EiiMacroFor` attribute, that points to a function
|
||||
// signature that we'd like to compare the function we're currently checking with
|
||||
if let Some(foreign_item) = find_attr!(tcx.get_all_attrs(*def_id), AttributeKind::EiiExternTarget(EiiDecl {eii_extern_target: t, ..}) => *t)
|
||||
if let Some(foreign_item) = find_attr!(tcx.get_all_attrs(*def_id), AttributeKind::EiiDeclaration(EiiDecl {foreign_item: t, ..}) => *t)
|
||||
{
|
||||
(foreign_item, tcx.item_name(*def_id))
|
||||
} else {
|
||||
|
|
@ -1213,7 +1213,7 @@ fn check_eiis(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
|||
continue;
|
||||
}
|
||||
}
|
||||
EiiImplResolution::Known(decl) => (decl.eii_extern_target, decl.name.name),
|
||||
EiiImplResolution::Known(decl) => (decl.foreign_item, decl.name.name),
|
||||
EiiImplResolution::Error(_eg) => continue,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -31,9 +31,9 @@ pub(crate) fn collect<'tcx>(tcx: TyCtxt<'tcx>, LocalCrate: LocalCrate) -> EiiMap
|
|||
let decl = match i.resolution {
|
||||
EiiImplResolution::Macro(macro_defid) => {
|
||||
// find the decl for this one if it wasn't in yet (maybe it's from the local crate? not very useful but not illegal)
|
||||
let Some(decl) = find_attr!(tcx.get_all_attrs(macro_defid), AttributeKind::EiiExternTarget(d) => *d)
|
||||
let Some(decl) = find_attr!(tcx.get_all_attrs(macro_defid), AttributeKind::EiiDeclaration(d) => *d)
|
||||
else {
|
||||
// skip if it doesn't have eii_extern_target (if we resolved to another macro that's not an EII)
|
||||
// skip if it doesn't have eii_declaration (if we resolved to another macro that's not an EII)
|
||||
tcx.dcx()
|
||||
.span_delayed_bug(i.span, "resolved to something that's not an EII");
|
||||
continue;
|
||||
|
|
@ -45,7 +45,7 @@ pub(crate) fn collect<'tcx>(tcx: TyCtxt<'tcx>, LocalCrate: LocalCrate) -> EiiMap
|
|||
};
|
||||
|
||||
// FIXME(eii) remove extern target from encoded decl
|
||||
eiis.entry(decl.eii_extern_target)
|
||||
eiis.entry(decl.foreign_item)
|
||||
.or_insert_with(|| (decl, Default::default()))
|
||||
.1
|
||||
.insert(id.into(), *i);
|
||||
|
|
@ -53,9 +53,9 @@ pub(crate) fn collect<'tcx>(tcx: TyCtxt<'tcx>, LocalCrate: LocalCrate) -> EiiMap
|
|||
|
||||
// if we find a new declaration, add it to the list without a known implementation
|
||||
if let Some(decl) =
|
||||
find_attr!(tcx.get_all_attrs(id), AttributeKind::EiiExternTarget(d) => *d)
|
||||
find_attr!(tcx.get_all_attrs(id), AttributeKind::EiiDeclaration(d) => *d)
|
||||
{
|
||||
eiis.entry(decl.eii_extern_target).or_insert((decl, Default::default()));
|
||||
eiis.entry(decl.foreign_item).or_insert((decl, Default::default()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1536,7 +1536,7 @@ impl<'a> CrateMetadataRef<'a> {
|
|||
.get((self, tcx), id)
|
||||
.unwrap()
|
||||
.decode((self, tcx));
|
||||
ast::MacroDef { macro_rules, body: Box::new(body), eii_extern_target: None }
|
||||
ast::MacroDef { macro_rules, body: Box::new(body), eii_declaration: None }
|
||||
}
|
||||
_ => bug!(),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2283,7 +2283,7 @@ impl<'a> Parser<'a> {
|
|||
self.psess.gated_spans.gate(sym::decl_macro, lo.to(self.prev_token.span));
|
||||
Ok(ItemKind::MacroDef(
|
||||
ident,
|
||||
ast::MacroDef { body, macro_rules: false, eii_extern_target: None },
|
||||
ast::MacroDef { body, macro_rules: false, eii_declaration: None },
|
||||
))
|
||||
}
|
||||
|
||||
|
|
@ -2333,7 +2333,7 @@ impl<'a> Parser<'a> {
|
|||
|
||||
Ok(ItemKind::MacroDef(
|
||||
ident,
|
||||
ast::MacroDef { body, macro_rules: true, eii_extern_target: None },
|
||||
ast::MacroDef { body, macro_rules: true, eii_declaration: None },
|
||||
))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
|||
self.check_rustc_must_implement_one_of(*attr_span, fn_names, hir_id,target)
|
||||
},
|
||||
Attribute::Parsed(
|
||||
AttributeKind::EiiExternTarget { .. }
|
||||
AttributeKind::EiiDeclaration { .. }
|
||||
| AttributeKind::EiiExternItem
|
||||
| AttributeKind::BodyStability { .. }
|
||||
| AttributeKind::ConstStabilityIndirect
|
||||
|
|
@ -553,7 +553,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
|||
}
|
||||
|
||||
if let EiiImplResolution::Macro(eii_macro) = resolution
|
||||
&& find_attr!(self.tcx.get_all_attrs(*eii_macro), AttributeKind::EiiExternTarget(EiiDecl { impl_unsafe, .. }) if *impl_unsafe)
|
||||
&& find_attr!(self.tcx.get_all_attrs(*eii_macro), AttributeKind::EiiDeclaration(EiiDecl { impl_unsafe, .. }) if *impl_unsafe)
|
||||
&& !impl_marked_unsafe
|
||||
{
|
||||
self.dcx().emit_err(errors::EiiImplRequiresUnsafe {
|
||||
|
|
|
|||
|
|
@ -1079,7 +1079,7 @@ impl<'ast, 'ra, 'tcx> Visitor<'ast> for LateResolutionVisitor<'_, 'ast, 'ra, 'tc
|
|||
self.smart_resolve_path(
|
||||
*node_id,
|
||||
&None,
|
||||
&target.extern_item_path,
|
||||
&target.foreign_item,
|
||||
PathSource::Expr(None),
|
||||
);
|
||||
} else {
|
||||
|
|
@ -2931,8 +2931,8 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
|
|||
self.parent_scope.macro_rules = self.r.macro_rules_scopes[&def_id];
|
||||
}
|
||||
|
||||
if let Some(EiiExternTarget { extern_item_path, impl_unsafe: _ }) =
|
||||
¯o_def.eii_extern_target
|
||||
if let Some(EiiDecl { foreign_item: extern_item_path, impl_unsafe: _ }) =
|
||||
¯o_def.eii_declaration
|
||||
{
|
||||
self.smart_resolve_path(
|
||||
item.id,
|
||||
|
|
|
|||
|
|
@ -935,7 +935,7 @@ symbols! {
|
|||
eh_catch_typeinfo,
|
||||
eh_personality,
|
||||
eii,
|
||||
eii_extern_target,
|
||||
eii_declaration,
|
||||
eii_impl,
|
||||
eii_internals,
|
||||
eii_shared_macro,
|
||||
|
|
|
|||
|
|
@ -1912,7 +1912,7 @@ pub(crate) mod builtin {
|
|||
/// Impl detail of EII
|
||||
#[unstable(feature = "eii_internals", issue = "none")]
|
||||
#[rustc_builtin_macro]
|
||||
pub macro eii_extern_target($item:item) {
|
||||
pub macro eii_declaration($item:item) {
|
||||
/* compiler built-in */
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,4 +122,4 @@ pub use crate::macros::builtin::define_opaque;
|
|||
pub use crate::macros::builtin::{eii, unsafe_eii};
|
||||
|
||||
#[unstable(feature = "eii_internals", issue = "none")]
|
||||
pub use crate::macros::builtin::eii_extern_target;
|
||||
pub use crate::macros::builtin::eii_declaration;
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ pub use core::prelude::v1::define_opaque;
|
|||
pub use core::prelude::v1::{eii, unsafe_eii};
|
||||
|
||||
#[unstable(feature = "eii_internals", issue = "none")]
|
||||
pub use core::prelude::v1::eii_extern_target;
|
||||
pub use core::prelude::v1::eii_declaration;
|
||||
|
||||
// The file so far is equivalent to core/src/prelude/v1.rs. It is duplicated
|
||||
// rather than glob imported because we want docs to show these re-exports as
|
||||
|
|
|
|||
|
|
@ -5,19 +5,19 @@
|
|||
#![feature(rustc_attrs)]
|
||||
#![feature(eii_internals)]
|
||||
|
||||
#[eii_extern_target(bar)] //~ ERROR `#[eii_extern_target(...)]` is only valid on macros
|
||||
#[eii_declaration(bar)] //~ ERROR `#[eii_declaration(...)]` is only valid on macros
|
||||
fn hello() {
|
||||
#[eii_extern_target(bar)] //~ ERROR `#[eii_extern_target(...)]` is only valid on macros
|
||||
#[eii_declaration(bar)] //~ ERROR `#[eii_declaration(...)]` is only valid on macros
|
||||
let x = 3 + 3;
|
||||
}
|
||||
|
||||
#[eii_extern_target] //~ ERROR `#[eii_extern_target(...)]` expects a list of one or two elements
|
||||
#[eii_extern_target()] //~ ERROR `#[eii_extern_target(...)]` expects a list of one or two elements
|
||||
#[eii_extern_target(bar, hello)] //~ ERROR expected this argument to be "unsafe"
|
||||
#[eii_extern_target(bar, "unsafe", hello)] //~ ERROR `#[eii_extern_target(...)]` expects a list of one or two elements
|
||||
#[eii_extern_target(bar, hello, "unsafe")] //~ ERROR `#[eii_extern_target(...)]` expects a list of one or two elements
|
||||
#[eii_extern_target = "unsafe"] //~ ERROR `#[eii_extern_target(...)]` expects a list of one or two elements
|
||||
#[eii_extern_target(bar)]
|
||||
#[eii_declaration] //~ ERROR `#[eii_declaration(...)]` expects a list of one or two elements
|
||||
#[eii_declaration()] //~ ERROR `#[eii_declaration(...)]` expects a list of one or two elements
|
||||
#[eii_declaration(bar, hello)] //~ ERROR expected this argument to be "unsafe"
|
||||
#[eii_declaration(bar, "unsafe", hello)] //~ ERROR `#[eii_declaration(...)]` expects a list of one or two elements
|
||||
#[eii_declaration(bar, hello, "unsafe")] //~ ERROR `#[eii_declaration(...)]` expects a list of one or two elements
|
||||
#[eii_declaration = "unsafe"] //~ ERROR `#[eii_declaration(...)]` expects a list of one or two elements
|
||||
#[eii_declaration(bar)]
|
||||
#[rustc_builtin_macro(eii_shared_macro)]
|
||||
macro foo() {}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,56 +1,56 @@
|
|||
error: `#[eii_extern_target(...)]` is only valid on macros
|
||||
error: `#[eii_declaration(...)]` is only valid on macros
|
||||
--> $DIR/errors.rs:8:1
|
||||
|
|
||||
LL | #[eii_extern_target(bar)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | #[eii_declaration(bar)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `#[eii_extern_target(...)]` is only valid on macros
|
||||
error: `#[eii_declaration(...)]` is only valid on macros
|
||||
--> $DIR/errors.rs:10:5
|
||||
|
|
||||
LL | #[eii_extern_target(bar)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | #[eii_declaration(bar)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `#[eii_extern_target(...)]` expects a list of one or two elements
|
||||
error: `#[eii_declaration(...)]` expects a list of one or two elements
|
||||
--> $DIR/errors.rs:14:1
|
||||
|
|
||||
LL | #[eii_extern_target]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
LL | #[eii_declaration]
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `#[eii_extern_target(...)]` expects a list of one or two elements
|
||||
error: `#[eii_declaration(...)]` expects a list of one or two elements
|
||||
--> $DIR/errors.rs:15:1
|
||||
|
|
||||
LL | #[eii_extern_target()]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | #[eii_declaration()]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: expected this argument to be "unsafe"
|
||||
--> $DIR/errors.rs:16:26
|
||||
--> $DIR/errors.rs:16:24
|
||||
|
|
||||
LL | #[eii_extern_target(bar, hello)]
|
||||
| ^^^^^
|
||||
LL | #[eii_declaration(bar, hello)]
|
||||
| ^^^^^
|
||||
|
|
||||
note: the second argument is optional
|
||||
--> $DIR/errors.rs:16:26
|
||||
--> $DIR/errors.rs:16:24
|
||||
|
|
||||
LL | #[eii_extern_target(bar, hello)]
|
||||
| ^^^^^
|
||||
LL | #[eii_declaration(bar, hello)]
|
||||
| ^^^^^
|
||||
|
||||
error: `#[eii_extern_target(...)]` expects a list of one or two elements
|
||||
error: `#[eii_declaration(...)]` expects a list of one or two elements
|
||||
--> $DIR/errors.rs:17:1
|
||||
|
|
||||
LL | #[eii_extern_target(bar, "unsafe", hello)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | #[eii_declaration(bar, "unsafe", hello)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `#[eii_extern_target(...)]` expects a list of one or two elements
|
||||
error: `#[eii_declaration(...)]` expects a list of one or two elements
|
||||
--> $DIR/errors.rs:18:1
|
||||
|
|
||||
LL | #[eii_extern_target(bar, hello, "unsafe")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | #[eii_declaration(bar, hello, "unsafe")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `#[eii_extern_target(...)]` expects a list of one or two elements
|
||||
error: `#[eii_declaration(...)]` expects a list of one or two elements
|
||||
--> $DIR/errors.rs:19:1
|
||||
|
|
||||
LL | #[eii_extern_target = "unsafe"]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | #[eii_declaration = "unsafe"]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `#[foo]` is only valid on functions
|
||||
--> $DIR/errors.rs:28:1
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#![feature(rustc_attrs)]
|
||||
#![feature(eii_internals)]
|
||||
|
||||
#[eii_extern_target(bar)]
|
||||
#[eii_declaration(bar)]
|
||||
#[rustc_builtin_macro(eii_shared_macro)]
|
||||
pub macro foo() {}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
#![feature(rustc_attrs)]
|
||||
#![feature(eii_internals)]
|
||||
|
||||
#[eii_extern_target(bar)]
|
||||
#[eii_declaration(bar)]
|
||||
#[rustc_builtin_macro(eii_shared_macro)]
|
||||
macro foo() {}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
#![feature(rustc_attrs)]
|
||||
#![feature(eii_internals)]
|
||||
|
||||
#[eii_extern_target(bar)]
|
||||
#[eii_declaration(bar)]
|
||||
#[rustc_builtin_macro(eii_shared_macro)]
|
||||
macro foo() {}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#![feature(rustc_attrs)]
|
||||
#![feature(eii_internals)]
|
||||
|
||||
#[eii_extern_target(bar)]
|
||||
#[eii_declaration(bar)]
|
||||
#[rustc_builtin_macro(eii_shared_macro)]
|
||||
macro foo() {}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#![feature(rustc_attrs)]
|
||||
#![feature(eii_internals)]
|
||||
|
||||
#[eii_extern_target(bar)]
|
||||
#[eii_declaration(bar)]
|
||||
#[rustc_builtin_macro(eii_shared_macro)]
|
||||
macro foo() {}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#![feature(rustc_attrs)]
|
||||
#![feature(eii_internals)]
|
||||
|
||||
#[eii_extern_target(bar)]
|
||||
#[eii_declaration(bar)]
|
||||
#[rustc_builtin_macro(eii_shared_macro)]
|
||||
macro foo() {}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#![feature(rustc_attrs)]
|
||||
#![feature(eii_internals)]
|
||||
|
||||
#[eii_extern_target(bar)]
|
||||
#[eii_declaration(bar)]
|
||||
#[rustc_builtin_macro(eii_shared_macro)]
|
||||
macro foo() {}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#![feature(rustc_attrs)]
|
||||
#![feature(eii_internals)]
|
||||
|
||||
#[eii_extern_target(bar)]
|
||||
#[eii_declaration(bar)]
|
||||
#[rustc_builtin_macro(eii_shared_macro)]
|
||||
macro foo() {}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#![feature(rustc_attrs)]
|
||||
#![feature(eii_internals)]
|
||||
|
||||
#[eii_extern_target(bar, "unsafe")]
|
||||
#[eii_declaration(bar, "unsafe")]
|
||||
#[rustc_builtin_macro(eii_shared_macro)]
|
||||
macro foo() {}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#![feature(rustc_attrs)]
|
||||
#![feature(eii_internals)]
|
||||
|
||||
#[eii_extern_target(bar, "unsafe")]
|
||||
#[eii_declaration(bar, "unsafe")]
|
||||
#[rustc_builtin_macro(eii_shared_macro)]
|
||||
macro foo() {}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#![feature(decl_macro)]
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
#[eii_extern_target(bar)] //~ ERROR use of unstable library feature `eii_internals`
|
||||
#[eii_declaration(bar)] //~ ERROR use of unstable library feature `eii_internals`
|
||||
#[rustc_builtin_macro(eii_macro)]
|
||||
macro foo() {} //~ ERROR: cannot find a built-in macro with name `foo`
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error[E0658]: use of unstable library feature `eii_internals`
|
||||
--> $DIR/feature-gate-eii-internals.rs:5:3
|
||||
|
|
||||
LL | #[eii_extern_target(bar)]
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
LL | #[eii_declaration(bar)]
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add `#![feature(eii_internals)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue