Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit de9b5c3

Browse files
committed
Stabilize unsafe_attributes
1 parent 2f3dc46 commit de9b5c3

37 files changed

+64
-134
lines changed

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ fn validate_generic_param_order(dcx: DiagCtxtHandle<'_>, generics: &[GenericPara
887887

888888
impl<'a> Visitor<'a> for AstValidator<'a> {
889889
fn visit_attribute(&mut self, attr: &Attribute) {
890-
validate_attr::check_attr(&self.features, &self.session.psess, attr);
890+
validate_attr::check_attr(&self.session.psess, attr);
891891
}
892892

893893
fn visit_ty(&mut self, ty: &'a Ty) {

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
559559
gate_all!(mut_ref, "mutable by-reference bindings are experimental");
560560
gate_all!(precise_capturing, "precise captures on `impl Trait` are experimental");
561561
gate_all!(global_registration, "global registration is experimental");
562-
gate_all!(unsafe_attributes, "`#[unsafe()]` markers for attributes are experimental");
563562
gate_all!(return_type_notation, "return type notation is experimental");
564563

565564
if !visitor.features.never_patterns {

compiler/rustc_builtin_macros/src/cfg_accessible.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ impl MultiItemModifier for Expander {
4747
) -> ExpandResult<Vec<Annotatable>, Annotatable> {
4848
let template = AttributeTemplate { list: Some("path"), ..Default::default() };
4949
validate_attr::check_builtin_meta_item(
50-
&ecx.ecfg.features,
5150
&ecx.sess.psess,
5251
meta_item,
5352
ast::AttrStyle::Outer,

compiler/rustc_builtin_macros/src/derive.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ impl MultiItemModifier for Expander {
3838
let template =
3939
AttributeTemplate { list: Some("Trait1, Trait2, ..."), ..Default::default() };
4040
validate_attr::check_builtin_meta_item(
41-
features,
4241
&sess.psess,
4342
meta_item,
4443
ast::AttrStyle::Outer,

compiler/rustc_builtin_macros/src/util.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ pub(crate) fn check_builtin_macro_attribute(ecx: &ExtCtxt<'_>, meta_item: &MetaI
1717
// All the built-in macro attributes are "words" at the moment.
1818
let template = AttributeTemplate { word: true, ..Default::default() };
1919
validate_attr::check_builtin_meta_item(
20-
&ecx.ecfg.features,
2120
&ecx.sess.psess,
2221
meta_item,
2322
AttrStyle::Outer,

compiler/rustc_expand/src/config.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,7 @@ impl<'a> StripUnconfigured<'a> {
265265
/// is in the original source file. Gives a compiler error if the syntax of
266266
/// the attribute is incorrect.
267267
pub(crate) fn expand_cfg_attr(&self, cfg_attr: &Attribute, recursive: bool) -> Vec<Attribute> {
268-
validate_attr::check_attribute_safety(
269-
self.features.unwrap_or(&Features::default()),
270-
&self.sess.psess,
271-
AttributeSafety::Normal,
272-
&cfg_attr,
273-
);
268+
validate_attr::check_attribute_safety(&self.sess.psess, AttributeSafety::Normal, &cfg_attr);
274269

275270
let Some((cfg_predicate, expanded_attrs)) =
276271
rustc_parse::parse_cfg_attr(cfg_attr, &self.sess.psess)
@@ -395,11 +390,7 @@ impl<'a> StripUnconfigured<'a> {
395390
}
396391
};
397392

398-
validate_attr::deny_builtin_meta_unsafety(
399-
self.features.unwrap_or(&Features::default()),
400-
&self.sess.psess,
401-
&meta_item,
402-
);
393+
validate_attr::deny_builtin_meta_unsafety(&self.sess.psess, &meta_item);
403394

404395
(
405396
parse_cfg(&meta_item, self.sess).map_or(true, |meta_item| {

compiler/rustc_expand/src/expand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1883,7 +1883,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
18831883
let mut span: Option<Span> = None;
18841884
while let Some(attr) = attrs.next() {
18851885
rustc_ast_passes::feature_gate::check_attribute(attr, self.cx.sess, features);
1886-
validate_attr::check_attr(features, &self.cx.sess.psess, attr);
1886+
validate_attr::check_attr(&self.cx.sess.psess, attr);
18871887

18881888
let current_span = if let Some(sp) = span { sp.to(attr.span) } else { attr.span };
18891889
span = Some(current_span);

compiler/rustc_feature/src/accepted.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,8 @@ declare_features! (
388388
(accepted, universal_impl_trait, "1.26.0", Some(34511)),
389389
/// Allows arbitrary delimited token streams in non-macro attributes.
390390
(accepted, unrestricted_attribute_tokens, "1.34.0", Some(55208)),
391+
/// Allows unsafe attributes.
392+
(accepted, unsafe_attributes, "CURRENT_RUSTC_VERSION", Some(123757)),
391393
/// The `unsafe_op_in_unsafe_fn` lint (allowed by default): no longer treat an unsafe function as an unsafe block.
392394
(accepted, unsafe_block_in_unsafe_fn, "1.52.0", Some(71668)),
393395
/// Allows unsafe on extern declarations and safety qualifiers over internal items.

compiler/rustc_feature/src/unstable.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,8 +627,6 @@ declare_features! (
627627
(unstable, type_changing_struct_update, "1.58.0", Some(86555)),
628628
/// Allows unnamed fields of struct and union type
629629
(incomplete, unnamed_fields, "1.74.0", Some(49804)),
630-
/// Allows unsafe attributes.
631-
(unstable, unsafe_attributes, "1.80.0", Some(123757)),
632630
/// Allows const generic parameters to be defined with types that
633631
/// are not `Sized`, e.g. `fn foo<const N: [u8]>() {`.
634632
(incomplete, unsized_const_params, "CURRENT_RUSTC_VERSION", Some(95174)),

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4937,7 +4937,6 @@ declare_lint! {
49374937
/// ### Example
49384938
///
49394939
/// ```rust
4940-
/// #![feature(unsafe_attributes)]
49414940
/// #![warn(unsafe_attr_outside_unsafe)]
49424941
///
49434942
/// #[no_mangle]

0 commit comments

Comments
 (0)