diff --git a/compiler/rustc_middle/src/traits/select.rs b/compiler/rustc_middle/src/traits/select.rs index 6bcdfd6394a94..11758599cffa1 100644 --- a/compiler/rustc_middle/src/traits/select.rs +++ b/compiler/rustc_middle/src/traits/select.rs @@ -115,7 +115,7 @@ pub enum SelectionCandidate<'tcx> { ParamCandidate(ty::PolyTraitPredicate<'tcx>), ImplCandidate(DefId), - AutoImplCandidate(DefId), + AutoImplCandidate, /// This is a trait matching with a projected type as `Self`, and we found /// an applicable bound in the trait definition. The `usize` is an index @@ -143,7 +143,7 @@ pub enum SelectionCandidate<'tcx> { /// Builtin implementation of `Pointee`. PointeeCandidate, - TraitAliasCandidate(DefId), + TraitAliasCandidate, /// Matching `dyn Trait` with a supertrait of `Trait`. The index is the /// position in the iterator returned by diff --git a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs index 9a8331614b0e8..f6c0930eb5f37 100644 --- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs +++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs @@ -625,7 +625,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { } } - _ => candidates.vec.push(AutoImplCandidate(def_id)), + _ => candidates.vec.push(AutoImplCandidate), } } } @@ -914,7 +914,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let def_id = obligation.predicate.def_id(); if self.tcx().is_trait_alias(def_id) { - candidates.vec.push(TraitAliasCandidate(def_id)); + candidates.vec.push(TraitAliasCandidate); } } diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs index 5c8a76401d233..98c99e9ad4fb6 100644 --- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs +++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs @@ -64,8 +64,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { ImplSource::UserDefined(self.confirm_impl_candidate(obligation, impl_def_id)) } - AutoImplCandidate(trait_def_id) => { - let data = self.confirm_auto_impl_candidate(obligation, trait_def_id); + AutoImplCandidate => { + let data = self.confirm_auto_impl_candidate(obligation); ImplSource::AutoImpl(data) } @@ -100,8 +100,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { PointeeCandidate => ImplSource::Pointee(ImplSourcePointeeData), - TraitAliasCandidate(alias_def_id) => { - let data = self.confirm_trait_alias_candidate(obligation, alias_def_id); + TraitAliasCandidate => { + let data = self.confirm_trait_alias_candidate(obligation); ImplSource::TraitAlias(data) } @@ -317,13 +317,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { fn confirm_auto_impl_candidate( &mut self, obligation: &TraitObligation<'tcx>, - trait_def_id: DefId, ) -> ImplSourceAutoImplData> { - debug!(?obligation, ?trait_def_id, "confirm_auto_impl_candidate"); + debug!(?obligation, "confirm_auto_impl_candidate"); let self_ty = self.infcx.shallow_resolve(obligation.predicate.self_ty()); let types = self.constituent_types_for_ty(self_ty); - self.vtable_auto_impl(obligation, trait_def_id, types) + self.vtable_auto_impl(obligation, obligation.predicate.def_id(), types) } /// See `confirm_auto_impl_candidate`. @@ -658,10 +657,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { fn confirm_trait_alias_candidate( &mut self, obligation: &TraitObligation<'tcx>, - alias_def_id: DefId, ) -> ImplSourceTraitAliasData<'tcx, PredicateObligation<'tcx>> { - debug!(?obligation, ?alias_def_id, "confirm_trait_alias_candidate"); + debug!(?obligation, "confirm_trait_alias_candidate"); + let alias_def_id = obligation.predicate.def_id(); let predicate = self.infcx().replace_bound_vars_with_placeholders(obligation.predicate); let trait_ref = predicate.trait_ref; let trait_def_id = trait_ref.def_id; diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index 8f2a6f337baad..c9c47d6fb5456 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -1150,7 +1150,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // const projection ProjectionCandidate(_, ty::BoundConstness::ConstIfConst) => {} // auto trait impl - AutoImplCandidate(..) => {} + AutoImplCandidate => {} // generator, this will raise error in other places // or ignore error with const_async_blocks feature GeneratorCandidate => {} @@ -1568,7 +1568,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // This is a fix for #53123 and prevents winnowing from accidentally extending the // lifetime of a variable. match (&other.candidate, &victim.candidate) { - (_, AutoImplCandidate(..)) | (AutoImplCandidate(..), _) => { + (_, AutoImplCandidate) | (AutoImplCandidate, _) => { bug!( "default implementations shouldn't be recorded \ when there are other valid candidates" @@ -1638,7 +1638,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { | BuiltinUnsizeCandidate | TraitUpcastingUnsizeCandidate(_) | BuiltinCandidate { .. } - | TraitAliasCandidate(..) + | TraitAliasCandidate | ObjectCandidate(_) | ProjectionCandidate(..), ) => !is_global(cand), @@ -1656,7 +1656,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { | BuiltinUnsizeCandidate | TraitUpcastingUnsizeCandidate(_) | BuiltinCandidate { has_nested: true } - | TraitAliasCandidate(..), + | TraitAliasCandidate, ParamCandidate(ref cand), ) => { // Prefer these to a global where-clause bound @@ -1686,7 +1686,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { | BuiltinUnsizeCandidate | TraitUpcastingUnsizeCandidate(_) | BuiltinCandidate { .. } - | TraitAliasCandidate(..), + | TraitAliasCandidate, ) => true, ( @@ -1698,7 +1698,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { | BuiltinUnsizeCandidate | TraitUpcastingUnsizeCandidate(_) | BuiltinCandidate { .. } - | TraitAliasCandidate(..), + | TraitAliasCandidate, ObjectCandidate(_) | ProjectionCandidate(..), ) => false, @@ -1779,7 +1779,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { | BuiltinUnsizeCandidate | TraitUpcastingUnsizeCandidate(_) | BuiltinCandidate { has_nested: true } - | TraitAliasCandidate(..), + | TraitAliasCandidate, ImplCandidate(_) | ClosureCandidate | GeneratorCandidate @@ -1788,7 +1788,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { | BuiltinUnsizeCandidate | TraitUpcastingUnsizeCandidate(_) | BuiltinCandidate { has_nested: true } - | TraitAliasCandidate(..), + | TraitAliasCandidate, ) => false, } }