Skip to content

Commit 6845c0d

Browse files
committed
Auto merge of rust-lang#118686 - compiler-errors:object-safety, r=<try>
Only check principal trait ref for object safety It should make things a bit faster, in case we end up registering a bunch of object safety preds. r? `@ghost`
2 parents 7a34091 + 5d3a294 commit 6845c0d

File tree

1 file changed

+7
-10
lines changed
  • compiler/rustc_trait_selection/src/traits

1 file changed

+7
-10
lines changed

compiler/rustc_trait_selection/src/traits/wf.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -761,18 +761,15 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
761761
let defer_to_coercion = self.tcx().features().object_safe_for_dispatch;
762762

763763
if !defer_to_coercion {
764-
let cause = self.cause(traits::WellFormed(None));
765-
let component_traits = data.auto_traits().chain(data.principal_def_id());
766-
let tcx = self.tcx();
767-
self.out.extend(component_traits.map(|did| {
768-
traits::Obligation::with_depth(
769-
tcx,
770-
cause.clone(),
764+
if let Some(principal) = data.principal_def_id() {
765+
self.out.push(traits::Obligation::with_depth(
766+
self.tcx(),
767+
self.cause(traits::WellFormed(None)),
771768
depth,
772769
param_env,
773-
ty::Binder::dummy(ty::PredicateKind::ObjectSafe(did)),
774-
)
775-
}));
770+
ty::Binder::dummy(ty::PredicateKind::ObjectSafe(principal)),
771+
));
772+
}
776773
}
777774
}
778775

0 commit comments

Comments
 (0)