Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit db1cdd4

Browse files
committedNov 22, 2022
move 2 candidates into builtin candidate
1 parent b7463e8 commit db1cdd4

File tree

8 files changed

+166
-246
lines changed

8 files changed

+166
-246
lines changed
 

‎compiler/rustc_middle/src/traits/mod.rs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -651,12 +651,6 @@ pub enum ImplSource<'tcx, N> {
651651
/// Same as above, but for a function pointer type with the given signature.
652652
FnPointer(ImplSourceFnPointerData<'tcx, N>),
653653

654-
/// ImplSource for a builtin `DeterminantKind` trait implementation.
655-
DiscriminantKind(ImplSourceDiscriminantKindData),
656-
657-
/// ImplSource for a builtin `Pointee` trait implementation.
658-
Pointee(ImplSourcePointeeData),
659-
660654
/// ImplSource automatically generated for a generator.
661655
Generator(ImplSourceGeneratorData<'tcx, N>),
662656

@@ -678,8 +672,6 @@ impl<'tcx, N> ImplSource<'tcx, N> {
678672
ImplSource::Generator(c) => c.nested,
679673
ImplSource::Object(d) => d.nested,
680674
ImplSource::FnPointer(d) => d.nested,
681-
ImplSource::DiscriminantKind(ImplSourceDiscriminantKindData)
682-
| ImplSource::Pointee(ImplSourcePointeeData) => vec![],
683675
ImplSource::TraitAlias(d) => d.nested,
684676
ImplSource::TraitUpcasting(d) => d.nested,
685677
ImplSource::ConstDestruct(i) => i.nested,
@@ -696,8 +688,6 @@ impl<'tcx, N> ImplSource<'tcx, N> {
696688
ImplSource::Generator(c) => &c.nested,
697689
ImplSource::Object(d) => &d.nested,
698690
ImplSource::FnPointer(d) => &d.nested,
699-
ImplSource::DiscriminantKind(ImplSourceDiscriminantKindData)
700-
| ImplSource::Pointee(ImplSourcePointeeData) => &[],
701691
ImplSource::TraitAlias(d) => &d.nested,
702692
ImplSource::TraitUpcasting(d) => &d.nested,
703693
ImplSource::ConstDestruct(i) => &i.nested,
@@ -741,12 +731,6 @@ impl<'tcx, N> ImplSource<'tcx, N> {
741731
fn_ty: p.fn_ty,
742732
nested: p.nested.into_iter().map(f).collect(),
743733
}),
744-
ImplSource::DiscriminantKind(ImplSourceDiscriminantKindData) => {
745-
ImplSource::DiscriminantKind(ImplSourceDiscriminantKindData)
746-
}
747-
ImplSource::Pointee(ImplSourcePointeeData) => {
748-
ImplSource::Pointee(ImplSourcePointeeData)
749-
}
750734
ImplSource::TraitAlias(d) => ImplSource::TraitAlias(ImplSourceTraitAliasData {
751735
alias_def_id: d.alias_def_id,
752736
substs: d.substs,
@@ -856,13 +840,6 @@ pub struct ImplSourceFnPointerData<'tcx, N> {
856840
pub nested: Vec<N>,
857841
}
858842

859-
// FIXME(@lcnr): This should be refactored and merged with other builtin vtables.
860-
#[derive(Clone, Debug, PartialEq, Eq, TyEncodable, TyDecodable, HashStable)]
861-
pub struct ImplSourceDiscriminantKindData;
862-
863-
#[derive(Clone, Debug, PartialEq, Eq, TyEncodable, TyDecodable, HashStable)]
864-
pub struct ImplSourcePointeeData;
865-
866843
#[derive(Clone, PartialEq, Eq, TyEncodable, TyDecodable, HashStable, Lift)]
867844
#[derive(TypeFoldable, TypeVisitable)]
868845
pub struct ImplSourceConstDestructData<N> {

‎compiler/rustc_middle/src/traits/select.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,6 @@ pub enum SelectionCandidate<'tcx> {
137137
is_const: bool,
138138
},
139139

140-
/// Builtin implementation of `DiscriminantKind`.
141-
DiscriminantKindCandidate,
142-
143-
/// Builtin implementation of `Pointee`.
144-
PointeeCandidate,
145-
146140
TraitAliasCandidate,
147141

148142
/// Matching `dyn Trait` with a supertrait of `Trait`. The index is the

‎compiler/rustc_middle/src/traits/structural_impls.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSource<'tcx, N> {
1717

1818
super::ImplSource::FnPointer(ref d) => write!(f, "({:?})", d),
1919

20-
super::ImplSource::DiscriminantKind(ref d) => write!(f, "{:?}", d),
21-
22-
super::ImplSource::Pointee(ref d) => write!(f, "{:?}", d),
23-
2420
super::ImplSource::Object(ref d) => write!(f, "{:?}", d),
2521

2622
super::ImplSource::Param(ref n, ct) => {
@@ -125,11 +121,3 @@ impl<N: fmt::Debug> fmt::Debug for traits::ImplSourceConstDestructData<N> {
125121
write!(f, "ImplSourceConstDestructData(nested={:?})", self.nested)
126122
}
127123
}
128-
129-
///////////////////////////////////////////////////////////////////////////
130-
// Lift implementations
131-
132-
TrivialTypeTraversalAndLiftImpls! {
133-
super::ImplSourceDiscriminantKindData,
134-
super::ImplSourcePointeeData,
135-
}

‎compiler/rustc_trait_selection/src/traits/project.rs

Lines changed: 157 additions & 176 deletions
Large diffs are not rendered by default.

‎compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
284284
self.assemble_builtin_bound_candidates(copy_conditions, &mut candidates);
285285
} else if lang_items.discriminant_kind_trait() == Some(def_id) {
286286
// `DiscriminantKind` is automatically implemented for every type.
287-
candidates.vec.push(DiscriminantKindCandidate);
287+
candidates.vec.push(BuiltinCandidate { has_nested: false });
288288
} else if lang_items.pointee_trait() == Some(def_id) {
289289
// `Pointee` is automatically implemented for every type.
290-
candidates.vec.push(PointeeCandidate);
290+
candidates.vec.push(BuiltinCandidate { has_nested: false });
291291
} else if lang_items.sized_trait() == Some(def_id) {
292292
// Sized is never implementable by end-users, it is
293293
// always automatically computed.

‎compiler/rustc_trait_selection/src/traits/select/confirmation.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ use crate::traits::util::{self, closure_trait_ref_and_return_type, predicate_for
2222
use crate::traits::{
2323
BuiltinDerivedObligation, ImplDerivedObligation, ImplDerivedObligationCause, ImplSource,
2424
ImplSourceAutoImplData, ImplSourceBuiltinData, ImplSourceClosureData,
25-
ImplSourceConstDestructData, ImplSourceDiscriminantKindData, ImplSourceFnPointerData,
26-
ImplSourceGeneratorData, ImplSourceObjectData, ImplSourcePointeeData, ImplSourceTraitAliasData,
27-
ImplSourceTraitUpcastingData, ImplSourceUserDefinedData, Normalized, ObjectCastObligation,
28-
Obligation, ObligationCause, OutputTypeParameterMismatch, PredicateObligation, Selection,
29-
SelectionError, TraitNotObjectSafe, TraitObligation, Unimplemented, VtblSegment,
25+
ImplSourceConstDestructData, ImplSourceFnPointerData, ImplSourceGeneratorData,
26+
ImplSourceObjectData, ImplSourceTraitAliasData, ImplSourceTraitUpcastingData,
27+
ImplSourceUserDefinedData, Normalized, ObjectCastObligation, Obligation, ObligationCause,
28+
OutputTypeParameterMismatch, PredicateObligation, Selection, SelectionError,
29+
TraitNotObjectSafe, TraitObligation, Unimplemented, VtblSegment,
3030
};
3131

3232
use super::BuiltinImplConditions;
@@ -94,12 +94,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
9494
ImplSource::FnPointer(data)
9595
}
9696

97-
DiscriminantKindCandidate => {
98-
ImplSource::DiscriminantKind(ImplSourceDiscriminantKindData)
99-
}
100-
101-
PointeeCandidate => ImplSource::Pointee(ImplSourcePointeeData),
102-
10397
TraitAliasCandidate => {
10498
let data = self.confirm_trait_alias_candidate(obligation);
10599
ImplSource::TraitAlias(data)

‎compiler/rustc_trait_selection/src/traits/select/mod.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,20 +1591,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
15911591
(TransmutabilityCandidate, _) | (_, TransmutabilityCandidate) => false,
15921592

15931593
// (*)
1594-
(
1595-
BuiltinCandidate { has_nested: false }
1596-
| DiscriminantKindCandidate
1597-
| PointeeCandidate
1598-
| ConstDestructCandidate(_),
1599-
_,
1600-
) => true,
1601-
(
1602-
_,
1603-
BuiltinCandidate { has_nested: false }
1604-
| DiscriminantKindCandidate
1605-
| PointeeCandidate
1606-
| ConstDestructCandidate(_),
1607-
) => false,
1594+
(BuiltinCandidate { has_nested: false } | ConstDestructCandidate(_), _) => true,
1595+
(_, BuiltinCandidate { has_nested: false } | ConstDestructCandidate(_)) => false,
16081596

16091597
(ParamCandidate(other), ParamCandidate(victim)) => {
16101598
let same_except_bound_vars = other.skip_binder().trait_ref

‎compiler/rustc_ty_utils/src/instance.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,6 @@ fn resolve_associated_item<'tcx>(
264264
traits::ImplSource::AutoImpl(..)
265265
| traits::ImplSource::Param(..)
266266
| traits::ImplSource::TraitAlias(..)
267-
| traits::ImplSource::DiscriminantKind(..)
268-
| traits::ImplSource::Pointee(..)
269267
| traits::ImplSource::TraitUpcasting(_)
270268
| traits::ImplSource::ConstDestruct(_) => None,
271269
})

0 commit comments

Comments
 (0)
Please sign in to comment.