about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-12-07 21:38:08 +0100
committerGitHub <noreply@github.com>2023-12-07 21:38:08 +0100
commitb20430345e46f0f67265b677dfa580a8b320efcb (patch)
tree56dc6a574dd53d8c5ceefd4dd3895284d87ef01e
parent71a8ca0522d727e2900e4a6f0899f3664de97035 (diff)
parent5d3a294b46896d0b0c7c2cb3cf6ce4085a1e64fe (diff)
downloadrust-b20430345e46f0f67265b677dfa580a8b320efcb.tar.gz
rust-b20430345e46f0f67265b677dfa580a8b320efcb.zip
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```
-rw-r--r--compiler/rustc_trait_selection/src/traits/wf.rs17
1 files changed, 7 insertions, 10 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/wf.rs b/compiler/rustc_trait_selection/src/traits/wf.rs
index 3a890d70d79..0f8d9c6bf4b 100644
--- a/compiler/rustc_trait_selection/src/traits/wf.rs
+++ b/compiler/rustc_trait_selection/src/traits/wf.rs
@@ -761,18 +761,15 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
                     let defer_to_coercion = self.tcx().features().object_safe_for_dispatch;
 
                     if !defer_to_coercion {
-                        let cause = self.cause(traits::WellFormed(None));
-                        let component_traits = data.auto_traits().chain(data.principal_def_id());
-                        let tcx = self.tcx();
-                        self.out.extend(component_traits.map(|did| {
-                            traits::Obligation::with_depth(
-                                tcx,
-                                cause.clone(),
+                        if let Some(principal) = data.principal_def_id() {
+                            self.out.push(traits::Obligation::with_depth(
+                                self.tcx(),
+                                self.cause(traits::WellFormed(None)),
                                 depth,
                                 param_env,
-                                ty::Binder::dummy(ty::PredicateKind::ObjectSafe(did)),
-                            )
-                        }));
+                                ty::Binder::dummy(ty::PredicateKind::ObjectSafe(principal)),
+                            ));
+                        }
                     }
                 }