1
Fork 0

Fix build

This commit is contained in:
carbotaniuman 2024-05-21 08:37:05 -05:00
parent b82c524996
commit 87be1bae73
11 changed files with 32 additions and 32 deletions

View file

@ -488,7 +488,7 @@ pub struct Crate {
/// E.g., `#[test]`, `#[derive(..)]`, `#[rustfmt::skip]` or `#[feature = "foo"]`. /// E.g., `#[test]`, `#[derive(..)]`, `#[rustfmt::skip]` or `#[feature = "foo"]`.
#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic)] #[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic)]
pub struct MetaItem { pub struct MetaItem {
pub unsafety: Unsafe, pub unsafety: Safety,
pub path: Path, pub path: Path,
pub kind: MetaItemKind, pub kind: MetaItemKind,
pub span: Span, pub span: Span,
@ -2825,7 +2825,7 @@ impl NormalAttr {
pub fn from_ident(ident: Ident) -> Self { pub fn from_ident(ident: Ident) -> Self {
Self { Self {
item: AttrItem { item: AttrItem {
unsafety: Unsafe::No, unsafety: Safety::Default,
path: Path::from_ident(ident), path: Path::from_ident(ident),
args: AttrArgs::Empty, args: AttrArgs::Empty,
tokens: None, tokens: None,
@ -2837,7 +2837,7 @@ impl NormalAttr {
#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic)] #[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic)]
pub struct AttrItem { pub struct AttrItem {
pub unsafety: Unsafe, pub unsafety: Safety,
pub path: Path, pub path: Path,
pub args: AttrArgs, pub args: AttrArgs,
// Tokens for the meta item, e.g. just the `foo` within `#[foo]` or `#![foo]`. // Tokens for the meta item, e.g. just the `foo` within `#[foo]` or `#![foo]`.

View file

@ -1,7 +1,7 @@
//! Functions dealing with attributes and meta items. //! Functions dealing with attributes and meta items.
use crate::ast::{ 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::{DelimArgs, Expr, ExprKind, LitKind, MetaItemLit};
use crate::ast::{MetaItem, MetaItemKind, NestedMetaItem, NormalAttr}; use crate::ast::{MetaItem, MetaItemKind, NestedMetaItem, NormalAttr};
@ -241,7 +241,7 @@ impl AttrItem {
pub fn meta(&self, span: Span) -> Option<MetaItem> { pub fn meta(&self, span: Span) -> Option<MetaItem> {
Some(MetaItem { Some(MetaItem {
unsafety: Unsafe::No, unsafety: Safety::Default,
path: self.path.clone(), path: self.path.clone(),
kind: self.meta_kind()?, kind: self.meta_kind()?,
span, span,
@ -379,7 +379,7 @@ impl MetaItem {
}; };
let span = path.span.with_hi(hi); let span = path.span.with_hi(hi);
// FIX THIS LATER // 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( pub fn mk_attr(
g: &AttrIdGenerator, g: &AttrIdGenerator,
style: AttrStyle, style: AttrStyle,
unsafety: Unsafe, unsafety: Safety,
path: Path, path: Path,
args: AttrArgs, args: AttrArgs,
span: Span, span: Span,
@ -589,7 +589,7 @@ pub fn mk_attr_from_item(
pub fn mk_attr_word( pub fn mk_attr_word(
g: &AttrIdGenerator, g: &AttrIdGenerator,
style: AttrStyle, style: AttrStyle,
unsafety: Unsafe, unsafety: Safety,
name: Symbol, name: Symbol,
span: Span, span: Span,
) -> Attribute { ) -> Attribute {
@ -601,7 +601,7 @@ pub fn mk_attr_word(
pub fn mk_attr_nested_word( pub fn mk_attr_nested_word(
g: &AttrIdGenerator, g: &AttrIdGenerator,
style: AttrStyle, style: AttrStyle,
unsafety: Unsafe, unsafety: Safety,
outer: Symbol, outer: Symbol,
inner: Symbol, inner: Symbol,
span: Span, span: Span,
@ -623,7 +623,7 @@ pub fn mk_attr_nested_word(
pub fn mk_attr_name_value_str( pub fn mk_attr_name_value_str(
g: &AttrIdGenerator, g: &AttrIdGenerator,
style: AttrStyle, style: AttrStyle,
unsafety: Unsafe, unsafety: Safety,
name: Symbol, name: Symbol,
val: Symbol, val: Symbol,
span: Span, span: Span,

View file

@ -1801,7 +1801,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
let attr = attr::mk_attr_nested_word( let attr = attr::mk_attr_nested_word(
&self.tcx.sess.psess.attr_id_generator, &self.tcx.sess.psess.attr_id_generator,
AttrStyle::Outer, AttrStyle::Outer,
Unsafe::No, Safety::Default,
sym::allow, sym::allow,
sym::unreachable_code, sym::unreachable_code,
self.lower_span(span), self.lower_span(span),

View file

@ -16,7 +16,7 @@ use rustc_ast::token::{self, BinOpToken, CommentKind, Delimiter, Nonterminal, To
use rustc_ast::tokenstream::{Spacing, TokenStream, TokenTree}; use rustc_ast::tokenstream::{Spacing, TokenStream, TokenTree};
use rustc_ast::util::classify; use rustc_ast::util::classify;
use rustc_ast::util::comments::{Comment, CommentStyle}; 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::{attr, BindingMode, ByRef, DelimArgs, RangeEnd, RangeSyntax, Term};
use rustc_ast::{GenericArg, GenericBound, SelfKind}; use rustc_ast::{GenericArg, GenericBound, SelfKind};
use rustc_ast::{InlineAsmOperand, InlineAsmRegOrRegClass}; use rustc_ast::{InlineAsmOperand, InlineAsmRegOrRegClass};
@ -249,7 +249,7 @@ pub fn print_crate<'a>(
let fake_attr = attr::mk_attr_nested_word( let fake_attr = attr::mk_attr_nested_word(
g, g,
ast::AttrStyle::Inner, ast::AttrStyle::Inner,
Unsafe::No, Safety::Default,
sym::feature, sym::feature,
sym::prelude_import, sym::prelude_import,
DUMMY_SP, DUMMY_SP,
@ -261,7 +261,7 @@ pub fn print_crate<'a>(
if edition.is_rust_2015() { if edition.is_rust_2015() {
// `#![no_std]` // `#![no_std]`
let fake_attr = 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); s.print_attribute(&fake_attr);
} }
} }

View file

@ -2,7 +2,7 @@ use crate::cfg_eval::cfg_eval;
use crate::errors; use crate::errors;
use rustc_ast as ast; 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::{ use rustc_expand::base::{
Annotatable, DeriveResolution, ExpandResult, ExtCtxt, Indeterminate, MultiItemModifier, 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) { fn report_unsafe_args(sess: &Session, meta: &ast::MetaItem) {
match meta.unsafety { match meta.unsafety {
Unsafe::Yes(span) => { Safety::Unsafe(span) => {
sess.dcx().emit_err(errors::DeriveUnsafePath { span }); sess.dcx().emit_err(errors::DeriveUnsafePath { span });
} }
Unsafe::No => {} Safety::Default => {}
} }
} }

View file

@ -203,7 +203,7 @@ impl<'a> MutVisitor for EntryPointCleaner<'a> {
let allow_dead_code = attr::mk_attr_nested_word( let allow_dead_code = attr::mk_attr_nested_word(
&self.sess.psess.attr_id_generator, &self.sess.psess.attr_id_generator,
ast::AttrStyle::Outer, ast::AttrStyle::Outer,
ast::Unsafe::No, ast::Safety::Default,
sym::allow, sym::allow,
sym::dead_code, sym::dead_code,
self.def_site, self.def_site,

View file

@ -666,7 +666,7 @@ impl<'a> ExtCtxt<'a> {
// Builds `#[name]`. // Builds `#[name]`.
pub fn attr_word(&self, name: Symbol, span: Span) -> ast::Attribute { pub fn attr_word(&self, name: Symbol, span: Span) -> ast::Attribute {
let g = &self.sess.psess.attr_id_generator; 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]`. // Builds `#[name = val]`.
@ -674,12 +674,12 @@ impl<'a> ExtCtxt<'a> {
// Note: `span` is used for both the identifier and the value. // 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 { pub fn attr_name_value_str(&self, name: Symbol, val: Symbol, span: Span) -> ast::Attribute {
let g = &self.sess.psess.attr_id_generator; 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)]`. // Builds `#[outer(inner)]`.
pub fn attr_nested_word(&self, outer: Symbol, inner: Symbol, span: Span) -> ast::Attribute { pub fn attr_nested_word(&self, outer: Symbol, inner: Symbol, span: Span) -> ast::Attribute {
let g = &self.sess.psess.attr_id_generator; 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)
} }
} }

View file

@ -781,7 +781,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
// The `MetaItem` representing the trait to derive can't // The `MetaItem` representing the trait to derive can't
// have an unsafe around it (as of now). // have an unsafe around it (as of now).
let meta = ast::MetaItem { let meta = ast::MetaItem {
unsafety: ast::Unsafe::No, unsafety: ast::Safety::Default,
kind: MetaItemKind::Word, kind: MetaItemKind::Word,
span, span,
path, path,

View file

@ -258,9 +258,9 @@ impl<'a> Parser<'a> {
this.psess.gated_spans.gate(sym::unsafe_attributes, unsafe_span); this.psess.gated_spans.gate(sym::unsafe_attributes, unsafe_span);
this.expect(&token::OpenDelim(Delimiter::Parenthesis))?; this.expect(&token::OpenDelim(Delimiter::Parenthesis))?;
ast::Unsafe::Yes(unsafe_span) ast::Safety::Unsafe(unsafe_span)
} else { } else {
ast::Unsafe::No ast::Safety::Default
}; };
let path = this.parse_path(PathStyle::Mod)?; 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.psess.gated_spans.gate(sym::unsafe_attributes, unsafe_span);
self.expect(&token::OpenDelim(Delimiter::Parenthesis))?; self.expect(&token::OpenDelim(Delimiter::Parenthesis))?;
ast::Unsafe::Yes(unsafe_span) ast::Safety::Unsafe(unsafe_span)
} else { } else {
ast::Unsafe::No ast::Safety::Default
}; };
let path = self.parse_path(PathStyle::Mod)?; let path = self.parse_path(PathStyle::Mod)?;

View file

@ -317,7 +317,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
fn check_unsafe_attr(&self, attr: &Attribute) { fn check_unsafe_attr(&self, attr: &Attribute) {
if !attr.is_doc_comment() { if !attr.is_doc_comment() {
let attr_item = attr.get_normal_item(); 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()) { if !is_unsafe_attr(attr.name_or_empty()) {
self.dcx().emit_err(errors::InvalidAttrUnsafe { self.dcx().emit_err(errors::InvalidAttrUnsafe {
span: unsafe_span, span: unsafe_span,

View file

@ -1,6 +1,6 @@
use super::*; 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::create_default_session_globals_then;
use rustc_span::symbol::{kw, Ident}; use rustc_span::symbol::{kw, Ident};
use rustc_span::DUMMY_SP; 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 { fn dummy_meta_item_word(name: &str) -> MetaItem {
MetaItem { MetaItem {
unsafety: Unsafe::No, unsafety: Safety::Default,
path: Path::from_ident(Ident::from_str(name)), path: Path::from_ident(Ident::from_str(name)),
kind: MetaItemKind::Word, kind: MetaItemKind::Word,
span: DUMMY_SP, 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 { fn dummy_meta_item_name_value(name: &str, symbol: Symbol, kind: LitKind) -> MetaItem {
let lit = MetaItemLit { symbol, suffix: None, kind, span: DUMMY_SP }; let lit = MetaItemLit { symbol, suffix: None, kind, span: DUMMY_SP };
MetaItem { MetaItem {
unsafety: Unsafe::No, unsafety: Safety::Default,
path: Path::from_ident(Ident::from_str(name)), path: Path::from_ident(Ident::from_str(name)),
kind: MetaItemKind::NameValue(lit), kind: MetaItemKind::NameValue(lit),
span: DUMMY_SP, 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 { macro_rules! dummy_meta_item_list {
($name:ident, [$($list:ident),* $(,)?]) => { ($name:ident, [$($list:ident),* $(,)?]) => {
MetaItem { MetaItem {
unsafety: Unsafe::No, unsafety: Safety::Default,
path: Path::from_ident(Ident::from_str(stringify!($name))), path: Path::from_ident(Ident::from_str(stringify!($name))),
kind: MetaItemKind::List(thin_vec![ kind: MetaItemKind::List(thin_vec![
$( $(
@ -51,7 +51,7 @@ macro_rules! dummy_meta_item_list {
($name:ident, [$($list:expr),* $(,)?]) => { ($name:ident, [$($list:expr),* $(,)?]) => {
MetaItem { MetaItem {
unsafety: Unsafe::No, unsafety: Safety::Default,
path: Path::from_ident(Ident::from_str(stringify!($name))), path: Path::from_ident(Ident::from_str(stringify!($name))),
kind: MetaItemKind::List(thin_vec![ kind: MetaItemKind::List(thin_vec![
$( $(