Skip to content

Rollup of 8 pull requests #123027

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

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
56e152d
Add rust-lldb pretty printing for Path and PathBuf
n8henrie Feb 1, 2024
6b24fdf
Provide structured suggestion for unconstrained generic constant
estebank Mar 21, 2024
fb65ca1
Clarify transmute example
SkiFire13 Mar 24, 2024
b5ee20f
Clean up unnecessary headers/flags in coverage mir-opt tests
Zalathar Mar 24, 2024
ea45185
CFI: Handle dyn with no principal
maurer Feb 19, 2024
40f41e7
CFI: Support arbitrary receivers
maurer Mar 23, 2024
50b49ae
Temporarily remove nnethercote from the review rotation.
nnethercote Mar 24, 2024
42066b0
Inline and remove `Parser::parse_expr_tuple_field_access_float`.
nnethercote Mar 13, 2024
90eeb3d
Remove `next_token` handling from `parse_expr_tuple_field_access`.
nnethercote Mar 13, 2024
9c09116
Change `parse_expr_tuple_field_access`.
nnethercote Mar 13, 2024
dce0f7f
Clarify `parse_dot_suffix_expr`.
nnethercote Mar 21, 2024
eab1377
Rollup merge of #120557 - n8henrie:issue_120553, r=Mark-Simulacrum
matthiaskrgr Mar 25, 2024
449db0e
Rollup merge of #122802 - estebank:unconstrained-generic-const, r=Nad…
matthiaskrgr Mar 25, 2024
6ba2470
Rollup merge of #122858 - nnethercote:tweak-parse_dot_suffix_expr, r=…
matthiaskrgr Mar 25, 2024
c8f3029
Rollup merge of #122990 - SkiFire13:transmute-may-copy, r=jhpratt
matthiaskrgr Mar 25, 2024
d69a079
Rollup merge of #122995 - Zalathar:flags-mir-opt, r=Mark-Simulacrum
matthiaskrgr Mar 25, 2024
e029264
Rollup merge of #123003 - maurer:dyn-empty, r=compiler-errors
matthiaskrgr Mar 25, 2024
870fae9
Rollup merge of #123005 - maurer:cfi-arbitrary-receivers, r=compiler-…
matthiaskrgr Mar 25, 2024
d96c95f
Rollup merge of #123020 - nnethercote:rm-nnethercote-review, r=nnethe…
matthiaskrgr Mar 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
CFI: Handle dyn with no principal
In user-facing Rust, `dyn` always has at least one predicate following
it. Unfortunately, because we filter out marker traits from receivers at
callsites and `dyn Sync` is, for example, legal, this results in us
having `dyn` types with no predicates on occasion in our alias set
encoding. This patch handles cases where there are no predicates in a
`dyn` type which are relevant to its alias set.

Fixes #122998
  • Loading branch information
maurer committed Mar 24, 2024
commit ea4518522f65480eb507a255dc215d39231e659f
27 changes: 14 additions & 13 deletions compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -747,9 +747,8 @@ fn transform_predicates<'tcx>(
tcx: TyCtxt<'tcx>,
predicates: &List<ty::PolyExistentialPredicate<'tcx>>,
) -> &'tcx List<ty::PolyExistentialPredicate<'tcx>> {
let predicates: Vec<ty::PolyExistentialPredicate<'tcx>> = predicates
.iter()
.filter_map(|predicate| match predicate.skip_binder() {
tcx.mk_poly_existential_predicates_from_iter(predicates.iter().filter_map(|predicate| {
match predicate.skip_binder() {
ty::ExistentialPredicate::Trait(trait_ref) => {
let trait_ref = ty::TraitRef::identity(tcx, trait_ref.def_id);
Some(ty::Binder::dummy(ty::ExistentialPredicate::Trait(
Expand All @@ -758,9 +757,8 @@ fn transform_predicates<'tcx>(
}
ty::ExistentialPredicate::Projection(..) => None,
ty::ExistentialPredicate::AutoTrait(..) => Some(predicate),
})
.collect();
tcx.mk_poly_existential_predicates(&predicates)
}
}))
}

/// Transforms args for being encoded and used in the substitution dictionary.
Expand Down Expand Up @@ -1171,14 +1169,17 @@ fn strip_receiver_auto<'tcx>(
let ty::Dynamic(preds, lifetime, kind) = ty.kind() else {
bug!("Tried to strip auto traits from non-dynamic type {ty}");
};
let filtered_preds =
if preds.principal().is_some() {
let new_rcvr = if preds.principal().is_some() {
let filtered_preds =
tcx.mk_poly_existential_predicates_from_iter(preds.into_iter().filter(|pred| {
!matches!(pred.skip_binder(), ty::ExistentialPredicate::AutoTrait(..))
}))
} else {
ty::List::empty()
};
let new_rcvr = Ty::new_dynamic(tcx, filtered_preds, *lifetime, *kind);
}));
Ty::new_dynamic(tcx, filtered_preds, *lifetime, *kind)
} else {
// If there's no principal type, re-encode it as a unit, since we don't know anything
// about it. This technically discards the knowledge that it was a type that was made
// into a trait object at some point, but that's not a lot.
tcx.types.unit
};
tcx.mk_args_trait(new_rcvr, args.into_iter().skip(1))
}
21 changes: 21 additions & 0 deletions tests/ui/sanitizer/cfi-drop-no-principal.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Check that dropping a trait object without a principal trait succeeds

//@ needs-sanitizer-cfi
// FIXME(#122848) Remove only-linux once OSX CFI binaries works
//@ only-linux
//@ compile-flags: --crate-type=bin -Cprefer-dynamic=off -Clto -Zsanitizer=cfi
//@ compile-flags: -C target-feature=-crt-static -C codegen-units=1 -C opt-level=0
// FIXME(#118761) Should be run-pass once the labels on drop are compatible.
// This test is being landed ahead of that to test that the compiler doesn't ICE while labeling the
// callsite for a drop, but the vtable doesn't have the correct label yet.
//@ build-pass

struct CustomDrop;

impl Drop for CustomDrop {
fn drop(&mut self) {}
}

fn main() {
let _ = Box::new(CustomDrop) as Box<dyn Send>;
}