Skip to content

Rollup of 4 pull requests #113406

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 8 commits into from
Jul 6, 2023
8 changes: 7 additions & 1 deletion compiler/rustc_monomorphize/src/partitioning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 6 additions & 4 deletions compiler/rustc_trait_selection/src/solve/eval_ctxt/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/tools/compiletest/src/read2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 4 additions & 1 deletion src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4022,8 +4022,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")
Expand Down
4 changes: 3 additions & 1 deletion tests/ui/dyn-star/box.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down