diff options
| author | bors <bors@rust-lang.org> | 2023-07-06 10:29:49 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-07-06 10:29:49 +0000 |
| commit | 4b6749b21e680a6280cf05ace533ae20c93d9bff (patch) | |
| tree | cd8c871d1bdbbf229af8bd6310b095b460eddfbb /compiler | |
| parent | 4dd1719b3406d80f539d2f49e9842f3563908632 (diff) | |
| parent | a7532d9278961f5f6188a3a3f525034408812920 (diff) | |
| download | rust-4b6749b21e680a6280cf05ace533ae20c93d9bff.tar.gz rust-4b6749b21e680a6280cf05ace533ae20c93d9bff.zip | |
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
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_monomorphize/src/partitioning.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_trait_selection/src/solve/eval_ctxt/select.rs | 10 |
2 files changed, 13 insertions, 5 deletions
diff --git a/compiler/rustc_monomorphize/src/partitioning.rs b/compiler/rustc_monomorphize/src/partitioning.rs index e663f4486f7..f4535fbd58f 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 } 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 18332d6811d..366e9aa793d 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<PredicateObligation<'tcx>>, ) -> 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 { |
