Skip to content

Commit 12865ff

Browse files
committed
Auto merge of #144166 - matthiaskrgr:rollup-wccepuo, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - #141076 (fix Zip unsoundness (again)) - #142444 (adding run-make test to autodiff) - #143704 (Be a bit more careful around exotic cycles in in the inliner) - #144073 (Don't test panic=unwind in panic_main.rs on Fuchsia) - #144083 (miri sleep tests: increase slack) - #144092 (bootstrap: Detect musl hosts) - #144098 (Do not lint private-in-public for RPITIT) - #144103 (Rename `emit_unless` to `emit_unless_delay`) - #144108 (Ignore tests/run-make/link-eh-frame-terminator/rmake.rs when cross-compiling) - #144115 (fix outdated comment) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 83825dd + cc699e1 commit 12865ff

File tree

95 files changed

+1785
-168
lines changed

Some content is hidden

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

95 files changed

+1785
-168
lines changed

compiler/rustc_errors/src/diagnostic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1421,7 +1421,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
14211421
///
14221422
/// See `emit` and `delay_as_bug` for details.
14231423
#[track_caller]
1424-
pub fn emit_unless(mut self, delay: bool) -> G::EmitResult {
1424+
pub fn emit_unless_delay(mut self, delay: bool) -> G::EmitResult {
14251425
if delay {
14261426
self.downgrade_to_delayed_bug();
14271427
}

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,7 @@ fn check_region_bounds_on_impl_item<'tcx>(
11731173
bounds_span,
11741174
where_span,
11751175
})
1176-
.emit_unless(delay);
1176+
.emit_unless_delay(delay);
11771177

11781178
Err(reported)
11791179
}
@@ -1481,7 +1481,7 @@ fn compare_self_type<'tcx>(
14811481
} else {
14821482
err.note_trait_signature(trait_m.name(), trait_m.signature(tcx));
14831483
}
1484-
return Err(err.emit_unless(delay));
1484+
return Err(err.emit_unless_delay(delay));
14851485
}
14861486

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

1505-
return Err(err.emit_unless(delay));
1505+
return Err(err.emit_unless_delay(delay));
15061506
}
15071507
}
15081508

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

1665-
let reported = err.emit_unless(delay);
1665+
let reported = err.emit_unless_delay(delay);
16661666
err_occurred = Some(reported);
16671667
}
16681668
}
@@ -1745,7 +1745,7 @@ fn compare_number_of_method_arguments<'tcx>(
17451745
),
17461746
);
17471747

1748-
return Err(err.emit_unless(delay));
1748+
return Err(err.emit_unless_delay(delay));
17491749
}
17501750

17511751
Ok(())
@@ -1872,7 +1872,7 @@ fn compare_synthetic_generics<'tcx>(
18721872
);
18731873
};
18741874
}
1875-
error_found = Some(err.emit_unless(delay));
1875+
error_found = Some(err.emit_unless_delay(delay));
18761876
}
18771877
}
18781878
if let Some(reported) = error_found { Err(reported) } else { Ok(()) }
@@ -1974,7 +1974,7 @@ fn compare_generic_param_kinds<'tcx>(
19741974
err.span_label(impl_header_span, "");
19751975
err.span_label(param_impl_span, make_param_message("found", param_impl));
19761976

1977-
let reported = err.emit_unless(delay);
1977+
let reported = err.emit_unless_delay(delay);
19781978
return Err(reported);
19791979
}
19801980
}

compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2495,7 +2495,7 @@ fn deny_non_region_late_bound(
24952495
format!("late-bound {what} parameter not allowed on {where_}"),
24962496
);
24972497

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

25002500
first = false;
25012501
*arg = ResolvedArg::Error(guar);

compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ pub(crate) fn check_generic_arg_count(
570570
gen_args,
571571
def_id,
572572
))
573-
.emit_unless(all_params_are_binded)
573+
.emit_unless_delay(all_params_are_binded)
574574
});
575575

576576
Err(reported)

