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

+3-1
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

+2-2
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

+1-7
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

+9-9
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

+1-1
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

+1-1
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

+1-2
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

+3-3
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

+3-9
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

+1-1
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));

compiler/rustc_builtin_macros/src/source_util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ pub fn expand_include_bytes(
216216
}
217217
};
218218
match cx.source_map().load_binary_file(&file) {
219-
Ok(bytes) => base::MacEager::expr(cx.expr_lit(sp, ast::LitKind::ByteStr(bytes.into()))),
219+
Ok(bytes) => base::MacEager::expr(cx.expr_byte_str(sp, bytes)),
220220
Err(e) => {
221221
cx.span_err(sp, &format!("couldn't read {}: {}", file.display(), e));
222222
DummyResult::any(sp)

compiler/rustc_codegen_ssa/src/back/write.rs

+11-9
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc_data_structures::profiling::TimingGuard;
1515
use rustc_data_structures::profiling::VerboseTimingGuard;
1616
use rustc_data_structures::sync::Lrc;
1717
use rustc_errors::emitter::Emitter;
18-
use rustc_errors::{DiagnosticId, FatalError, Handler, Level};
18+
use rustc_errors::{translation::Translate, DiagnosticId, FatalError, Handler, Level};
1919
use rustc_fs_util::link_or_copy;
2020
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
2121
use rustc_incremental::{
@@ -1740,6 +1740,16 @@ impl SharedEmitter {
17401740
}
17411741
}
17421742

1743+
impl Translate for SharedEmitter {
1744+
fn fluent_bundle(&self) -> Option<&Lrc<rustc_errors::FluentBundle>> {
1745+
None
1746+
}
1747+
1748+
fn fallback_fluent_bundle(&self) -> &rustc_errors::FluentBundle {
1749+
panic!("shared emitter attempted to translate a diagnostic");
1750+
}
1751+
}
1752+
17431753
impl Emitter for SharedEmitter {
17441754
fn emit_diagnostic(&mut self, diag: &rustc_errors::Diagnostic) {
17451755
let fluent_args = self.to_fluent_args(diag.args());
@@ -1761,14 +1771,6 @@ impl Emitter for SharedEmitter {
17611771
fn source_map(&self) -> Option<&Lrc<SourceMap>> {
17621772
None
17631773
}
1764-
1765-
fn fluent_bundle(&self) -> Option<&Lrc<rustc_errors::FluentBundle>> {
1766-
None
1767-
}
1768-
1769-
fn fallback_fluent_bundle(&self) -> &rustc_errors::FluentBundle {
1770-
panic!("shared emitter attempted to translate a diagnostic");
1771-
}
17721774
}
17731775

17741776
impl SharedEmitterMain {

compiler/rustc_const_eval/src/interpret/terminator.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
534534
let mut non_zst_field = None;
535535
for i in 0..receiver.layout.fields.count() {
536536
let field = self.operand_field(&receiver, i)?;
537-
if !field.layout.is_zst() {
537+
let zst =
538+
field.layout.is_zst() && field.layout.align.abi.bytes() == 1;
539+
if !zst {
538540
assert!(
539541
non_zst_field.is_none(),
540542
"multiple non-ZST fields in dyn receiver type {}",

compiler/rustc_data_structures/src/sync.rs

-2
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ cfg_if! {
5656
pub fn new(v: T) -> Self {
5757
Atomic(Cell::new(v))
5858
}
59-
}
6059

61-
impl<T: Copy> Atomic<T> {
6260
#[inline]
6361
pub fn into_inner(self) -> T {
6462
self.0.into_inner()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
interface_ferris_identifier =
2+
Ferris cannot be used as an identifier
3+
.suggestion = try using their name instead
4+
5+
interface_emoji_identifier =
6+
identifiers cannot contain emoji: `{$ident}`

compiler/rustc_error_messages/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ fluent_messages! {
3434
builtin_macros => "../locales/en-US/builtin_macros.ftl",
3535
const_eval => "../locales/en-US/const_eval.ftl",
3636
expand => "../locales/en-US/expand.ftl",
37+
interface => "../locales/en-US/interface.ftl",
3738
lint => "../locales/en-US/lint.ftl",
3839
parser => "../locales/en-US/parser.ftl",
3940
passes => "../locales/en-US/passes.ftl",

compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs

+11-8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
88
use crate::emitter::FileWithAnnotatedLines;
99
use crate::snippet::Line;
10+
use crate::translation::Translate;
1011
use crate::{
1112
CodeSuggestion, Diagnostic, DiagnosticId, DiagnosticMessage, Emitter, FluentBundle,
1213
LazyFallbackBundle, Level, MultiSpan, Style, SubDiagnostic,
@@ -32,6 +33,16 @@ pub struct AnnotateSnippetEmitterWriter {
3233
macro_backtrace: bool,
3334
}
3435

36+
impl Translate for AnnotateSnippetEmitterWriter {
37+
fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
38+
self.fluent_bundle.as_ref()
39+
}
40+
41+
fn fallback_fluent_bundle(&self) -> &FluentBundle {
42+
&**self.fallback_bundle
43+
}
44+
}
45+
3546
impl Emitter for AnnotateSnippetEmitterWriter {
3647
/// The entry point for the diagnostics generation
3748
fn emit_diagnostic(&mut self, diag: &Diagnostic) {
@@ -63,14 +74,6 @@ impl Emitter for AnnotateSnippetEmitterWriter {
6374
self.source_map.as_ref()
6475
}
6576

66-
fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
67-
self.fluent_bundle.as_ref()
68-
}
69-
70-
fn fallback_fluent_bundle(&self) -> &FluentBundle {
71-
&**self.fallback_bundle
72-
}
73-
7477
fn should_show_explain(&self) -> bool {
7578
!self.short_message
7679
}

0 commit comments

Comments
 (0)