Skip to content

Commit ca4ddc2

Browse files
committed
fully de-stabilize all custom inner attributes
1 parent 4847d6a commit ca4ddc2

File tree

1 file changed

+9
-42
lines changed

1 file changed

+9
-42
lines changed

compiler/rustc_resolve/src/macros.rs

+9-42
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ use std::cell::Cell;
55
use std::mem;
66

77
use rustc_ast::expand::StrippedCfgItem;
8-
use rustc_ast::{self as ast, Crate, Inline, ItemKind, ModKind, NodeId, attr};
8+
use rustc_ast::{self as ast, Crate, NodeId, attr};
99
use rustc_ast_pretty::pprust;
1010
use rustc_attr::StabilityLevel;
1111
use rustc_data_structures::intern::Interned;
1212
use rustc_data_structures::sync::Lrc;
1313
use rustc_errors::{Applicability, StashKey};
1414
use rustc_expand::base::{
15-
Annotatable, DeriveResolution, Indeterminate, ResolverExpand, SyntaxExtension,
16-
SyntaxExtensionKind,
15+
DeriveResolution, Indeterminate, ResolverExpand, SyntaxExtension, SyntaxExtensionKind,
1716
};
1817
use rustc_expand::compile_declarative_macro;
1918
use rustc_expand::expand::{
@@ -25,8 +24,8 @@ use rustc_middle::middle::stability;
2524
use rustc_middle::ty::{RegisteredTools, TyCtxt, Visibility};
2625
use rustc_session::lint::BuiltinLintDiag;
2726
use rustc_session::lint::builtin::{
28-
LEGACY_DERIVE_HELPERS, OUT_OF_SCOPE_MACRO_CALLS, SOFT_UNSTABLE,
29-
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES, UNUSED_MACRO_RULES, UNUSED_MACROS,
27+
LEGACY_DERIVE_HELPERS, OUT_OF_SCOPE_MACRO_CALLS, UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
28+
UNUSED_MACRO_RULES, UNUSED_MACROS,
3029
};
3130
use rustc_session::parse::feature_err;
3231
use rustc_span::edit_distance::edit_distance;
@@ -157,26 +156,6 @@ pub(crate) fn registered_tools(tcx: TyCtxt<'_>, (): ()) -> RegisteredTools {
157156
registered_tools
158157
}
159158

160-
// Some feature gates for inner attributes are reported as lints for backward compatibility.
161-
fn soft_custom_inner_attributes_gate(path: &ast::Path, invoc: &Invocation) -> bool {
162-
match &path.segments[..] {
163-
// `#![test]`
164-
[seg] if seg.ident.name == sym::test => return true,
165-
// `#![rustfmt::skip]` on out-of-line modules
166-
[seg1, seg2] if seg1.ident.name == sym::rustfmt && seg2.ident.name == sym::skip => {
167-
if let InvocationKind::Attr { item, .. } = &invoc.kind {
168-
if let Annotatable::Item(item) = item {
169-
if let ItemKind::Mod(_, ModKind::Loaded(_, Inline::No, _)) = item.kind {
170-
return true;
171-
}
172-
}
173-
}
174-
}
175-
_ => {}
176-
}
177-
false
178-
}
179-
180159
impl<'ra, 'tcx> ResolverExpand for Resolver<'ra, 'tcx> {
181160
fn next_node_id(&mut self) -> NodeId {
182161
self.next_node_id()
@@ -317,7 +296,6 @@ impl<'ra, 'tcx> ResolverExpand for Resolver<'ra, 'tcx> {
317296
parent_scope,
318297
node_id,
319298
force,
320-
soft_custom_inner_attributes_gate(path, invoc),
321299
deleg_impl,
322300
looks_like_invoc_in_mod_inert_attr,
323301
)?;
@@ -549,7 +527,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
549527
parent_scope: &ParentScope<'ra>,
550528
node_id: NodeId,
551529
force: bool,
552-
soft_custom_inner_attributes_gate: bool,
553530
deleg_impl: Option<LocalDefId>,
554531
invoc_in_mod_inert_attr: Option<LocalDefId>,
555532
) -> Result<(Lrc<SyntaxExtension>, Res), Indeterminate> {
@@ -667,22 +644,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
667644
Res::NonMacroAttr(..) => false,
668645
_ => unreachable!(),
669646
};
670-
if soft_custom_inner_attributes_gate {
671-
self.tcx.sess.psess.buffer_lint(
672-
SOFT_UNSTABLE,
673-
path.span,
674-
node_id,
675-
BuiltinLintDiag::InnerAttributeUnstable { is_macro },
676-
);
647+
let msg = if is_macro {
648+
"inner macro attributes are unstable"
677649
} else {
678-
// FIXME: deduplicate with rustc_lint (`BuiltinLintDiag::InnerAttributeUnstable`)
679-
let msg = if is_macro {
680-
"inner macro attributes are unstable"
681-
} else {
682-
"custom inner attributes are unstable"
683-
};
684-
feature_err(&self.tcx.sess, sym::custom_inner_attributes, path.span, msg).emit();
685-
}
650+
"custom inner attributes are unstable"
651+
};
652+
feature_err(&self.tcx.sess, sym::custom_inner_attributes, path.span, msg).emit();
686653
}
687654

688655
if res == Res::NonMacroAttr(NonMacroAttrKind::Tool)

0 commit comments

Comments
 (0)