From ec18a34e1b3644fdb4aa1ef8723475ed9a8049d1 Mon Sep 17 00:00:00 2001 From: ForrestOfBarnes Date: Sun, 4 Jun 2023 18:25:25 -0600 Subject: [PATCH 1/4] Fixes tests/ui/test-attrs/tests-listing-format-json.rs on Windows --- src/tools/compiletest/src/runtest.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 25b16e38e534a..0a4ddf59ad3be 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -3712,8 +3712,11 @@ impl<'test> TestCx<'test> { } fn normalize_output(&self, output: &str, custom_rules: &[(String, String)]) -> String { + let rflags = self.props.run_flags.as_ref(); let cflags = self.props.compile_flags.join(" "); - let json = cflags.contains("--error-format json") + let json = rflags + .map_or(false, |s| s.contains("--format json") || s.contains("--format=json")) + || cflags.contains("--error-format json") || cflags.contains("--error-format pretty-json") || cflags.contains("--error-format=json") || cflags.contains("--error-format=pretty-json") From 3ed2b46f2867ee3f5684c0e0617d814eedc2a47d Mon Sep 17 00:00:00 2001 From: Jan-Mirko Otter Date: Sat, 1 Jul 2023 23:58:47 +0200 Subject: [PATCH 2/4] fix compiletest crash --- src/tools/compiletest/src/read2.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/compiletest/src/read2.rs b/src/tools/compiletest/src/read2.rs index 725f7a1515c62..a455a1badc053 100644 --- a/src/tools/compiletest/src/read2.rs +++ b/src/tools/compiletest/src/read2.rs @@ -83,7 +83,7 @@ impl ProcOutput { } let new_len = bytes.len(); - if *filtered_len <= HEAD_LEN + TAIL_LEN { + if (*filtered_len).min(new_len) <= HEAD_LEN + TAIL_LEN { return; } From cd26d10edfa8df69266e85b5ab7b991de0a10b38 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Thu, 6 Jul 2023 03:10:11 +0000 Subject: [PATCH 3/4] Dont ICE for `dyn* Trait: Trait` goals during selection in new trait solver --- .../src/solve/eval_ctxt/select.rs | 10 ++++++---- tests/ui/dyn-star/box.rs | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_trait_selection/src/solve/eval_ctxt/select.rs b/compiler/rustc_trait_selection/src/solve/eval_ctxt/select.rs index 18332d6811d56..366e9aa793d71 100644 --- a/compiler/rustc_trait_selection/src/solve/eval_ctxt/select.rs +++ b/compiler/rustc_trait_selection/src/solve/eval_ctxt/select.rs @@ -213,15 +213,16 @@ fn rematch_object<'tcx>( mut nested: Vec>, ) -> SelectionResult<'tcx, Selection<'tcx>> { let self_ty = goal.predicate.self_ty(); - let source_trait_ref = if let ty::Dynamic(data, _, ty::Dyn) = self_ty.kind() { - data.principal().unwrap().with_self_ty(infcx.tcx, self_ty) - } else { + let ty::Dynamic(data, _, source_kind) = *self_ty.kind() + else { bug!() }; + let source_trait_ref = data.principal().unwrap().with_self_ty(infcx.tcx, self_ty); let (is_upcasting, target_trait_ref_unnormalized) = if Some(goal.predicate.def_id()) == infcx.tcx.lang_items().unsize_trait() { + assert_eq!(source_kind, ty::Dyn, "cannot upcast dyn*"); if let ty::Dynamic(data, _, ty::Dyn) = goal.predicate.trait_ref.substs.type_at(1).kind() { (true, data.principal().unwrap().with_self_ty(infcx.tcx, self_ty)) } else { @@ -288,7 +289,8 @@ fn rematch_object<'tcx>( bug!(); }; - // If we're upcasting, get the offset of the vtable pointer, which is + // If we're upcasting, get the offset of the vtable pointer, otherwise get + // the base of the vtable. Ok(Some(if is_upcasting { ImplSource::TraitUpcasting(ImplSourceTraitUpcastingData { vtable_vptr_slot, nested }) } else { diff --git a/tests/ui/dyn-star/box.rs b/tests/ui/dyn-star/box.rs index d1f1819d9f35f..87c8356a174ed 100644 --- a/tests/ui/dyn-star/box.rs +++ b/tests/ui/dyn-star/box.rs @@ -1,5 +1,7 @@ // run-pass -// compile-flags: -C opt-level=0 +// revisions: current next +//[current] compile-flags: -C opt-level=0 +//[next] compile-flags: -Ztrait-solver=next -C opt-level=0 #![feature(dyn_star)] #![allow(incomplete_features)] From fc8536669ca9b1a3820da9f29dc01d87a44ee151 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 6 Jul 2023 17:51:18 +1000 Subject: [PATCH 4/4] Diagnose unsorted CGUs. An assertion failure was reported in #112946. This extra information will help diagnose the problem. --- compiler/rustc_monomorphize/src/partitioning.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_monomorphize/src/partitioning.rs b/compiler/rustc_monomorphize/src/partitioning.rs index e663f4486f7fe..f4535fbd58fa0 100644 --- a/compiler/rustc_monomorphize/src/partitioning.rs +++ b/compiler/rustc_monomorphize/src/partitioning.rs @@ -187,7 +187,13 @@ where } // Ensure CGUs are sorted by name, so that we get deterministic results. - assert!(codegen_units.is_sorted_by(|a, b| Some(a.name().as_str().cmp(b.name().as_str())))); + if !codegen_units.is_sorted_by(|a, b| Some(a.name().as_str().cmp(b.name().as_str()))) { + let mut names = String::new(); + for cgu in codegen_units.iter() { + names += &format!("- {}\n", cgu.name()); + } + bug!("unsorted CGUs:\n{names}"); + } codegen_units }