diff options
| author | bors <bors@rust-lang.org> | 2025-03-13 05:37:55 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-03-13 05:37:55 +0000 |
| commit | 961351c76c812e3aeb65bfb542742500a6436aed (patch) | |
| tree | bf78bb00169d1d90ecc68bf24cc3a882bfe911d8 /compiler/rustc_trait_selection/src | |
| parent | 8536f201ffdb2c24925d7f9e87996d7dca93428b (diff) | |
| parent | 3129802f902c361aa5ed2f7c44a7e5c892c8a37a (diff) | |
| download | rust-961351c76c812e3aeb65bfb542742500a6436aed.tar.gz rust-961351c76c812e3aeb65bfb542742500a6436aed.zip | |
Auto merge of #138249 - compiler-errors:auto-self, r=lcnr
Do not register `Self: AutoTrait` when confirming auto trait (in old solver) Every built-in auto impl for a trait goal like `Ty: Auto` immediately registers another obligation of `Ty: Auto` as one of its nested obligations, leading to us stressing the cycle detection machinery a lot more than we need to. This is because all traits have a `Self: Trait` predicate. To fix this, remove the call to `impl_or_trait_obligations` in `vtable_auto_impl`, since auto traits do not have where clauses. r? lcnr
Diffstat (limited to 'compiler/rustc_trait_selection/src')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/select/confirmation.rs | 16 |
1 files changed, 1 insertions, 15 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs index 6db97fc321a..4cd6781ab89 100644 --- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs +++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs @@ -463,18 +463,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let cause = obligation.derived_cause(ObligationCauseCode::BuiltinDerived); assert_eq!(obligation.predicate.polarity(), ty::PredicatePolarity::Positive); - let trait_ref = - self.infcx.enter_forall_and_leak_universe(obligation.predicate).trait_ref; - let trait_obligations = self.impl_or_trait_obligations( - &cause, - obligation.recursion_depth + 1, - obligation.param_env, - trait_def_id, - trait_ref.args, - obligation.predicate, - ); - let mut obligations = self.collect_predicates_for_types( + let obligations = self.collect_predicates_for_types( obligation.param_env, cause, obligation.recursion_depth + 1, @@ -482,10 +472,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { nested, ); - // Adds the predicates from the trait. Note that this contains a `Self: Trait` - // predicate as usual. It won't have any effect since auto traits are coinductive. - obligations.extend(trait_obligations); - debug!(?obligations, "vtable_auto_impl"); obligations |
