1
Fork 0

Remove some leftover dead code

This commit is contained in:
Jonathan Dönszelmann 2024-10-17 01:11:31 +02:00
parent d50c0a5480
commit 1d5ec2cd6a
No known key found for this signature in database
2 changed files with 8 additions and 55 deletions

View file

@ -19,7 +19,7 @@
//! - [`UnOp`], [`BinOp`], and [`BinOpKind`]: Unary and binary operators. //! - [`UnOp`], [`BinOp`], and [`BinOpKind`]: Unary and binary operators.
use std::borrow::Cow; use std::borrow::Cow;
use std::{cmp, fmt, mem}; use std::{cmp, fmt};
pub use GenericArgs::*; pub use GenericArgs::*;
pub use UnsafeSource::*; pub use UnsafeSource::*;
@ -1758,47 +1758,10 @@ pub enum AttrArgs {
Eq { Eq {
/// Span of the `=` token. /// Span of the `=` token.
eq_span: Span, eq_span: Span,
expr: P<Expr>, expr: P<Expr>,
}, },
} }
// The RHS of an `AttrArgs::Eq` starts out as an expression. Once macro
// expansion is completed, all cases end up either as a meta item literal,
// which is the form used after lowering to HIR, or as an error.
#[derive(Clone, Encodable, Decodable, Debug)]
pub enum AttrArgsEq {
Ast(P<Expr>),
Hir(MetaItemLit),
}
impl AttrArgsEq {
pub fn span(&self) -> Span {
match self {
AttrArgsEq::Ast(p) => p.span,
AttrArgsEq::Hir(lit) => lit.span,
}
}
pub fn unwrap_ast(&self) -> &Expr {
match self {
AttrArgsEq::Ast(p) => p,
AttrArgsEq::Hir(lit) => {
unreachable!("in literal form when getting inner tokens: {lit:?}")
}
}
}
pub fn unwrap_ast_mut(&mut self) -> &mut P<Expr> {
match self {
AttrArgsEq::Ast(p) => p,
AttrArgsEq::Hir(lit) => {
unreachable!("in literal form when getting inner tokens: {lit:?}")
}
}
}
}
impl AttrArgs { impl AttrArgs {
pub fn span(&self) -> Option<Span> { pub fn span(&self) -> Option<Span> {
match self { match self {
@ -1819,22 +1782,6 @@ impl AttrArgs {
} }
} }
impl<CTX> HashStable<CTX> for AttrArgs
where
CTX: crate::HashStableContext,
{
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
mem::discriminant(self).hash_stable(ctx, hasher);
match self {
AttrArgs::Empty => {}
AttrArgs::Delimited(args) => args.hash_stable(ctx, hasher),
AttrArgs::Eq { expr, .. } => {
unreachable!("hash_stable {:?}", expr);
}
}
}
}
/// Delimited arguments, as used in `#[attr()/[]/{}]` or `mac!()/[]/{}`. /// Delimited arguments, as used in `#[attr()/[]/{}]` or `mac!()/[]/{}`.
#[derive(Clone, Encodable, Decodable, Debug)] #[derive(Clone, Encodable, Decodable, Debug)]
pub struct DelimArgs { pub struct DelimArgs {
@ -3047,7 +2994,7 @@ impl NormalAttr {
} }
} }
#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic)] #[derive(Clone, Encodable, Decodable, Debug)]
pub struct AttrItem { pub struct AttrItem {
pub unsafety: Safety, pub unsafety: Safety,
pub path: Path, pub path: Path,

View file

@ -121,7 +121,13 @@ impl<'a> State<'a> {
ast::AttrStyle::Inner => self.word("#!["), ast::AttrStyle::Inner => self.word("#!["),
ast::AttrStyle::Outer => self.word("#["), ast::AttrStyle::Outer => self.word("#["),
} }
if normal.unsafety == hir::Safety::Unsafe {
self.word("unsafe(");
}
self.print_attr_item(&normal, attr.span); self.print_attr_item(&normal, attr.span);
if normal.unsafety == hir::Safety::Unsafe {
self.word(")");
}
self.word("]"); self.word("]");
} }
hir::AttrKind::DocComment(comment_kind, data) => { hir::AttrKind::DocComment(comment_kind, data) => {