compiler/rustc_hir_typeck/src/coercion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1775,7 +1775,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
17751775
);
17761776
}
17771777

1778-
let reported = err.emit_unless(unsized_return);
1778+
let reported = err.emit_unless_delay(unsized_return);
17791779

17801780
self.final_ty = Some(Ty::new_error(fcx.tcx, reported));
17811781
}

compiler/rustc_hir_typeck/src/expr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,7 +1549,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
15491549

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

15551555
pub(super) fn check_expr_let(
@@ -3865,7 +3865,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
38653865
self.dcx()
38663866
.create_err(NoVariantNamed { span: ident.span, ident, ty: container })
38673867
.with_span_label(field.span, "variant not found")
3868-
.emit_unless(container.references_error());
3868+
.emit_unless_delay(container.references_error());
38693869
break;
38703870
};
38713871
let Some(&subfield) = fields.next() else {
@@ -3897,7 +3897,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
38973897
enum_span: field.span,
38983898
field_span: subident.span,
38993899
})
3900-
.emit_unless(container.references_error());
3900+
.emit_unless_delay(container.references_error());
39013901
break;
39023902
};
39033903

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,10 @@ struct LLVMRustSanitizerOptions {
700700
#ifdef ENZYME
701701
extern "C" void registerEnzymeAndPassPipeline(llvm::PassBuilder &PB,
702702
/* augmentPassBuilder */ bool);
703+
704+
extern "C" {
705+
extern llvm::cl::opt<std::string> EnzymeFunctionToAnalyze;
706+
}
703707
#endif
704708

705709
extern "C" LLVMRustResult LLVMRustOptimize(
@@ -1069,6 +1073,15 @@ extern "C" LLVMRustResult LLVMRustOptimize(
10691073
return LLVMRustResult::Failure;
10701074
}
10711075

1076+
// Check if PrintTAFn was used and add type analysis pass if needed
1077+
if (!EnzymeFunctionToAnalyze.empty()) {
1078+
if (auto Err = PB.parsePassPipeline(MPM, "print-type-analysis")) {
1079+
std::string ErrMsg = toString(std::move(Err));
1080+
LLVMRustSetLastError(ErrMsg.c_str());
1081+
return LLVMRustResult::Failure;
1082+
}
1083+
}
1084+
10721085
if (PrintAfterEnzyme) {
10731086
// Handle the Rust flag `-Zautodiff=PrintModAfter`.
10741087
std::string Banner = "Module after EnzymeNewPM";

compiler/rustc_mir_transform/src/inline/cycle.rs

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ fn process<'tcx>(
6464
typing_env: ty::TypingEnv<'tcx>,
6565
caller: ty::Instance<'tcx>,
6666
target: LocalDefId,
67-
seen: &mut FxHashSet<ty::Instance<'tcx>>,
67+
seen: &mut FxHashMap<ty::Instance<'tcx>, bool>,
6868
involved: &mut FxHashSet<LocalDefId>,
6969
recursion_limiter: &mut FxHashMap<DefId, usize>,
7070
recursion_limit: Limit,
7171
) -> bool {
7272
trace!(%caller);
73-
let mut cycle_found = false;
73+
let mut reaches_root = false;
7474

75-
for &(callee, args) in tcx.mir_inliner_callees(caller.def) {
75+
for &(callee_def_id, args) in tcx.mir_inliner_callees(caller.def) {
7676
let Ok(args) = caller.try_instantiate_mir_and_normalize_erasing_regions(
7777
tcx,
7878
typing_env,
@@ -81,14 +81,17 @@ fn process<'tcx>(
8181
trace!(?caller, ?typing_env, ?args, "cannot normalize, skipping");
8282
continue;
8383
};
84-
let Ok(Some(callee)) = ty::Instance::try_resolve(tcx, typing_env, callee, args) else {
85-
trace!(?callee, "cannot resolve, skipping");
84+
let Ok(Some(callee)) = ty::Instance::try_resolve(tcx, typing_env, callee_def_id, args)
85+
else {
86+
trace!(?callee_def_id, "cannot resolve, skipping");
8687
continue;
8788
};
8889

8990
// Found a path.
9091
if callee.def_id() == target.to_def_id() {
91-
cycle_found = true;
92+
reaches_root = true;
93+
seen.insert(callee, true);
94+
continue;
9295
}
9396

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

104-
if seen.insert(callee) {
107+
let callee_reaches_root = if let Some(&c) = seen.get(&callee) {
108+
// Even if we have seen this callee before, and thus don't need
109+
// to recurse into it, we still need to propagate whether it reaches
110+
// the root so that we can mark all the involved callers, in case we
111+
// end up reaching that same recursive callee through some *other* cycle.
112+
c
113+
} else {
114+
seen.insert(callee, false);
105115
let recursion = recursion_limiter.entry(callee.def_id()).or_default();
106116
trace!(?callee, recursion = *recursion);
107-
let found_recursion = if recursion_limit.value_within_limit(*recursion) {
117+
let callee_reaches_root = if recursion_limit.value_within_limit(*recursion) {
108118
*recursion += 1;
109119
ensure_sufficient_stack(|| {
110120
process(
@@ -122,17 +132,19 @@ fn process<'tcx>(
122132
// Pessimistically assume that there could be recursion.
123133
true
124134
};
125-
if found_recursion {
126-
if let Some(callee) = callee.def_id().as_local() {
127-
// Calling `optimized_mir` of a non-local definition cannot cycle.
128-
involved.insert(callee);
129-
}
130-
cycle_found = true;
135+
seen.insert(callee, callee_reaches_root);
136+
callee_reaches_root
137+
};
138+
if callee_reaches_root {
139+
if let Some(callee_def_id) = callee.def_id().as_local() {
140+
// Calling `optimized_mir` of a non-local definition cannot cycle.
141+
involved.insert(callee_def_id);
131142
}
143+
reaches_root = true;
132144
}
133145
}
134146

135-
cycle_found
147+
reaches_root
136148
}
137149

138150
#[instrument(level = "debug", skip(tcx), ret)]
@@ -166,7 +178,7 @@ pub(crate) fn mir_callgraph_cyclic<'tcx>(
166178
typing_env,
167179
root_instance,
168180
root,
169-
&mut FxHashSet::default(),
181+
&mut FxHashMap::default(),
170182
&mut involved,
171183
&mut FxHashMap::default(),
172184
recursion_limit,

compiler/rustc_next_trait_solver/src/solve/trait_goals.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,10 +1219,8 @@ where
12191219
// the type (even if after unification and processing nested goals
12201220
// it does not hold) will disqualify the built-in auto impl.
12211221
//
1222-
// This differs from the current stable behavior and fixes #84857.
1223-
// Due to breakage found via crater, we currently instead lint
1224-
// patterns which can be used to exploit this unsoundness on stable,
1225-
// see #93367 for more details.
1222+
// We've originally had a more permissive check here which resulted
1223+
// in unsoundness, see #84857.
12261224
ty::Bool
12271225
| ty::Char
12281226
| ty::Int(_)

compiler/rustc_privacy/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,6 +1624,10 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'_, 'tcx> {
16241624
self.check(def_id, item_visibility, effective_vis).generics().predicates();
16251625

16261626
for assoc_item in tcx.associated_items(id.owner_id).in_definition_order() {
1627+
if assoc_item.is_impl_trait_in_trait() {
1628+
continue;
1629+
}
1630+
16271631
self.check_assoc_item(assoc_item, item_visibility, effective_vis);
16281632

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

17381742
for assoc_item in tcx.associated_items(id.owner_id).in_definition_order() {
1743+
if assoc_item.is_impl_trait_in_trait() {
1744+
continue;
1745+
}
1746+
17391747
let impl_item_vis = if !of_trait {
17401748
min(tcx.local_visibility(assoc_item.def_id.expect_local()), impl_vis, tcx)
17411749
} else {

0 commit comments

Comments
 (0)