fully de-stabilize all custom inner attributes
This commit is contained in:
parent
d61f55d8b9
commit
5bd20b0608
6 changed files with 40 additions and 97 deletions
|
@ -6,15 +6,14 @@ use std::mem;
|
||||||
|
|
||||||
use rustc_ast::attr::AttributeExt;
|
use rustc_ast::attr::AttributeExt;
|
||||||
use rustc_ast::expand::StrippedCfgItem;
|
use rustc_ast::expand::StrippedCfgItem;
|
||||||
use rustc_ast::{self as ast, Crate, Inline, ItemKind, ModKind, NodeId, attr};
|
use rustc_ast::{self as ast, Crate, NodeId, attr};
|
||||||
use rustc_ast_pretty::pprust;
|
use rustc_ast_pretty::pprust;
|
||||||
use rustc_attr_parsing::StabilityLevel;
|
use rustc_attr_parsing::StabilityLevel;
|
||||||
use rustc_data_structures::intern::Interned;
|
use rustc_data_structures::intern::Interned;
|
||||||
use rustc_data_structures::sync::Lrc;
|
use rustc_data_structures::sync::Lrc;
|
||||||
use rustc_errors::{Applicability, StashKey};
|
use rustc_errors::{Applicability, StashKey};
|
||||||
use rustc_expand::base::{
|
use rustc_expand::base::{
|
||||||
Annotatable, DeriveResolution, Indeterminate, ResolverExpand, SyntaxExtension,
|
DeriveResolution, Indeterminate, ResolverExpand, SyntaxExtension, SyntaxExtensionKind,
|
||||||
SyntaxExtensionKind,
|
|
||||||
};
|
};
|
||||||
use rustc_expand::compile_declarative_macro;
|
use rustc_expand::compile_declarative_macro;
|
||||||
use rustc_expand::expand::{
|
use rustc_expand::expand::{
|
||||||
|
@ -26,8 +25,8 @@ use rustc_middle::middle::stability;
|
||||||
use rustc_middle::ty::{RegisteredTools, TyCtxt, Visibility};
|
use rustc_middle::ty::{RegisteredTools, TyCtxt, Visibility};
|
||||||
use rustc_session::lint::BuiltinLintDiag;
|
use rustc_session::lint::BuiltinLintDiag;
|
||||||
use rustc_session::lint::builtin::{
|
use rustc_session::lint::builtin::{
|
||||||
LEGACY_DERIVE_HELPERS, OUT_OF_SCOPE_MACRO_CALLS, SOFT_UNSTABLE,
|
LEGACY_DERIVE_HELPERS, OUT_OF_SCOPE_MACRO_CALLS, UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
|
||||||
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES, UNUSED_MACRO_RULES, UNUSED_MACROS,
|
UNUSED_MACRO_RULES, UNUSED_MACROS,
|
||||||
};
|
};
|
||||||
use rustc_session::parse::feature_err;
|
use rustc_session::parse::feature_err;
|
||||||
use rustc_span::edit_distance::edit_distance;
|
use rustc_span::edit_distance::edit_distance;
|
||||||
|
@ -157,26 +156,6 @@ pub(crate) fn registered_tools(tcx: TyCtxt<'_>, (): ()) -> RegisteredTools {
|
||||||
registered_tools
|
registered_tools
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some feature gates for inner attributes are reported as lints for backward compatibility.
|
|
||||||
fn soft_custom_inner_attributes_gate(path: &ast::Path, invoc: &Invocation) -> bool {
|
|
||||||
match &path.segments[..] {
|
|
||||||
// `#![test]`
|
|
||||||
[seg] if seg.ident.name == sym::test => return true,
|
|
||||||
// `#![rustfmt::skip]` on out-of-line modules
|
|
||||||
[seg1, seg2] if seg1.ident.name == sym::rustfmt && seg2.ident.name == sym::skip => {
|
|
||||||
if let InvocationKind::Attr { item, .. } = &invoc.kind {
|
|
||||||
if let Annotatable::Item(item) = item {
|
|
||||||
if let ItemKind::Mod(_, ModKind::Loaded(_, Inline::No, _, _)) = item.kind {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'ra, 'tcx> ResolverExpand for Resolver<'ra, 'tcx> {
|
impl<'ra, 'tcx> ResolverExpand for Resolver<'ra, 'tcx> {
|
||||||
fn next_node_id(&mut self) -> NodeId {
|
fn next_node_id(&mut self) -> NodeId {
|
||||||
self.next_node_id()
|
self.next_node_id()
|
||||||
|
@ -317,7 +296,6 @@ impl<'ra, 'tcx> ResolverExpand for Resolver<'ra, 'tcx> {
|
||||||
parent_scope,
|
parent_scope,
|
||||||
node_id,
|
node_id,
|
||||||
force,
|
force,
|
||||||
soft_custom_inner_attributes_gate(path, invoc),
|
|
||||||
deleg_impl,
|
deleg_impl,
|
||||||
looks_like_invoc_in_mod_inert_attr,
|
looks_like_invoc_in_mod_inert_attr,
|
||||||
)?;
|
)?;
|
||||||
|
@ -549,7 +527,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
||||||
parent_scope: &ParentScope<'ra>,
|
parent_scope: &ParentScope<'ra>,
|
||||||
node_id: NodeId,
|
node_id: NodeId,
|
||||||
force: bool,
|
force: bool,
|
||||||
soft_custom_inner_attributes_gate: bool,
|
|
||||||
deleg_impl: Option<LocalDefId>,
|
deleg_impl: Option<LocalDefId>,
|
||||||
invoc_in_mod_inert_attr: Option<LocalDefId>,
|
invoc_in_mod_inert_attr: Option<LocalDefId>,
|
||||||
) -> Result<(Lrc<SyntaxExtension>, Res), Indeterminate> {
|
) -> Result<(Lrc<SyntaxExtension>, Res), Indeterminate> {
|
||||||
|
@ -667,22 +644,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
||||||
Res::NonMacroAttr(..) => false,
|
Res::NonMacroAttr(..) => false,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
if soft_custom_inner_attributes_gate {
|
let msg = if is_macro {
|
||||||
self.tcx.sess.psess.buffer_lint(
|
"inner macro attributes are unstable"
|
||||||
SOFT_UNSTABLE,
|
|
||||||
path.span,
|
|
||||||
node_id,
|
|
||||||
BuiltinLintDiag::InnerAttributeUnstable { is_macro },
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
// FIXME: deduplicate with rustc_lint (`BuiltinLintDiag::InnerAttributeUnstable`)
|
"custom inner attributes are unstable"
|
||||||
let msg = if is_macro {
|
};
|
||||||
"inner macro attributes are unstable"
|
feature_err(&self.tcx.sess, sym::custom_inner_attributes, path.span, msg).emit();
|
||||||
} else {
|
|
||||||
"custom inner attributes are unstable"
|
|
||||||
};
|
|
||||||
feature_err(&self.tcx.sess, sym::custom_inner_attributes, path.span, msg).emit();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if res == Res::NonMacroAttr(NonMacroAttrKind::Tool)
|
if res == Res::NonMacroAttr(NonMacroAttrKind::Tool)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
//@ compile-flags: -Z span-debug
|
//@ compile-flags: -Z span-debug
|
||||||
//@ error-pattern:custom inner attributes are unstable
|
//@ error-pattern:custom inner attributes are unstable
|
||||||
//@ error-pattern:inner macro attributes are unstable
|
//@ error-pattern:inner macro attributes are unstable
|
||||||
//@ error-pattern:this was previously accepted
|
|
||||||
//@ proc-macro: test-macros.rs
|
//@ proc-macro: test-macros.rs
|
||||||
|
|
||||||
#![no_std] // Don't load unnecessary hygiene information from std
|
#![no_std] // Don't load unnecessary hygiene information from std
|
||||||
|
|
|
@ -1,3 +1,13 @@
|
||||||
|
error[E0658]: custom inner attributes are unstable
|
||||||
|
--> $DIR/module_with_attrs.rs:3:4
|
||||||
|
|
|
||||||
|
LL | #![rustfmt::skip]
|
||||||
|
| ^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #54726 <https://github.com/rust-lang/rust/issues/54726> for more information
|
||||||
|
= help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable
|
||||||
|
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||||
|
|
||||||
error[E0658]: inner macro attributes are unstable
|
error[E0658]: inner macro attributes are unstable
|
||||||
--> $DIR/module_with_attrs.rs:4:4
|
--> $DIR/module_with_attrs.rs:4:4
|
||||||
|
|
|
|
||||||
|
@ -9,7 +19,7 @@ LL | #![print_attr]
|
||||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||||
|
|
||||||
error[E0658]: non-inline modules in proc macro input are unstable
|
error[E0658]: non-inline modules in proc macro input are unstable
|
||||||
--> $DIR/inner-attr-non-inline-mod.rs:14:1
|
--> $DIR/inner-attr-non-inline-mod.rs:13:1
|
||||||
|
|
|
|
||||||
LL | mod module_with_attrs;
|
LL | mod module_with_attrs;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -19,7 +29,7 @@ LL | mod module_with_attrs;
|
||||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||||
|
|
||||||
error[E0658]: custom inner attributes are unstable
|
error[E0658]: custom inner attributes are unstable
|
||||||
--> $DIR/inner-attr-non-inline-mod.rs:14:1
|
--> $DIR/inner-attr-non-inline-mod.rs:13:1
|
||||||
|
|
|
|
||||||
LL | mod module_with_attrs;
|
LL | mod module_with_attrs;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -28,27 +38,6 @@ LL | mod module_with_attrs;
|
||||||
= help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable
|
= help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable
|
||||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||||
|
|
||||||
error: custom inner attributes are unstable
|
|
||||||
--> $DIR/module_with_attrs.rs:3:4
|
|
||||||
|
|
|
||||||
LL | #![rustfmt::skip]
|
|
||||||
| ^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
|
||||||
= note: for more information, see issue #64266 <https://github.com/rust-lang/rust/issues/64266>
|
|
||||||
= note: `#[deny(soft_unstable)]` on by default
|
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0658`.
|
For more information about this error, try `rustc --explain E0658`.
|
||||||
Future incompatibility report: Future breakage diagnostic:
|
|
||||||
error: custom inner attributes are unstable
|
|
||||||
--> $DIR/module_with_attrs.rs:3:4
|
|
||||||
|
|
|
||||||
LL | #![rustfmt::skip]
|
|
||||||
| ^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
|
||||||
= note: for more information, see issue #64266 <https://github.com/rust-lang/rust/issues/64266>
|
|
||||||
= note: `#[deny(soft_unstable)]` on by default
|
|
||||||
|
|
||||||
|
|
|
@ -4,35 +4,35 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
|
||||||
Punct {
|
Punct {
|
||||||
ch: '#',
|
ch: '#',
|
||||||
spacing: Alone,
|
spacing: Alone,
|
||||||
span: $DIR/inner-attr-non-inline-mod.rs:14:1: 14:23 (#0),
|
span: $DIR/inner-attr-non-inline-mod.rs:13:1: 13:23 (#0),
|
||||||
},
|
},
|
||||||
Group {
|
Group {
|
||||||
delimiter: Bracket,
|
delimiter: Bracket,
|
||||||
stream: TokenStream [
|
stream: TokenStream [
|
||||||
Ident {
|
Ident {
|
||||||
ident: "deny",
|
ident: "deny",
|
||||||
span: $DIR/inner-attr-non-inline-mod.rs:14:1: 14:23 (#0),
|
span: $DIR/inner-attr-non-inline-mod.rs:13:1: 13:23 (#0),
|
||||||
},
|
},
|
||||||
Group {
|
Group {
|
||||||
delimiter: Parenthesis,
|
delimiter: Parenthesis,
|
||||||
stream: TokenStream [
|
stream: TokenStream [
|
||||||
Ident {
|
Ident {
|
||||||
ident: "unused_attributes",
|
ident: "unused_attributes",
|
||||||
span: $DIR/inner-attr-non-inline-mod.rs:14:1: 14:23 (#0),
|
span: $DIR/inner-attr-non-inline-mod.rs:13:1: 13:23 (#0),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
span: $DIR/inner-attr-non-inline-mod.rs:14:1: 14:23 (#0),
|
span: $DIR/inner-attr-non-inline-mod.rs:13:1: 13:23 (#0),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
span: $DIR/inner-attr-non-inline-mod.rs:14:1: 14:23 (#0),
|
span: $DIR/inner-attr-non-inline-mod.rs:13:1: 13:23 (#0),
|
||||||
},
|
},
|
||||||
Ident {
|
Ident {
|
||||||
ident: "mod",
|
ident: "mod",
|
||||||
span: $DIR/inner-attr-non-inline-mod.rs:14:1: 14:23 (#0),
|
span: $DIR/inner-attr-non-inline-mod.rs:13:1: 13:23 (#0),
|
||||||
},
|
},
|
||||||
Ident {
|
Ident {
|
||||||
ident: "module_with_attrs",
|
ident: "module_with_attrs",
|
||||||
span: $DIR/inner-attr-non-inline-mod.rs:14:1: 14:23 (#0),
|
span: $DIR/inner-attr-non-inline-mod.rs:13:1: 13:23 (#0),
|
||||||
},
|
},
|
||||||
Group {
|
Group {
|
||||||
delimiter: Brace,
|
delimiter: Brace,
|
||||||
|
@ -40,38 +40,38 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
|
||||||
Punct {
|
Punct {
|
||||||
ch: '#',
|
ch: '#',
|
||||||
spacing: Joint,
|
spacing: Joint,
|
||||||
span: $DIR/inner-attr-non-inline-mod.rs:14:1: 14:23 (#0),
|
span: $DIR/inner-attr-non-inline-mod.rs:13:1: 13:23 (#0),
|
||||||
},
|
},
|
||||||
Punct {
|
Punct {
|
||||||
ch: '!',
|
ch: '!',
|
||||||
spacing: Alone,
|
spacing: Alone,
|
||||||
span: $DIR/inner-attr-non-inline-mod.rs:14:1: 14:23 (#0),
|
span: $DIR/inner-attr-non-inline-mod.rs:13:1: 13:23 (#0),
|
||||||
},
|
},
|
||||||
Group {
|
Group {
|
||||||
delimiter: Bracket,
|
delimiter: Bracket,
|
||||||
stream: TokenStream [
|
stream: TokenStream [
|
||||||
Ident {
|
Ident {
|
||||||
ident: "rustfmt",
|
ident: "rustfmt",
|
||||||
span: $DIR/inner-attr-non-inline-mod.rs:14:1: 14:23 (#0),
|
span: $DIR/inner-attr-non-inline-mod.rs:13:1: 13:23 (#0),
|
||||||
},
|
},
|
||||||
Punct {
|
Punct {
|
||||||
ch: ':',
|
ch: ':',
|
||||||
spacing: Joint,
|
spacing: Joint,
|
||||||
span: $DIR/inner-attr-non-inline-mod.rs:14:1: 14:23 (#0),
|
span: $DIR/inner-attr-non-inline-mod.rs:13:1: 13:23 (#0),
|
||||||
},
|
},
|
||||||
Punct {
|
Punct {
|
||||||
ch: ':',
|
ch: ':',
|
||||||
spacing: Alone,
|
spacing: Alone,
|
||||||
span: $DIR/inner-attr-non-inline-mod.rs:14:1: 14:23 (#0),
|
span: $DIR/inner-attr-non-inline-mod.rs:13:1: 13:23 (#0),
|
||||||
},
|
},
|
||||||
Ident {
|
Ident {
|
||||||
ident: "skip",
|
ident: "skip",
|
||||||
span: $DIR/inner-attr-non-inline-mod.rs:14:1: 14:23 (#0),
|
span: $DIR/inner-attr-non-inline-mod.rs:13:1: 13:23 (#0),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
span: $DIR/inner-attr-non-inline-mod.rs:14:1: 14:23 (#0),
|
span: $DIR/inner-attr-non-inline-mod.rs:13:1: 13:23 (#0),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
span: $DIR/inner-attr-non-inline-mod.rs:14:1: 14:23 (#0),
|
span: $DIR/inner-attr-non-inline-mod.rs:13:1: 13:23 (#0),
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
|
@ -47,7 +47,6 @@ fn attrs() {
|
||||||
|
|
||||||
fn test_case() {
|
fn test_case() {
|
||||||
#![test] //~ ERROR inner macro attributes are unstable
|
#![test] //~ ERROR inner macro attributes are unstable
|
||||||
//~| WARN this was previously accepted
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -84,27 +84,16 @@ LL | let _x = #[identity_attr] println!();
|
||||||
= help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable
|
= help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable
|
||||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||||
|
|
||||||
error: inner macro attributes are unstable
|
error[E0658]: inner macro attributes are unstable
|
||||||
--> $DIR/proc-macro-gates.rs:49:8
|
--> $DIR/proc-macro-gates.rs:49:8
|
||||||
|
|
|
|
||||||
LL | #![test]
|
LL | #![test]
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
|
|
|
||||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
= note: see issue #54726 <https://github.com/rust-lang/rust/issues/54726> for more information
|
||||||
= note: for more information, see issue #64266 <https://github.com/rust-lang/rust/issues/64266>
|
= help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable
|
||||||
= note: `#[deny(soft_unstable)]` on by default
|
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||||
|
|
||||||
error: aborting due to 10 previous errors
|
error: aborting due to 10 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0658`.
|
For more information about this error, try `rustc --explain E0658`.
|
||||||
Future incompatibility report: Future breakage diagnostic:
|
|
||||||
error: inner macro attributes are unstable
|
|
||||||
--> $DIR/proc-macro-gates.rs:49:8
|
|
||||||
|
|
|
||||||
LL | #![test]
|
|
||||||
| ^^^^
|
|
||||||
|
|
|
||||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
|
||||||
= note: for more information, see issue #64266 <https://github.com/rust-lang/rust/issues/64266>
|
|
||||||
= note: `#[deny(soft_unstable)]` on by default
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue