Skip to content

Commit 412628d

Browse files
authored
Merge pull request #4377 from rust-lang/rustup-2025-06-05
Automatic Rustup
2 parents d55a99a + bd898e3 commit 412628d

File tree

270 files changed

+1706
-1659
lines changed

Some content is hidden

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

270 files changed

+1706
-1659
lines changed

compiler/rustc_abi/src/layout.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
758758
niche_variants,
759759
niche_start,
760760
},
761-
tag_field: 0,
761+
tag_field: FieldIdx::new(0),
762762
variants: IndexVec::new(),
763763
},
764764
fields: FieldsShape::Arbitrary {
@@ -1072,7 +1072,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
10721072
variants: Variants::Multiple {
10731073
tag,
10741074
tag_encoding: TagEncoding::Direct,
1075-
tag_field: 0,
1075+
tag_field: FieldIdx::new(0),
10761076
variants: IndexVec::new(),
10771077
},
10781078
fields: FieldsShape::Arbitrary {

compiler/rustc_abi/src/layout/coroutine.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ pub(super) fn layout<
158158
// Build a prefix layout, including "promoting" all ineligible
159159
// locals as part of the prefix. We compute the layout of all of
160160
// these fields at once to get optimal packing.
161-
let tag_index = prefix_layouts.len();
161+
let tag_index = prefix_layouts.next_index();
162162

163163
// `variant_fields` already accounts for the reserved variants, so no need to add them.
164164
let max_discr = (variant_fields.len() - 1) as u128;
@@ -187,7 +187,7 @@ pub(super) fn layout<
187187

188188
// "a" (`0..b_start`) and "b" (`b_start..`) correspond to
189189
// "outer" and "promoted" fields respectively.
190-
let b_start = FieldIdx::new(tag_index + 1);
190+
let b_start = tag_index.plus(1);
191191
let offsets_b = IndexVec::from_raw(offsets.raw.split_off(b_start.index()));
192192
let offsets_a = offsets;
193193

compiler/rustc_abi/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1573,7 +1573,7 @@ pub enum Variants<FieldIdx: Idx, VariantIdx: Idx> {
15731573
Multiple {
15741574
tag: Scalar,
15751575
tag_encoding: TagEncoding<VariantIdx>,
1576-
tag_field: usize,
1576+
tag_field: FieldIdx,
15771577
variants: IndexVec<VariantIdx, LayoutData<FieldIdx, VariantIdx>>,
15781578
},
15791579
}

compiler/rustc_ast/src/tokenstream.rs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ impl TokenTree {
5757
match (self, other) {
5858
(TokenTree::Token(token, _), TokenTree::Token(token2, _)) => token.kind == token2.kind,
5959
(TokenTree::Delimited(.., delim, tts), TokenTree::Delimited(.., delim2, tts2)) => {
60-
delim == delim2 && tts.eq_unspanned(tts2)
60+
delim == delim2
61+
&& tts.len() == tts2.len()
62+
&& tts.iter().zip(tts2.iter()).all(|(a, b)| a.eq_unspanned(b))
6163
}
6264
_ => false,
6365
}
@@ -694,18 +696,6 @@ impl TokenStream {
694696
TokenStreamIter::new(self)
695697
}
696698

697-
/// Compares two `TokenStream`s, checking equality without regarding span information.
698-
pub fn eq_unspanned(&self, other: &TokenStream) -> bool {
699-
let mut iter1 = self.iter();
700-
let mut iter2 = other.iter();
701-
for (tt1, tt2) in iter::zip(&mut iter1, &mut iter2) {
702-
if !tt1.eq_unspanned(tt2) {
703-
return false;
704-
}
705-
}
706-
iter1.next().is_none() && iter2.next().is_none()
707-
}
708-
709699
/// Create a token stream containing a single token with alone spacing. The
710700
/// spacing used for the final token in a constructed stream doesn't matter
711701
/// because it's never used. In practice we arbitrarily use

compiler/rustc_ast/src/visit.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ pub enum LifetimeCtxt {
121121
/// explicitly, you need to override each method. (And you also need
122122
/// to monitor future changes to `Visitor` in case a new method with a
123123
/// new default implementation gets introduced.)
124+
///
125+
/// Every `walk_*` method uses deconstruction to access fields of structs and
126+
/// enums. This will result in a compile error if a field is added, which makes
127+
/// it more likely the appropriate visit call will be added for it.
124128
pub trait Visitor<'ast>: Sized {
125129
/// The result type of the `visit_*` methods. Can be either `()`,
126130
/// or `ControlFlow<T>`.

compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ fn parse_unstable<'a>(
5353

5454
for param in list.mixed() {
5555
let param_span = param.span();
56-
if let Some(ident) = param.meta_item().and_then(|i| i.path_without_args().word()) {
56+
if let Some(ident) = param.meta_item().and_then(|i| i.path().word()) {
5757
res.push(ident.name);
5858
} else {
5959
cx.emit_err(session_diagnostics::ExpectsFeatures {

compiler/rustc_attr_parsing/src/attributes/deprecation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl SingleAttributeParser for DeprecationParser {
7979
return None;
8080
};
8181

82-
let ident_name = param.path_without_args().word_sym();
82+
let ident_name = param.path().word_sym();
8383

8484
match ident_name {
8585
Some(name @ sym::since) => {
@@ -102,7 +102,7 @@ impl SingleAttributeParser for DeprecationParser {
102102
_ => {
103103
cx.emit_err(session_diagnostics::UnknownMetaItem {
104104
span: param_span,
105-
item: param.path_without_args().to_string(),
105+
item: param.path().to_string(),
106106
expected: if features.deprecated_suggestion() {
107107
&["since", "note", "suggestion"]
108108
} else {

compiler/rustc_attr_parsing/src/attributes/repr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ fn parse_repr(cx: &AcceptContext<'_>, param: &MetaItemParser<'_>) -> Option<Repr
9696

9797
// FIXME(jdonszelmann): invert the parsing here to match on the word first and then the
9898
// structure.
99-
let (name, ident_span) = if let Some(ident) = param.path_without_args().word() {
99+
let (name, ident_span) = if let Some(ident) = param.path().word() {
100100
(Some(ident.name), ident.span)
101101
} else {
102102
(None, DUMMY_SP)

compiler/rustc_attr_parsing/src/attributes/stability.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ fn insert_value_into_option_or_error(
204204
if item.is_some() {
205205
cx.emit_err(session_diagnostics::MultipleItem {
206206
span: param.span(),
207-
item: param.path_without_args().to_string(),
207+
item: param.path().to_string(),
208208
});
209209
None
210210
} else if let Some(v) = param.args().name_value()
@@ -242,13 +242,13 @@ pub(crate) fn parse_stability(
242242
return None;
243243
};
244244

245-
match param.path_without_args().word_sym() {
245+
match param.path().word_sym() {
246246
Some(sym::feature) => insert_value_into_option_or_error(cx, &param, &mut feature)?,
247247
Some(sym::since) => insert_value_into_option_or_error(cx, &param, &mut since)?,
248248
_ => {
249249
cx.emit_err(session_diagnostics::UnknownMetaItem {
250250
span: param_span,
251-
item: param.path_without_args().to_string(),
251+
item: param.path().to_string(),
252252
expected: &["feature", "since"],
253253
});
254254
return None;
@@ -310,7 +310,7 @@ pub(crate) fn parse_unstability(
310310
return None;
311311
};
312312

313-
match param.path_without_args().word_sym() {
313+
match param.path().word_sym() {
314314
Some(sym::feature) => insert_value_into_option_or_error(cx, &param, &mut feature)?,
315315
Some(sym::reason) => insert_value_into_option_or_error(cx, &param, &mut reason)?,
316316
Some(sym::issue) => {
@@ -349,7 +349,7 @@ pub(crate) fn parse_unstability(
349349
_ => {
350350
cx.emit_err(session_diagnostics::UnknownMetaItem {
351351
span: param.span(),
352-
item: param.path_without_args().to_string(),
352+
item: param.path().to_string(),
353353
expected: &["feature", "reason", "issue", "soft", "implied_by"],
354354
});
355355
return None;

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ impl<'sess> AttributeParser<'sess> {
264264
// }
265265
ast::AttrKind::Normal(n) => {
266266
let parser = MetaItemParser::from_attr(n, self.dcx());
267-
let (path, args) = parser.deconstruct();
267+
let path = parser.path();
268+
let args = parser.args();
268269
let parts = path.segments().map(|i| i.name).collect::<Vec<_>>();
269270

270271
if let Some(accept) = ATTRIBUTE_MAPPING.0.get(parts.as_slice()) {

compiler/rustc_attr_parsing/src/parser.rs

Lines changed: 8 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -252,35 +252,18 @@ impl<'a> MetaItemParser<'a> {
252252
}
253253
}
254254

255-
/// Gets just the path, without the args.
256-
pub fn path_without_args(&self) -> PathParser<'a> {
257-
self.path.clone()
258-
}
259-
260-
/// Gets just the args parser, without caring about the path.
261-
pub fn args(&self) -> &ArgParser<'a> {
262-
&self.args
263-
}
264-
265-
pub fn deconstruct(&self) -> (PathParser<'a>, &ArgParser<'a>) {
266-
(self.path_without_args(), self.args())
267-
}
268-
269-
/// Asserts that this MetaItem starts with a path. Some examples:
255+
/// Gets just the path, without the args. Some examples:
270256
///
271257
/// - `#[rustfmt::skip]`: `rustfmt::skip` is a path
272258
/// - `#[allow(clippy::complexity)]`: `clippy::complexity` is a path
273259
/// - `#[inline]`: `inline` is a single segment path
274-
pub fn path(&self) -> (PathParser<'a>, &ArgParser<'a>) {
275-
self.deconstruct()
260+
pub fn path(&self) -> &PathParser<'a> {
261+
&self.path
276262
}
277263

278-
/// Asserts that this MetaItem starts with a word, or single segment path.
279-
/// Doesn't return the args parser.
280-
///
281-
/// For examples. see [`Self::word`]
282-
pub fn word_without_args(&self) -> Option<Ident> {
283-
Some(self.word()?.0)
264+
/// Gets just the args parser, without caring about the path.
265+
pub fn args(&self) -> &ArgParser<'a> {
266+
&self.args
284267
}
285268

286269
/// Asserts that this MetaItem starts with a word, or single segment path.
@@ -289,23 +272,8 @@ impl<'a> MetaItemParser<'a> {
289272
/// - `#[inline]`: `inline` is a word
290273
/// - `#[rustfmt::skip]`: `rustfmt::skip` is a path,
291274
/// and not a word and should instead be parsed using [`path`](Self::path)
292-
pub fn word(&self) -> Option<(Ident, &ArgParser<'a>)> {
293-
let (path, args) = self.deconstruct();
294-
Some((path.word()?, args))
295-
}
296-
297-
/// Asserts that this MetaItem starts with some specific word.
298-
///
299-
/// See [`word`](Self::word) for examples of what a word is.
300275
pub fn word_is(&self, sym: Symbol) -> Option<&ArgParser<'a>> {
301-
self.path_without_args().word_is(sym).then(|| self.args())
302-
}
303-
304-
/// Asserts that this MetaItem starts with some specific path.
305-
///
306-
/// See [`word`](Self::path) for examples of what a word is.
307-
pub fn path_is(&self, segments: &[Symbol]) -> Option<&ArgParser<'a>> {
308-
self.path_without_args().segments_is(segments).then(|| self.args())
276+
self.path().word_is(sym).then(|| self.args())
309277
}
310278
}
311279

@@ -548,7 +516,7 @@ impl<'a> MetaItemListParser<'a> {
548516
}
549517

550518
/// Lets you pick and choose as what you want to parse each element in the list
551-
pub fn mixed<'s>(&'s self) -> impl Iterator<Item = &'s MetaItemOrLitParser<'a>> + 's {
519+
pub fn mixed(&self) -> impl Iterator<Item = &MetaItemOrLitParser<'a>> {
552520
self.sub_parsers.iter()
553521
}
554522

@@ -560,20 +528,6 @@ impl<'a> MetaItemListParser<'a> {
560528
self.len() == 0
561529
}
562530

563-
/// Asserts that every item in the list is another list starting with a word.
564-
///
565-
/// See [`MetaItemParser::word`] for examples of words.
566-
pub fn all_word_list<'s>(&'s self) -> Option<Vec<(Ident, &'s ArgParser<'a>)>> {
567-
self.mixed().map(|i| i.meta_item()?.word()).collect()
568-
}
569-
570-
/// Asserts that every item in the list is another list starting with a full path.
571-
///
572-
/// See [`MetaItemParser::path`] for examples of paths.
573-
pub fn all_path_list<'s>(&'s self) -> Option<Vec<(PathParser<'a>, &'s ArgParser<'a>)>> {
574-
self.mixed().map(|i| Some(i.meta_item()?.path())).collect()
575-
}
576-
577531
/// Returns Some if the list contains only a single element.
578532
///
579533
/// Inside the Some is the parser to parse this single element.

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3314,7 +3314,13 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
33143314
"function parameter".to_string(),
33153315
"function parameter borrowed here".to_string(),
33163316
),
3317-
LocalKind::Temp if self.body.local_decls[local].is_user_variable() => {
3317+
LocalKind::Temp
3318+
if self.body.local_decls[local].is_user_variable()
3319+
&& !self.body.local_decls[local]
3320+
.source_info
3321+
.span
3322+
.in_external_macro(self.infcx.tcx.sess.source_map()) =>
3323+
{
33183324
("local binding".to_string(), "local binding introduced here".to_string())
33193325
}
33203326
LocalKind::ReturnPointer | LocalKind::Temp => {

compiler/rustc_codegen_cranelift/src/discriminant.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub(crate) fn codegen_set_discriminant<'tcx>(
2828
tag_encoding: TagEncoding::Direct,
2929
variants: _,
3030
} => {
31-
let ptr = place.place_field(fx, FieldIdx::new(tag_field));
31+
let ptr = place.place_field(fx, tag_field);
3232
let to = layout.ty.discriminant_for_variant(fx.tcx, variant_index).unwrap().val;
3333
let to = match ptr.layout().ty.kind() {
3434
ty::Uint(UintTy::U128) | ty::Int(IntTy::I128) => {
@@ -53,7 +53,7 @@ pub(crate) fn codegen_set_discriminant<'tcx>(
5353
variants: _,
5454
} => {
5555
if variant_index != untagged_variant {
56-
let niche = place.place_field(fx, FieldIdx::new(tag_field));
56+
let niche = place.place_field(fx, tag_field);
5757
let niche_type = fx.clif_type(niche.layout().ty).unwrap();
5858
let niche_value = variant_index.as_u32() - niche_variants.start().as_u32();
5959
let niche_value = (niche_value as u128).wrapping_add(niche_start);
@@ -118,7 +118,7 @@ pub(crate) fn codegen_get_discriminant<'tcx>(
118118
let cast_to = fx.clif_type(dest_layout.ty).unwrap();
119119

120120
// Read the tag/niche-encoded discriminant from memory.
121-
let tag = value.value_field(fx, FieldIdx::new(tag_field));
121+
let tag = value.value_field(fx, tag_field);
122122
let tag = tag.load_scalar(fx);
123123

124124
// Decode the discriminant (specifically if it's niche-encoded).

compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::borrow::Cow;
22

33
use libc::c_uint;
4-
use rustc_abi::{Align, Endian, Size, TagEncoding, VariantIdx, Variants};
4+
use rustc_abi::{Align, Endian, FieldIdx, Size, TagEncoding, VariantIdx, Variants};
55
use rustc_codegen_ssa::debuginfo::type_names::compute_debuginfo_type_name;
66
use rustc_codegen_ssa::debuginfo::{tag_base_type, wants_c_like_enum_debuginfo};
77
use rustc_codegen_ssa::traits::{ConstCodegenMethods, MiscCodegenMethods};
@@ -401,7 +401,7 @@ fn build_union_fields_for_enum<'ll, 'tcx>(
401401
enum_type_and_layout: TyAndLayout<'tcx>,
402402
enum_type_di_node: &'ll DIType,
403403
variant_indices: impl Iterator<Item = VariantIdx> + Clone,
404-
tag_field: usize,
404+
tag_field: FieldIdx,
405405
untagged_variant_index: Option<VariantIdx>,
406406
) -> SmallVec<&'ll DIType> {
407407
let tag_base_type = tag_base_type(cx.tcx, enum_type_and_layout);
@@ -805,7 +805,7 @@ fn build_union_fields_for_direct_tag_enum_or_coroutine<'ll, 'tcx>(
805805
variant_field_infos: &[VariantFieldInfo<'ll>],
806806
discr_type_di_node: &'ll DIType,
807807
tag_base_type: Ty<'tcx>,
808-
tag_field: usize,
808+
tag_field: FieldIdx,
809809
untagged_variant_index: Option<VariantIdx>,
810810
di_flags: DIFlags,
811811
) -> SmallVec<&'ll DIType> {
@@ -858,7 +858,7 @@ fn build_union_fields_for_direct_tag_enum_or_coroutine<'ll, 'tcx>(
858858
}));
859859

860860
assert_eq!(
861-
cx.size_and_align_of(enum_type_and_layout.field(cx, tag_field).ty),
861+
cx.size_and_align_of(enum_type_and_layout.field(cx, tag_field.as_usize()).ty),
862862
cx.size_and_align_of(self::tag_base_type(cx.tcx, enum_type_and_layout))
863863
);
864864

@@ -875,7 +875,7 @@ fn build_union_fields_for_direct_tag_enum_or_coroutine<'ll, 'tcx>(
875875
Endian::Big => (8, 0),
876876
};
877877

878-
let tag_field_offset = enum_type_and_layout.fields.offset(tag_field).bytes();
878+
let tag_field_offset = enum_type_and_layout.fields.offset(tag_field.as_usize()).bytes();
879879
let lo_offset = Size::from_bytes(tag_field_offset + lo_offset);
880880
let hi_offset = Size::from_bytes(tag_field_offset + hi_offset);
881881

@@ -905,8 +905,8 @@ fn build_union_fields_for_direct_tag_enum_or_coroutine<'ll, 'tcx>(
905905
cx,
906906
enum_type_di_node,
907907
TAG_FIELD_NAME,
908-
enum_type_and_layout.field(cx, tag_field),
909-
enum_type_and_layout.fields.offset(tag_field),
908+
enum_type_and_layout.field(cx, tag_field.as_usize()),
909+
enum_type_and_layout.fields.offset(tag_field.as_usize()),
910910
di_flags,
911911
tag_base_type_di_node,
912912
None,

compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ fn build_discr_member_di_node<'ll, 'tcx>(
373373
file,
374374
UNKNOWN_LINE_NUMBER,
375375
layout,
376-
enum_or_coroutine_type_and_layout.fields.offset(tag_field),
376+
enum_or_coroutine_type_and_layout.fields.offset(tag_field.as_usize()),
377377
DIFlags::FlagArtificial,
378378
ty,
379379
))

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,14 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea
282282
}
283283
// Filter out features that are not supported by the current LLVM version
284284
("riscv32" | "riscv64", "zacas") if get_version().0 < 20 => None,
285+
(
286+
"s390x",
287+
"message-security-assist-extension12"
288+
| "concurrent-functions"
289+
| "miscellaneous-extensions-4"
290+
| "vector-enhancements-3"
291+
| "vector-packed-decimal-enhancement-3",
292+
) if get_version().0 < 20 => None,
285293
// Enable the evex512 target feature if an avx512 target feature is enabled.
286294
("x86", s) if s.starts_with("avx512") => Some(LLVMFeature::with_dependencies(
287295
s,

0 commit comments

Comments
 (0)