Skip to content

Commit 8959eb3

Browse files
committed
Remove suffix from MetaItemLit and StrLit
1 parent ff49e59 commit 8959eb3

File tree

7 files changed

+9
-25
lines changed

7 files changed

+9
-25
lines changed

compiler/rustc_ast/src/ast.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -1764,8 +1764,6 @@ pub enum StrStyle {
17641764
pub struct MetaItemLit {
17651765
/// The original literal as written in the source code.
17661766
pub symbol: Symbol,
1767-
/// The original suffix as written in the source code.
1768-
pub suffix: Option<Symbol>,
17691767
/// The "semantic" representation of the literal lowered from the original tokens.
17701768
/// Strings are unescaped, hexadecimal forms are eliminated, etc.
17711769
pub kind: LitKind,
@@ -1777,8 +1775,6 @@ pub struct MetaItemLit {
17771775
pub struct StrLit {
17781776
/// The original literal as written in source code.
17791777
pub symbol: Symbol,
1780-
/// The original suffix as written in source code.
1781-
pub suffix: Option<Symbol>,
17821778
/// The semantic (unescaped) representation of the literal.
17831779
pub symbol_unescaped: Symbol,
17841780
pub style: StrStyle,
@@ -1791,7 +1787,7 @@ impl StrLit {
17911787
StrStyle::Cooked => token::Str,
17921788
StrStyle::Raw(n) => token::StrRaw(n),
17931789
};
1794-
token::Lit::new(token_kind, self.symbol, self.suffix)
1790+
token::Lit::new(token_kind, self.symbol, None)
17951791
}
17961792
}
17971793

@@ -3315,7 +3311,7 @@ mod size_asserts {
33153311
static_assert_size!(Block, 32);
33163312
static_assert_size!(Expr, 72);
33173313
static_assert_size!(ExprKind, 40);
3318-
static_assert_size!(Fn, 160);
3314+
static_assert_size!(Fn, 152);
33193315
static_assert_size!(ForeignItem, 96);
33203316
static_assert_size!(ForeignItemKind, 24);
33213317
static_assert_size!(GenericArg, 24);

compiler/rustc_ast/src/util/literal.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ impl MetaItemLit {
218218
pub fn from_token_lit(token_lit: token::Lit, span: Span) -> Result<MetaItemLit, LitError> {
219219
Ok(MetaItemLit {
220220
symbol: token_lit.symbol,
221-
suffix: token_lit.suffix,
222221
kind: LitKind::from_token_lit(token_lit)?,
223222
span,
224223
})
@@ -241,7 +240,7 @@ impl MetaItemLit {
241240
LitKind::Err => token::Err,
242241
};
243242

244-
token::Lit::new(kind, self.symbol, self.suffix)
243+
token::Lit::new(kind, self.symbol, self.kind.suffix())
245244
}
246245

247246
/// Converts an arbitrary token into meta item literal.

compiler/rustc_ast_lowering/src/lib.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -968,12 +968,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
968968
{
969969
lit
970970
} else {
971-
MetaItemLit {
972-
symbol: kw::Empty,
973-
suffix: None,
974-
kind: LitKind::Err,
975-
span: DUMMY_SP,
976-
}
971+
MetaItemLit { symbol: kw::Empty, kind: LitKind::Err, span: DUMMY_SP }
977972
};
978973
AttrArgs::Eq(*eq_span, AttrArgsEq::Hir(lit))
979974
}

compiler/rustc_parse/src/parser/expr.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -2005,13 +2005,9 @@ impl<'a> Parser<'a> {
20052005
pub fn parse_str_lit(&mut self) -> Result<ast::StrLit, Option<MetaItemLit>> {
20062006
match self.parse_opt_meta_item_lit() {
20072007
Some(lit) => match lit.kind {
2008-
ast::LitKind::Str(symbol_unescaped, style) => Ok(ast::StrLit {
2009-
style,
2010-
symbol: lit.symbol,
2011-
suffix: lit.suffix,
2012-
span: lit.span,
2013-
symbol_unescaped,
2014-
}),
2008+
ast::LitKind::Str(symbol_unescaped, style) => {
2009+
Ok(ast::StrLit { style, symbol: lit.symbol, span: lit.span, symbol_unescaped })
2010+
}
20152011
_ => Err(Some(lit)),
20162012
},
20172013
None => Err(None),
@@ -2025,7 +2021,6 @@ impl<'a> Parser<'a> {
20252021
fn mk_meta_item_lit_char(name: Symbol, span: Span) -> MetaItemLit {
20262022
ast::MetaItemLit {
20272023
symbol: name,
2028-
suffix: None,
20292024
kind: ast::LitKind::Char(name.as_str().chars().next().unwrap_or('_')),
20302025
span,
20312026
}

compiler/rustc_parse/src/validate_attr.rs

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ pub fn parse_meta<'a>(sess: &'a ParseSess, attr: &Attribute) -> PResult<'a, Meta
7373
report_lit_error(sess, err, token_lit, expr.span);
7474
let lit = ast::MetaItemLit {
7575
symbol: token_lit.symbol,
76-
suffix: token_lit.suffix,
7776
kind: ast::LitKind::Err,
7877
span: expr.span,
7978
};

src/librustdoc/clean/cfg/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn dummy_meta_item_word(name: &str) -> MetaItem {
2323
}
2424

2525
fn dummy_meta_item_name_value(name: &str, symbol: Symbol, kind: LitKind) -> MetaItem {
26-
let lit = MetaItemLit { symbol, suffix: None, kind, span: DUMMY_SP };
26+
let lit = MetaItemLit { symbol, kind, span: DUMMY_SP };
2727
MetaItem {
2828
path: Path::from_ident(Ident::from_str(name)),
2929
kind: MetaItemKind::NameValue(lit),

src/tools/clippy/clippy_utils/src/ast_utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ pub fn eq_ext(l: &Extern, r: &Extern) -> bool {
723723
}
724724

725725
pub fn eq_str_lit(l: &StrLit, r: &StrLit) -> bool {
726-
l.style == r.style && l.symbol == r.symbol && l.suffix == r.suffix
726+
l.style == r.style && l.symbol == r.symbol
727727
}
728728

729729
pub fn eq_poly_ref_trait(l: &PolyTraitRef, r: &PolyTraitRef) -> bool {

0 commit comments

Comments
 (0)