Skip to content

Commit 9c20b2a

Browse files
committed
Auto merge of #100677 - matthiaskrgr:rollup-au41ho1, r=matthiaskrgr
Rollup of 15 pull requests Successful merges: - #99474 (Rustdoc json tests: New `@hasexact` test command) - #99972 (interpret: only consider 1-ZST when searching for receiver) - #100018 (Clean up `LitKind`) - #100379 (triagebot: add translation-related mention groups) - #100389 (Do not report cycle error when inferring return type for suggestion) - #100489 (`is_knowable` use `Result` instead of `Option`) - #100532 (unwind: don't build dependency when building for Miri) - #100608 (needless separation of impl blocks) - #100621 (Pass +atomics-32 feature for {arm,thumb}v4t-none-eabi) - #100646 (Migrate emoji identifier diagnostics to `SessionDiagnostic` in rustc_interface) - #100652 (Remove deferred sized checks (make them eager)) - #100655 (Update books) - #100656 (Update cargo) - #100660 (Fixed a few documentation errors) - #100661 (Fixed a few documentation errors) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 86c6ebe + 1199dbd commit 9c20b2a

File tree

84 files changed

+584
-421
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+584
-421
lines changed

Cargo.lock

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ dependencies = [
321321

322322
[[package]]
323323
name = "cargo"
324-
version = "0.65.0"
324+
version = "0.66.0"
325325
dependencies = [
326326
"anyhow",
327327
"atty",
@@ -4011,6 +4011,7 @@ dependencies = [
40114011
"rustc_hir",
40124012
"rustc_incremental",
40134013
"rustc_lint",
4014+
"rustc_macros",
40144015
"rustc_metadata",
40154016
"rustc_middle",
40164017
"rustc_mir_build",
@@ -4359,6 +4360,7 @@ dependencies = [
43594360
"rustc_serialize",
43604361
"rustc_session",
43614362
"rustc_span",
4363+
"rustc_target",
43624364
"tracing",
43634365
]
43644366

compiler/rustc_ast/src/ast.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,7 +1689,7 @@ pub enum StrStyle {
16891689
#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic)]
16901690
pub struct Lit {
16911691
/// The original literal token as written in source code.
1692-
pub token: token::Lit,
1692+
pub token_lit: token::Lit,
16931693
/// The "semantic" representation of the literal lowered from the original tokens.
16941694
/// Strings are unescaped, hexadecimal forms are eliminated, etc.
16951695
/// FIXME: Remove this and only create the semantic representation during lowering to HIR.
@@ -1717,7 +1717,7 @@ impl StrLit {
17171717
StrStyle::Raw(n) => token::StrRaw(n),
17181718
};
17191719
Lit {
1720-
token: token::Lit::new(token_kind, self.symbol, self.suffix),
1720+
token_lit: token::Lit::new(token_kind, self.symbol, self.suffix),
17211721
span: self.span,
17221722
kind: LitKind::Str(self.symbol_unescaped, self.style),
17231723
}

compiler/rustc_ast/src/attr/mod.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,7 @@ impl MetaItem {
184184
}
185185

186186
pub fn value_str(&self) -> Option<Symbol> {
187-
match self.kind {
188-
MetaItemKind::NameValue(ref v) => match v.kind {
189-
LitKind::Str(ref s, _) => Some(*s),
190-
_ => None,
191-
},
192-
_ => None,
193-
}
187+
self.kind.value_str()
194188
}
195189

196190
pub fn meta_item_list(&self) -> Option<&[NestedMetaItem]> {

compiler/rustc_ast/src/util/literal.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub enum LitError {
2323

2424
impl LitKind {
2525
/// Converts literal token into a semantic literal.
26-
pub fn from_lit_token(lit: token::Lit) -> Result<LitKind, LitError> {
26+
pub fn from_token_lit(lit: token::Lit) -> Result<LitKind, LitError> {
2727
let token::Lit { kind, symbol, suffix } = lit;
2828
if suffix.is_some() && !kind.may_have_suffix() {
2929
return Err(LitError::InvalidSuffix);
@@ -153,7 +153,7 @@ impl LitKind {
153153
/// Attempts to recover a token from semantic literal.
154154
/// This function is used when the original token doesn't exist (e.g. the literal is created
155155
/// by an AST-based macro) or unavailable (e.g. from HIR pretty-printing).
156-
pub fn to_lit_token(&self) -> token::Lit {
156+
pub fn to_token_lit(&self) -> token::Lit {
157157
let (kind, symbol, suffix) = match *self {
158158
LitKind::Str(symbol, ast::StrStyle::Cooked) => {
159159
// Don't re-intern unless the escaped string is different.
@@ -208,8 +208,8 @@ impl LitKind {
208208

209209
impl Lit {
210210
/// Converts literal token into an AST literal.
211-
pub fn from_lit_token(token: token::Lit, span: Span) -> Result<Lit, LitError> {
212-
Ok(Lit { token, kind: LitKind::from_lit_token(token)?, span })
211+
pub fn from_token_lit(token_lit: token::Lit, span: Span) -> Result<Lit, LitError> {
212+
Ok(Lit { token_lit, kind: LitKind::from_token_lit(token_lit)?, span })
213213
}
214214

215215
/// Converts arbitrary token into an AST literal.
@@ -232,21 +232,21 @@ impl Lit {
232232
_ => return Err(LitError::NotLiteral),
233233
};
234234

235-
Lit::from_lit_token(lit, token.span)
235+
Lit::from_token_lit(lit, token.span)
236236
}
237237

238238
/// Attempts to recover an AST literal from semantic literal.
239239
/// This function is used when the original token doesn't exist (e.g. the literal is created
240240
/// by an AST-based macro) or unavailable (e.g. from HIR pretty-printing).
241241
pub fn from_lit_kind(kind: LitKind, span: Span) -> Lit {
242-
Lit { token: kind.to_lit_token(), kind, span }
242+
Lit { token_lit: kind.to_token_lit(), kind, span }
243243
}
244244

245245
/// Losslessly convert an AST literal into a token.
246246
pub fn to_token(&self) -> Token {
247-
let kind = match self.token.kind {
248-
token::Bool => token::Ident(self.token.symbol, false),
249-
_ => token::Literal(self.token),
247+
let kind = match self.token_lit.kind {
248+
token::Bool => token::Ident(self.token_lit.symbol, false),
249+
_ => token::Literal(self.token_lit),
250250
};
251251
Token::new(kind, self.span)
252252
}

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
927927
lit.clone()
928928
} else {
929929
Lit {
930-
token: token::Lit::new(token::LitKind::Err, kw::Empty, None),
930+
token_lit: token::Lit::new(token::LitKind::Err, kw::Empty, None),
931931
kind: LitKind::Err(kw::Empty),
932932
span: DUMMY_SP,
933933
}

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
372372

373373
fn print_literal(&mut self, lit: &ast::Lit) {
374374
self.maybe_print_comment(lit.span.lo());
375-
self.word(lit.token.to_string())
375+
self.word(lit.token_lit.to_string())
376376
}
377377

378378
fn print_string(&mut self, st: &str, style: ast::StrStyle) {

compiler/rustc_builtin_macros/src/concat_bytes.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use rustc_ast as ast;
22
use rustc_ast::{ptr::P, tokenstream::TokenStream};
3-
use rustc_data_structures::sync::Lrc;
43
use rustc_errors::Applicability;
54
use rustc_expand::base::{self, DummyResult};
65

@@ -185,5 +184,5 @@ pub fn expand_concat_bytes(
185184
return base::MacEager::expr(DummyResult::raw_expr(sp, true));
186185
}
187186
let sp = cx.with_def_site_ctxt(sp);
188-
base::MacEager::expr(cx.expr_lit(sp, ast::LitKind::ByteStr(Lrc::from(accumulator))))
187+
base::MacEager::expr(cx.expr_byte_str(sp, accumulator))
189188
}

compiler/rustc_builtin_macros/src/derive.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ fn report_bad_target(sess: &Session, item: &Annotatable, span: Span) -> bool {
126126
}
127127

128128
fn report_unexpected_literal(sess: &Session, lit: &ast::Lit) {
129-
let help_msg = match lit.token.kind {
130-
token::Str if rustc_lexer::is_ident(lit.token.symbol.as_str()) => {
131-
format!("try using `#[derive({})]`", lit.token.symbol)
129+
let help_msg = match lit.token_lit.kind {
130+
token::Str if rustc_lexer::is_ident(lit.token_lit.symbol.as_str()) => {
131+
format!("try using `#[derive({})]`", lit.token_lit.symbol)
132132
}
133133
_ => "for example, write `#[derive(Debug)]` for `Debug`".to_string(),
134134
};

compiler/rustc_builtin_macros/src/deriving/debug.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>
5252

5353
// We want to make sure we have the ctxt set so that we can use unstable methods
5454
let span = cx.with_def_site_ctxt(span);
55-
let name = cx.expr_lit(span, ast::LitKind::Str(ident.name, ast::StrStyle::Cooked));
55+
let name = cx.expr_str(span, ident.name);
5656
let fmt = substr.nonselflike_args[0].clone();
5757

5858
// Struct and tuples are similar enough that we use the same code for both,
@@ -89,10 +89,7 @@ fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>
8989
for i in 0..fields.len() {
9090
let field = &fields[i];
9191
if is_struct {
92-
let name = cx.expr_lit(
93-
field.span,
94-
ast::LitKind::Str(field.name.unwrap().name, ast::StrStyle::Cooked),
95-
);
92+
let name = cx.expr_str(field.span, field.name.unwrap().name);
9693
args.push(name);
9794
}
9895
// Use an extra indirection to make sure this works for unsized types.
@@ -108,10 +105,7 @@ fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>
108105

109106
for field in fields {
110107
if is_struct {
111-
name_exprs.push(cx.expr_lit(
112-
field.span,
113-
ast::LitKind::Str(field.name.unwrap().name, ast::StrStyle::Cooked),
114-
));
108+
name_exprs.push(cx.expr_str(field.span, field.name.unwrap().name));
115109
}
116110

117111
// Use an extra indirection to make sure this works for unsized types.

compiler/rustc_builtin_macros/src/format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ impl<'a, 'b> Context<'a, 'b> {
923923
}
924924

925925
// Build the format
926-
let fill = self.ecx.expr_lit(sp, ast::LitKind::Char(fill));
926+
let fill = self.ecx.expr_char(sp, fill);
927927
let align = |name| {
928928
let mut p = Context::rtpath(self.ecx, sym::Alignment);
929929
p.push(Ident::new(name, sp));

0 commit comments

Comments
 (0)