Skip to content

Rollup of 10 pull requests #144166

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 23 commits into from
Jul 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
cdeca5c
fix Zip unsoundness (again)
the8472 Apr 30, 2025
61c2c12
add comments to Zip unsoundness regression test
the8472 Jun 4, 2025
5773d38
fix: Fix TypePrintFn flag passing for autodiff codegen
KMJ-007 Jun 30, 2025
80224c3
test: Add UI tests for testing type analysis autodiff
KMJ-007 Jun 13, 2025
0a71873
panic_main.rs panic=unwind tests needs unwinding
erickt Jul 17, 2025
bf24c0d
miri sleep tests: increase slack
RalfJung Jul 17, 2025
247d4f4
Add test.
cjgillot Jul 17, 2025
c004a96
Do not check privacy for RPITIT.
cjgillot Jul 17, 2025
99507a3
update comment
lcnr Jul 18, 2025
9e4f777
bootstrap: Detect musl hosts
Gelbpunkt Jul 17, 2025
d5411f7
Ignore tests/run-make/link-eh-frame-terminator/rmake.rs when cross-co…
Jul 18, 2025
3b9c16b
Be a bit more careful around exotic cycles in in the inliner
compiler-errors Jul 9, 2025
c58e0bd
rename `emit_unless` to `emit_unless_delay`
xizheyin Jul 18, 2025
fff53f1
Rollup merge of #141076 - the8472:fix-zip-panic-safety2, r=workingjub…
matthiaskrgr Jul 19, 2025
44ee51d
Rollup merge of #142444 - KMJ-007:autodiff-codegen-test, r=ZuseZ4
matthiaskrgr Jul 19, 2025
3b4d79c
Rollup merge of #143704 - compiler-errors:cycle-exotic, r=cjgillot
matthiaskrgr Jul 19, 2025
5e2416f
Rollup merge of #144073 - erickt:ignore-test-on-fuchsia, r=lqd
matthiaskrgr Jul 19, 2025
17e2d69
Rollup merge of #144083 - RalfJung:miri-sleep, r=oli-obk
matthiaskrgr Jul 19, 2025
870d429
Rollup merge of #144092 - Gelbpunkt:musl-stage0, r=Kobzol
matthiaskrgr Jul 19, 2025
4b94717
Rollup merge of #144098 - cjgillot:lint-rpitit, r=compiler-errors
matthiaskrgr Jul 19, 2025
bd23cd6
Rollup merge of #144103 - xizheyin:emit-unless, r=compiler-errors
matthiaskrgr Jul 19, 2025
ae77628
Rollup merge of #144108 - CaiWeiran:run-make_test, r=jieyouxu
matthiaskrgr Jul 19, 2025
cc699e1
Rollup merge of #144115 - lcnr:auto-trait-comment, r=compiler-errors
matthiaskrgr Jul 19, 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
2 changes: 1 addition & 1 deletion compiler/rustc_errors/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1421,7 +1421,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
///
/// See `emit` and `delay_as_bug` for details.
#[track_caller]
pub fn emit_unless(mut self, delay: bool) -> G::EmitResult {
pub fn emit_unless_delay(mut self, delay: bool) -> G::EmitResult {
if delay {
self.downgrade_to_delayed_bug();
}
Expand Down
14 changes: 7 additions & 7 deletions compiler/rustc_hir_analysis/src/check/compare_impl_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,7 @@ fn check_region_bounds_on_impl_item<'tcx>(
bounds_span,
where_span,
})
.emit_unless(delay);
.emit_unless_delay(delay);

Err(reported)
}
Expand Down Expand Up @@ -1481,7 +1481,7 @@ fn compare_self_type<'tcx>(
} else {
err.note_trait_signature(trait_m.name(), trait_m.signature(tcx));
}
return Err(err.emit_unless(delay));
return Err(err.emit_unless_delay(delay));
}

(true, false) => {
Expand All @@ -1502,7 +1502,7 @@ fn compare_self_type<'tcx>(
err.note_trait_signature(trait_m.name(), trait_m.signature(tcx));
}

return Err(err.emit_unless(delay));
return Err(err.emit_unless_delay(delay));
}
}

Expand Down Expand Up @@ -1662,7 +1662,7 @@ fn compare_number_of_generics<'tcx>(
err.span_label(*span, "`impl Trait` introduces an implicit type parameter");
}

let reported = err.emit_unless(delay);
let reported = err.emit_unless_delay(delay);
err_occurred = Some(reported);
}
}
Expand Down Expand Up @@ -1745,7 +1745,7 @@ fn compare_number_of_method_arguments<'tcx>(
),
);

