mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
yeet ImplSource::TraitAlias too
This commit is contained in:
parent
db235a07f7
commit
42571c4847
@ -660,9 +660,6 @@ pub enum ImplSource<'tcx, N> {
|
||||
|
||||
/// ImplSource for trait upcasting coercion
|
||||
TraitUpcasting(ImplSourceTraitUpcastingData<N>),
|
||||
|
||||
/// ImplSource for a trait alias.
|
||||
TraitAlias(ImplSourceTraitAliasData<'tcx, N>),
|
||||
}
|
||||
|
||||
impl<'tcx, N> ImplSource<'tcx, N> {
|
||||
@ -671,7 +668,6 @@ impl<'tcx, N> ImplSource<'tcx, N> {
|
||||
ImplSource::UserDefined(i) => i.nested,
|
||||
ImplSource::Param(n, _) | ImplSource::Builtin(n) => n,
|
||||
ImplSource::Object(d) => d.nested,
|
||||
ImplSource::TraitAlias(d) => d.nested,
|
||||
ImplSource::TraitUpcasting(d) => d.nested,
|
||||
}
|
||||
}
|
||||
@ -681,7 +677,6 @@ impl<'tcx, N> ImplSource<'tcx, N> {
|
||||
ImplSource::UserDefined(i) => &i.nested,
|
||||
ImplSource::Param(n, _) | ImplSource::Builtin(n) => &n,
|
||||
ImplSource::Object(d) => &d.nested,
|
||||
ImplSource::TraitAlias(d) => &d.nested,
|
||||
ImplSource::TraitUpcasting(d) => &d.nested,
|
||||
}
|
||||
}
|
||||
@ -691,7 +686,6 @@ impl<'tcx, N> ImplSource<'tcx, N> {
|
||||
ImplSource::UserDefined(i) => &mut i.nested,
|
||||
ImplSource::Param(n, _) | ImplSource::Builtin(n) => n,
|
||||
ImplSource::Object(d) => &mut d.nested,
|
||||
ImplSource::TraitAlias(d) => &mut d.nested,
|
||||
ImplSource::TraitUpcasting(d) => &mut d.nested,
|
||||
}
|
||||
}
|
||||
@ -713,11 +707,6 @@ impl<'tcx, N> ImplSource<'tcx, N> {
|
||||
vtable_base: o.vtable_base,
|
||||
nested: o.nested.into_iter().map(f).collect(),
|
||||
}),
|
||||
ImplSource::TraitAlias(d) => ImplSource::TraitAlias(ImplSourceTraitAliasData {
|
||||
alias_def_id: d.alias_def_id,
|
||||
substs: d.substs,
|
||||
nested: d.nested.into_iter().map(f).collect(),
|
||||
}),
|
||||
ImplSource::TraitUpcasting(d) => {
|
||||
ImplSource::TraitUpcasting(ImplSourceTraitUpcastingData {
|
||||
vtable_vptr_slot: d.vtable_vptr_slot,
|
||||
@ -773,14 +762,6 @@ pub struct ImplSourceObjectData<N> {
|
||||
pub nested: Vec<N>,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, TyEncodable, TyDecodable, HashStable, Lift)]
|
||||
#[derive(TypeFoldable, TypeVisitable)]
|
||||
pub struct ImplSourceTraitAliasData<'tcx, N> {
|
||||
pub alias_def_id: DefId,
|
||||
pub substs: SubstsRef<'tcx>,
|
||||
pub nested: Vec<N>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, HashStable, PartialOrd, Ord)]
|
||||
pub enum ObjectSafetyViolation {
|
||||
/// `Self: Sized` declared on the trait.
|
||||
|
@ -17,8 +17,6 @@ impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSource<'tcx, N> {
|
||||
write!(f, "ImplSourceParamData({:?}, {:?})", n, ct)
|
||||
}
|
||||
|
||||
super::ImplSource::TraitAlias(ref d) => write!(f, "{:?}", d),
|
||||
|
||||
super::ImplSource::TraitUpcasting(ref d) => write!(f, "{:?}", d),
|
||||
}
|
||||
}
|
||||
@ -53,13 +51,3 @@ impl<N: fmt::Debug> fmt::Debug for traits::ImplSourceObjectData<N> {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSourceTraitAliasData<'tcx, N> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"ImplSourceTraitAliasData(alias_def_id={:?}, substs={:?}, nested={:?})",
|
||||
self.alias_def_id, self.substs, self.nested
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -1721,7 +1721,6 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
|
||||
};
|
||||
|
||||
let eligible = match &impl_source {
|
||||
super::ImplSource::TraitAlias(_) => true,
|
||||
super::ImplSource::UserDefined(impl_data) => {
|
||||
// We have to be careful when projecting out of an
|
||||
// impl because of specialization. If we are not in
|
||||
@ -2013,8 +2012,7 @@ fn confirm_select_candidate<'cx, 'tcx>(
|
||||
}
|
||||
super::ImplSource::Object(_)
|
||||
| super::ImplSource::Param(..)
|
||||
| super::ImplSource::TraitUpcasting(_)
|
||||
| super::ImplSource::TraitAlias(..) => {
|
||||
| super::ImplSource::TraitUpcasting(_) => {
|
||||
// we don't create Select candidates with this kind of resolution
|
||||
span_bug!(
|
||||
obligation.cause.span,
|
||||
|
@ -27,10 +27,9 @@ use crate::traits::vtable::{
|
||||
};
|
||||
use crate::traits::{
|
||||
BuiltinDerivedObligation, ImplDerivedObligation, ImplDerivedObligationCause, ImplSource,
|
||||
ImplSourceObjectData, ImplSourceTraitAliasData, ImplSourceTraitUpcastingData,
|
||||
ImplSourceUserDefinedData, Normalized, Obligation, ObligationCause,
|
||||
OutputTypeParameterMismatch, PredicateObligation, Selection, SelectionError,
|
||||
TraitNotObjectSafe, TraitObligation, Unimplemented,
|
||||
ImplSourceObjectData, ImplSourceTraitUpcastingData, ImplSourceUserDefinedData, Normalized,
|
||||
Obligation, ObligationCause, OutputTypeParameterMismatch, PredicateObligation, Selection,
|
||||
SelectionError, TraitNotObjectSafe, TraitObligation, Unimplemented,
|
||||
};
|
||||
|
||||
use super::BuiltinImplConditions;
|
||||
@ -105,7 +104,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
|
||||
TraitAliasCandidate => {
|
||||
let data = self.confirm_trait_alias_candidate(obligation);
|
||||
ImplSource::TraitAlias(data)
|
||||
ImplSource::Builtin(data)
|
||||
}
|
||||
|
||||
BuiltinObjectCandidate => {
|
||||
@ -721,10 +720,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
fn confirm_trait_alias_candidate(
|
||||
&mut self,
|
||||
obligation: &TraitObligation<'tcx>,
|
||||
) -> ImplSourceTraitAliasData<'tcx, PredicateObligation<'tcx>> {
|
||||
) -> Vec<PredicateObligation<'tcx>> {
|
||||
debug!(?obligation, "confirm_trait_alias_candidate");
|
||||
|
||||
let alias_def_id = obligation.predicate.def_id();
|
||||
let predicate = self.infcx.instantiate_binder_with_placeholders(obligation.predicate);
|
||||
let trait_ref = predicate.trait_ref;
|
||||
let trait_def_id = trait_ref.def_id;
|
||||
@ -741,7 +739,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
|
||||
debug!(?trait_def_id, ?trait_obligations, "trait alias obligations");
|
||||
|
||||
ImplSourceTraitAliasData { alias_def_id, substs, nested: trait_obligations }
|
||||
trait_obligations
|
||||
}
|
||||
|
||||
fn confirm_generator_candidate(
|
||||
|
@ -293,9 +293,7 @@ fn resolve_associated_item<'tcx>(
|
||||
None
|
||||
}
|
||||
}
|
||||
traits::ImplSource::Param(..)
|
||||
| traits::ImplSource::TraitAlias(..)
|
||||
| traits::ImplSource::TraitUpcasting(_) => None,
|
||||
traits::ImplSource::Param(..) | traits::ImplSource::TraitUpcasting(_) => None,
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user