Skip to content

Commit ef86cbd

Browse files
committed
Auto merge of rust-lang#3639 - rust-lang:rustup-2024-05-28, r=RalfJung
Automatic Rustup
2 parents 2c1a5a7 + 54db9aa commit ef86cbd

File tree

99 files changed

+1624
-882
lines changed

Some content is hidden

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

99 files changed

+1624
-882
lines changed

Cargo.lock

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,18 @@ name = "addr2line"
77
version = "0.21.0"
88
source = "registry+https://github.com/rust-lang/crates.io-index"
99
checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb"
10+
dependencies = [
11+
"gimli 0.28.1",
12+
]
13+
14+
[[package]]
15+
name = "addr2line"
16+
version = "0.22.0"
17+
source = "registry+https://github.com/rust-lang/crates.io-index"
18+
checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678"
1019
dependencies = [
1120
"compiler_builtins",
12-
"gimli",
21+
"gimli 0.29.0",
1322
"rustc-std-workspace-alloc",
1423
"rustc-std-workspace-core",
1524
]
@@ -287,7 +296,7 @@ version = "0.3.71"
287296
source = "registry+https://github.com/rust-lang/crates.io-index"
288297
checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d"
289298
dependencies = [
290-
"addr2line",
299+
"addr2line 0.21.0",
291300
"cc",
292301
"cfg-if",
293302
"libc",
@@ -1575,6 +1584,17 @@ dependencies = [
15751584
"stable_deref_trait",
15761585
]
15771586

1587+
[[package]]
1588+
name = "gimli"
1589+
version = "0.29.0"
1590+
source = "registry+https://github.com/rust-lang/crates.io-index"
1591+
checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd"
1592+
dependencies = [
1593+
"compiler_builtins",
1594+
"rustc-std-workspace-alloc",
1595+
"rustc-std-workspace-core",
1596+
]
1597+
15781598
[[package]]
15791599
name = "glob"
15801600
version = "0.3.1"
@@ -3234,7 +3254,7 @@ dependencies = [
32343254
name = "run_make_support"
32353255
version = "0.0.0"
32363256
dependencies = [
3237-
"gimli",
3257+
"gimli 0.28.1",
32383258
"object 0.34.0",
32393259
"regex",
32403260
"similar",
@@ -4686,6 +4706,7 @@ dependencies = [
46864706
"rustc_span",
46874707
"rustc_type_ir_macros",
46884708
"smallvec",
4709+
"tracing",
46894710
]
46904711

46914712
[[package]]
@@ -5129,7 +5150,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
51295150
name = "std"
51305151
version = "0.0.0"
51315152
dependencies = [
5132-
"addr2line",
5153+
"addr2line 0.22.0",
51335154
"alloc",
51345155
"cfg-if",
51355156
"compiler_builtins",
@@ -5408,7 +5429,7 @@ version = "0.7.0"
54085429
source = "registry+https://github.com/rust-lang/crates.io-index"
54095430
checksum = "4db52ee8fec06e119b692ef3dd2c4cf621a99204c1b8c47407870ed050305b9b"
54105431
dependencies = [
5411-
"gimli",
5432+
"gimli 0.28.1",
54125433
"hashbrown",
54135434
"object 0.32.2",
54145435
"tracing",
@@ -5908,7 +5929,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
59085929
checksum = "37a19a21a537f635c16c7576f22d0f2f7d63353c1337ad4ce0d8001c7952a25b"
59095930
dependencies = [
59105931
"compiler_builtins",
5911-
"gimli",
5932+
"gimli 0.28.1",
59125933
"rustc-std-workspace-core",
59135934
]
59145935

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,13 @@ pub fn coerce_unsized_into<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
294294
}
295295
}
296296

297-
/// Returns `rhs` sufficiently masked, truncated, and/or extended so that
298-
/// it can be used to shift `lhs`.
297+
/// Returns `rhs` sufficiently masked, truncated, and/or extended so that it can be used to shift
298+
/// `lhs`: it has the same size as `lhs`, and the value, when interpreted unsigned (no matter its
299+
/// type), will not exceed the size of `lhs`.
299300
///
300-
/// Shifts in MIR are all allowed to have mismatched LHS & RHS types.
301+
/// Shifts in MIR are all allowed to have mismatched LHS & RHS types, and signed RHS.
301302
/// The shift methods in `BuilderMethods`, however, are fully homogeneous
302-
/// (both parameters and the return type are all the same type).
303+
/// (both parameters and the return type are all the same size) and assume an unsigned RHS.
303304
///
304305
/// If `is_unchecked` is false, this masks the RHS to ensure it stays in-bounds,
305306
/// as the `BuilderMethods` shifts are UB for out-of-bounds shift amounts.

compiler/rustc_codegen_ssa/src/traits/builder.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,16 @@ pub trait BuilderMethods<'a, 'tcx>:
110110
fn frem(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
111111
fn frem_fast(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
112112
fn frem_algebraic(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
113+
/// Generate a left-shift. Both operands must have the same size. The right operand must be
114+
/// interpreted as unsigned and can be assumed to be less than the size of the left operand.
113115
fn shl(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
116+
/// Generate a logical right-shift. Both operands must have the same size. The right operand
117+
/// must be interpreted as unsigned and can be assumed to be less than the size of the left
118+
/// operand.
114119
fn lshr(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
120+
/// Generate an arithmetic right-shift. Both operands must have the same size. The right operand
121+
/// must be interpreted as unsigned and can be assumed to be less than the size of the left
122+
/// operand.
115123
fn ashr(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
116124
fn unchecked_sadd(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
117125
fn unchecked_uadd(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;

compiler/rustc_expand/src/mbe/macro_rules.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ fn expand_macro<'cx>(
223223
let arm_span = rhses[i].span();
224224

225225
// rhs has holes ( `$id` and `$(...)` that need filled)
226-
let tts = match transcribe(cx, &named_matches, rhs, rhs_span, transparency) {
226+
let id = cx.current_expansion.id;
227+
let tts = match transcribe(psess, &named_matches, rhs, rhs_span, transparency, id) {
227228
Ok(tts) => tts,
228229
Err(err) => {
229230
let guar = err.emit();

compiler/rustc_expand/src/mbe/transcribe.rs

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use crate::base::ExtCtxt;
21
use crate::errors::{
32
CountRepetitionMisplaced, MetaVarExprUnrecognizedVar, MetaVarsDifSeqMatchers, MustRepeatOnce,
43
NoSyntaxVarsExprRepeat, VarStillRepeating,
@@ -9,12 +8,13 @@ use rustc_ast::mut_visit::{self, MutVisitor};
98
use rustc_ast::token::{self, Delimiter, Token, TokenKind};
109
use rustc_ast::tokenstream::{DelimSpacing, DelimSpan, Spacing, TokenStream, TokenTree};
1110
use rustc_data_structures::fx::FxHashMap;
12-
use rustc_errors::{pluralize, Diag, PResult};
11+
use rustc_errors::{pluralize, Diag, DiagCtxt, PResult};
1312
use rustc_parse::parser::ParseNtResult;
1413
use rustc_span::hygiene::{LocalExpnId, Transparency};
1514
use rustc_span::symbol::{sym, Ident, MacroRulesNormalizedIdent};
1615
use rustc_span::{with_metavar_spans, Span, SyntaxContext};
1716

17+
use rustc_session::parse::ParseSess;
1818
use smallvec::{smallvec, SmallVec};
1919
use std::mem;
2020

@@ -99,11 +99,12 @@ impl<'a> Iterator for Frame<'a> {
9999
///
100100
/// Along the way, we do some additional error checking.
101101
pub(super) fn transcribe<'a>(
102-
cx: &ExtCtxt<'a>,
102+
psess: &'a ParseSess,
103103
interp: &FxHashMap<MacroRulesNormalizedIdent, NamedMatch>,
104104
src: &mbe::Delimited,
105105
src_span: DelimSpan,
106106
transparency: Transparency,
107+
expand_id: LocalExpnId,
107108
) -> PResult<'a, TokenStream> {
108109
// Nothing for us to transcribe...
109110
if src.tts.is_empty() {
@@ -137,8 +138,9 @@ pub(super) fn transcribe<'a>(
137138
// again, and we are done transcribing.
138139
let mut result: Vec<TokenTree> = Vec::new();
139140
let mut result_stack = Vec::new();
140-
let mut marker = Marker(cx.current_expansion.id, transparency, Default::default());
141+
let mut marker = Marker(expand_id, transparency, Default::default());
141142

143+
let dcx = &psess.dcx;
142144
loop {
143145
// Look at the last frame on the stack.
144146
// If it still has a TokenTree we have not looked at yet, use that tree.
@@ -201,19 +203,17 @@ pub(super) fn transcribe<'a>(
201203
seq @ mbe::TokenTree::Sequence(_, seq_rep) => {
202204
match lockstep_iter_size(seq, interp, &repeats) {
203205
LockstepIterSize::Unconstrained => {
204-
return Err(cx
205-
.dcx()
206-
.create_err(NoSyntaxVarsExprRepeat { span: seq.span() }));
206+
return Err(dcx.create_err(NoSyntaxVarsExprRepeat { span: seq.span() }));
207207
}
208208

209209
LockstepIterSize::Contradiction(msg) => {
210210
// FIXME: this really ought to be caught at macro definition time... It
211211
// happens when two meta-variables are used in the same repetition in a
212212
// sequence, but they come from different sequence matchers and repeat
213213
// different amounts.
214-
return Err(cx
215-
.dcx()
216-
.create_err(MetaVarsDifSeqMatchers { span: seq.span(), msg }));
214+
return Err(
215+
dcx.create_err(MetaVarsDifSeqMatchers { span: seq.span(), msg })
216+
);
217217
}
218218

219219
LockstepIterSize::Constraint(len, _) => {
@@ -227,9 +227,7 @@ pub(super) fn transcribe<'a>(
227227
// FIXME: this really ought to be caught at macro definition
228228
// time... It happens when the Kleene operator in the matcher and
229229
// the body for the same meta-variable do not match.
230-
return Err(cx
231-
.dcx()
232-
.create_err(MustRepeatOnce { span: sp.entire() }));
230+
return Err(dcx.create_err(MustRepeatOnce { span: sp.entire() }));
233231
}
234232
} else {
235233
// 0 is the initial counter (we have done 0 repetitions so far). `len`
@@ -274,7 +272,7 @@ pub(super) fn transcribe<'a>(
274272
MatchedSingle(ParseNtResult::Tt(tt)) => {
275273
// `tt`s are emitted into the output stream directly as "raw tokens",
276274
// without wrapping them into groups.
277-
maybe_use_metavar_location(cx, &stack, sp, tt, &mut marker)
275+
maybe_use_metavar_location(psess, &stack, sp, tt, &mut marker)
278276
}
279277
MatchedSingle(ParseNtResult::Ident(ident, is_raw)) => {
280278
marker.visit_span(&mut sp);
@@ -295,7 +293,7 @@ pub(super) fn transcribe<'a>(
295293
}
296294
MatchedSeq(..) => {
297295
// We were unable to descend far enough. This is an error.
298-
return Err(cx.dcx().create_err(VarStillRepeating { span: sp, ident }));
296+
return Err(dcx.create_err(VarStillRepeating { span: sp, ident }));
299297
}
300298
};
301299
result.push(tt)
@@ -314,7 +312,7 @@ pub(super) fn transcribe<'a>(
314312

315313
// Replace meta-variable expressions with the result of their expansion.
316314
mbe::TokenTree::MetaVarExpr(sp, expr) => {
317-
transcribe_metavar_expr(cx, expr, interp, &mut marker, &repeats, &mut result, sp)?;
315+
transcribe_metavar_expr(dcx, expr, interp, &mut marker, &repeats, &mut result, sp)?;
318316
}
319317

320318
// If we are entering a new delimiter, we push its contents to the `stack` to be
@@ -374,7 +372,7 @@ pub(super) fn transcribe<'a>(
374372
/// combine with each other and not with tokens outside of the sequence.
375373
/// - The metavariable span comes from a different crate, then we prefer the more local span.
376374
fn maybe_use_metavar_location(
377-
cx: &ExtCtxt<'_>,
375+
psess: &ParseSess,
378376
stack: &[Frame<'_>],
379377
mut metavar_span: Span,
380378
orig_tt: &TokenTree,
@@ -412,7 +410,7 @@ fn maybe_use_metavar_location(
412410
&& insert(mspans, dspan.entire(), metavar_span)
413411
}),
414412
};
415-
if no_collision || cx.source_map().is_imported(metavar_span) {
413+
if no_collision || psess.source_map().is_imported(metavar_span) {
416414
return orig_tt.clone();
417415
}
418416

@@ -573,7 +571,7 @@ fn lockstep_iter_size(
573571
/// * `[ $( ${count(foo, 1)} ),* ]` will return an error because `${count(foo, 1)}` is
574572
/// declared inside a single repetition and the index `1` implies two nested repetitions.
575573
fn count_repetitions<'a>(
576-
cx: &ExtCtxt<'a>,
574+
dcx: &'a DiagCtxt,
577575
depth_user: usize,
578576
mut matched: &NamedMatch,
579577
repeats: &[(usize, usize)],
@@ -610,7 +608,7 @@ fn count_repetitions<'a>(
610608
.and_then(|el| el.checked_sub(repeats.len()))
611609
.unwrap_or_default();
612610
if depth_user > depth_max {
613-
return Err(out_of_bounds_err(cx, depth_max + 1, sp.entire(), "count"));
611+
return Err(out_of_bounds_err(dcx, depth_max + 1, sp.entire(), "count"));
614612
}
615613

616614
// `repeats` records all of the nested levels at which we are currently
@@ -626,15 +624,15 @@ fn count_repetitions<'a>(
626624
}
627625

628626
if let MatchedSingle(_) = matched {
629-
return Err(cx.dcx().create_err(CountRepetitionMisplaced { span: sp.entire() }));
627+
return Err(dcx.create_err(CountRepetitionMisplaced { span: sp.entire() }));
630628
}
631629

632630
count(depth_user, depth_max, matched)
633631
}
634632

635633
/// Returns a `NamedMatch` item declared on the LHS given an arbitrary [Ident]
636634
fn matched_from_ident<'ctx, 'interp, 'rslt>(
637-
cx: &ExtCtxt<'ctx>,
635+
dcx: &'ctx DiagCtxt,
638636
ident: Ident,
639637
interp: &'interp FxHashMap<MacroRulesNormalizedIdent, NamedMatch>,
640638
) -> PResult<'ctx, &'rslt NamedMatch>
@@ -643,12 +641,12 @@ where
643641
{
644642
let span = ident.span;
645643
let key = MacroRulesNormalizedIdent::new(ident);
646-
interp.get(&key).ok_or_else(|| cx.dcx().create_err(MetaVarExprUnrecognizedVar { span, key }))
644+
interp.get(&key).ok_or_else(|| dcx.create_err(MetaVarExprUnrecognizedVar { span, key }))
647645
}
648646

649647
/// Used by meta-variable expressions when an user input is out of the actual declared bounds. For
650648
/// example, index(999999) in an repetition of only three elements.
651-
fn out_of_bounds_err<'a>(cx: &ExtCtxt<'a>, max: usize, span: Span, ty: &str) -> Diag<'a> {
649+
fn out_of_bounds_err<'a>(dcx: &'a DiagCtxt, max: usize, span: Span, ty: &str) -> Diag<'a> {
652650
let msg = if max == 0 {
653651
format!(
654652
"meta-variable expression `{ty}` with depth parameter \
@@ -660,11 +658,11 @@ fn out_of_bounds_err<'a>(cx: &ExtCtxt<'a>, max: usize, span: Span, ty: &str) ->
660658
must be less than {max}"
661659
)
662660
};
663-
cx.dcx().struct_span_err(span, msg)
661+
dcx.struct_span_err(span, msg)
664662
}
665663

666664
fn transcribe_metavar_expr<'a>(
667-
cx: &ExtCtxt<'a>,
665+
dcx: &'a DiagCtxt,
668666
expr: &MetaVarExpr,
669667
interp: &FxHashMap<MacroRulesNormalizedIdent, NamedMatch>,
670668
marker: &mut Marker,
@@ -679,8 +677,8 @@ fn transcribe_metavar_expr<'a>(
679677
};
680678
match *expr {
681679
MetaVarExpr::Count(original_ident, depth) => {
682-
let matched = matched_from_ident(cx, original_ident, interp)?;
683-
let count = count_repetitions(cx, depth, matched, repeats, sp)?;
680+
let matched = matched_from_ident(dcx, original_ident, interp)?;
681+
let count = count_repetitions(dcx, depth, matched, repeats, sp)?;
684682
let tt = TokenTree::token_alone(
685683
TokenKind::lit(token::Integer, sym::integer(count), None),
686684
visited_span(),
@@ -689,7 +687,7 @@ fn transcribe_metavar_expr<'a>(
689687
}
690688
MetaVarExpr::Ignore(original_ident) => {
691689
// Used to ensure that `original_ident` is present in the LHS
692-
let _ = matched_from_ident(cx, original_ident, interp)?;
690+
let _ = matched_from_ident(dcx, original_ident, interp)?;
693691
}
694692
MetaVarExpr::Index(depth) => match repeats.iter().nth_back(depth) {
695693
Some((index, _)) => {
@@ -698,7 +696,7 @@ fn transcribe_metavar_expr<'a>(
698696
visited_span(),
699697
));
700698
}
701-
None => return Err(out_of_bounds_err(cx, repeats.len(), sp.entire(), "index")),
699+
None => return Err(out_of_bounds_err(dcx, repeats.len(), sp.entire(), "index")),
702700
},
703701
MetaVarExpr::Len(depth) => match repeats.iter().nth_back(depth) {
704702
Some((_, length)) => {
@@ -707,7 +705,7 @@ fn transcribe_metavar_expr<'a>(
707705
visited_span(),
708706
));
709707
}
710-
None => return Err(out_of_bounds_err(cx, repeats.len(), sp.entire(), "len")),
708+
None => return Err(out_of_bounds_err(dcx, repeats.len(), sp.entire(), "len")),
711709
},
712710
}
713711
Ok(())

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for RemapLateBound<'_, 'tcx> {
449449
pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
450450
tcx: TyCtxt<'tcx>,
451451
impl_m_def_id: LocalDefId,
452-
) -> Result<&'tcx DefIdMap<ty::EarlyBinder<Ty<'tcx>>>, ErrorGuaranteed> {
452+
) -> Result<&'tcx DefIdMap<ty::EarlyBinder<'tcx, Ty<'tcx>>>, ErrorGuaranteed> {
453453
let impl_m = tcx.opt_associated_item(impl_m_def_id.to_def_id()).unwrap();
454454
let trait_m = tcx.opt_associated_item(impl_m.trait_item_def_id.unwrap()).unwrap();
455455
let impl_trait_ref =

compiler/rustc_hir_analysis/src/collect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
12771277
}
12781278

12791279
#[instrument(level = "debug", skip(tcx))]
1280-
fn fn_sig(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<ty::PolyFnSig<'_>> {
1280+
fn fn_sig(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_, ty::PolyFnSig<'_>> {
12811281
use rustc_hir::Node::*;
12821282
use rustc_hir::*;
12831283

0 commit comments

Comments
 (0)