Skip to content

Commit ace9924

Browse files
authored
Rollup merge of rust-lang#104716 - lcnr:selection-candidate, r=lcnr
move 2 candidates into builtin candidate having separate candidates for these isn't too helpful i think r? types
2 parents 872631d + f995583 commit ace9924

File tree

8 files changed

+172
-246
lines changed

8 files changed

+172
-246
lines changed

compiler/rustc_middle/src/traits/mod.rs

-23
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

+6-6
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ pub type EvaluationCache<'tcx> = Cache<
105105
/// parameter environment.
106106
#[derive(PartialEq, Eq, Debug, Clone, TypeFoldable, TypeVisitable)]
107107
pub enum SelectionCandidate<'tcx> {
108+
/// A builtin implementation for some specific traits, used in cases
109+
/// where we cannot rely an ordinary library implementations.
110+
///
111+
/// The most notable examples are `sized`, `Copy` and `Clone`. This is also
112+
/// used for the `DiscriminantKind` and `Pointee` trait, both of which have
113+
/// an associated type.
108114
BuiltinCandidate {
109115
/// `false` if there are no *further* obligations.
110116
has_nested: bool,
@@ -137,12 +143,6 @@ pub enum SelectionCandidate<'tcx> {
137143
is_const: bool,
138144
},
139145

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

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

compiler/rustc_middle/src/traits/structural_impls.rs

-12
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-
}

0 commit comments

Comments
 (0)