return Err(err.emit_unless(delay));
return Err(err.emit_unless_delay(delay));
}

Ok(())
Expand Down Expand Up @@ -1872,7 +1872,7 @@ fn compare_synthetic_generics<'tcx>(
);
};
}
error_found = Some(err.emit_unless(delay));
error_found = Some(err.emit_unless_delay(delay));
}
}
if let Some(reported) = error_found { Err(reported) } else { Ok(()) }
Expand Down Expand Up @@ -1974,7 +1974,7 @@ fn compare_generic_param_kinds<'tcx>(
err.span_label(impl_header_span, "");
err.span_label(param_impl_span, make_param_message("found", param_impl));

let reported = err.emit_unless(delay);
let reported = err.emit_unless_delay(delay);
return Err(reported);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2495,7 +2495,7 @@ fn deny_non_region_late_bound(
format!("late-bound {what} parameter not allowed on {where_}"),
);

let guar = diag.emit_unless(!tcx.features().non_lifetime_binders() || !first);
let guar = diag.emit_unless_delay(!tcx.features().non_lifetime_binders() || !first);

first = false;
*arg = ResolvedArg::Error(guar);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ pub(crate) fn check_generic_arg_count(
gen_args,
def_id,
))
.emit_unless(all_params_are_binded)
.emit_unless_delay(all_params_are_binded)
});

Err(reported)
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/coercion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1775,7 +1775,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
);
}

let reported = err.emit_unless(unsized_return);
let reported = err.emit_unless_delay(unsized_return);

self.final_ty = Some(Ty::new_error(fcx.tcx, reported));
}
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_hir_typeck/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1549,7 +1549,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

// If the assignment expression itself is ill-formed, don't
// bother emitting another error
err.emit_unless(lhs_ty.references_error() || rhs_ty.references_error())
err.emit_unless_delay(lhs_ty.references_error() || rhs_ty.references_error())
}

pub(super) fn check_expr_let(
Expand Down Expand Up @@ -3865,7 +3865,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.dcx()
.create_err(NoVariantNamed { span: ident.span, ident, ty: container })
.with_span_label(field.span, "variant not found")
.emit_unless(container.references_error());
.emit_unless_delay(container.references_error());
break;
};
let Some(&subfield) = fields.next() else {
Expand Down Expand Up @@ -3897,7 +3897,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
enum_span: field.span,
field_span: subident.span,
})
.emit_unless(container.references_error());
.emit_unless_delay(container.references_error());
break;
};

