Skip to content

Commit 4b6749b

Browse files
committed
Auto merge of #113406 - matthiaskrgr:rollup-0rprs5k, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - #112295 (Fix the tests-listing-format-json test on Windows) - #113246 (fix compiletest crash) - #113395 (Dont ICE for `dyn* Trait: Trait` (built-in object) goals during selection in new trait solver) - #113402 (Diagnose unsorted CGUs.) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 4dd1719 + a7532d9 commit 4b6749b

File tree

5 files changed

+21
-8
lines changed

5 files changed

+21
-8
lines changed

compiler/rustc_monomorphize/src/partitioning.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,13 @@ where
187187
}
188188

189189
// Ensure CGUs are sorted by name, so that we get deterministic results.
190-
assert!(codegen_units.is_sorted_by(|a, b| Some(a.name().as_str().cmp(b.name().as_str()))));
190+
if !codegen_units.is_sorted_by(|a, b| Some(a.name().as_str().cmp(b.name().as_str()))) {
191+
let mut names = String::new();
192+
for cgu in codegen_units.iter() {
193+
names += &format!("- {}\n", cgu.name());
194+
}
195+
bug!("unsorted CGUs:\n{names}");
196+
}
191197

192198
codegen_units
193199
}

compiler/rustc_trait_selection/src/solve/eval_ctxt/select.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,16 @@ fn rematch_object<'tcx>(
213213
mut nested: Vec<PredicateObligation<'tcx>>,
214214
) -> SelectionResult<'tcx, Selection<'tcx>> {
215215
let self_ty = goal.predicate.self_ty();
216-
let source_trait_ref = if let ty::Dynamic(data, _, ty::Dyn) = self_ty.kind() {
217-
data.principal().unwrap().with_self_ty(infcx.tcx, self_ty)
218-
} else {
216+
let ty::Dynamic(data, _, source_kind) = *self_ty.kind()
217+
else {
219218
bug!()
220219
};
220+
let source_trait_ref = data.principal().unwrap().with_self_ty(infcx.tcx, self_ty);
221221

222222
let (is_upcasting, target_trait_ref_unnormalized) = if Some(goal.predicate.def_id())
223223
== infcx.tcx.lang_items().unsize_trait()
224224
{
225+
assert_eq!(source_kind, ty::Dyn, "cannot upcast dyn*");
225226
if let ty::Dynamic(data, _, ty::Dyn) = goal.predicate.trait_ref.substs.type_at(1).kind() {
226227
(true, data.principal().unwrap().with_self_ty(infcx.tcx, self_ty))
227228
} else {
@@ -288,7 +289,8 @@ fn rematch_object<'tcx>(
288289
bug!();
289290
};
290291

291-
// If we're upcasting, get the offset of the vtable pointer, which is
292+
// If we're upcasting, get the offset of the vtable pointer, otherwise get
293+
// the base of the vtable.
292294
Ok(Some(if is_upcasting {
293295
ImplSource::TraitUpcasting(ImplSourceTraitUpcastingData { vtable_vptr_slot, nested })
294296
} else {

src/tools/compiletest/src/read2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl ProcOutput {
8383
}
8484

8585
let new_len = bytes.len();
86-
if *filtered_len <= HEAD_LEN + TAIL_LEN {
86+
if (*filtered_len).min(new_len) <= HEAD_LEN + TAIL_LEN {
8787
return;
8888
}
8989

src/tools/compiletest/src/runtest.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -4022,8 +4022,11 @@ impl<'test> TestCx<'test> {
40224022
}
40234023

40244024
fn normalize_output(&self, output: &str, custom_rules: &[(String, String)]) -> String {
4025+
let rflags = self.props.run_flags.as_ref();
40254026
let cflags = self.props.compile_flags.join(" ");
4026-
let json = cflags.contains("--error-format json")
4027+
let json = rflags
4028+
.map_or(false, |s| s.contains("--format json") || s.contains("--format=json"))
4029+
|| cflags.contains("--error-format json")
40274030
|| cflags.contains("--error-format pretty-json")
40284031
|| cflags.contains("--error-format=json")
40294032
|| cflags.contains("--error-format=pretty-json")

tests/ui/dyn-star/box.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// run-pass
2-
// compile-flags: -C opt-level=0
2+
// revisions: current next
3+
//[current] compile-flags: -C opt-level=0
4+
//[next] compile-flags: -Ztrait-solver=next -C opt-level=0
35

46
#![feature(dyn_star)]
57
#![allow(incomplete_features)]

0 commit comments

Comments
 (0)