Skip to content

Commit 58d533d

Browse files
authored
Rollup merge of #102786 - compiler-errors:no-tuple-candidate, r=lcnr
Remove tuple candidate, nothing special about it r? `@lcnr` you mentioned this during the talk you gave i think
2 parents 0c17324 + 8b9a1f1 commit 58d533d

File tree

8 files changed

+9
-28
lines changed

8 files changed

+9
-28
lines changed

compiler/rustc_middle/src/traits/mod.rs

+2-9
Original file line numberDiff line numberDiff line change
@@ -664,10 +664,6 @@ pub enum ImplSource<'tcx, N> {
664664

665665
/// ImplSource for a `const Drop` implementation.
666666
ConstDestruct(ImplSourceConstDestructData<N>),
667-
668-
/// ImplSource for a `std::marker::Tuple` implementation.
669-
/// This has no nested predicates ever, so no data.
670-
Tuple,
671667
}
672668

673669
impl<'tcx, N> ImplSource<'tcx, N> {
@@ -682,8 +678,7 @@ impl<'tcx, N> ImplSource<'tcx, N> {
682678
ImplSource::Object(d) => d.nested,
683679
ImplSource::FnPointer(d) => d.nested,
684680
ImplSource::DiscriminantKind(ImplSourceDiscriminantKindData)
685-
| ImplSource::Pointee(ImplSourcePointeeData)
686-
| ImplSource::Tuple => Vec::new(),
681+
| ImplSource::Pointee(ImplSourcePointeeData) => vec![],
687682
ImplSource::TraitAlias(d) => d.nested,
688683
ImplSource::TraitUpcasting(d) => d.nested,
689684
ImplSource::ConstDestruct(i) => i.nested,
@@ -701,8 +696,7 @@ impl<'tcx, N> ImplSource<'tcx, N> {
701696
ImplSource::Object(d) => &d.nested,
702697
ImplSource::FnPointer(d) => &d.nested,
703698
ImplSource::DiscriminantKind(ImplSourceDiscriminantKindData)
704-
| ImplSource::Pointee(ImplSourcePointeeData)
705-
| ImplSource::Tuple => &[],
699+
| ImplSource::Pointee(ImplSourcePointeeData) => &[],
706700
ImplSource::TraitAlias(d) => &d.nested,
707701
ImplSource::TraitUpcasting(d) => &d.nested,
708702
ImplSource::ConstDestruct(i) => &i.nested,
@@ -769,7 +763,6 @@ impl<'tcx, N> ImplSource<'tcx, N> {
769763
nested: i.nested.into_iter().map(f).collect(),
770764
})
771765
}
772-
ImplSource::Tuple => ImplSource::Tuple,
773766
}
774767
}
775768
}

compiler/rustc_middle/src/traits/select.rs

-3
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,6 @@ pub enum SelectionCandidate<'tcx> {
161161

162162
/// Implementation of `const Destruct`, optionally from a custom `impl const Drop`.
163163
ConstDestructCandidate(Option<DefId>),
164-
165-
/// Witnesses the fact that a type is a tuple.
166-
TupleCandidate,
167164
}
168165

169166
/// The result of trait evaluation. The order is important

compiler/rustc_middle/src/traits/structural_impls.rs

-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSource<'tcx, N> {
3434
super::ImplSource::TraitUpcasting(ref d) => write!(f, "{:?}", d),
3535

3636
super::ImplSource::ConstDestruct(ref d) => write!(f, "{:?}", d),
37-
38-
super::ImplSource::Tuple => write!(f, "ImplSource::Tuple"),
3937
}
4038
}
4139
}

compiler/rustc_trait_selection/src/traits/project.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1750,8 +1750,7 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
17501750
super::ImplSource::AutoImpl(..)
17511751
| super::ImplSource::Builtin(..)
17521752
| super::ImplSource::TraitUpcasting(_)
1753-
| super::ImplSource::ConstDestruct(_)
1754-
| super::ImplSource::Tuple => {
1753+
| super::ImplSource::ConstDestruct(_) => {
17551754
// These traits have no associated types.
17561755
selcx.tcx().sess.delay_span_bug(
17571756
obligation.cause.span,
@@ -1829,8 +1828,7 @@ fn confirm_select_candidate<'cx, 'tcx>(
18291828
| super::ImplSource::Builtin(..)
18301829
| super::ImplSource::TraitUpcasting(_)
18311830
| super::ImplSource::TraitAlias(..)
1832-
| super::ImplSource::ConstDestruct(_)
1833-
| super::ImplSource::Tuple => {
1831+
| super::ImplSource::ConstDestruct(_) => {
18341832
// we don't create Select candidates with this kind of resolution
18351833
span_bug!(
18361834
obligation.cause.span,

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
10211021
let self_ty = self.infcx().shallow_resolve(obligation.self_ty().skip_binder());
10221022
match self_ty.kind() {
10231023
ty::Tuple(_) => {
1024-
candidates.vec.push(TupleCandidate);
1024+
candidates.vec.push(BuiltinCandidate { has_nested: false });
10251025
}
10261026
ty::Infer(ty::TyVar(_)) => {
10271027
candidates.ambiguous = true;

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

-2
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
126126
let data = self.confirm_const_destruct_candidate(obligation, def_id)?;
127127
ImplSource::ConstDestruct(data)
128128
}
129-
130-
TupleCandidate => ImplSource::Tuple,
131129
};
132130

133131
if !obligation.predicate.is_const_if_const() {

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

+3-5
Original file line numberDiff line numberDiff line change
@@ -1562,7 +1562,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
15621562
};
15631563

15641564
// (*) Prefer `BuiltinCandidate { has_nested: false }`, `PointeeCandidate`,
1565-
// `DiscriminantKindCandidate`, `ConstDestructCandidate`, and `TupleCandidate`
1565+
// `DiscriminantKindCandidate`, `ConstDestructCandidate`
15661566
// to anything else.
15671567
//
15681568
// This is a fix for #53123 and prevents winnowing from accidentally extending the
@@ -1583,17 +1583,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
15831583
BuiltinCandidate { has_nested: false }
15841584
| DiscriminantKindCandidate
15851585
| PointeeCandidate
1586-
| ConstDestructCandidate(_)
1587-
| TupleCandidate,
1586+
| ConstDestructCandidate(_),
15881587
_,
15891588
) => true,
15901589
(
15911590
_,
15921591
BuiltinCandidate { has_nested: false }
15931592
| DiscriminantKindCandidate
15941593
| PointeeCandidate
1595-
| ConstDestructCandidate(_)
1596-
| TupleCandidate,
1594+
| ConstDestructCandidate(_),
15971595
) => false,
15981596

15991597
(ParamCandidate(other), ParamCandidate(victim)) => {

compiler/rustc_ty_utils/src/instance.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,7 @@ fn resolve_associated_item<'tcx>(
267267
| traits::ImplSource::DiscriminantKind(..)
268268
| traits::ImplSource::Pointee(..)
269269
| traits::ImplSource::TraitUpcasting(_)
270-
| traits::ImplSource::ConstDestruct(_)
271-
| traits::ImplSource::Tuple => None,
270+
| traits::ImplSource::ConstDestruct(_) => None,
272271
})
273272
}
274273

0 commit comments

Comments
 (0)