Skip to content
/ rust Public
forked from rust-lang/rust

Commit 1d5ec2c

Browse files
committed
Remove some leftover dead code
1 parent d50c0a5 commit 1d5ec2c

File tree

2 files changed

+8
-55
lines changed

2 files changed

+8
-55
lines changed

compiler/rustc_ast/src/ast.rs

+2-55
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
//! - [`UnOp`], [`BinOp`], and [`BinOpKind`]: Unary and binary operators.
2020
2121
use std::borrow::Cow;
22-
use std::{cmp, fmt, mem};
22+
use std::{cmp, fmt};
2323

2424
pub use GenericArgs::*;
2525
pub use UnsafeSource::*;
@@ -1758,47 +1758,10 @@ pub enum AttrArgs {
17581758
Eq {
17591759
/// Span of the `=` token.
17601760
eq_span: Span,
1761-
17621761
expr: P<Expr>,
17631762
},
17641763
}
17651764

1766-
// The RHS of an `AttrArgs::Eq` starts out as an expression. Once macro
1767-
// expansion is completed, all cases end up either as a meta item literal,
1768-
// which is the form used after lowering to HIR, or as an error.
1769-
#[derive(Clone, Encodable, Decodable, Debug)]
1770-
pub enum AttrArgsEq {
1771-
Ast(P<Expr>),
1772-
Hir(MetaItemLit),
1773-
}
1774-
1775-
impl AttrArgsEq {
1776-
pub fn span(&self) -> Span {
1777-
match self {
1778-
AttrArgsEq::Ast(p) => p.span,
1779-
AttrArgsEq::Hir(lit) => lit.span,
1780-
}
1781-
}
1782-
1783-
pub fn unwrap_ast(&self) -> &Expr {
1784-
match self {
1785-
AttrArgsEq::Ast(p) => p,
1786-
AttrArgsEq::Hir(lit) => {
1787-
unreachable!("in literal form when getting inner tokens: {lit:?}")
1788-
}
1789-
}
1790-
}
1791-
1792-
pub fn unwrap_ast_mut(&mut self) -> &mut P<Expr> {
1793-
match self {
1794-
AttrArgsEq::Ast(p) => p,
1795-
AttrArgsEq::Hir(lit) => {
1796-
unreachable!("in literal form when getting inner tokens: {lit:?}")
1797-
}
1798-
}
1799-
}
1800-
}
1801-
18021765
impl AttrArgs {
18031766
pub fn span(&self) -> Option<Span> {
18041767
match self {
@@ -1819,22 +1782,6 @@ impl AttrArgs {
18191782
}
18201783
}
18211784

1822-
impl<CTX> HashStable<CTX> for AttrArgs
1823-
where
1824-
CTX: crate::HashStableContext,
1825-
{
1826-
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
1827-
mem::discriminant(self).hash_stable(ctx, hasher);
1828-
match self {
1829-
AttrArgs::Empty => {}
1830-
AttrArgs::Delimited(args) => args.hash_stable(ctx, hasher),
1831-
AttrArgs::Eq { expr, .. } => {
1832-
unreachable!("hash_stable {:?}", expr);
1833-
}
1834-
}
1835-
}
1836-
}
1837-
18381785
/// Delimited arguments, as used in `#[attr()/[]/{}]` or `mac!()/[]/{}`.
18391786
#[derive(Clone, Encodable, Decodable, Debug)]
18401787
pub struct DelimArgs {
@@ -3047,7 +2994,7 @@ impl NormalAttr {
30472994
}
30482995
}
30492996

3050-
#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic)]
2997+
#[derive(Clone, Encodable, Decodable, Debug)]
30512998
pub struct AttrItem {
30522999
pub unsafety: Safety,
30533000
pub path: Path,

compiler/rustc_hir_pretty/src/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,13 @@ impl<'a> State<'a> {
121121
ast::AttrStyle::Inner => self.word("#!["),
122122
ast::AttrStyle::Outer => self.word("#["),
123123
}
124+
if normal.unsafety == hir::Safety::Unsafe {
125+
self.word("unsafe(");
126+
}
124127
self.print_attr_item(&normal, attr.span);
128+
if normal.unsafety == hir::Safety::Unsafe {
129+
self.word(")");
130+
}
125131
self.word("]");
126132
}
127133
hir::AttrKind::DocComment(comment_kind, data) => {

0 commit comments

Comments
 (0)