Skip to content

Commit e4b9e72

Browse files
Rollup merge of #114827 - compiler-errors:next-solver-dyn-safe-candidates, r=lcnr
Only consider object candidates for object-safe dyn types in new solver We apparently allow this per RFC2027 💀 r? lcnr
2 parents 0e7f9e5 + e8ab56f commit e4b9e72

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

compiler/rustc_trait_selection/src/solve/assembly/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,11 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
826826
ty::Dynamic(bounds, ..) => bounds,
827827
};
828828

829+
// Do not consider built-in object impls for non-object-safe types.
830+
if bounds.principal_def_id().is_some_and(|def_id| !tcx.check_is_object_safe(def_id)) {
831+
return;
832+
}
833+
829834
// Consider all of the auto-trait and projection bounds, which don't
830835
// need to be recorded as a `BuiltinImplSource::Object` since they don't
831836
// really have a vtable base...

tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Check that we can manually implement an object-unsafe trait for its trait object.
22

3+
// revisions: current next
4+
//[next] compile-flags: -Ztrait-solver=next
35
// run-pass
46

57
#![feature(object_safe_for_dispatch)]

0 commit comments

Comments
 (0)