Skip to content

Commit 24071bd

Browse files
committed
Auto merge of rust-lang#3378 - rust-lang:rustup-2024-03-14, r=RalfJung
Automatic Rustup
2 parents 34d6f07 + 4cd673b commit 24071bd

File tree

497 files changed

+5443
-2560
lines changed

Some content is hidden

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

497 files changed

+5443
-2560
lines changed

.reuse/dep5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Copyright: 2019 The Crossbeam Project Developers
5252
The Rust Project Developers (see https://thanks.rust-lang.org)
5353
License: MIT OR Apache-2.0
5454

55-
Files: library/std/src/sys/locks/mutex/fuchsia.rs
55+
Files: library/std/src/sys/sync/mutex/fuchsia.rs
5656
Copyright: 2016 The Fuchsia Authors
5757
The Rust Project Developers (see https://thanks.rust-lang.org)
5858
License: BSD-2-Clause AND (MIT OR Apache-2.0)

compiler/rustc_abi/src/layout.rs

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -816,15 +816,37 @@ where
816816
break;
817817
}
818818
};
819-
if let Some(pair) = common_prim {
820-
// This is pretty conservative. We could go fancier
821-
// by conflating things like i32 and u32, or even
822-
// realising that (u8, u8) could just cohabit with
823-
// u16 or even u32.
824-
if pair != (prim, offset) {
819+
if let Some((old_prim, common_offset)) = common_prim {
820+
// All variants must be at the same offset
821+
if offset != common_offset {
825822
common_prim = None;
826823
break;
827824
}
825+
// This is pretty conservative. We could go fancier
826+
// by realising that (u8, u8) could just cohabit with
827+
// u16 or even u32.
828+
let new_prim = match (old_prim, prim) {
829+
// Allow all identical primitives.
830+
(x, y) if x == y => x,
831+
// Allow integers of the same size with differing signedness.
832+
// We arbitrarily choose the signedness of the first variant.
833+
(p @ Primitive::Int(x, _), Primitive::Int(y, _)) if x == y => p,
834+
// Allow integers mixed with pointers of the same layout.
835+
// We must represent this using a pointer, to avoid
836+
// roundtripping pointers through ptrtoint/inttoptr.
837+
(p @ Primitive::Pointer(_), i @ Primitive::Int(..))
838+
| (i @ Primitive::Int(..), p @ Primitive::Pointer(_))
839+
if p.size(dl) == i.size(dl) && p.align(dl) == i.align(dl) =>
840+
{
841+
p
842+
}
843+
_ => {
844+
common_prim = None;
845+
break;
846+
}
847+
};
848+
// We may be updating the primitive here, for example from int->ptr.
849+
common_prim = Some((new_prim, common_offset));
828850
} else {
829851
common_prim = Some((prim, offset));
830852
}

compiler/rustc_ast/src/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ impl Stmt {
10211021
#[derive(Clone, Encodable, Decodable, Debug)]
10221022
pub enum StmtKind {
10231023
/// A local (let) binding.
1024-
Local(P<Local>),
1024+
Let(P<Local>),
10251025
/// An item definition.
10261026
Item(P<Item>),
10271027
/// Expr without trailing semi-colon.

compiler/rustc_ast/src/ast_traits.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ impl<T: HasTokens> HasTokens for Option<T> {
182182
impl HasTokens for StmtKind {
183183
fn tokens(&self) -> Option<&LazyAttrTokenStream> {
184184
match self {
185-
StmtKind::Local(local) => local.tokens.as_ref(),
185+
StmtKind::Let(local) => local.tokens.as_ref(),
186186
StmtKind::Item(item) => item.tokens(),
187187
StmtKind::Expr(expr) | StmtKind::Semi(expr) => expr.tokens(),
188188
StmtKind::Empty => return None,
@@ -191,7 +191,7 @@ impl HasTokens for StmtKind {
191191
}
192192
fn tokens_mut(&mut self) -> Option<&mut Option<LazyAttrTokenStream>> {
193193
match self {
194-
StmtKind::Local(local) => Some(&mut local.tokens),
194+
StmtKind::Let(local) => Some(&mut local.tokens),
195195
StmtKind::Item(item) => item.tokens_mut(),
196196
StmtKind::Expr(expr) | StmtKind::Semi(expr) => expr.tokens_mut(),
197197
StmtKind::Empty => return None,
@@ -355,7 +355,7 @@ impl HasAttrs for StmtKind {
355355

356356
fn attrs(&self) -> &[Attribute] {
357357
match self {
358-
StmtKind::Local(local) => &local.attrs,
358+
StmtKind::Let(local) => &local.attrs,
359359
StmtKind::Expr(expr) | StmtKind::Semi(expr) => expr.attrs(),
360360
StmtKind::Item(item) => item.attrs(),
361361
StmtKind::Empty => &[],
@@ -365,7 +365,7 @@ impl HasAttrs for StmtKind {
365365

366366
fn visit_attrs(&mut self, f: impl FnOnce(&mut AttrVec)) {
367367
match self {
368-
StmtKind::Local(local) => f(&mut local.attrs),
368+
StmtKind::Let(local) => f(&mut local.attrs),
369369
StmtKind::Expr(expr) | StmtKind::Semi(expr) => expr.visit_attrs(f),
370370
StmtKind::Item(item) => item.visit_attrs(f),
371371
StmtKind::Empty => {}

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1567,7 +1567,7 @@ pub fn noop_flat_map_stmt_kind<T: MutVisitor>(
15671567
vis: &mut T,
15681568
) -> SmallVec<[StmtKind; 1]> {
15691569
match kind {
1570-
StmtKind::Local(mut local) => smallvec![StmtKind::Local({
1570+
StmtKind::Let(mut local) => smallvec![StmtKind::Let({
15711571
vis.visit_local(&mut local);
15721572
local
15731573
})],

compiler/rustc_ast/src/visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ pub fn walk_block<'a, V: Visitor<'a>>(visitor: &mut V, block: &'a Block) -> V::R
787787

788788
pub fn walk_stmt<'a, V: Visitor<'a>>(visitor: &mut V, statement: &'a Stmt) -> V::Result {
789789
match &statement.kind {
790-
StmtKind::Local(local) => try_visit!(visitor.visit_local(local)),
790+
StmtKind::Let(local) => try_visit!(visitor.visit_local(local)),
791791
StmtKind::Item(item) => try_visit!(visitor.visit_item(item)),
792792
StmtKind::Expr(expr) | StmtKind::Semi(expr) => try_visit!(visitor.visit_expr(expr)),
793793
StmtKind::Empty => {}

compiler/rustc_ast_lowering/src/asm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
196196
.get_partial_res(sym.id)
197197
.and_then(|res| res.full_res())
198198
.and_then(|res| match res {
199-
Res::Def(DefKind::Static(_), def_id) => Some(def_id),
199+
Res::Def(DefKind::Static { .. }, def_id) => Some(def_id),
200200
_ => None,
201201
});
202202

compiler/rustc_ast_lowering/src/block.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
3232
let mut expr = None;
3333
while let [s, tail @ ..] = ast_stmts {
3434
match &s.kind {
35-
StmtKind::Local(local) => {
35+
StmtKind::Let(local) => {
3636
let hir_id = self.lower_node_id(s.id);
3737
let local = self.lower_local(local);
3838
self.alias_attrs(hir_id, local.hir_id);
39-
let kind = hir::StmtKind::Local(local);
39+
let kind = hir::StmtKind::Let(local);
4040
let span = self.lower_span(s.span);
4141
stmts.push(hir::Stmt { hir_id, kind, span });
4242
}

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2356,7 +2356,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23562356
span: self.lower_span(span),
23572357
ty: None,
23582358
};
2359-
self.stmt(span, hir::StmtKind::Local(self.arena.alloc(local)))
2359+
self.stmt(span, hir::StmtKind::Let(self.arena.alloc(local)))
23602360
}
23612361

23622362
fn block_expr(&mut self, expr: &'hir hir::Expr<'hir>) -> &'hir hir::Block<'hir> {

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,7 @@ impl<'a> State<'a> {
12121212
fn print_stmt(&mut self, st: &ast::Stmt) {
12131213
self.maybe_print_comment(st.span.lo());
12141214
match &st.kind {
1215-
ast::StmtKind::Local(loc) => {
1215+
ast::StmtKind::Let(loc) => {
12161216
self.print_outer_attributes(&loc.attrs);
12171217
self.space_if_not_bol();
12181218
self.ibox(INDENT_UNIT);

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
616616

617617
// FIXME: We make sure that this is a normal top-level binding,
618618
// but we could suggest `todo!()` for all uninitalized bindings in the pattern pattern
619-
if let hir::StmtKind::Local(hir::Local { span, ty, init: None, pat, .. }) =
619+
if let hir::StmtKind::Let(hir::Local { span, ty, init: None, pat, .. }) =
620620
&ex.kind
621621
&& let hir::PatKind::Binding(..) = pat.kind
622622
&& span.contains(self.decl_span)

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
558558
hir::intravisit::walk_stmt(self, stmt);
559559
let expr = match stmt.kind {
560560
hir::StmtKind::Semi(expr) | hir::StmtKind::Expr(expr) => expr,
561-
hir::StmtKind::Local(hir::Local { init: Some(expr), .. }) => expr,
561+
hir::StmtKind::Let(hir::Local { init: Some(expr), .. }) => expr,
562562
_ => {
563563
return;
564564
}
@@ -1305,7 +1305,7 @@ struct BindingFinder {
13051305
impl<'tcx> Visitor<'tcx> for BindingFinder {
13061306
type Result = ControlFlow<hir::HirId>;
13071307
fn visit_stmt(&mut self, s: &'tcx hir::Stmt<'tcx>) -> Self::Result {
1308-
if let hir::StmtKind::Local(local) = s.kind
1308+
if let hir::StmtKind::Let(local) = s.kind
13091309
&& local.pat.span == self.span
13101310
{
13111311
ControlFlow::Break(local.hir_id)

compiler/rustc_builtin_macros/src/asm.rs

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_ast::token::{self, Delimiter};
55
use rustc_ast::tokenstream::TokenStream;
66
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
77
use rustc_errors::PResult;
8-
use rustc_expand::base::{self, *};
8+
use rustc_expand::base::*;
99
use rustc_index::bit_set::GrowableBitSet;
1010
use rustc_parse::parser::Parser;
1111
use rustc_parse_format as parse;
@@ -443,7 +443,7 @@ fn parse_reg<'a>(
443443
fn expand_preparsed_asm(
444444
ecx: &mut ExtCtxt<'_>,
445445
args: AsmArgs,
446-
) -> Result<ast::InlineAsm, ErrorGuaranteed> {
446+
) -> ExpandResult<Result<ast::InlineAsm, ErrorGuaranteed>, ()> {
447447
let mut template = vec![];
448448
// Register operands are implicitly used since they are not allowed to be
449449
// referenced in the template string.
@@ -465,16 +465,20 @@ fn expand_preparsed_asm(
465465

466466
let msg = "asm template must be a string literal";
467467
let template_sp = template_expr.span;
468-
let (template_str, template_style, template_span) =
469-
match expr_to_spanned_string(ecx, template_expr, msg) {
468+
let (template_str, template_style, template_span) = {
469+
let ExpandResult::Ready(mac) = expr_to_spanned_string(ecx, template_expr, msg) else {
470+
return ExpandResult::Retry(());
471+
};
472+
match mac {
470473
Ok(template_part) => template_part,
471474
Err(err) => {
472-
return Err(match err {
475+
return ExpandResult::Ready(Err(match err {
473476
Ok((err, _)) => err.emit(),
474477
Err(guar) => guar,
475-
});
478+
}));
476479
}
477-
};
480+
}
481+
};
478482

479483
let str_style = match template_style {
480484
ast::StrStyle::Cooked => None,
@@ -562,7 +566,7 @@ fn expand_preparsed_asm(
562566
e.span_label(err_sp, label);
563567
}
564568
let guar = e.emit();
565-
return Err(guar);
569+
return ExpandResult::Ready(Err(guar));
566570
}
567571

568572
curarg = parser.curarg;
@@ -729,24 +733,27 @@ fn expand_preparsed_asm(
729733
}
730734
}
731735

732-
Ok(ast::InlineAsm {
736+
ExpandResult::Ready(Ok(ast::InlineAsm {
733737
template,
734738
template_strs: template_strs.into_boxed_slice(),
735739
operands: args.operands,
736740
clobber_abis: args.clobber_abis,
737741
options: args.options,
738742
line_spans,
739-
})
743+
}))
740744
}
741745

742746
pub(super) fn expand_asm<'cx>(
743747
ecx: &'cx mut ExtCtxt<'_>,
744748
sp: Span,
745749
tts: TokenStream,
746-
) -> Box<dyn base::MacResult + 'cx> {
747-
match parse_args(ecx, sp, tts, false) {
750+
) -> MacroExpanderResult<'cx> {
751+
ExpandResult::Ready(match parse_args(ecx, sp, tts, false) {
748752
Ok(args) => {
749-
let expr = match expand_preparsed_asm(ecx, args) {
753+
let ExpandResult::Ready(mac) = expand_preparsed_asm(ecx, args) else {
754+
return ExpandResult::Retry(());
755+
};
756+
let expr = match mac {
750757
Ok(inline_asm) => P(ast::Expr {
751758
id: ast::DUMMY_NODE_ID,
752759
kind: ast::ExprKind::InlineAsm(P(inline_asm)),
@@ -762,34 +769,39 @@ pub(super) fn expand_asm<'cx>(
762769
let guar = err.emit();
763770
DummyResult::any(sp, guar)
764771
}
765-
}
772+
})
766773
}
767774

768775
pub(super) fn expand_global_asm<'cx>(
769776
ecx: &'cx mut ExtCtxt<'_>,
770777
sp: Span,
771778
tts: TokenStream,
772-
) -> Box<dyn base::MacResult + 'cx> {
773-
match parse_args(ecx, sp, tts, true) {
774-
Ok(args) => match expand_preparsed_asm(ecx, args) {
775-
Ok(inline_asm) => MacEager::items(smallvec![P(ast::Item {
776-
ident: Ident::empty(),
777-
attrs: ast::AttrVec::new(),
778-
id: ast::DUMMY_NODE_ID,
779-
kind: ast::ItemKind::GlobalAsm(Box::new(inline_asm)),
780-
vis: ast::Visibility {
781-
span: sp.shrink_to_lo(),
782-
kind: ast::VisibilityKind::Inherited,
779+
) -> MacroExpanderResult<'cx> {
780+
ExpandResult::Ready(match parse_args(ecx, sp, tts, true) {
781+
Ok(args) => {
782+
let ExpandResult::Ready(mac) = expand_preparsed_asm(ecx, args) else {
783+
return ExpandResult::Retry(());
784+
};
785+
match mac {
786+
Ok(inline_asm) => MacEager::items(smallvec![P(ast::Item {
787+
ident: Ident::empty(),
788+
attrs: ast::AttrVec::new(),
789+
id: ast::DUMMY_NODE_ID,
790+
kind: ast::ItemKind::GlobalAsm(Box::new(inline_asm)),
791+
vis: ast::Visibility {
792+
span: sp.shrink_to_lo(),
793+
kind: ast::VisibilityKind::Inherited,
794+
tokens: None,
795+
},
796+
span: sp,
783797
tokens: None,
784-
},
785-
span: sp,
786-
tokens: None,
787-
})]),
788-
Err(guar) => DummyResult::any(sp, guar),
789-
},
798+
})]),
799+
Err(guar) => DummyResult::any(sp, guar),
800+
}
801+
}
790802
Err(err) => {
791803
let guar = err.emit();
792804
DummyResult::any(sp, guar)
793805
}
794-
}
806+
})
795807
}

compiler/rustc_builtin_macros/src/assert.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_ast::tokenstream::{DelimSpan, TokenStream};
99
use rustc_ast::{DelimArgs, Expr, ExprKind, MacCall, Path, PathSegment, UnOp};
1010
use rustc_ast_pretty::pprust;
1111
use rustc_errors::PResult;
12-
use rustc_expand::base::{DummyResult, ExtCtxt, MacEager, MacResult};
12+
use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult};
1313
use rustc_parse::parser::Parser;
1414
use rustc_span::symbol::{sym, Ident, Symbol};
1515
use rustc_span::{Span, DUMMY_SP};
@@ -19,12 +19,12 @@ pub fn expand_assert<'cx>(
1919
cx: &'cx mut ExtCtxt<'_>,
2020
span: Span,
2121
tts: TokenStream,
22-
) -> Box<dyn MacResult + 'cx> {
22+
) -> MacroExpanderResult<'cx> {
2323
let Assert { cond_expr, custom_message } = match parse_assert(cx, span, tts) {
2424
Ok(assert) => assert,
2525
Err(err) => {
2626
let guar = err.emit();
27-
return DummyResult::any(span, guar);
27+
return ExpandResult::Ready(DummyResult::any(span, guar));
2828
}
2929
};
3030

@@ -92,7 +92,7 @@ pub fn expand_assert<'cx>(
9292
expr_if_not(cx, call_site_span, cond_expr, then, None)
9393
};
9494

95-
MacEager::expr(expr)
95+
ExpandResult::Ready(MacEager::expr(expr))
9696
}
9797

9898
struct Assert {

compiler/rustc_builtin_macros/src/cfg.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ use rustc_ast::token;
88
use rustc_ast::tokenstream::TokenStream;
99
use rustc_attr as attr;
1010
use rustc_errors::PResult;
11-
use rustc_expand::base::{DummyResult, ExtCtxt, MacEager, MacResult};
11+
use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult};
1212
use rustc_span::Span;
1313

1414
pub fn expand_cfg(
1515
cx: &mut ExtCtxt<'_>,
1616
sp: Span,
1717
tts: TokenStream,
18-
) -> Box<dyn MacResult + 'static> {
18+
) -> MacroExpanderResult<'static> {
1919
let sp = cx.with_def_site_ctxt(sp);
2020

21-
match parse_cfg(cx, sp, tts) {
21+
ExpandResult::Ready(match parse_cfg(cx, sp, tts) {
2222
Ok(cfg) => {
2323
let matches_cfg = attr::cfg_matches(
2424
&cfg,
@@ -32,7 +32,7 @@ pub fn expand_cfg(
3232
let guar = err.emit();
3333
DummyResult::any(sp, guar)
3434
}
35-
}
35+
})
3636
}
3737

3838
fn parse_cfg<'a>(cx: &mut ExtCtxt<'a>, span: Span, tts: TokenStream) -> PResult<'a, ast::MetaItem> {

0 commit comments

Comments
 (0)