Skip to content

Commit 45f256d

Browse files
committed
Auto merge of #141662 - matthiaskrgr:rollup-9kt4zj7, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #141312 (Add From<TryLockError> for io::Error) - #141495 (Rename `{GenericArg,Term}::unpack()` to `kind()`) - #141602 (triagebot: label LLVM submodule changes with `A-LLVM`) - #141632 (remove `visit_mt` from `ast::mut_visit`) - #141640 (test: convert version_check ui test to run-make) - #141645 (bump fluent-* crates) - #141650 (coverage: Revert "unused local file IDs" due to empty function names) - #141654 (tests: mark option-niche-eq as fixed on LLVM 21) Failed merges: - #141430 (remove `visit_clobber` and move `DummyAstNode` to `rustc_expand`) - #141636 (avoid some usages of `&mut P<T>` in AST visitors) r? `@ghost` `@rustbot` modify labels: rollup
2 parents c583fa6 + c7d0a61 commit 45f256d

File tree

112 files changed

+336
-413
lines changed

Some content is hidden

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

112 files changed

+336
-413
lines changed

Cargo.lock

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,16 +1259,16 @@ dependencies = [
12591259

12601260
[[package]]
12611261
name = "fluent-bundle"
1262-
version = "0.15.3"
1262+
version = "0.16.0"
12631263
source = "registry+https://github.com/rust-lang/crates.io-index"
1264-
checksum = "7fe0a21ee80050c678013f82edf4b705fe2f26f1f9877593d13198612503f493"
1264+
checksum = "01203cb8918f5711e73891b347816d932046f95f54207710bda99beaeb423bf4"
12651265
dependencies = [
12661266
"fluent-langneg",
12671267
"fluent-syntax",
12681268
"intl-memoizer",
12691269
"intl_pluralrules",
1270-
"rustc-hash 1.1.0",
1271-
"self_cell 0.10.3",
1270+
"rustc-hash 2.1.1",
1271+
"self_cell",
12721272
"smallvec",
12731273
"unic-langid",
12741274
]
@@ -1284,11 +1284,12 @@ dependencies = [
12841284

12851285
[[package]]
12861286
name = "fluent-syntax"
1287-
version = "0.11.1"
1287+
version = "0.12.0"
12881288
source = "registry+https://github.com/rust-lang/crates.io-index"
1289-
checksum = "2a530c4694a6a8d528794ee9bbd8ba0122e779629ac908d15ad5a7ae7763a33d"
1289+
checksum = "54f0d287c53ffd184d04d8677f590f4ac5379785529e5e08b1c8083acdd5c198"
12901290
dependencies = [
1291-
"thiserror 1.0.69",
1291+
"memchr",
1292+
"thiserror 2.0.12",
12921293
]
12931294

12941295
[[package]]
@@ -1934,9 +1935,9 @@ dependencies = [
19341935

19351936
[[package]]
19361937
name = "intl-memoizer"
1937-
version = "0.5.2"
1938+
version = "0.5.3"
19381939
source = "registry+https://github.com/rust-lang/crates.io-index"
1939-
checksum = "fe22e020fce238ae18a6d5d8c502ee76a52a6e880d99477657e6acc30ec57bda"
1940+
checksum = "310da2e345f5eb861e7a07ee182262e94975051db9e4223e909ba90f392f163f"
19401941
dependencies = [
19411942
"type-map",
19421943
"unic-langid",
@@ -4832,15 +4833,6 @@ version = "1.2.0"
48324833
source = "registry+https://github.com/rust-lang/crates.io-index"
48334834
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
48344835

4835-
[[package]]
4836-
name = "self_cell"
4837-
version = "0.10.3"
4838-
source = "registry+https://github.com/rust-lang/crates.io-index"
4839-
checksum = "e14e4d63b804dc0c7ec4a1e52bcb63f02c7ac94476755aa579edac21e01f915d"
4840-
dependencies = [
4841-
"self_cell 1.2.0",
4842-
]
4843-
48444836
[[package]]
48454837
name = "self_cell"
48464838
version = "1.2.0"

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -300,10 +300,6 @@ pub trait MutVisitor: Sized {
300300
walk_precise_capturing_arg(self, arg);
301301
}
302302

303-
fn visit_mt(&mut self, mt: &mut MutTy) {
304-
walk_mt(self, mt);
305-
}
306-
307303
fn visit_expr_field(&mut self, f: &mut ExprField) {
308304
walk_expr_field(self, f);
309305
}
@@ -519,10 +515,10 @@ pub fn walk_ty<T: MutVisitor>(vis: &mut T, ty: &mut P<Ty>) {
519515
TyKind::Infer | TyKind::ImplicitSelf | TyKind::Dummy | TyKind::Never | TyKind::CVarArgs => {
520516
}
521517
TyKind::Slice(ty) => vis.visit_ty(ty),
522-
TyKind::Ptr(mt) => vis.visit_mt(mt),
523-
TyKind::Ref(lt, mt) | TyKind::PinnedRef(lt, mt) => {
518+
TyKind::Ptr(MutTy { ty, mutbl: _ }) => vis.visit_ty(ty),
519+
TyKind::Ref(lt, MutTy { ty, mutbl: _ }) | TyKind::PinnedRef(lt, MutTy { ty, mutbl: _ }) => {
524520
visit_opt(lt, |lt| vis.visit_lifetime(lt));
525-
vis.visit_mt(mt);
521+
vis.visit_ty(ty);
526522
}
527523
TyKind::BareFn(bft) => {
528524
let BareFnTy { safety, ext: _, generic_params, decl, decl_span } = bft.deref_mut();
@@ -1003,10 +999,6 @@ pub fn walk_flat_map_expr_field<T: MutVisitor>(
1003999
smallvec![f]
10041000
}
10051001

1006-
fn walk_mt<T: MutVisitor>(vis: &mut T, MutTy { ty, mutbl: _ }: &mut MutTy) {
1007-
vis.visit_ty(ty);
1008-
}
1009-
10101002
pub fn walk_block<T: MutVisitor>(vis: &mut T, block: &mut P<Block>) {
10111003
let Block { id, stmts, rules: _, span, tokens: _ } = block.deref_mut();
10121004
vis.visit_id(id);

compiler/rustc_borrowck/src/diagnostics/region_name.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -606,8 +606,8 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
606606
hir_args: &'hir hir::GenericArgs<'hir>,
607607
search_stack: &mut Vec<(Ty<'tcx>, &'hir hir::Ty<'hir>)>,
608608
) -> Option<&'hir hir::Lifetime> {
609-
for (kind, hir_arg) in iter::zip(args, hir_args.args) {
610-
match (kind.unpack(), hir_arg) {
609+
for (arg, hir_arg) in iter::zip(args, hir_args.args) {
610+
match (arg.kind(), hir_arg) {
611611
(GenericArgKind::Lifetime(r), hir::GenericArg::Lifetime(lt)) => {
612612
if r.as_var() == needle_fr {
613613
return Some(lt);
@@ -631,7 +631,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
631631
) => {
632632
self.dcx().span_delayed_bug(
633633
hir_arg.span(),
634-
format!("unmatched arg and hir arg: found {kind:?} vs {hir_arg:?}"),
634+
format!("unmatched arg and hir arg: found {arg:?} vs {hir_arg:?}"),
635635
);
636636
}
637637
}
@@ -997,7 +997,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
997997
) -> bool {
998998
let tcx = self.infcx.tcx;
999999
ty.walk().any(|arg| {
1000-
if let ty::GenericArgKind::Type(ty) = arg.unpack()
1000+
if let ty::GenericArgKind::Type(ty) = arg.kind()
10011001
&& let ty::Param(_) = ty.kind()
10021002
{
10031003
clauses.iter().any(|pred| {

compiler/rustc_borrowck/src/type_check/constraint_conversion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
148148

149149
let mut next_outlives_predicates = vec![];
150150
for (ty::OutlivesPredicate(k1, r2), constraint_category) in outlives_predicates {
151-
match k1.unpack() {
151+
match k1.kind() {
152152
GenericArgKind::Lifetime(r1) => {
153153
let r1_vid = self.to_region_vid(r1);
154154
let r2_vid = self.to_region_vid(r2);

compiler/rustc_borrowck/src/type_check/opaque_types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ fn register_member_constraints<'tcx>(
221221
.iter()
222222
.enumerate()
223223
.filter(|(i, _)| variances[*i] == ty::Invariant)
224-
.filter_map(|(_, arg)| match arg.unpack() {
224+
.filter_map(|(_, arg)| match arg.kind() {
225225
GenericArgKind::Lifetime(r) => Some(typeck.to_region_vid(r)),
226226
GenericArgKind::Type(_) | GenericArgKind::Const(_) => None,
227227
})

compiler/rustc_codegen_llvm/src/coverageinfo/ffi.rs

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -155,20 +155,6 @@ pub(crate) struct Regions {
155155
impl Regions {
156156
/// Returns true if none of this structure's tables contain any regions.
157157
pub(crate) fn has_no_regions(&self) -> bool {
158-
// Every region has a span, so if there are no spans then there are no regions.
159-
self.all_cov_spans().next().is_none()
160-
}
161-
162-
pub(crate) fn all_cov_spans(&self) -> impl Iterator<Item = &CoverageSpan> {
163-
macro_rules! iter_cov_spans {
164-
( $( $regions:expr ),* $(,)? ) => {
165-
std::iter::empty()
166-
$(
167-
.chain( $regions.iter().map(|region| &region.cov_span) )
168-
)*
169-
}
170-
}
171-
172158
let Self {
173159
code_regions,
174160
expansion_regions,
@@ -177,13 +163,11 @@ impl Regions {
177163
mcdc_decision_regions,
178164
} = self;
179165

180-
iter_cov_spans!(
181-
code_regions,
182-
expansion_regions,
183-
branch_regions,
184-
mcdc_branch_regions,
185-
mcdc_decision_regions,
186-
)
166+
code_regions.is_empty()
167+
&& expansion_regions.is_empty()
168+
&& branch_regions.is_empty()
169+
&& mcdc_branch_regions.is_empty()
170+
&& mcdc_decision_regions.is_empty()
187171
}
188172
}
189173

compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/covfun.rs

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use rustc_abi::Align;
1111
use rustc_codegen_ssa::traits::{
1212
BaseTypeCodegenMethods as _, ConstCodegenMethods, StaticCodegenMethods,
1313
};
14-
use rustc_index::IndexVec;
1514
use rustc_middle::mir::coverage::{
1615
BasicCoverageBlock, CovTerm, CoverageIdsInfo, Expression, FunctionCoverageInfo, Mapping,
1716
MappingKind, Op,
@@ -105,16 +104,6 @@ fn fill_region_tables<'tcx>(
105104
ids_info: &'tcx CoverageIdsInfo,
106105
covfun: &mut CovfunRecord<'tcx>,
107106
) {
108-
// If this function is unused, replace all counters with zero.
109-
let counter_for_bcb = |bcb: BasicCoverageBlock| -> ffi::Counter {
110-
let term = if covfun.is_used {
111-
ids_info.term_for_bcb[bcb].expect("every BCB in a mapping was given a term")
112-
} else {
113-
CovTerm::Zero
114-
};
115-
ffi::Counter::from_term(term)
116-
};
117-
118107
// Currently a function's mappings must all be in the same file, so use the
119108
// first mapping's span to determine the file.
120109
let source_map = tcx.sess.source_map();
@@ -126,12 +115,6 @@ fn fill_region_tables<'tcx>(
126115

127116
let local_file_id = covfun.virtual_file_mapping.push_file(&source_file);
128117

129-
// If this testing flag is set, add an extra unused entry to the local
130-
// file table, to help test the code for detecting unused file IDs.
131-
if tcx.sess.coverage_inject_unused_local_file() {
132-
covfun.virtual_file_mapping.push_file(&source_file);
133-
}
134-
135118
// In rare cases, _all_ of a function's spans are discarded, and coverage
136119
// codegen needs to handle that gracefully to avoid #133606.
137120
// It's hard for tests to trigger this organically, so instead we set
@@ -152,6 +135,16 @@ fn fill_region_tables<'tcx>(
152135
// For each counter/region pair in this function+file, convert it to a
153136
// form suitable for FFI.
154137
for &Mapping { ref kind, span } in &fn_cov_info.mappings {
138+
// If this function is unused, replace all counters with zero.
139+
let counter_for_bcb = |bcb: BasicCoverageBlock| -> ffi::Counter {
140+
let term = if covfun.is_used {
141+
ids_info.term_for_bcb[bcb].expect("every BCB in a mapping was given a term")
142+
} else {
143+
CovTerm::Zero
144+
};
145+
ffi::Counter::from_term(term)
146+
};
147+
155148
let Some(coords) = make_coords(span) else { continue };
156149
let cov_span = coords.make_coverage_span(local_file_id);
157150

@@ -184,19 +177,6 @@ fn fill_region_tables<'tcx>(
184177
}
185178
}
186179

187-
/// LLVM requires all local file IDs to have at least one mapping region.
188-
/// If that's not the case, skip this function, to avoid an assertion failure
189-
/// (or worse) in LLVM.
190-
fn check_local_file_table(covfun: &CovfunRecord<'_>) -> bool {
191-
let mut local_file_id_seen =
192-
IndexVec::<u32, _>::from_elem_n(false, covfun.virtual_file_mapping.local_file_table.len());
193-
for cov_span in covfun.regions.all_cov_spans() {
194-
local_file_id_seen[cov_span.file_id] = true;
195-
}
196-
197-
local_file_id_seen.into_iter().all(|seen| seen)
198-
}
199-
200180
/// Generates the contents of the covfun record for this function, which
201181
/// contains the function's coverage mapping data. The record is then stored
202182
/// as a global variable in the `__llvm_covfun` section.
@@ -205,10 +185,6 @@ pub(crate) fn generate_covfun_record<'tcx>(
205185
global_file_table: &GlobalFileTable,
206186
covfun: &CovfunRecord<'tcx>,
207187
) {
208-
if !check_local_file_table(covfun) {
209-
return;
210-
}
211-
212188
let &CovfunRecord {
213189
mangled_function_name,
214190
source_hash,

compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/spans.rs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ impl Coords {
3939
/// or other expansions), and if it does happen then skipping a span or function is
4040
/// better than an ICE or `llvm-cov` failure that the user might have no way to avoid.
4141
pub(crate) fn make_coords(source_map: &SourceMap, file: &SourceFile, span: Span) -> Option<Coords> {
42-
if span.is_empty() {
43-
debug_assert!(false, "can't make coords from empty span: {span:?}");
44-
return None;
45-
}
42+
let span = ensure_non_empty_span(source_map, span)?;
4643

4744
let lo = span.lo();
4845
let hi = span.hi();
@@ -73,6 +70,29 @@ pub(crate) fn make_coords(source_map: &SourceMap, file: &SourceFile, span: Span)
7370
})
7471
}
7572

73+
fn ensure_non_empty_span(source_map: &SourceMap, span: Span) -> Option<Span> {
74+
if !span.is_empty() {
75+
return Some(span);
76+
}
77+
78+
// The span is empty, so try to enlarge it to cover an adjacent '{' or '}'.
79+
source_map
80+
.span_to_source(span, |src, start, end| try {
81+
// Adjusting span endpoints by `BytePos(1)` is normally a bug,
82+
// but in this case we have specifically checked that the character
83+
// we're skipping over is one of two specific ASCII characters, so
84+
// adjusting by exactly 1 byte is correct.
85+
if src.as_bytes().get(end).copied() == Some(b'{') {
86+
Some(span.with_hi(span.hi() + BytePos(1)))
87+
} else if start > 0 && src.as_bytes()[start - 1] == b'}' {
88+
Some(span.with_lo(span.lo() - BytePos(1)))
89+
} else {
90+
None
91+
}
92+
})
93+
.ok()?
94+
}
95+
7696
/// If `llvm-cov` sees a source region that is improperly ordered (end < start),
7797
/// it will immediately exit with a fatal error. To prevent that from happening,
7898
/// discard regions that are improperly ordered, or might be interpreted in a

compiler/rustc_codegen_ssa/src/meth.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ fn dyn_trait_in_self<'tcx>(
7777
ty: Ty<'tcx>,
7878
) -> Option<ty::ExistentialTraitRef<'tcx>> {
7979
for arg in ty.peel_refs().walk() {
80-
if let GenericArgKind::Type(ty) = arg.unpack()
80+
if let GenericArgKind::Type(ty) = arg.kind()
8181
&& let ty::Dynamic(data, _, _) = ty.kind()
8282
{
8383
// FIXME(arbitrary_self_types): This is likely broken for receivers which

compiler/rustc_const_eval/src/check_consts/ops.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ fn build_error_for_const_call<'tcx>(
281281
let mut sugg = None;
282282

283283
if ccx.tcx.is_lang_item(trait_id, LangItem::PartialEq) {
284-
match (args[0].unpack(), args[1].unpack()) {
284+
match (args[0].kind(), args[1].kind()) {
285285
(GenericArgKind::Type(self_ty), GenericArgKind::Type(rhs_ty))
286286
if self_ty == rhs_ty
287287
&& self_ty.is_ref()

compiler/rustc_const_eval/src/util/type_name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
125125
) -> Result<(), PrintError> {
126126
print_prefix(self)?;
127127
let args =
128-
args.iter().cloned().filter(|arg| !matches!(arg.unpack(), GenericArgKind::Lifetime(_)));
128+
args.iter().cloned().filter(|arg| !matches!(arg.kind(), GenericArgKind::Lifetime(_)));
129129
if args.clone().next().is_some() {
130130
self.generic_delimiters(|cx| cx.comma_sep(args))
131131
} else {

compiler/rustc_error_messages/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ edition = "2024"
55

66
[dependencies]
77
# tidy-alphabetical-start
8-
fluent-bundle = "0.15.2"
9-
fluent-syntax = "0.11"
8+
fluent-bundle = "0.16"
9+
fluent-syntax = "0.12"
1010
icu_list = "1.2"
1111
icu_locid = "1.2"
1212
icu_provider_adapters = "1.2"

compiler/rustc_fluent_macro/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ proc-macro = true
99
[dependencies]
1010
# tidy-alphabetical-start
1111
annotate-snippets = "0.11"
12-
fluent-bundle = "0.15.2"
13-
fluent-syntax = "0.11"
12+
fluent-bundle = "0.16"
13+
fluent-syntax = "0.12"
1414
proc-macro2 = "1"
1515
quote = "1"
1616
syn = { version = "2", features = ["full"] }

compiler/rustc_hir_analysis/src/check/check.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,7 +1575,7 @@ fn check_type_alias_type_params_are_used<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalD
15751575

15761576
let mut params_used = DenseBitSet::new_empty(generics.own_params.len());
15771577
for leaf in ty.walk() {
1578-
if let GenericArgKind::Type(leaf_ty) = leaf.unpack()
1578+
if let GenericArgKind::Type(leaf_ty) = leaf.kind()
15791579
&& let ty::Param(param) = leaf_ty.kind()
15801580
{
15811581
debug!("found use of ty param {:?}", param);
@@ -1700,7 +1700,7 @@ fn opaque_type_cycle_error(tcx: TyCtxt<'_>, opaque_def_id: LocalDefId) -> ErrorG
17001700

17011701
let mut label_match = |ty: Ty<'_>, span| {
17021702
for arg in ty.walk() {
1703-
if let ty::GenericArgKind::Type(ty) = arg.unpack()
1703+
if let ty::GenericArgKind::Type(ty) = arg.kind()
17041704
&& let ty::Alias(
17051705
ty::Opaque,
17061706
ty::AliasTy { def_id: captured_def_id, .. },

0 commit comments

Comments
 (0)