Skip to content

Rollup of 8 pull requests #141662

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
May 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
9febbf8
Remove unnecessary handling of ERROR_IO_PENDING
cberner May 7, 2025
fd260d5
Add From<TryLockError> for io::Error
cberner May 20, 2025
7fdf35e
remove `visit_mt` from `ast::mut_visit`
fee1-dead May 27, 2025
dd148a0
test: convert version_check ui test to run-make
Fabian-Gruenbichler May 27, 2025
e6312c9
bump fluent-* crates
klensy May 27, 2025
29c3bab
Rename unpack to kind
compiler-errors May 24, 2025
5f3ae06
Fix some var names
compiler-errors May 24, 2025
e25cf45
triagebot: label `src/llvm-project` and `rustc_{llvm, codegen_llvm}` …
jieyouxu May 26, 2025
3f526ee
coverage: Revert "unused local file IDs" due to empty function names
Zalathar May 27, 2025
a963e6f
tests: mark option-niche-eq as fixed on LLVM 21
durin42 May 27, 2025
88b12f3
Rollup merge of #141312 - cberner:filelock_from, r=joshtriplett
matthiaskrgr May 27, 2025
16af814
Rollup merge of #141495 - compiler-errors:rename-unpack, r=fmease
matthiaskrgr May 27, 2025
732f671
Rollup merge of #141602 - jieyouxu:llvm-submodule, r=apiraino
matthiaskrgr May 27, 2025
7807f5f
Rollup merge of #141632 - fee1-dead-contrib:push-txmttkxvwqxl, r=oli-obk
matthiaskrgr May 27, 2025
09e643f
Rollup merge of #141640 - Fabian-Gruenbichler:mr/test-version-check-r…
matthiaskrgr May 27, 2025
043e498
Rollup merge of #141645 - klensy:fluent-b, r=jieyouxu
matthiaskrgr May 27, 2025
003fbf1
Rollup merge of #141650 - Zalathar:revert-unused-local-file, r=Zalathar
matthiaskrgr May 27, 2025
c7d0a61
Rollup merge of #141654 - durin42:randomly-fixed-test, r=jieyouxu
matthiaskrgr May 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 10 additions & 18 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1259,16 +1259,16 @@ dependencies = [

[[package]]
name = "fluent-bundle"
version = "0.15.3"
version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fe0a21ee80050c678013f82edf4b705fe2f26f1f9877593d13198612503f493"
checksum = "01203cb8918f5711e73891b347816d932046f95f54207710bda99beaeb423bf4"
dependencies = [
"fluent-langneg",
"fluent-syntax",
"intl-memoizer",
"intl_pluralrules",
"rustc-hash 1.1.0",
"self_cell 0.10.3",
"rustc-hash 2.1.1",
"self_cell",
"smallvec",
"unic-langid",
]
Expand All @@ -1284,11 +1284,12 @@ dependencies = [

[[package]]
name = "fluent-syntax"
version = "0.11.1"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a530c4694a6a8d528794ee9bbd8ba0122e779629ac908d15ad5a7ae7763a33d"
checksum = "54f0d287c53ffd184d04d8677f590f4ac5379785529e5e08b1c8083acdd5c198"
dependencies = [
"thiserror 1.0.69",
"memchr",
"thiserror 2.0.12",
]

[[package]]
Expand Down Expand Up @@ -1934,9 +1935,9 @@ dependencies = [

[[package]]
name = "intl-memoizer"
version = "0.5.2"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe22e020fce238ae18a6d5d8c502ee76a52a6e880d99477657e6acc30ec57bda"
checksum = "310da2e345f5eb861e7a07ee182262e94975051db9e4223e909ba90f392f163f"
dependencies = [
"type-map",
"unic-langid",
Expand Down Expand Up @@ -4832,15 +4833,6 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"

[[package]]
name = "self_cell"
version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e14e4d63b804dc0c7ec4a1e52bcb63f02c7ac94476755aa579edac21e01f915d"
dependencies = [
"self_cell 1.2.0",
]

[[package]]
name = "self_cell"
version = "1.2.0"
Expand Down
14 changes: 3 additions & 11 deletions compiler/rustc_ast/src/mut_visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,6 @@ pub trait MutVisitor: Sized {
walk_precise_capturing_arg(self, arg);
}

fn visit_mt(&mut self, mt: &mut MutTy) {
walk_mt(self, mt);
}

fn visit_expr_field(&mut self, f: &mut ExprField) {
walk_expr_field(self, f);
}
Expand Down Expand Up @@ -519,10 +515,10 @@ pub fn walk_ty<T: MutVisitor>(vis: &mut T, ty: &mut P<Ty>) {
TyKind::Infer | TyKind::ImplicitSelf | TyKind::Dummy | TyKind::Never | TyKind::CVarArgs => {
}
TyKind::Slice(ty) => vis.visit_ty(ty),
TyKind::Ptr(mt) => vis.visit_mt(mt),
TyKind::Ref(lt, mt) | TyKind::PinnedRef(lt, mt) => {
TyKind::Ptr(MutTy { ty, mutbl: _ }) => vis.visit_ty(ty),
TyKind::Ref(lt, MutTy { ty, mutbl: _ }) | TyKind::PinnedRef(lt, MutTy { ty, mutbl: _ }) => {
visit_opt(lt, |lt| vis.visit_lifetime(lt));
vis.visit_mt(mt);
vis.visit_ty(ty);
}
TyKind::BareFn(bft) => {
let BareFnTy { safety, ext: _, generic_params, decl, decl_span } = bft.deref_mut();
Expand Down Expand Up @@ -1003,10 +999,6 @@ pub fn walk_flat_map_expr_field<T: MutVisitor>(
smallvec![f]
}

fn walk_mt<T: MutVisitor>(vis: &mut T, MutTy { ty, mutbl: _ }: &mut MutTy) {
vis.visit_ty(ty);
}

pub fn walk_block<T: MutVisitor>(vis: &mut T, block: &mut P<Block>) {
let Block { id, stmts, rules: _, span, tokens: _ } = block.deref_mut();
vis.visit_id(id);
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_borrowck/src/diagnostics/region_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,8 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
hir_args: &'hir hir::GenericArgs<'hir>,
search_stack: &mut Vec<(Ty<'tcx>, &'hir hir::Ty<'hir>)>,
) -> Option<&'hir hir::Lifetime> {
for (kind, hir_arg) in iter::zip(args, hir_args.args) {
match (kind.unpack(), hir_arg) {
for (arg, hir_arg) in iter::zip(args, hir_args.args) {
match (arg.kind(), hir_arg) {
(GenericArgKind::Lifetime(r), hir::GenericArg::Lifetime(lt)) => {
if r.as_var() == needle_fr {
return Some(lt);
Expand All @@ -631,7 +631,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
) => {
self.dcx().span_delayed_bug(
hir_arg.span(),
format!("unmatched arg and hir arg: found {kind:?} vs {hir_arg:?}"),
format!("unmatched arg and hir arg: found {arg:?} vs {hir_arg:?}"),
);
}
}
Expand Down Expand Up @@ -997,7 +997,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
) -> bool {
let tcx = self.infcx.tcx;
ty.walk().any(|arg| {
if let ty::GenericArgKind::Type(ty) = arg.unpack()
if let ty::GenericArgKind::Type(ty) = arg.kind()
&& let ty::Param(_) = ty.kind()
{
clauses.iter().any(|pred| {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {

let mut next_outlives_predicates = vec![];
for (ty::OutlivesPredicate(k1, r2), constraint_category) in outlives_predicates {
match k1.unpack() {
match k1.kind() {
GenericArgKind::Lifetime(r1) => {
let r1_vid = self.to_region_vid(r1);
let r2_vid = self.to_region_vid(r2);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/type_check/opaque_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ fn register_member_constraints<'tcx>(
.iter()
.enumerate()
.filter(|(i, _)| variances[*i] == ty::Invariant)
.filter_map(|(_, arg)| match arg.unpack() {
.filter_map(|(_, arg)| match arg.kind() {
GenericArgKind::Lifetime(r) => Some(typeck.to_region_vid(r)),
GenericArgKind::Type(_) | GenericArgKind::Const(_) => None,
})
Expand Down
26 changes: 5 additions & 21 deletions compiler/rustc_codegen_llvm/src/coverageinfo/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,20 +155,6 @@ pub(crate) struct Regions {
impl Regions {
/// Returns true if none of this structure's tables contain any regions.
pub(crate) fn has_no_regions(&self) -> bool {
// Every region has a span, so if there are no spans then there are no regions.
self.all_cov_spans().next().is_none()
}

pub(crate) fn all_cov_spans(&self) -> impl Iterator<Item = &CoverageSpan> {
macro_rules! iter_cov_spans {
( $( $regions:expr ),* $(,)? ) => {
std::iter::empty()
$(
.chain( $regions.iter().map(|region| &region.cov_span) )
)*
}
}

let Self {
code_regions,
expansion_regions,
Expand All @@ -177,13 +163,11 @@ impl Regions {
mcdc_decision_regions,
} = self;

iter_cov_spans!(
code_regions,
expansion_regions,
branch_regions,
mcdc_branch_regions,
mcdc_decision_regions,
)
code_regions.is_empty()
&& expansion_regions.is_empty()
&& branch_regions.is_empty()
&& mcdc_branch_regions.is_empty()
&& mcdc_decision_regions.is_empty()
}
}

Expand Down
44 changes: 10 additions & 34 deletions compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/covfun.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use rustc_abi::Align;
use rustc_codegen_ssa::traits::{
BaseTypeCodegenMethods as _, ConstCodegenMethods, StaticCodegenMethods,
};
use rustc_index::IndexVec;
use rustc_middle::mir::coverage::{
BasicCoverageBlock, CovTerm, CoverageIdsInfo, Expression, FunctionCoverageInfo, Mapping,
MappingKind, Op,
Expand Down Expand Up @@ -105,16 +104,6 @@ fn fill_region_tables<'tcx>(
ids_info: &'tcx CoverageIdsInfo,
covfun: &mut CovfunRecord<'tcx>,
) {
// If this function is unused, replace all counters with zero.
let counter_for_bcb = |bcb: BasicCoverageBlock| -> ffi::Counter {
let term = if covfun.is_used {
ids_info.term_for_bcb[bcb].expect("every BCB in a mapping was given a term")
} else {
CovTerm::Zero
};
ffi::Counter::from_term(term)
};

// Currently a function's mappings must all be in the same file, so use the
// first mapping's span to determine the file.
let source_map = tcx.sess.source_map();
Expand All @@ -126,12 +115,6 @@ fn fill_region_tables<'tcx>(

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

// If this testing flag is set, add an extra unused entry to the local
// file table, to help test the code for detecting unused file IDs.
if tcx.sess.coverage_inject_unused_local_file() {
covfun.virtual_file_mapping.push_file(&source_file);
}

// In rare cases, _all_ of a function's spans are discarded, and coverage
// codegen needs to handle that gracefully to avoid #133606.
// It's hard for tests to trigger this organically, so instead we set
Expand All @@ -152,6 +135,16 @@ fn fill_region_tables<'tcx>(
// For each counter/region pair in this function+file, convert it to a
// form suitable for FFI.
for &Mapping { ref kind, span } in &fn_cov_info.mappings {
// If this function is unused, replace all counters with zero.
let counter_for_bcb = |bcb: BasicCoverageBlock| -> ffi::Counter {
let term = if covfun.is_used {
ids_info.term_for_bcb[bcb].expect("every BCB in a mapping was given a term")
} else {
CovTerm::Zero
};
ffi::Counter::from_term(term)
};

let Some(coords) = make_coords(span) else { continue };
let cov_span = coords.make_coverage_span(local_file_id);

Expand Down Expand Up @@ -184,19 +177,6 @@ fn fill_region_tables<'tcx>(
}
}

/// LLVM requires all local file IDs to have at least one mapping region.
/// If that's not the case, skip this function, to avoid an assertion failure
/// (or worse) in LLVM.
fn check_local_file_table(covfun: &CovfunRecord<'_>) -> bool {
let mut local_file_id_seen =
IndexVec::<u32, _>::from_elem_n(false, covfun.virtual_file_mapping.local_file_table.len());
for cov_span in covfun.regions.all_cov_spans() {
local_file_id_seen[cov_span.file_id] = true;
}

local_file_id_seen.into_iter().all(|seen| seen)
}

/// Generates the contents of the covfun record for this function, which
/// contains the function's coverage mapping data. The record is then stored
/// as a global variable in the `__llvm_covfun` section.
Expand All @@ -205,10 +185,6 @@ pub(crate) fn generate_covfun_record<'tcx>(
global_file_table: &GlobalFileTable,
covfun: &CovfunRecord<'tcx>,
) {
if !check_local_file_table(covfun) {
return;
}

let &CovfunRecord {
mangled_function_name,
source_hash,
Expand Down
28 changes: 24 additions & 4 deletions compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/spans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ impl Coords {
/// or other expansions), and if it does happen then skipping a span or function is
/// better than an ICE or `llvm-cov` failure that the user might have no way to avoid.
pub(crate) fn make_coords(source_map: &SourceMap, file: &SourceFile, span: Span) -> Option<Coords> {
if span.is_empty() {
debug_assert!(false, "can't make coords from empty span: {span:?}");
return None;
}
let span = ensure_non_empty_span(source_map, span)?;

let lo = span.lo();
let hi = span.hi();
Expand Down Expand Up @@ -73,6 +70,29 @@ pub(crate) fn make_coords(source_map: &SourceMap, file: &SourceFile, span: Span)
})
}

fn ensure_non_empty_span(source_map: &SourceMap, span: Span) -> Option<Span> {
if !span.is_empty() {
return Some(span);
}

// The span is empty, so try to enlarge it to cover an adjacent '{' or '}'.
source_map
.span_to_source(span, |src, start, end| try {
// Adjusting span endpoints by `BytePos(1)` is normally a bug,
// but in this case we have specifically checked that the character
// we're skipping over is one of two specific ASCII characters, so
// adjusting by exactly 1 byte is correct.
if src.as_bytes().get(end).copied() == Some(b'{') {
Some(span.with_hi(span.hi() + BytePos(1)))
} else if start > 0 && src.as_bytes()[start - 1] == b'}' {
Some(span.with_lo(span.lo() - BytePos(1)))
} else {
None
}
})
.ok()?
}

/// If `llvm-cov` sees a source region that is improperly ordered (end < start),
/// it will immediately exit with a fatal error. To prevent that from happening,
/// discard regions that are improperly ordered, or might be interpreted in a
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/meth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ fn dyn_trait_in_self<'tcx>(
ty: Ty<'tcx>,
) -> Option<ty::ExistentialTraitRef<'tcx>> {
for arg in ty.peel_refs().walk() {
if let GenericArgKind::Type(ty) = arg.unpack()
if let GenericArgKind::Type(ty) = arg.kind()
&& let ty::Dynamic(data, _, _) = ty.kind()
{
// FIXME(arbitrary_self_types): This is likely broken for receivers which
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/check_consts/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ fn build_error_for_const_call<'tcx>(
let mut sugg = None;

if ccx.tcx.is_lang_item(trait_id, LangItem::PartialEq) {
match (args[0].unpack(), args[1].unpack()) {
match (args[0].kind(), args[1].kind()) {
(GenericArgKind::Type(self_ty), GenericArgKind::Type(rhs_ty))
if self_ty == rhs_ty
&& self_ty.is_ref()
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/util/type_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
) -> Result<(), PrintError> {
print_prefix(self)?;
let args =
args.iter().cloned().filter(|arg| !matches!(arg.unpack(), GenericArgKind::Lifetime(_)));
args.iter().cloned().filter(|arg| !matches!(arg.kind(), GenericArgKind::Lifetime(_)));
if args.clone().next().is_some() {
self.generic_delimiters(|cx| cx.comma_sep(args))
} else {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_error_messages/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ edition = "2024"

[dependencies]
# tidy-alphabetical-start
fluent-bundle = "0.15.2"
fluent-syntax = "0.11"
fluent-bundle = "0.16"
fluent-syntax = "0.12"
icu_list = "1.2"
icu_locid = "1.2"
icu_provider_adapters = "1.2"
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_fluent_macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ proc-macro = true
[dependencies]
# tidy-alphabetical-start
annotate-snippets = "0.11"
fluent-bundle = "0.15.2"
fluent-syntax = "0.11"
fluent-bundle = "0.16"
fluent-syntax = "0.12"
proc-macro2 = "1"
quote = "1"
syn = { version = "2", features = ["full"] }
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/check/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1575,7 +1575,7 @@ fn check_type_alias_type_params_are_used<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalD

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

let mut label_match = |ty: Ty<'_>, span| {
for arg in ty.walk() {
if let ty::GenericArgKind::Type(ty) = arg.unpack()
if let ty::GenericArgKind::Type(ty) = arg.kind()
&& let ty::Alias(
ty::Opaque,
ty::AliasTy { def_id: captured_def_id, .. },
Expand Down
Loading
Loading