1
Fork 0

Rollup merge of #118686 - compiler-errors:object-safety, r=lcnr

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```
This commit is contained in:
Matthias Krüger 2023-12-07 21:38:08 +01:00 committed by GitHub
commit b20430345e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -761,18 +761,15 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
let defer_to_coercion = self.tcx().features().object_safe_for_dispatch; let defer_to_coercion = self.tcx().features().object_safe_for_dispatch;
if !defer_to_coercion { if !defer_to_coercion {
let cause = self.cause(traits::WellFormed(None)); if let Some(principal) = data.principal_def_id() {
let component_traits = data.auto_traits().chain(data.principal_def_id()); self.out.push(traits::Obligation::with_depth(
let tcx = self.tcx(); self.tcx(),
self.out.extend(component_traits.map(|did| { self.cause(traits::WellFormed(None)),
traits::Obligation::with_depth(
tcx,
cause.clone(),
depth, depth,
param_env, param_env,
ty::Binder::dummy(ty::PredicateKind::ObjectSafe(did)), ty::Binder::dummy(ty::PredicateKind::ObjectSafe(principal)),
) ));
})); }
} }
} }