From 87be1bae73586eaf917790f10ac2240186cb7b2b Mon Sep 17 00:00:00 2001 From: carbotaniuman <41451839+carbotaniuman@users.noreply.github.com> Date: Tue, 21 May 2024 08:37:05 -0500 Subject: [PATCH] Fix build --- compiler/rustc_ast/src/ast.rs | 6 +++--- compiler/rustc_ast/src/attr/mod.rs | 14 +++++++------- compiler/rustc_ast_lowering/src/expr.rs | 2 +- compiler/rustc_ast_pretty/src/pprust/state.rs | 6 +++--- compiler/rustc_builtin_macros/src/derive.rs | 6 +++--- compiler/rustc_builtin_macros/src/test_harness.rs | 2 +- compiler/rustc_expand/src/build.rs | 6 +++--- compiler/rustc_expand/src/expand.rs | 2 +- compiler/rustc_parse/src/parser/attr.rs | 8 ++++---- compiler/rustc_passes/src/check_attr.rs | 2 +- src/librustdoc/clean/cfg/tests.rs | 10 +++++----- 11 files changed, 32 insertions(+), 32 deletions(-) diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 8cb49a1b760..957c4d7c698 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -488,7 +488,7 @@ pub struct Crate { /// E.g., `#[test]`, `#[derive(..)]`, `#[rustfmt::skip]` or `#[feature = "foo"]`. #[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic)] pub struct MetaItem { - pub unsafety: Unsafe, + pub unsafety: Safety, pub path: Path, pub kind: MetaItemKind, pub span: Span, @@ -2825,7 +2825,7 @@ impl NormalAttr { pub fn from_ident(ident: Ident) -> Self { Self { item: AttrItem { - unsafety: Unsafe::No, + unsafety: Safety::Default, path: Path::from_ident(ident), args: AttrArgs::Empty, tokens: None, @@ -2837,7 +2837,7 @@ impl NormalAttr { #[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic)] pub struct AttrItem { - pub unsafety: Unsafe, + pub unsafety: Safety, pub path: Path, pub args: AttrArgs, // Tokens for the meta item, e.g. just the `foo` within `#[foo]` or `#![foo]`. diff --git a/compiler/rustc_ast/src/attr/mod.rs b/compiler/rustc_ast/src/attr/mod.rs index 62b7a276219..ed1b4733820 100644 --- a/compiler/rustc_ast/src/attr/mod.rs +++ b/compiler/rustc_ast/src/attr/mod.rs @@ -1,7 +1,7 @@ //! Functions dealing with attributes and meta items. use crate::ast::{ - AttrArgs, AttrArgsEq, AttrId, AttrItem, AttrKind, AttrStyle, AttrVec, Attribute, Unsafe, + AttrArgs, AttrArgsEq, AttrId, AttrItem, AttrKind, AttrStyle, AttrVec, Attribute, Safety, }; use crate::ast::{DelimArgs, Expr, ExprKind, LitKind, MetaItemLit}; use crate::ast::{MetaItem, MetaItemKind, NestedMetaItem, NormalAttr}; @@ -241,7 +241,7 @@ impl AttrItem { pub fn meta(&self, span: Span) -> Option { Some(MetaItem { - unsafety: Unsafe::No, + unsafety: Safety::Default, path: self.path.clone(), kind: self.meta_kind()?, span, @@ -379,7 +379,7 @@ impl MetaItem { }; let span = path.span.with_hi(hi); // FIX THIS LATER - Some(MetaItem { unsafety: Unsafe::No, path, kind, span }) + Some(MetaItem { unsafety: Safety::Default, path, kind, span }) } } @@ -563,7 +563,7 @@ pub fn mk_doc_comment( pub fn mk_attr( g: &AttrIdGenerator, style: AttrStyle, - unsafety: Unsafe, + unsafety: Safety, path: Path, args: AttrArgs, span: Span, @@ -589,7 +589,7 @@ pub fn mk_attr_from_item( pub fn mk_attr_word( g: &AttrIdGenerator, style: AttrStyle, - unsafety: Unsafe, + unsafety: Safety, name: Symbol, span: Span, ) -> Attribute { @@ -601,7 +601,7 @@ pub fn mk_attr_word( pub fn mk_attr_nested_word( g: &AttrIdGenerator, style: AttrStyle, - unsafety: Unsafe, + unsafety: Safety, outer: Symbol, inner: Symbol, span: Span, @@ -623,7 +623,7 @@ pub fn mk_attr_nested_word( pub fn mk_attr_name_value_str( g: &AttrIdGenerator, style: AttrStyle, - unsafety: Unsafe, + unsafety: Safety, name: Symbol, val: Symbol, span: Span, diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index 5fbae6a34e5..554f9f09858 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -1801,7 +1801,7 @@ impl<'hir> LoweringContext<'_, 'hir> { let attr = attr::mk_attr_nested_word( &self.tcx.sess.psess.attr_id_generator, AttrStyle::Outer, - Unsafe::No, + Safety::Default, sym::allow, sym::unreachable_code, self.lower_span(span), diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs index e3ccbbe391e..54d642f6a0f 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state.rs @@ -16,7 +16,7 @@ use rustc_ast::token::{self, BinOpToken, CommentKind, Delimiter, Nonterminal, To use rustc_ast::tokenstream::{Spacing, TokenStream, TokenTree}; use rustc_ast::util::classify; use rustc_ast::util::comments::{Comment, CommentStyle}; -use rustc_ast::{self as ast, AttrArgs, AttrArgsEq, BlockCheckMode, PatKind, Unsafe}; +use rustc_ast::{self as ast, AttrArgs, AttrArgsEq, BlockCheckMode, PatKind, Safety}; use rustc_ast::{attr, BindingMode, ByRef, DelimArgs, RangeEnd, RangeSyntax, Term}; use rustc_ast::{GenericArg, GenericBound, SelfKind}; use rustc_ast::{InlineAsmOperand, InlineAsmRegOrRegClass}; @@ -249,7 +249,7 @@ pub fn print_crate<'a>( let fake_attr = attr::mk_attr_nested_word( g, ast::AttrStyle::Inner, - Unsafe::No, + Safety::Default, sym::feature, sym::prelude_import, DUMMY_SP, @@ -261,7 +261,7 @@ pub fn print_crate<'a>( if edition.is_rust_2015() { // `#![no_std]` let fake_attr = - attr::mk_attr_word(g, ast::AttrStyle::Inner, Unsafe::No, sym::no_std, DUMMY_SP); + attr::mk_attr_word(g, ast::AttrStyle::Inner, Safety::Default, sym::no_std, DUMMY_SP); s.print_attribute(&fake_attr); } } diff --git a/compiler/rustc_builtin_macros/src/derive.rs b/compiler/rustc_builtin_macros/src/derive.rs index d70eaa617ca..dea668ff8f4 100644 --- a/compiler/rustc_builtin_macros/src/derive.rs +++ b/compiler/rustc_builtin_macros/src/derive.rs @@ -2,7 +2,7 @@ use crate::cfg_eval::cfg_eval; use crate::errors; use rustc_ast as ast; -use rustc_ast::{GenericParamKind, ItemKind, MetaItemKind, NestedMetaItem, StmtKind, Unsafe}; +use rustc_ast::{GenericParamKind, ItemKind, MetaItemKind, NestedMetaItem, StmtKind, Safety}; use rustc_expand::base::{ Annotatable, DeriveResolution, ExpandResult, ExtCtxt, Indeterminate, MultiItemModifier, }; @@ -163,9 +163,9 @@ fn report_path_args(sess: &Session, meta: &ast::MetaItem) { fn report_unsafe_args(sess: &Session, meta: &ast::MetaItem) { match meta.unsafety { - Unsafe::Yes(span) => { + Safety::Unsafe(span) => { sess.dcx().emit_err(errors::DeriveUnsafePath { span }); } - Unsafe::No => {} + Safety::Default => {} } } diff --git a/compiler/rustc_builtin_macros/src/test_harness.rs b/compiler/rustc_builtin_macros/src/test_harness.rs index fec54cfe38f..ba4e5cfd130 100644 --- a/compiler/rustc_builtin_macros/src/test_harness.rs +++ b/compiler/rustc_builtin_macros/src/test_harness.rs @@ -203,7 +203,7 @@ impl<'a> MutVisitor for EntryPointCleaner<'a> { let allow_dead_code = attr::mk_attr_nested_word( &self.sess.psess.attr_id_generator, ast::AttrStyle::Outer, - ast::Unsafe::No, + ast::Safety::Default, sym::allow, sym::dead_code, self.def_site, diff --git a/compiler/rustc_expand/src/build.rs b/compiler/rustc_expand/src/build.rs index 9451102c010..e513e61f4d1 100644 --- a/compiler/rustc_expand/src/build.rs +++ b/compiler/rustc_expand/src/build.rs @@ -666,7 +666,7 @@ impl<'a> ExtCtxt<'a> { // Builds `#[name]`. pub fn attr_word(&self, name: Symbol, span: Span) -> ast::Attribute { let g = &self.sess.psess.attr_id_generator; - attr::mk_attr_word(g, ast::AttrStyle::Outer, ast::Unsafe::No, name, span) + attr::mk_attr_word(g, ast::AttrStyle::Outer, ast::Safety::Default, name, span) } // Builds `#[name = val]`. @@ -674,12 +674,12 @@ impl<'a> ExtCtxt<'a> { // Note: `span` is used for both the identifier and the value. pub fn attr_name_value_str(&self, name: Symbol, val: Symbol, span: Span) -> ast::Attribute { let g = &self.sess.psess.attr_id_generator; - attr::mk_attr_name_value_str(g, ast::AttrStyle::Outer, ast::Unsafe::No, name, val, span) + attr::mk_attr_name_value_str(g, ast::AttrStyle::Outer, ast::Safety::Default, name, val, span) } // Builds `#[outer(inner)]`. pub fn attr_nested_word(&self, outer: Symbol, inner: Symbol, span: Span) -> ast::Attribute { let g = &self.sess.psess.attr_id_generator; - attr::mk_attr_nested_word(g, ast::AttrStyle::Outer, ast::Unsafe::No, outer, inner, span) + attr::mk_attr_nested_word(g, ast::AttrStyle::Outer, ast::Safety::Default, outer, inner, span) } } diff --git a/compiler/rustc_expand/src/expand.rs b/compiler/rustc_expand/src/expand.rs index dfef2540d29..c28a09eb57c 100644 --- a/compiler/rustc_expand/src/expand.rs +++ b/compiler/rustc_expand/src/expand.rs @@ -781,7 +781,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { // The `MetaItem` representing the trait to derive can't // have an unsafe around it (as of now). let meta = ast::MetaItem { - unsafety: ast::Unsafe::No, + unsafety: ast::Safety::Default, kind: MetaItemKind::Word, span, path, diff --git a/compiler/rustc_parse/src/parser/attr.rs b/compiler/rustc_parse/src/parser/attr.rs index 2dd19f6c20a..58fef9b6c45 100644 --- a/compiler/rustc_parse/src/parser/attr.rs +++ b/compiler/rustc_parse/src/parser/attr.rs @@ -258,9 +258,9 @@ impl<'a> Parser<'a> { this.psess.gated_spans.gate(sym::unsafe_attributes, unsafe_span); this.expect(&token::OpenDelim(Delimiter::Parenthesis))?; - ast::Unsafe::Yes(unsafe_span) + ast::Safety::Unsafe(unsafe_span) } else { - ast::Unsafe::No + ast::Safety::Default }; let path = this.parse_path(PathStyle::Mod)?; @@ -395,9 +395,9 @@ impl<'a> Parser<'a> { self.psess.gated_spans.gate(sym::unsafe_attributes, unsafe_span); self.expect(&token::OpenDelim(Delimiter::Parenthesis))?; - ast::Unsafe::Yes(unsafe_span) + ast::Safety::Unsafe(unsafe_span) } else { - ast::Unsafe::No + ast::Safety::Default }; let path = self.parse_path(PathStyle::Mod)?; diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index d826eacbd15..29bc165159d 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -317,7 +317,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { fn check_unsafe_attr(&self, attr: &Attribute) { if !attr.is_doc_comment() { let attr_item = attr.get_normal_item(); - if let ast::Unsafe::Yes(unsafe_span) = attr_item.unsafety { + if let ast::Safety::Unsafe(unsafe_span) = attr_item.unsafety { if !is_unsafe_attr(attr.name_or_empty()) { self.dcx().emit_err(errors::InvalidAttrUnsafe { span: unsafe_span, diff --git a/src/librustdoc/clean/cfg/tests.rs b/src/librustdoc/clean/cfg/tests.rs index 2579c15fc5f..56a10f9fb9c 100644 --- a/src/librustdoc/clean/cfg/tests.rs +++ b/src/librustdoc/clean/cfg/tests.rs @@ -1,6 +1,6 @@ use super::*; -use rustc_ast::{MetaItemLit, Path, StrStyle, Unsafe}; +use rustc_ast::{MetaItemLit, Path, StrStyle, Safety}; use rustc_span::create_default_session_globals_then; use rustc_span::symbol::{kw, Ident}; use rustc_span::DUMMY_SP; @@ -16,7 +16,7 @@ fn name_value_cfg(name: &str, value: &str) -> Cfg { fn dummy_meta_item_word(name: &str) -> MetaItem { MetaItem { - unsafety: Unsafe::No, + unsafety: Safety::Default, path: Path::from_ident(Ident::from_str(name)), kind: MetaItemKind::Word, span: DUMMY_SP, @@ -26,7 +26,7 @@ fn dummy_meta_item_word(name: &str) -> MetaItem { fn dummy_meta_item_name_value(name: &str, symbol: Symbol, kind: LitKind) -> MetaItem { let lit = MetaItemLit { symbol, suffix: None, kind, span: DUMMY_SP }; MetaItem { - unsafety: Unsafe::No, + unsafety: Safety::Default, path: Path::from_ident(Ident::from_str(name)), kind: MetaItemKind::NameValue(lit), span: DUMMY_SP, @@ -36,7 +36,7 @@ fn dummy_meta_item_name_value(name: &str, symbol: Symbol, kind: LitKind) -> Meta macro_rules! dummy_meta_item_list { ($name:ident, [$($list:ident),* $(,)?]) => { MetaItem { - unsafety: Unsafe::No, + unsafety: Safety::Default, path: Path::from_ident(Ident::from_str(stringify!($name))), kind: MetaItemKind::List(thin_vec![ $( @@ -51,7 +51,7 @@ macro_rules! dummy_meta_item_list { ($name:ident, [$($list:expr),* $(,)?]) => { MetaItem { - unsafety: Unsafe::No, + unsafety: Safety::Default, path: Path::from_ident(Ident::from_str(stringify!($name))), kind: MetaItemKind::List(thin_vec![ $(