Expand Down
13 changes: 13 additions & 0 deletions compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,10 @@ struct LLVMRustSanitizerOptions {
#ifdef ENZYME
extern "C" void registerEnzymeAndPassPipeline(llvm::PassBuilder &PB,
/* augmentPassBuilder */ bool);

extern "C" {
extern llvm::cl::opt<std::string> EnzymeFunctionToAnalyze;
}
#endif

extern "C" LLVMRustResult LLVMRustOptimize(
Expand Down Expand Up @@ -1069,6 +1073,15 @@ extern "C" LLVMRustResult LLVMRustOptimize(
return LLVMRustResult::Failure;
}

// Check if PrintTAFn was used and add type analysis pass if needed
if (!EnzymeFunctionToAnalyze.empty()) {
if (auto Err = PB.parsePassPipeline(MPM, "print-type-analysis")) {
std::string ErrMsg = toString(std::move(Err));
LLVMRustSetLastError(ErrMsg.c_str());
return LLVMRustResult::Failure;
}
}

if (PrintAfterEnzyme) {
// Handle the Rust flag `-Zautodiff=PrintModAfter`.
std::string Banner = "Module after EnzymeNewPM";
Expand Down
44 changes: 28 additions & 16 deletions compiler/rustc_mir_transform/src/inline/cycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ fn process<'tcx>(
typing_env: ty::TypingEnv<'tcx>,
caller: ty::Instance<'tcx>,
target: LocalDefId,
seen: &mut FxHashSet<ty::Instance<'tcx>>,
seen: &mut FxHashMap<ty::Instance<'tcx>, bool>,
involved: &mut FxHashSet<LocalDefId>,
recursion_limiter: &mut FxHashMap<DefId, usize>,
recursion_limit: Limit,
) -> bool {
trace!(%caller);
let mut cycle_found = false;
let mut reaches_root = false;

for &(callee, args) in tcx.mir_inliner_callees(caller.def) {
for &(callee_def_id, args) in tcx.mir_inliner_callees(caller.def) {
let Ok(args) = caller.try_instantiate_mir_and_normalize_erasing_regions(
tcx,
typing_env,
Expand All @@ -81,14 +81,17 @@ fn process<'tcx>(
trace!(?caller, ?typing_env, ?args, "cannot normalize, skipping");
continue;
};
let Ok(Some(callee)) = ty::Instance::try_resolve(tcx, typing_env, callee, args) else {
trace!(?callee, "cannot resolve, skipping");
let Ok(Some(callee)) = ty::Instance::try_resolve(tcx, typing_env, callee_def_id, args)
else {
trace!(?callee_def_id, "cannot resolve, skipping");
continue;
};

// Found a path.
if callee.def_id() == target.to_def_id() {
cycle_found = true;
reaches_root = true;
seen.insert(callee, true);
continue;
}

if tcx.is_constructor(callee.def_id()) {
Expand All @@ -101,10 +104,17 @@ fn process<'tcx>(
continue;
}

if seen.insert(callee) {
let callee_reaches_root = if let Some(&c) = seen.get(&callee) {
// Even if we have seen this callee before, and thus don't need
// to recurse into it, we still need to propagate whether it reaches
// the root so that we can mark all the involved callers, in case we
// end up reaching that same recursive callee through some *other* cycle.
c
} else {
seen.insert(callee, false);
let recursion = recursion_limiter.entry(callee.def_id()).or_default();
trace!(?callee, recursion = *recursion);
let found_recursion = if recursion_limit.value_within_limit(*recursion) {
let callee_reaches_root = if recursion_limit.value_within_limit(*recursion) {
*recursion += 1;
ensure_sufficient_stack(|| {
process(
Expand All @@ -122,17 +132,19 @@ fn process<'tcx>(
// Pessimistically assume that there could be recursion.
true
};
if found_recursion {
if let Some(callee) = callee.def_id().as_local() {
// Calling `optimized_mir` of a non-local definition cannot cycle.
involved.insert(callee);
}
cycle_found = true;
seen.insert(callee, callee_reaches_root);
callee_reaches_root
};
if callee_reaches_root {
if let Some(callee_def_id) = callee.def_id().as_local() {
// Calling `optimized_mir` of a non-local definition cannot cycle.
involved.insert(callee_def_id);
}
reaches_root = true;
}
}

cycle_found
reaches_root
}

#[instrument(level = "debug", skip(tcx), ret)]
Expand Down Expand Up @@ -166,7 +178,7 @@ pub(crate) fn mir_callgraph_cyclic<'tcx>(
typing_env,
root_instance,
root,
&mut FxHashSet::default(),
&mut FxHashMap::default(),
&mut involved,
&mut FxHashMap::default(),
recursion_limit,
Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_next_trait_solver/src/solve/trait_goals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1219,10 +1219,8 @@ where
// the type (even if after unification and processing nested goals
// it does not hold) will disqualify the built-in auto impl.
//
// This differs from the current stable behavior and fixes #84857.
// Due to breakage found via crater, we currently instead lint
// patterns which can be used to exploit this unsoundness on stable,
// see #93367 for more details.
// We've originally had a more permissive check here which resulted
// in unsoundness, see #84857.
ty::Bool
| ty::Char
| ty::Int(_)
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_privacy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1624,6 +1624,10 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'_, 'tcx> {
self.check(def_id, item_visibility, effective_vis).generics().predicates();

for assoc_item in tcx.associated_items(id.owner_id).in_definition_order() {
if assoc_item.is_impl_trait_in_trait() {
continue;
}

self.check_assoc_item(assoc_item, item_visibility, effective_vis);

if assoc_item.is_type() {
Expand Down Expand Up @@ -1736,6 +1740,10 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'_, 'tcx> {
check.ty().trait_ref();

for assoc_item in tcx.associated_items(id.owner_id).in_definition_order() {
if assoc_item.is_impl_trait_in_trait() {
continue;
}

let impl_item_vis = if !of_trait {
min(tcx.local_visibility(assoc_item.def_id.expect_local()), impl_vis, tcx)
} else {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2913,7 +2913,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
self.r
.dcx()
.create_err(errors::UnderscoreLifetimeIsReserved { span: param.ident.span })
.emit_unless(is_raw_underscore_lifetime);
.emit_unless_delay(is_raw_underscore_lifetime);
// Record lifetime res, so lowering knows there is something fishy.
self.record_lifetime_param(param.id, LifetimeRes::Error);
continue;
Expand Down
Loading