Skip to content

Commit 9c7dc3e

Browse files
authored
Rollup merge of #104716 - lcnr:selection-candidate, r=jackh726
move 2 candidates into builtin candidate having separate candidates for these isn't too helpful i think r? types
2 parents e704e95 + 84e9790 commit 9c7dc3e

File tree

8 files changed

+171
-247
lines changed

8 files changed

+171
-247
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

@@ -682,8 +676,6 @@ impl<'tcx, N> ImplSource<'tcx, N> {
682676
ImplSource::Future(c) => c.nested,
683677
ImplSource::Object(d) => d.nested,
684678
ImplSource::FnPointer(d) => d.nested,
685-
ImplSource::DiscriminantKind(ImplSourceDiscriminantKindData)
686-
| ImplSource::Pointee(ImplSourcePointeeData) => vec![],
687679
ImplSource::TraitAlias(d) => d.nested,
688680
ImplSource::TraitUpcasting(d) => d.nested,
689681
ImplSource::ConstDestruct(i) => i.nested,
@@ -701,8 +693,6 @@ impl<'tcx, N> ImplSource<'tcx, N> {
701693
ImplSource::Future(c) => &c.nested,
702694
ImplSource::Object(d) => &d.nested,
703695
ImplSource::FnPointer(d) => &d.nested,
704-
ImplSource::DiscriminantKind(ImplSourceDiscriminantKindData)
705-
| ImplSource::Pointee(ImplSourcePointeeData) => &[],
706696
ImplSource::TraitAlias(d) => &d.nested,
707697
ImplSource::TraitUpcasting(d) => &d.nested,
708698
ImplSource::ConstDestruct(i) => &i.nested,
@@ -751,12 +741,6 @@ impl<'tcx, N> ImplSource<'tcx, N> {
751741
fn_ty: p.fn_ty,
752742
nested: p.nested.into_iter().map(f).collect(),
753743
}),
754-
ImplSource::DiscriminantKind(ImplSourceDiscriminantKindData) => {
755-
ImplSource::DiscriminantKind(ImplSourceDiscriminantKindData)
756-
}
757-
ImplSource::Pointee(ImplSourcePointeeData) => {
758-
ImplSource::Pointee(ImplSourcePointeeData)
759-
}
760744
ImplSource::TraitAlias(d) => ImplSource::TraitAlias(ImplSourceTraitAliasData {
761745
alias_def_id: d.alias_def_id,
762746
substs: d.substs,
@@ -876,13 +860,6 @@ pub struct ImplSourceFnPointerData<'tcx, N> {
876860
pub nested: Vec<N>,
877861
}
878862

879-
// FIXME(@lcnr): This should be refactored and merged with other builtin vtables.
880-
#[derive(Clone, Debug, PartialEq, Eq, TyEncodable, TyDecodable, HashStable)]
881-
pub struct ImplSourceDiscriminantKindData;
882-
883-
#[derive(Clone, Debug, PartialEq, Eq, TyEncodable, TyDecodable, HashStable)]
884-
pub struct ImplSourcePointeeData;
885-
886863
#[derive(Clone, PartialEq, Eq, TyEncodable, TyDecodable, HashStable, Lift)]
887864
#[derive(TypeFoldable, TypeVisitable)]
888865
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,
@@ -141,12 +147,6 @@ pub enum SelectionCandidate<'tcx> {
141147
is_const: bool,
142148
},
143149

144-
/// Builtin implementation of `DiscriminantKind`.
145-
DiscriminantKindCandidate,
146-
147-
/// Builtin implementation of `Pointee`.
148-
PointeeCandidate,
149-
150150
TraitAliasCandidate,
151151

152152
/// 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
@@ -19,10 +19,6 @@ impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSource<'tcx, N> {
1919

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

22-
super::ImplSource::DiscriminantKind(ref d) => write!(f, "{:?}", d),
23-
24-
super::ImplSource::Pointee(ref d) => write!(f, "{:?}", d),
25-
2622
super::ImplSource::Object(ref d) => write!(f, "{:?}", d),
2723

2824
super::ImplSource::Param(ref n, ct) => {
@@ -137,11 +133,3 @@ impl<N: fmt::Debug> fmt::Debug for traits::ImplSourceConstDestructData<N> {
137133
write!(f, "ImplSourceConstDestructData(nested={:?})", self.nested)
138134
}
139135
}
140-
141-
///////////////////////////////////////////////////////////////////////////
142-
// Lift implementations
143-
144-
TrivialTypeTraversalAndLiftImpls! {
145-
super::ImplSourceDiscriminantKindData,
146-
super::ImplSourcePointeeData,
147-
}

0 commit comments

Comments
 (0)