mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-02 07:22:42 +00:00
remove enum name from ImplSource variants
This commit is contained in:
parent
893fadd11a
commit
1857184cd1
@ -28,7 +28,6 @@ pub use self::select::{EvaluationCache, EvaluationResult, OverflowError, Selecti
|
|||||||
|
|
||||||
pub type CanonicalChalkEnvironmentAndGoal<'tcx> = Canonical<'tcx, ChalkEnvironmentAndGoal<'tcx>>;
|
pub type CanonicalChalkEnvironmentAndGoal<'tcx> = Canonical<'tcx, ChalkEnvironmentAndGoal<'tcx>>;
|
||||||
|
|
||||||
pub use self::ImplSource::*;
|
|
||||||
pub use self::ObligationCauseCode::*;
|
pub use self::ObligationCauseCode::*;
|
||||||
|
|
||||||
pub use self::chalk::{ChalkEnvironmentAndGoal, RustInterner as ChalkRustInterner};
|
pub use self::chalk::{ChalkEnvironmentAndGoal, RustInterner as ChalkRustInterner};
|
||||||
@ -418,10 +417,10 @@ pub type SelectionResult<'tcx, T> = Result<Option<T>, SelectionError<'tcx>>;
|
|||||||
///
|
///
|
||||||
/// // Case B: ImplSource must be provided by caller. This applies when
|
/// // Case B: ImplSource must be provided by caller. This applies when
|
||||||
/// // type is a type parameter.
|
/// // type is a type parameter.
|
||||||
/// param.clone(); // ImplSourceParam
|
/// param.clone(); // ImplSource::Param
|
||||||
///
|
///
|
||||||
/// // Case C: A mix of cases A and B.
|
/// // Case C: A mix of cases A and B.
|
||||||
/// mixed.clone(); // ImplSource(Impl_1, [ImplSourceParam])
|
/// mixed.clone(); // ImplSource(Impl_1, [ImplSource::Param])
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
@ -431,72 +430,72 @@ pub type SelectionResult<'tcx, T> = Result<Option<T>, SelectionError<'tcx>>;
|
|||||||
#[derive(Clone, PartialEq, Eq, TyEncodable, TyDecodable, HashStable, TypeFoldable, Lift)]
|
#[derive(Clone, PartialEq, Eq, TyEncodable, TyDecodable, HashStable, TypeFoldable, Lift)]
|
||||||
pub enum ImplSource<'tcx, N> {
|
pub enum ImplSource<'tcx, N> {
|
||||||
/// ImplSource identifying a particular impl.
|
/// ImplSource identifying a particular impl.
|
||||||
ImplSourceUserDefined(ImplSourceUserDefinedData<'tcx, N>),
|
UserDefined(ImplSourceUserDefinedData<'tcx, N>),
|
||||||
|
|
||||||
/// ImplSource for auto trait implementations.
|
/// ImplSource for auto trait implementations.
|
||||||
/// This carries the information and nested obligations with regards
|
/// This carries the information and nested obligations with regards
|
||||||
/// to an auto implementation for a trait `Trait`. The nested obligations
|
/// to an auto implementation for a trait `Trait`. The nested obligations
|
||||||
/// ensure the trait implementation holds for all the constituent types.
|
/// ensure the trait implementation holds for all the constituent types.
|
||||||
ImplSourceAutoImpl(ImplSourceAutoImplData<N>),
|
AutoImpl(ImplSourceAutoImplData<N>),
|
||||||
|
|
||||||
/// Successful resolution to an obligation provided by the caller
|
/// Successful resolution to an obligation provided by the caller
|
||||||
/// for some type parameter. The `Vec<N>` represents the
|
/// for some type parameter. The `Vec<N>` represents the
|
||||||
/// obligations incurred from normalizing the where-clause (if
|
/// obligations incurred from normalizing the where-clause (if
|
||||||
/// any).
|
/// any).
|
||||||
ImplSourceParam(Vec<N>),
|
Param(Vec<N>),
|
||||||
|
|
||||||
/// Virtual calls through an object.
|
/// Virtual calls through an object.
|
||||||
ImplSourceObject(ImplSourceObjectData<'tcx, N>),
|
Object(ImplSourceObjectData<'tcx, N>),
|
||||||
|
|
||||||
/// Successful resolution for a builtin trait.
|
/// Successful resolution for a builtin trait.
|
||||||
ImplSourceBuiltin(ImplSourceBuiltinData<N>),
|
Builtin(ImplSourceBuiltinData<N>),
|
||||||
|
|
||||||
/// ImplSource automatically generated for a closure. The `DefId` is the ID
|
/// ImplSource automatically generated for a closure. The `DefId` is the ID
|
||||||
/// of the closure expression. This is a `ImplSourceUserDefined` in spirit, but the
|
/// of the closure expression. This is a `ImplSource::UserDefined` in spirit, but the
|
||||||
/// impl is generated by the compiler and does not appear in the source.
|
/// impl is generated by the compiler and does not appear in the source.
|
||||||
ImplSourceClosure(ImplSourceClosureData<'tcx, N>),
|
Closure(ImplSourceClosureData<'tcx, N>),
|
||||||
|
|
||||||
/// Same as above, but for a function pointer type with the given signature.
|
/// Same as above, but for a function pointer type with the given signature.
|
||||||
ImplSourceFnPointer(ImplSourceFnPointerData<'tcx, N>),
|
FnPointer(ImplSourceFnPointerData<'tcx, N>),
|
||||||
|
|
||||||
/// ImplSource for a builtin `DeterminantKind` trait implementation.
|
/// ImplSource for a builtin `DeterminantKind` trait implementation.
|
||||||
ImplSourceDiscriminantKind(ImplSourceDiscriminantKindData),
|
DiscriminantKind(ImplSourceDiscriminantKindData),
|
||||||
|
|
||||||
/// ImplSource automatically generated for a generator.
|
/// ImplSource automatically generated for a generator.
|
||||||
ImplSourceGenerator(ImplSourceGeneratorData<'tcx, N>),
|
Generator(ImplSourceGeneratorData<'tcx, N>),
|
||||||
|
|
||||||
/// ImplSource for a trait alias.
|
/// ImplSource for a trait alias.
|
||||||
ImplSourceTraitAlias(ImplSourceTraitAliasData<'tcx, N>),
|
TraitAlias(ImplSourceTraitAliasData<'tcx, N>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, N> ImplSource<'tcx, N> {
|
impl<'tcx, N> ImplSource<'tcx, N> {
|
||||||
pub fn nested_obligations(self) -> Vec<N> {
|
pub fn nested_obligations(self) -> Vec<N> {
|
||||||
match self {
|
match self {
|
||||||
ImplSourceUserDefined(i) => i.nested,
|
ImplSource::UserDefined(i) => i.nested,
|
||||||
ImplSourceParam(n) => n,
|
ImplSource::Param(n) => n,
|
||||||
ImplSourceBuiltin(i) => i.nested,
|
ImplSource::Builtin(i) => i.nested,
|
||||||
ImplSourceAutoImpl(d) => d.nested,
|
ImplSource::AutoImpl(d) => d.nested,
|
||||||
ImplSourceClosure(c) => c.nested,
|
ImplSource::Closure(c) => c.nested,
|
||||||
ImplSourceGenerator(c) => c.nested,
|
ImplSource::Generator(c) => c.nested,
|
||||||
ImplSourceObject(d) => d.nested,
|
ImplSource::Object(d) => d.nested,
|
||||||
ImplSourceFnPointer(d) => d.nested,
|
ImplSource::FnPointer(d) => d.nested,
|
||||||
ImplSourceDiscriminantKind(ImplSourceDiscriminantKindData) => Vec::new(),
|
ImplSource::DiscriminantKind(ImplSourceDiscriminantKindData) => Vec::new(),
|
||||||
ImplSourceTraitAlias(d) => d.nested,
|
ImplSource::TraitAlias(d) => d.nested,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn borrow_nested_obligations(&self) -> &[N] {
|
pub fn borrow_nested_obligations(&self) -> &[N] {
|
||||||
match &self {
|
match &self {
|
||||||
ImplSourceUserDefined(i) => &i.nested[..],
|
ImplSource::UserDefined(i) => &i.nested[..],
|
||||||
ImplSourceParam(n) => &n[..],
|
ImplSource::Param(n) => &n[..],
|
||||||
ImplSourceBuiltin(i) => &i.nested[..],
|
ImplSource::Builtin(i) => &i.nested[..],
|
||||||
ImplSourceAutoImpl(d) => &d.nested[..],
|
ImplSource::AutoImpl(d) => &d.nested[..],
|
||||||
ImplSourceClosure(c) => &c.nested[..],
|
ImplSource::Closure(c) => &c.nested[..],
|
||||||
ImplSourceGenerator(c) => &c.nested[..],
|
ImplSource::Generator(c) => &c.nested[..],
|
||||||
ImplSourceObject(d) => &d.nested[..],
|
ImplSource::Object(d) => &d.nested[..],
|
||||||
ImplSourceFnPointer(d) => &d.nested[..],
|
ImplSource::FnPointer(d) => &d.nested[..],
|
||||||
ImplSourceDiscriminantKind(ImplSourceDiscriminantKindData) => &[],
|
ImplSource::DiscriminantKind(ImplSourceDiscriminantKindData) => &[],
|
||||||
ImplSourceTraitAlias(d) => &d.nested[..],
|
ImplSource::TraitAlias(d) => &d.nested[..],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -505,42 +504,42 @@ impl<'tcx, N> ImplSource<'tcx, N> {
|
|||||||
F: FnMut(N) -> M,
|
F: FnMut(N) -> M,
|
||||||
{
|
{
|
||||||
match self {
|
match self {
|
||||||
ImplSourceUserDefined(i) => ImplSourceUserDefined(ImplSourceUserDefinedData {
|
ImplSource::UserDefined(i) => ImplSource::UserDefined(ImplSourceUserDefinedData {
|
||||||
impl_def_id: i.impl_def_id,
|
impl_def_id: i.impl_def_id,
|
||||||
substs: i.substs,
|
substs: i.substs,
|
||||||
nested: i.nested.into_iter().map(f).collect(),
|
nested: i.nested.into_iter().map(f).collect(),
|
||||||
}),
|
}),
|
||||||
ImplSourceParam(n) => ImplSourceParam(n.into_iter().map(f).collect()),
|
ImplSource::Param(n) => ImplSource::Param(n.into_iter().map(f).collect()),
|
||||||
ImplSourceBuiltin(i) => ImplSourceBuiltin(ImplSourceBuiltinData {
|
ImplSource::Builtin(i) => ImplSource::Builtin(ImplSourceBuiltinData {
|
||||||
nested: i.nested.into_iter().map(f).collect(),
|
nested: i.nested.into_iter().map(f).collect(),
|
||||||
}),
|
}),
|
||||||
ImplSourceObject(o) => ImplSourceObject(ImplSourceObjectData {
|
ImplSource::Object(o) => ImplSource::Object(ImplSourceObjectData {
|
||||||
upcast_trait_ref: o.upcast_trait_ref,
|
upcast_trait_ref: o.upcast_trait_ref,
|
||||||
vtable_base: o.vtable_base,
|
vtable_base: o.vtable_base,
|
||||||
nested: o.nested.into_iter().map(f).collect(),
|
nested: o.nested.into_iter().map(f).collect(),
|
||||||
}),
|
}),
|
||||||
ImplSourceAutoImpl(d) => ImplSourceAutoImpl(ImplSourceAutoImplData {
|
ImplSource::AutoImpl(d) => ImplSource::AutoImpl(ImplSourceAutoImplData {
|
||||||
trait_def_id: d.trait_def_id,
|
trait_def_id: d.trait_def_id,
|
||||||
nested: d.nested.into_iter().map(f).collect(),
|
nested: d.nested.into_iter().map(f).collect(),
|
||||||
}),
|
}),
|
||||||
ImplSourceClosure(c) => ImplSourceClosure(ImplSourceClosureData {
|
ImplSource::Closure(c) => ImplSource::Closure(ImplSourceClosureData {
|
||||||
closure_def_id: c.closure_def_id,
|
closure_def_id: c.closure_def_id,
|
||||||
substs: c.substs,
|
substs: c.substs,
|
||||||
nested: c.nested.into_iter().map(f).collect(),
|
nested: c.nested.into_iter().map(f).collect(),
|
||||||
}),
|
}),
|
||||||
ImplSourceGenerator(c) => ImplSourceGenerator(ImplSourceGeneratorData {
|
ImplSource::Generator(c) => ImplSource::Generator(ImplSourceGeneratorData {
|
||||||
generator_def_id: c.generator_def_id,
|
generator_def_id: c.generator_def_id,
|
||||||
substs: c.substs,
|
substs: c.substs,
|
||||||
nested: c.nested.into_iter().map(f).collect(),
|
nested: c.nested.into_iter().map(f).collect(),
|
||||||
}),
|
}),
|
||||||
ImplSourceFnPointer(p) => ImplSourceFnPointer(ImplSourceFnPointerData {
|
ImplSource::FnPointer(p) => ImplSource::FnPointer(ImplSourceFnPointerData {
|
||||||
fn_ty: p.fn_ty,
|
fn_ty: p.fn_ty,
|
||||||
nested: p.nested.into_iter().map(f).collect(),
|
nested: p.nested.into_iter().map(f).collect(),
|
||||||
}),
|
}),
|
||||||
ImplSourceDiscriminantKind(ImplSourceDiscriminantKindData) => {
|
ImplSource::DiscriminantKind(ImplSourceDiscriminantKindData) => {
|
||||||
ImplSourceDiscriminantKind(ImplSourceDiscriminantKindData)
|
ImplSource::DiscriminantKind(ImplSourceDiscriminantKindData)
|
||||||
}
|
}
|
||||||
ImplSourceTraitAlias(d) => ImplSourceTraitAlias(ImplSourceTraitAliasData {
|
ImplSource::TraitAlias(d) => ImplSource::TraitAlias(ImplSourceTraitAliasData {
|
||||||
alias_def_id: d.alias_def_id,
|
alias_def_id: d.alias_def_id,
|
||||||
substs: d.substs,
|
substs: d.substs,
|
||||||
nested: d.nested.into_iter().map(f).collect(),
|
nested: d.nested.into_iter().map(f).collect(),
|
||||||
|
@ -7,25 +7,25 @@ use std::fmt;
|
|||||||
impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSource<'tcx, N> {
|
impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSource<'tcx, N> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
super::ImplSourceUserDefined(ref v) => write!(f, "{:?}", v),
|
super::ImplSource::UserDefined(ref v) => write!(f, "{:?}", v),
|
||||||
|
|
||||||
super::ImplSourceAutoImpl(ref t) => write!(f, "{:?}", t),
|
super::ImplSource::AutoImpl(ref t) => write!(f, "{:?}", t),
|
||||||
|
|
||||||
super::ImplSourceClosure(ref d) => write!(f, "{:?}", d),
|
super::ImplSource::Closure(ref d) => write!(f, "{:?}", d),
|
||||||
|
|
||||||
super::ImplSourceGenerator(ref d) => write!(f, "{:?}", d),
|
super::ImplSource::Generator(ref d) => write!(f, "{:?}", d),
|
||||||
|
|
||||||
super::ImplSourceFnPointer(ref d) => write!(f, "ImplSourceFnPointer({:?})", d),
|
super::ImplSource::FnPointer(ref d) => write!(f, "({:?})", d),
|
||||||
|
|
||||||
super::ImplSourceDiscriminantKind(ref d) => write!(f, "{:?}", d),
|
super::ImplSource::DiscriminantKind(ref d) => write!(f, "{:?}", d),
|
||||||
|
|
||||||
super::ImplSourceObject(ref d) => write!(f, "{:?}", d),
|
super::ImplSource::Object(ref d) => write!(f, "{:?}", d),
|
||||||
|
|
||||||
super::ImplSourceParam(ref n) => write!(f, "ImplSourceParam({:?})", n),
|
super::ImplSource::Param(ref n) => write!(f, "ImplSourceParamData({:?})", n),
|
||||||
|
|
||||||
super::ImplSourceBuiltin(ref d) => write!(f, "{:?}", d),
|
super::ImplSource::Builtin(ref d) => write!(f, "{:?}", d),
|
||||||
|
|
||||||
super::ImplSourceTraitAlias(ref d) => write!(f, "{:?}", d),
|
super::ImplSource::TraitAlias(ref d) => write!(f, "{:?}", d),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -96,7 +96,7 @@ impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSourceTraitAliasData<'tcx,
|
|||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"ImplSourceTraitAlias(alias_def_id={:?}, substs={:?}, nested={:?})",
|
"ImplSourceTraitAliasData(alias_def_id={:?}, substs={:?}, nested={:?})",
|
||||||
self.alias_def_id, self.substs, self.nested
|
self.alias_def_id, self.substs, self.nested
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ pub fn custom_coerce_unsize_info<'tcx>(
|
|||||||
});
|
});
|
||||||
|
|
||||||
match tcx.codegen_fulfill_obligation((ty::ParamEnv::reveal_all(), trait_ref)) {
|
match tcx.codegen_fulfill_obligation((ty::ParamEnv::reveal_all(), trait_ref)) {
|
||||||
Ok(traits::ImplSourceUserDefined(traits::ImplSourceUserDefinedData {
|
Ok(traits::ImplSource::UserDefined(traits::ImplSourceUserDefinedData {
|
||||||
impl_def_id,
|
impl_def_id,
|
||||||
..
|
..
|
||||||
})) => tcx.coerce_unsized_info(impl_def_id).custom_kind.unwrap(),
|
})) => tcx.coerce_unsized_info(impl_def_id).custom_kind.unwrap(),
|
||||||
|
@ -96,7 +96,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
|||||||
));
|
));
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
Ok(Some(ImplSource::ImplSourceUserDefined(_))) => {
|
Ok(Some(ImplSource::UserDefined(_))) => {
|
||||||
debug!(
|
debug!(
|
||||||
"find_auto_trait_generics({:?}): \
|
"find_auto_trait_generics({:?}): \
|
||||||
manual impl found, bailing out",
|
manual impl found, bailing out",
|
||||||
@ -315,9 +315,8 @@ impl AutoTraitFinder<'tcx> {
|
|||||||
// If we see an explicit negative impl (e.g., `impl !Send for MyStruct`),
|
// If we see an explicit negative impl (e.g., `impl !Send for MyStruct`),
|
||||||
// we immediately bail out, since it's impossible for us to continue.
|
// we immediately bail out, since it's impossible for us to continue.
|
||||||
|
|
||||||
if let ImplSource::ImplSourceUserDefined(ImplSourceUserDefinedData {
|
if let ImplSource::UserDefined(ImplSourceUserDefinedData {
|
||||||
impl_def_id,
|
impl_def_id, ..
|
||||||
..
|
|
||||||
}) = impl_source
|
}) = impl_source
|
||||||
{
|
{
|
||||||
// Blame 'tidy' for the weird bracket placement.
|
// Blame 'tidy' for the weird bracket placement.
|
||||||
|
@ -1000,15 +1000,15 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
|
|||||||
};
|
};
|
||||||
|
|
||||||
let eligible = match &impl_source {
|
let eligible = match &impl_source {
|
||||||
super::ImplSourceClosure(_)
|
super::ImplSource::Closure(_)
|
||||||
| super::ImplSourceGenerator(_)
|
| super::ImplSource::Generator(_)
|
||||||
| super::ImplSourceFnPointer(_)
|
| super::ImplSource::FnPointer(_)
|
||||||
| super::ImplSourceObject(_)
|
| super::ImplSource::Object(_)
|
||||||
| super::ImplSourceTraitAlias(_) => {
|
| super::ImplSource::TraitAlias(_) => {
|
||||||
debug!("assemble_candidates_from_impls: impl_source={:?}", impl_source);
|
debug!("assemble_candidates_from_impls: impl_source={:?}", impl_source);
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
super::ImplSourceUserDefined(impl_data) => {
|
super::ImplSource::UserDefined(impl_data) => {
|
||||||
// We have to be careful when projecting out of an
|
// We have to be careful when projecting out of an
|
||||||
// impl because of specialization. If we are not in
|
// impl because of specialization. If we are not in
|
||||||
// codegen (i.e., projection mode is not "any"), and the
|
// codegen (i.e., projection mode is not "any"), and the
|
||||||
@ -1060,7 +1060,7 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super::ImplSourceDiscriminantKind(..) => {
|
super::ImplSource::DiscriminantKind(..) => {
|
||||||
// While `DiscriminantKind` is automatically implemented for every type,
|
// While `DiscriminantKind` is automatically implemented for every type,
|
||||||
// the concrete discriminant may not be known yet.
|
// the concrete discriminant may not be known yet.
|
||||||
//
|
//
|
||||||
@ -1100,7 +1100,7 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
|
|||||||
| ty::Error(_) => false,
|
| ty::Error(_) => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super::ImplSourceParam(..) => {
|
super::ImplSource::Param(..) => {
|
||||||
// This case tell us nothing about the value of an
|
// This case tell us nothing about the value of an
|
||||||
// associated type. Consider:
|
// associated type. Consider:
|
||||||
//
|
//
|
||||||
@ -1128,7 +1128,7 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
|
|||||||
// in `assemble_candidates_from_param_env`.
|
// in `assemble_candidates_from_param_env`.
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
super::ImplSourceAutoImpl(..) | super::ImplSourceBuiltin(..) => {
|
super::ImplSource::AutoImpl(..) | super::ImplSource::Builtin(..) => {
|
||||||
// These traits have no associated types.
|
// These traits have no associated types.
|
||||||
selcx.tcx().sess.delay_span_bug(
|
selcx.tcx().sess.delay_span_bug(
|
||||||
obligation.cause.span,
|
obligation.cause.span,
|
||||||
@ -1186,20 +1186,20 @@ fn confirm_select_candidate<'cx, 'tcx>(
|
|||||||
impl_source: Selection<'tcx>,
|
impl_source: Selection<'tcx>,
|
||||||
) -> Progress<'tcx> {
|
) -> Progress<'tcx> {
|
||||||
match impl_source {
|
match impl_source {
|
||||||
super::ImplSourceUserDefined(data) => confirm_impl_candidate(selcx, obligation, data),
|
super::ImplSource::UserDefined(data) => confirm_impl_candidate(selcx, obligation, data),
|
||||||
super::ImplSourceGenerator(data) => confirm_generator_candidate(selcx, obligation, data),
|
super::ImplSource::Generator(data) => confirm_generator_candidate(selcx, obligation, data),
|
||||||
super::ImplSourceClosure(data) => confirm_closure_candidate(selcx, obligation, data),
|
super::ImplSource::Closure(data) => confirm_closure_candidate(selcx, obligation, data),
|
||||||
super::ImplSourceFnPointer(data) => confirm_fn_pointer_candidate(selcx, obligation, data),
|
super::ImplSource::FnPointer(data) => confirm_fn_pointer_candidate(selcx, obligation, data),
|
||||||
super::ImplSourceDiscriminantKind(data) => {
|
super::ImplSource::DiscriminantKind(data) => {
|
||||||
confirm_discriminant_kind_candidate(selcx, obligation, data)
|
confirm_discriminant_kind_candidate(selcx, obligation, data)
|
||||||
}
|
}
|
||||||
super::ImplSourceObject(_) => {
|
super::ImplSource::Object(_) => {
|
||||||
confirm_object_candidate(selcx, obligation, obligation_trait_ref)
|
confirm_object_candidate(selcx, obligation, obligation_trait_ref)
|
||||||
}
|
}
|
||||||
super::ImplSourceAutoImpl(..)
|
super::ImplSource::AutoImpl(..)
|
||||||
| super::ImplSourceParam(..)
|
| super::ImplSource::Param(..)
|
||||||
| super::ImplSourceBuiltin(..)
|
| super::ImplSource::Builtin(..)
|
||||||
| super::ImplSourceTraitAlias(..) =>
|
| super::ImplSource::TraitAlias(..) =>
|
||||||
// we don't create Select candidates with this kind of resolution
|
// we don't create Select candidates with this kind of resolution
|
||||||
{
|
{
|
||||||
span_bug!(
|
span_bug!(
|
||||||
|
@ -19,16 +19,12 @@ use crate::traits::project::{self, normalize_with_depth};
|
|||||||
use crate::traits::select::TraitObligationExt;
|
use crate::traits::select::TraitObligationExt;
|
||||||
use crate::traits::util;
|
use crate::traits::util;
|
||||||
use crate::traits::util::{closure_trait_ref_and_return_type, predicate_for_trait_def};
|
use crate::traits::util::{closure_trait_ref_and_return_type, predicate_for_trait_def};
|
||||||
|
use crate::traits::ImplSource;
|
||||||
use crate::traits::Normalized;
|
use crate::traits::Normalized;
|
||||||
use crate::traits::OutputTypeParameterMismatch;
|
use crate::traits::OutputTypeParameterMismatch;
|
||||||
use crate::traits::Selection;
|
use crate::traits::Selection;
|
||||||
use crate::traits::TraitNotObjectSafe;
|
use crate::traits::TraitNotObjectSafe;
|
||||||
use crate::traits::{BuiltinDerivedObligation, ImplDerivedObligation};
|
use crate::traits::{BuiltinDerivedObligation, ImplDerivedObligation};
|
||||||
use crate::traits::{
|
|
||||||
ImplSourceAutoImpl, ImplSourceBuiltin, ImplSourceClosure, ImplSourceDiscriminantKind,
|
|
||||||
ImplSourceFnPointer, ImplSourceGenerator, ImplSourceObject, ImplSourceParam,
|
|
||||||
ImplSourceTraitAlias, ImplSourceUserDefined,
|
|
||||||
};
|
|
||||||
use crate::traits::{
|
use crate::traits::{
|
||||||
ImplSourceAutoImplData, ImplSourceBuiltinData, ImplSourceClosureData,
|
ImplSourceAutoImplData, ImplSourceBuiltinData, ImplSourceClosureData,
|
||||||
ImplSourceDiscriminantKindData, ImplSourceFnPointerData, ImplSourceGeneratorData,
|
ImplSourceDiscriminantKindData, ImplSourceFnPointerData, ImplSourceGeneratorData,
|
||||||
@ -55,67 +51,67 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
match candidate {
|
match candidate {
|
||||||
BuiltinCandidate { has_nested } => {
|
BuiltinCandidate { has_nested } => {
|
||||||
let data = self.confirm_builtin_candidate(obligation, has_nested);
|
let data = self.confirm_builtin_candidate(obligation, has_nested);
|
||||||
Ok(ImplSourceBuiltin(data))
|
Ok(ImplSource::Builtin(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
ParamCandidate(param) => {
|
ParamCandidate(param) => {
|
||||||
let obligations = self.confirm_param_candidate(obligation, param);
|
let obligations = self.confirm_param_candidate(obligation, param);
|
||||||
Ok(ImplSourceParam(obligations))
|
Ok(ImplSource::Param(obligations))
|
||||||
}
|
}
|
||||||
|
|
||||||
ImplCandidate(impl_def_id) => {
|
ImplCandidate(impl_def_id) => {
|
||||||
Ok(ImplSourceUserDefined(self.confirm_impl_candidate(obligation, impl_def_id)))
|
Ok(ImplSource::UserDefined(self.confirm_impl_candidate(obligation, impl_def_id)))
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoImplCandidate(trait_def_id) => {
|
AutoImplCandidate(trait_def_id) => {
|
||||||
let data = self.confirm_auto_impl_candidate(obligation, trait_def_id);
|
let data = self.confirm_auto_impl_candidate(obligation, trait_def_id);
|
||||||
Ok(ImplSourceAutoImpl(data))
|
Ok(ImplSource::AutoImpl(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectionCandidate => {
|
ProjectionCandidate => {
|
||||||
self.confirm_projection_candidate(obligation);
|
self.confirm_projection_candidate(obligation);
|
||||||
Ok(ImplSourceParam(Vec::new()))
|
Ok(ImplSource::Param(Vec::new()))
|
||||||
}
|
}
|
||||||
|
|
||||||
ClosureCandidate => {
|
ClosureCandidate => {
|
||||||
let vtable_closure = self.confirm_closure_candidate(obligation)?;
|
let vtable_closure = self.confirm_closure_candidate(obligation)?;
|
||||||
Ok(ImplSourceClosure(vtable_closure))
|
Ok(ImplSource::Closure(vtable_closure))
|
||||||
}
|
}
|
||||||
|
|
||||||
GeneratorCandidate => {
|
GeneratorCandidate => {
|
||||||
let vtable_generator = self.confirm_generator_candidate(obligation)?;
|
let vtable_generator = self.confirm_generator_candidate(obligation)?;
|
||||||
Ok(ImplSourceGenerator(vtable_generator))
|
Ok(ImplSource::Generator(vtable_generator))
|
||||||
}
|
}
|
||||||
|
|
||||||
FnPointerCandidate => {
|
FnPointerCandidate => {
|
||||||
let data = self.confirm_fn_pointer_candidate(obligation)?;
|
let data = self.confirm_fn_pointer_candidate(obligation)?;
|
||||||
Ok(ImplSourceFnPointer(data))
|
Ok(ImplSource::FnPointer(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
DiscriminantKindCandidate => {
|
DiscriminantKindCandidate => {
|
||||||
Ok(ImplSourceDiscriminantKind(ImplSourceDiscriminantKindData))
|
Ok(ImplSource::DiscriminantKind(ImplSourceDiscriminantKindData))
|
||||||
}
|
}
|
||||||
|
|
||||||
TraitAliasCandidate(alias_def_id) => {
|
TraitAliasCandidate(alias_def_id) => {
|
||||||
let data = self.confirm_trait_alias_candidate(obligation, alias_def_id);
|
let data = self.confirm_trait_alias_candidate(obligation, alias_def_id);
|
||||||
Ok(ImplSourceTraitAlias(data))
|
Ok(ImplSource::TraitAlias(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectCandidate => {
|
ObjectCandidate => {
|
||||||
let data = self.confirm_object_candidate(obligation);
|
let data = self.confirm_object_candidate(obligation);
|
||||||
Ok(ImplSourceObject(data))
|
Ok(ImplSource::Object(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
BuiltinObjectCandidate => {
|
BuiltinObjectCandidate => {
|
||||||
// This indicates something like `Trait + Send: Send`. In this case, we know that
|
// This indicates something like `Trait + Send: Send`. In this case, we know that
|
||||||
// this holds because that's what the object type is telling us, and there's really
|
// this holds because that's what the object type is telling us, and there's really
|
||||||
// no additional obligations to prove and no types in particular to unify, etc.
|
// no additional obligations to prove and no types in particular to unify, etc.
|
||||||
Ok(ImplSourceParam(Vec::new()))
|
Ok(ImplSource::Param(Vec::new()))
|
||||||
}
|
}
|
||||||
|
|
||||||
BuiltinUnsizeCandidate => {
|
BuiltinUnsizeCandidate => {
|
||||||
let data = self.confirm_builtin_unsize_candidate(obligation)?;
|
let data = self.confirm_builtin_unsize_candidate(obligation)?;
|
||||||
Ok(ImplSourceBuiltin(data))
|
Ok(ImplSource::Builtin(data))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,9 +119,9 @@ fn resolve_associated_item<'tcx>(
|
|||||||
// Now that we know which impl is being used, we can dispatch to
|
// Now that we know which impl is being used, we can dispatch to
|
||||||
// the actual function:
|
// the actual function:
|
||||||
Ok(match vtbl {
|
Ok(match vtbl {
|
||||||
traits::ImplSourceUserDefined(impl_data) => {
|
traits::ImplSource::UserDefined(impl_data) => {
|
||||||
debug!(
|
debug!(
|
||||||
"resolving ImplSourceUserDefined: {:?}, {:?}, {:?}, {:?}",
|
"resolving ImplSource::UserDefined: {:?}, {:?}, {:?}, {:?}",
|
||||||
param_env, trait_item, rcvr_substs, impl_data
|
param_env, trait_item, rcvr_substs, impl_data
|
||||||
);
|
);
|
||||||
assert!(!rcvr_substs.needs_infer());
|
assert!(!rcvr_substs.needs_infer());
|
||||||
@ -216,13 +216,13 @@ fn resolve_associated_item<'tcx>(
|
|||||||
|
|
||||||
Some(ty::Instance::new(leaf_def.item.def_id, substs))
|
Some(ty::Instance::new(leaf_def.item.def_id, substs))
|
||||||
}
|
}
|
||||||
traits::ImplSourceGenerator(generator_data) => Some(Instance {
|
traits::ImplSource::Generator(generator_data) => Some(Instance {
|
||||||
def: ty::InstanceDef::Item(ty::WithOptConstParam::unknown(
|
def: ty::InstanceDef::Item(ty::WithOptConstParam::unknown(
|
||||||
generator_data.generator_def_id,
|
generator_data.generator_def_id,
|
||||||
)),
|
)),
|
||||||
substs: generator_data.substs,
|
substs: generator_data.substs,
|
||||||
}),
|
}),
|
||||||
traits::ImplSourceClosure(closure_data) => {
|
traits::ImplSource::Closure(closure_data) => {
|
||||||
let trait_closure_kind = tcx.fn_trait_kind_from_lang_item(trait_id).unwrap();
|
let trait_closure_kind = tcx.fn_trait_kind_from_lang_item(trait_id).unwrap();
|
||||||
Some(Instance::resolve_closure(
|
Some(Instance::resolve_closure(
|
||||||
tcx,
|
tcx,
|
||||||
@ -231,18 +231,18 @@ fn resolve_associated_item<'tcx>(
|
|||||||
trait_closure_kind,
|
trait_closure_kind,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
traits::ImplSourceFnPointer(ref data) => match data.fn_ty.kind() {
|
traits::ImplSource::FnPointer(ref data) => match data.fn_ty.kind() {
|
||||||
ty::FnDef(..) | ty::FnPtr(..) => Some(Instance {
|
ty::FnDef(..) | ty::FnPtr(..) => Some(Instance {
|
||||||
def: ty::InstanceDef::FnPtrShim(trait_item.def_id, data.fn_ty),
|
def: ty::InstanceDef::FnPtrShim(trait_item.def_id, data.fn_ty),
|
||||||
substs: rcvr_substs,
|
substs: rcvr_substs,
|
||||||
}),
|
}),
|
||||||
_ => None,
|
_ => None,
|
||||||
},
|
},
|
||||||
traits::ImplSourceObject(ref data) => {
|
traits::ImplSource::Object(ref data) => {
|
||||||
let index = traits::get_vtable_index_of_object_method(tcx, data, def_id);
|
let index = traits::get_vtable_index_of_object_method(tcx, data, def_id);
|
||||||
Some(Instance { def: ty::InstanceDef::Virtual(def_id, index), substs: rcvr_substs })
|
Some(Instance { def: ty::InstanceDef::Virtual(def_id, index), substs: rcvr_substs })
|
||||||
}
|
}
|
||||||
traits::ImplSourceBuiltin(..) => {
|
traits::ImplSource::Builtin(..) => {
|
||||||
if Some(trait_ref.def_id) == tcx.lang_items().clone_trait() {
|
if Some(trait_ref.def_id) == tcx.lang_items().clone_trait() {
|
||||||
// FIXME(eddyb) use lang items for methods instead of names.
|
// FIXME(eddyb) use lang items for methods instead of names.
|
||||||
let name = tcx.item_name(def_id);
|
let name = tcx.item_name(def_id);
|
||||||
@ -271,10 +271,10 @@ fn resolve_associated_item<'tcx>(
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
traits::ImplSourceAutoImpl(..)
|
traits::ImplSource::AutoImpl(..)
|
||||||
| traits::ImplSourceParam(..)
|
| traits::ImplSource::Param(..)
|
||||||
| traits::ImplSourceTraitAlias(..)
|
| traits::ImplSource::TraitAlias(..)
|
||||||
| traits::ImplSourceDiscriminantKind(..) => None,
|
| traits::ImplSource::DiscriminantKind(..) => None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1306,7 +1306,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
|||||||
.at(&ObligationCause::dummy(), self.param_env)
|
.at(&ObligationCause::dummy(), self.param_env)
|
||||||
.sup(candidate.xform_self_ty, self_ty);
|
.sup(candidate.xform_self_ty, self_ty);
|
||||||
match self.select_trait_candidate(trait_ref) {
|
match self.select_trait_candidate(trait_ref) {
|
||||||
Ok(Some(traits::ImplSource::ImplSourceUserDefined(ref impl_data))) => {
|
Ok(Some(traits::ImplSource::UserDefined(ref impl_data))) => {
|
||||||
// If only a single impl matches, make the error message point
|
// If only a single impl matches, make the error message point
|
||||||
// to that impl.
|
// to that impl.
|
||||||
ImplSource(impl_data.impl_def_id)
|
ImplSource(impl_data.impl_def_id)
|
||||||
|
Loading…
Reference in New Issue
Block a user