]> git.lizzy.rs Git - rust.git/commitdiff
Rename traits::Vtable to ImplSource.
authorAna-Maria Mihalache <mihalacheana.maria@yahoo.com>
Mon, 11 May 2020 15:25:33 +0000 (15:25 +0000)
committerAna-Maria Mihalache <mihalacheana.maria@yahoo.com>
Fri, 5 Jun 2020 13:20:09 +0000 (13:20 +0000)
17 files changed:
src/librustc_infer/traits/mod.rs
src/librustc_middle/query/mod.rs
src/librustc_middle/traits/mod.rs
src/librustc_middle/traits/structural_impls.rs
src/librustc_middle/ty/query/mod.rs
src/librustc_mir/monomorphize/mod.rs
src/librustc_trait_selection/traits/auto_trait.rs
src/librustc_trait_selection/traits/codegen/mod.rs
src/librustc_trait_selection/traits/fulfill.rs
src/librustc_trait_selection/traits/mod.rs
src/librustc_trait_selection/traits/project.rs
src/librustc_trait_selection/traits/select/confirmation.rs
src/librustc_trait_selection/traits/util.rs
src/librustc_ty/instance.rs
src/librustc_typeck/check/coercion.rs
src/librustc_typeck/check/method/probe.rs
src/librustc_typeck/check/mod.rs

index 892a62855a0a2e2cac46e69ea40df84464be876b..c4f1fa2cb26b359ac27f3d0a1461bd2621c14409 100644 (file)
@@ -14,9 +14,9 @@
 use rustc_span::Span;
 
 pub use self::FulfillmentErrorCode::*;
+pub use self::ImplSource::*;
 pub use self::ObligationCauseCode::*;
 pub use self::SelectionError::*;
-pub use self::Vtable::*;
 
 pub use self::engine::{TraitEngine, TraitEngineExt};
 pub use self::project::MismatchedProjectionTypes;
 pub use rustc_middle::traits::*;
 
 /// An `Obligation` represents some trait reference (e.g., `int: Eq`) for
-/// which the vtable must be found. The process of finding a vtable is
+/// which the "impl_source" must be found. The process of finding a "impl_source" is
 /// called "resolving" the `Obligation`. This process consists of
 /// either identifying an `impl` (e.g., `impl Eq for int`) that
-/// provides the required vtable, or else finding a bound that is in
+/// satisfies the obligation, or else finding a bound that is in
 /// scope. The eventual result is usually a `Selection` (defined below).
 #[derive(Clone, PartialEq, Eq, Hash)]
 pub struct Obligation<'tcx, T> {
@@ -65,7 +65,7 @@ pub struct Obligation<'tcx, T> {
 pub type PredicateObligations<'tcx> = Vec<PredicateObligation<'tcx>>;
 pub type TraitObligations<'tcx> = Vec<TraitObligation<'tcx>>;
 
-pub type Selection<'tcx> = Vtable<'tcx, PredicateObligation<'tcx>>;
+pub type Selection<'tcx> = ImplSource<'tcx, PredicateObligation<'tcx>>;
 
 pub struct FulfillmentError<'tcx> {
     pub obligation: PredicateObligation<'tcx>,
index 5a3ab205fc2381d323fe1a898d2a2ab0103e2192..59840118fd15d4abc9d70511e61abfc8b2266624 100644 (file)
@@ -735,7 +735,7 @@ fn describe_as_module(def_id: DefId, tcx: TyCtxt<'_>) -> String {
     Codegen {
         query codegen_fulfill_obligation(
             key: (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)
-        ) -> Result<Vtable<'tcx, ()>, ErrorReported> {
+        ) -> Result<ImplSource<'tcx, ()>, ErrorReported> {
             cache_on_disk_if { true }
             desc { |tcx|
                 "checking if `{}` fulfills its obligations",
index 9afab5a4d2fe9d49705f3e245c1ff09929c35411..16545a19732a6cbcd38a8d62fb626be783f4c04b 100644 (file)
@@ -27,9 +27,9 @@
 
 pub type ChalkCanonicalGoal<'tcx> = Canonical<'tcx, ChalkEnvironmentAndGoal<'tcx>>;
 
+pub use self::ImplSource::*;
 pub use self::ObligationCauseCode::*;
 pub use self::SelectionError::*;
-pub use self::Vtable::*;
 
 pub use self::chalk::{
     ChalkEnvironmentAndGoal, ChalkEnvironmentClause, RustDefId as ChalkRustDefId,
@@ -343,15 +343,10 @@ pub enum SelectionError<'tcx> {
 /// - `Err(e)`: error `e` occurred
 pub type SelectionResult<'tcx, T> = Result<Option<T>, SelectionError<'tcx>>;
 
-/// Given the successful resolution of an obligation, the `Vtable`
-/// indicates where the vtable comes from. Note that while we call this
-/// a "vtable", it does not necessarily indicate dynamic dispatch at
-/// runtime. `Vtable` instances just tell the compiler where to find
-/// methods, but in generic code those methods are typically statically
-/// dispatched -- only when an object is constructed is a `Vtable`
-/// instance reified into an actual vtable.
+/// Given the successful resolution of an obligation, the `ImplSource`
+/// indicates where the impl comes from.
 ///
-/// For example, the vtable may be tied to a specific impl (case A),
+/// For example, the obligation may be satisfied by a specific impl (case A),
 /// or it may be relative to some bound that is in scope (case B).
 ///
 /// ```
@@ -363,136 +358,136 @@ pub enum SelectionError<'tcx> {
 ///                 param: T,
 ///                 mixed: Option<T>) {
 ///
-///    // Case A: Vtable points at a specific impl. Only possible when
+///    // Case A: ImplSource points at a specific impl. Only possible when
 ///    // type is concretely known. If the impl itself has bounded
-///    // type parameters, Vtable will carry resolutions for those as well:
-///    concrete.clone(); // Vtable(Impl_1, [Vtable(Impl_2, [Vtable(Impl_3)])])
+///    // type parameters, ImplSource will carry resolutions for those as well:
+///    concrete.clone(); // ImplSource(Impl_1, [ImplSource(Impl_2, [ImplSource(Impl_3)])])
 ///
-///    // Case B: Vtable must be provided by caller. This applies when
+///    // Case B: ImplSource must be provided by caller. This applies when
 ///    // type is a type parameter.
-///    param.clone();    // VtableParam
+///    param.clone();    // ImplSourceParam
 ///
 ///    // Case C: A mix of cases A and B.
-///    mixed.clone();    // Vtable(Impl_1, [VtableParam])
+///    mixed.clone();    // ImplSource(Impl_1, [ImplSourceParam])
 /// }
 /// ```
 ///
 /// ### The type parameter `N`
 ///
-/// See explanation on `VtableImplData`.
+/// See explanation on `ImplSourceImplData`.
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, HashStable, TypeFoldable)]
-pub enum Vtable<'tcx, N> {
-    /// Vtable identifying a particular impl.
-    VtableImpl(VtableImplData<'tcx, N>),
+pub enum ImplSource<'tcx, N> {
+    /// ImplSource identifying a particular impl.
+    ImplSourceImpl(ImplSourceImplData<'tcx, N>),
 
-    /// Vtable for auto trait implementations.
+    /// ImplSource for auto trait implementations.
     /// This carries the information and nested obligations with regards
     /// to an auto implementation for a trait `Trait`. The nested obligations
     /// ensure the trait implementation holds for all the constituent types.
-    VtableAutoImpl(VtableAutoImplData<N>),
+    ImplSourceAutoImpl(ImplSourceAutoImplData<N>),
 
     /// Successful resolution to an obligation provided by the caller
     /// for some type parameter. The `Vec<N>` represents the
     /// obligations incurred from normalizing the where-clause (if
     /// any).
-    VtableParam(Vec<N>),
+    ImplSourceParam(Vec<N>),
 
     /// Virtual calls through an object.
-    VtableObject(VtableObjectData<'tcx, N>),
+    ImplSourceObject(ImplSourceObjectData<'tcx, N>),
 
     /// Successful resolution for a builtin trait.
-    VtableBuiltin(VtableBuiltinData<N>),
+    ImplSourceBuiltin(ImplSourceBuiltinData<N>),
 
-    /// Vtable automatically generated for a closure. The `DefId` is the ID
-    /// of the closure expression. This is a `VtableImpl` in spirit, but the
+    /// ImplSource automatically generated for a closure. The `DefId` is the ID
+    /// of the closure expression. This is a `ImplSourceImpl` in spirit, but the
     /// impl is generated by the compiler and does not appear in the source.
-    VtableClosure(VtableClosureData<'tcx, N>),
+    ImplSourceClosure(ImplSourceClosureData<'tcx, N>),
 
     /// Same as above, but for a function pointer type with the given signature.
-    VtableFnPointer(VtableFnPointerData<'tcx, N>),
+    ImplSourceFnPointer(ImplSourceFnPointerData<'tcx, N>),
 
-    /// Vtable for a builtin `DeterminantKind` trait implementation.
-    VtableDiscriminantKind(VtableDiscriminantKindData),
+    /// ImplSource for a builtin `DeterminantKind` trait implementation.
+    ImplSourceDiscriminantKind(ImplSourceDiscriminantKindData),
 
-    /// Vtable automatically generated for a generator.
-    VtableGenerator(VtableGeneratorData<'tcx, N>),
+    /// ImplSource automatically generated for a generator.
+    ImplSourceGenerator(ImplSourceGeneratorData<'tcx, N>),
 
-    /// Vtable for a trait alias.
-    VtableTraitAlias(VtableTraitAliasData<'tcx, N>),
+    /// ImplSource for a trait alias.
+    ImplSourceTraitAlias(ImplSourceTraitAliasData<'tcx, N>),
 }
 
-impl<'tcx, N> Vtable<'tcx, N> {
+impl<'tcx, N> ImplSource<'tcx, N> {
     pub fn nested_obligations(self) -> Vec<N> {
         match self {
-            VtableImpl(i) => i.nested,
-            VtableParam(n) => n,
-            VtableBuiltin(i) => i.nested,
-            VtableAutoImpl(d) => d.nested,
-            VtableClosure(c) => c.nested,
-            VtableGenerator(c) => c.nested,
-            VtableObject(d) => d.nested,
-            VtableFnPointer(d) => d.nested,
-            VtableDiscriminantKind(VtableDiscriminantKindData) => Vec::new(),
-            VtableTraitAlias(d) => d.nested,
+            ImplSourceImpl(i) => i.nested,
+            ImplSourceParam(n) => n,
+            ImplSourceBuiltin(i) => i.nested,
+            ImplSourceAutoImpl(d) => d.nested,
+            ImplSourceClosure(c) => c.nested,
+            ImplSourceGenerator(c) => c.nested,
+            ImplSourceObject(d) => d.nested,
+            ImplSourceFnPointer(d) => d.nested,
+            ImplSourceDiscriminantKind(ImplSourceDiscriminantKindData) => Vec::new(),
+            ImplSourceTraitAlias(d) => d.nested,
         }
     }
 
     pub fn borrow_nested_obligations(&self) -> &[N] {
         match &self {
-            VtableImpl(i) => &i.nested[..],
-            VtableParam(n) => &n[..],
-            VtableBuiltin(i) => &i.nested[..],
-            VtableAutoImpl(d) => &d.nested[..],
-            VtableClosure(c) => &c.nested[..],
-            VtableGenerator(c) => &c.nested[..],
-            VtableObject(d) => &d.nested[..],
-            VtableFnPointer(d) => &d.nested[..],
-            VtableDiscriminantKind(VtableDiscriminantKindData) => &[],
-            VtableTraitAlias(d) => &d.nested[..],
+            ImplSourceImpl(i) => &i.nested[..],
+            ImplSourceParam(n) => &n[..],
+            ImplSourceBuiltin(i) => &i.nested[..],
+            ImplSourceAutoImpl(d) => &d.nested[..],
+            ImplSourceClosure(c) => &c.nested[..],
+            ImplSourceGenerator(c) => &c.nested[..],
+            ImplSourceObject(d) => &d.nested[..],
+            ImplSourceFnPointer(d) => &d.nested[..],
+            ImplSourceDiscriminantKind(ImplSourceDiscriminantKindData) => &[],
+            ImplSourceTraitAlias(d) => &d.nested[..],
         }
     }
 
-    pub fn map<M, F>(self, f: F) -> Vtable<'tcx, M>
+    pub fn map<M, F>(self, f: F) -> ImplSource<'tcx, M>
     where
         F: FnMut(N) -> M,
     {
         match self {
-            VtableImpl(i) => VtableImpl(VtableImplData {
+            ImplSourceImpl(i) => ImplSourceImpl(ImplSourceImplData {
                 impl_def_id: i.impl_def_id,
                 substs: i.substs,
                 nested: i.nested.into_iter().map(f).collect(),
             }),
-            VtableParam(n) => VtableParam(n.into_iter().map(f).collect()),
-            VtableBuiltin(i) => {
-                VtableBuiltin(VtableBuiltinData { nested: i.nested.into_iter().map(f).collect() })
-            }
-            VtableObject(o) => VtableObject(VtableObjectData {
+            ImplSourceParam(n) => ImplSourceParam(n.into_iter().map(f).collect()),
+            ImplSourceBuiltin(i) => ImplSourceBuiltin(ImplSourceBuiltinData {
+                nested: i.nested.into_iter().map(f).collect(),
+            }),
+            ImplSourceObject(o) => ImplSourceObject(ImplSourceObjectData {
                 upcast_trait_ref: o.upcast_trait_ref,
                 vtable_base: o.vtable_base,
                 nested: o.nested.into_iter().map(f).collect(),
             }),
-            VtableAutoImpl(d) => VtableAutoImpl(VtableAutoImplData {
+            ImplSourceAutoImpl(d) => ImplSourceAutoImpl(ImplSourceAutoImplData {
                 trait_def_id: d.trait_def_id,
                 nested: d.nested.into_iter().map(f).collect(),
             }),
-            VtableClosure(c) => VtableClosure(VtableClosureData {
+            ImplSourceClosure(c) => ImplSourceClosure(ImplSourceClosureData {
                 closure_def_id: c.closure_def_id,
                 substs: c.substs,
                 nested: c.nested.into_iter().map(f).collect(),
             }),
-            VtableGenerator(c) => VtableGenerator(VtableGeneratorData {
+            ImplSourceGenerator(c) => ImplSourceGenerator(ImplSourceGeneratorData {
                 generator_def_id: c.generator_def_id,
                 substs: c.substs,
                 nested: c.nested.into_iter().map(f).collect(),
             }),
-            VtableFnPointer(p) => VtableFnPointer(VtableFnPointerData {
+            ImplSourceFnPointer(p) => ImplSourceFnPointer(ImplSourceFnPointerData {
                 fn_ty: p.fn_ty,
                 nested: p.nested.into_iter().map(f).collect(),
             }),
-            VtableDiscriminantKind(VtableDiscriminantKindData) => {
-                VtableDiscriminantKind(VtableDiscriminantKindData)
+            ImplSourceDiscriminantKind(ImplSourceDiscriminantKindData) => {
+                ImplSourceDiscriminantKind(ImplSourceDiscriminantKindData)
             }
-            VtableTraitAlias(d) => VtableTraitAlias(VtableTraitAliasData {
+            ImplSourceTraitAlias(d) => ImplSourceTraitAlias(ImplSourceTraitAliasData {
                 alias_def_id: d.alias_def_id,
                 substs: d.substs,
                 nested: d.nested.into_iter().map(f).collect(),
@@ -512,14 +507,14 @@ pub fn map<M, F>(self, f: F) -> Vtable<'tcx, M>
 /// is `()`, because codegen only requires a shallow resolution of an
 /// impl, and nested obligations are satisfied later.
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, HashStable, TypeFoldable)]
-pub struct VtableImplData<'tcx, N> {
+pub struct ImplSourceImplData<'tcx, N> {
     pub impl_def_id: DefId,
     pub substs: SubstsRef<'tcx>,
     pub nested: Vec<N>,
 }
 
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, HashStable, TypeFoldable)]
-pub struct VtableGeneratorData<'tcx, N> {
+pub struct ImplSourceGeneratorData<'tcx, N> {
     pub generator_def_id: DefId,
     pub substs: SubstsRef<'tcx>,
     /// Nested obligations. This can be non-empty if the generator
@@ -528,7 +523,7 @@ pub struct VtableGeneratorData<'tcx, N> {
 }
 
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, HashStable, TypeFoldable)]
-pub struct VtableClosureData<'tcx, N> {
+pub struct ImplSourceClosureData<'tcx, N> {
     pub closure_def_id: DefId,
     pub substs: SubstsRef<'tcx>,
     /// Nested obligations. This can be non-empty if the closure
@@ -537,20 +532,18 @@ pub struct VtableClosureData<'tcx, N> {
 }
 
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, HashStable, TypeFoldable)]
-pub struct VtableAutoImplData<N> {
+pub struct ImplSourceAutoImplData<N> {
     pub trait_def_id: DefId,
     pub nested: Vec<N>,
 }
 
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, HashStable, TypeFoldable)]
-pub struct VtableBuiltinData<N> {
+pub struct ImplSourceBuiltinData<N> {
     pub nested: Vec<N>,
 }
 
-/// A vtable for some object-safe trait `Foo` automatically derived
-/// for the object type `Foo`.
 #[derive(PartialEq, Eq, Clone, RustcEncodable, RustcDecodable, HashStable, TypeFoldable)]
-pub struct VtableObjectData<'tcx, N> {
+pub struct ImplSourceObjectData<'tcx, N> {
     /// `Foo` upcast to the obligation trait. This will be some supertrait of `Foo`.
     pub upcast_trait_ref: ty::PolyTraitRef<'tcx>,
 
@@ -563,17 +556,17 @@ pub struct VtableObjectData<'tcx, N> {
 }
 
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, HashStable, TypeFoldable)]
-pub struct VtableFnPointerData<'tcx, N> {
+pub struct ImplSourceFnPointerData<'tcx, N> {
     pub fn_ty: Ty<'tcx>,
     pub nested: Vec<N>,
 }
 
 // FIXME(@lcnr): This should be  refactored and merged with other builtin vtables.
 #[derive(Clone, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable, HashStable, TypeFoldable)]
-pub struct VtableDiscriminantKindData;
+pub struct ImplSourceDiscriminantKindData;
 
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, HashStable, TypeFoldable)]
-pub struct VtableTraitAliasData<'tcx, N> {
+pub struct ImplSourceTraitAliasData<'tcx, N> {
     pub alias_def_id: DefId,
     pub substs: SubstsRef<'tcx>,
     pub nested: Vec<N>,
index 74f744152949909adc6216ad159ce002a3d19ec3..50ecf677deaa401780d5a276425935a9e9f290e6 100644 (file)
@@ -6,99 +6,99 @@
 
 // Structural impls for the structs in `traits`.
 
-impl<'tcx, N: fmt::Debug> fmt::Debug for traits::Vtable<'tcx, N> {
+impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSource<'tcx, N> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         match *self {
-            super::VtableImpl(ref v) => write!(f, "{:?}", v),
+            super::ImplSourceImpl(ref v) => write!(f, "{:?}", v),
 
-            super::VtableAutoImpl(ref t) => write!(f, "{:?}", t),
+            super::ImplSourceAutoImpl(ref t) => write!(f, "{:?}", t),
 
-            super::VtableClosure(ref d) => write!(f, "{:?}", d),
+            super::ImplSourceClosure(ref d) => write!(f, "{:?}", d),
 
-            super::VtableGenerator(ref d) => write!(f, "{:?}", d),
+            super::ImplSourceGenerator(ref d) => write!(f, "{:?}", d),
 
-            super::VtableFnPointer(ref d) => write!(f, "VtableFnPointer({:?})", d),
+            super::ImplSourceFnPointer(ref d) => write!(f, "ImplSourceFnPointer({:?})", d),
 
-            super::VtableDiscriminantKind(ref d) => write!(f, "{:?}", d),
+            super::ImplSourceDiscriminantKind(ref d) => write!(f, "{:?}", d),
 
-            super::VtableObject(ref d) => write!(f, "{:?}", d),
+            super::ImplSourceObject(ref d) => write!(f, "{:?}", d),
 
-            super::VtableParam(ref n) => write!(f, "VtableParam({:?})", n),
+            super::ImplSourceParam(ref n) => write!(f, "ImplSourceParam({:?})", n),
 
-            super::VtableBuiltin(ref d) => write!(f, "{:?}", d),
+            super::ImplSourceBuiltin(ref d) => write!(f, "{:?}", d),
 
-            super::VtableTraitAlias(ref d) => write!(f, "{:?}", d),
+            super::ImplSourceTraitAlias(ref d) => write!(f, "{:?}", d),
         }
     }
 }
 
-impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableImplData<'tcx, N> {
+impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSourceImplData<'tcx, N> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(
             f,
-            "VtableImplData(impl_def_id={:?}, substs={:?}, nested={:?})",
+            "ImplSourceImplData(impl_def_id={:?}, substs={:?}, nested={:?})",
             self.impl_def_id, self.substs, self.nested
         )
     }
 }
 
-impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableGeneratorData<'tcx, N> {
+impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSourceGeneratorData<'tcx, N> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(
             f,
-            "VtableGeneratorData(generator_def_id={:?}, substs={:?}, nested={:?})",
+            "ImplSourceGeneratorData(generator_def_id={:?}, substs={:?}, nested={:?})",
             self.generator_def_id, self.substs, self.nested
         )
     }
 }
 
-impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableClosureData<'tcx, N> {
+impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSourceClosureData<'tcx, N> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(
             f,
-            "VtableClosureData(closure_def_id={:?}, substs={:?}, nested={:?})",
+            "ImplSourceClosureData(closure_def_id={:?}, substs={:?}, nested={:?})",
             self.closure_def_id, self.substs, self.nested
         )
     }
 }
 
-impl<N: fmt::Debug> fmt::Debug for traits::VtableBuiltinData<N> {
+impl<N: fmt::Debug> fmt::Debug for traits::ImplSourceBuiltinData<N> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        write!(f, "VtableBuiltinData(nested={:?})", self.nested)
+        write!(f, "ImplSourceBuiltinData(nested={:?})", self.nested)
     }
 }
 
-impl<N: fmt::Debug> fmt::Debug for traits::VtableAutoImplData<N> {
+impl<N: fmt::Debug> fmt::Debug for traits::ImplSourceAutoImplData<N> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(
             f,
-            "VtableAutoImplData(trait_def_id={:?}, nested={:?})",
+            "ImplSourceAutoImplData(trait_def_id={:?}, nested={:?})",
             self.trait_def_id, self.nested
         )
     }
 }
 
-impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableObjectData<'tcx, N> {
+impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSourceObjectData<'tcx, N> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(
             f,
-            "VtableObjectData(upcast={:?}, vtable_base={}, nested={:?})",
+            "ImplSourceObjectData(upcast={:?}, vtable_base={}, nested={:?})",
             self.upcast_trait_ref, self.vtable_base, self.nested
         )
     }
 }
 
-impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableFnPointerData<'tcx, N> {
+impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSourceFnPointerData<'tcx, N> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        write!(f, "VtableFnPointerData(fn_ty={:?}, nested={:?})", self.fn_ty, self.nested)
+        write!(f, "ImplSourceFnPointerData(fn_ty={:?}, nested={:?})", self.fn_ty, self.nested)
     }
 }
 
-impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableTraitAliasData<'tcx, N> {
+impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSourceTraitAliasData<'tcx, N> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(
             f,
-            "VtableTraitAlias(alias_def_id={:?}, substs={:?}, nested={:?})",
+            "ImplSourceTraitAlias(alias_def_id={:?}, substs={:?}, nested={:?})",
             self.alias_def_id, self.substs, self.nested
         )
     }
@@ -241,63 +241,69 @@ fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
 }
 
 // For codegen only.
-impl<'a, 'tcx> Lift<'tcx> for traits::Vtable<'a, ()> {
-    type Lifted = traits::Vtable<'tcx, ()>;
+impl<'a, 'tcx> Lift<'tcx> for traits::ImplSource<'a, ()> {
+    type Lifted = traits::ImplSource<'tcx, ()>;
     fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
         match self.clone() {
-            traits::VtableImpl(traits::VtableImplData { impl_def_id, substs, nested }) => {
+            traits::ImplSourceImpl(traits::ImplSourceImplData { impl_def_id, substs, nested }) => {
                 tcx.lift(&substs).map(|substs| {
-                    traits::VtableImpl(traits::VtableImplData { impl_def_id, substs, nested })
+                    traits::ImplSourceImpl(traits::ImplSourceImplData {
+                        impl_def_id,
+                        substs,
+                        nested,
+                    })
                 })
             }
-            traits::VtableAutoImpl(t) => Some(traits::VtableAutoImpl(t)),
-            traits::VtableGenerator(traits::VtableGeneratorData {
+            traits::ImplSourceAutoImpl(t) => Some(traits::ImplSourceAutoImpl(t)),
+            traits::ImplSourceGenerator(traits::ImplSourceGeneratorData {
                 generator_def_id,
                 substs,
                 nested,
             }) => tcx.lift(&substs).map(|substs| {
-                traits::VtableGenerator(traits::VtableGeneratorData {
+                traits::ImplSourceGenerator(traits::ImplSourceGeneratorData {
                     generator_def_id,
                     substs,
                     nested,
                 })
             }),
-            traits::VtableClosure(traits::VtableClosureData { closure_def_id, substs, nested }) => {
-                tcx.lift(&substs).map(|substs| {
-                    traits::VtableClosure(traits::VtableClosureData {
-                        closure_def_id,
-                        substs,
-                        nested,
-                    })
+            traits::ImplSourceClosure(traits::ImplSourceClosureData {
+                closure_def_id,
+                substs,
+                nested,
+            }) => tcx.lift(&substs).map(|substs| {
+                traits::ImplSourceClosure(traits::ImplSourceClosureData {
+                    closure_def_id,
+                    substs,
+                    nested,
                 })
-            }
-            traits::VtableFnPointer(traits::VtableFnPointerData { fn_ty, nested }) => {
+            }),
+            traits::ImplSourceFnPointer(traits::ImplSourceFnPointerData { fn_ty, nested }) => {
                 tcx.lift(&fn_ty).map(|fn_ty| {
-                    traits::VtableFnPointer(traits::VtableFnPointerData { fn_ty, nested })
+                    traits::ImplSourceFnPointer(traits::ImplSourceFnPointerData { fn_ty, nested })
                 })
             }
-            traits::VtableDiscriminantKind(traits::VtableDiscriminantKindData) => {
-                Some(traits::VtableDiscriminantKind(traits::VtableDiscriminantKindData))
+            traits::ImplSourceDiscriminantKind(traits::ImplSourceDiscriminantKindData) => {
+                Some(traits::ImplSourceDiscriminantKind(traits::ImplSourceDiscriminantKindData))
             }
-            traits::VtableParam(n) => Some(traits::VtableParam(n)),
-            traits::VtableBuiltin(n) => Some(traits::VtableBuiltin(n)),
-            traits::VtableObject(traits::VtableObjectData {
+            traits::ImplSourceParam(n) => Some(traits::ImplSourceParam(n)),
+            traits::ImplSourceBuiltin(n) => Some(traits::ImplSourceBuiltin(n)),
+            traits::ImplSourceObject(traits::ImplSourceObjectData {
                 upcast_trait_ref,
                 vtable_base,
                 nested,
             }) => tcx.lift(&upcast_trait_ref).map(|trait_ref| {
-                traits::VtableObject(traits::VtableObjectData {
+                traits::ImplSourceObject(traits::ImplSourceObjectData {
                     upcast_trait_ref: trait_ref,
                     vtable_base,
                     nested,
                 })
             }),
-            traits::VtableTraitAlias(traits::VtableTraitAliasData {
+            traits::ImplSourceTraitAlias(traits::ImplSourceTraitAliasData {
                 alias_def_id,
                 substs,
                 nested,
             }) => tcx.lift(&substs).map(|substs| {
-                traits::VtableTraitAlias(traits::VtableTraitAliasData {
+                traits::ImplSourceTraitAlias(traits::ImplSourceTraitAliasData {
                     alias_def_id,
                     substs,
                     nested,
index f61fc65ce394c066374c90ef36c6840ac365d902..35d19b7603fafa8483ab743fb26778e3eda24df0 100644 (file)
@@ -27,7 +27,7 @@
     OutlivesBound,
 };
 use crate::traits::specialization_graph;
-use crate::traits::{self, Vtable};
+use crate::traits::{self, ImplSource};
 use crate::ty::steal::Steal;
 use crate::ty::subst::{GenericArg, SubstsRef};
 use crate::ty::util::AlwaysRequiresDrop;
index 28edd87a3add5e055ebbeac083bb8f87ae559e2f..0b2ee3280df6ab06ae44606576783d32d100d82f 100644 (file)
@@ -20,11 +20,11 @@ pub fn custom_coerce_unsize_info<'tcx>(
     });
 
     match tcx.codegen_fulfill_obligation((ty::ParamEnv::reveal_all(), trait_ref)) {
-        Ok(traits::VtableImpl(traits::VtableImplData { impl_def_id, .. })) => {
+        Ok(traits::ImplSourceImpl(traits::ImplSourceImplData { impl_def_id, .. })) => {
             tcx.coerce_unsized_info(impl_def_id).custom_kind.unwrap()
         }
-        vtable => {
-            bug!("invalid `CoerceUnsized` vtable: {:?}", vtable);
+        impl_source => {
+            bug!("invalid `CoerceUnsized` impl_source: {:?}", impl_source);
         }
     }
 }
index 433e1e46f6bba24d74fc1f6b201e8c5ff43b2fc0..f773fa2ac6e6c7e5930fb31d1c008c05a3101d94 100644 (file)
@@ -96,7 +96,7 @@ pub fn find_auto_trait_generics<A>(
             ));
 
             match result {
-                Ok(Some(Vtable::VtableImpl(_))) => {
+                Ok(Some(ImplSource::ImplSourceImpl(_))) => {
                     debug!(
                         "find_auto_trait_generics({:?}): \
                          manual impl found, bailing out",
@@ -304,11 +304,13 @@ fn evaluate_predicates(
             let result = select.select(&obligation);
 
             match &result {
-                &Ok(Some(ref vtable)) => {
+                &Ok(Some(ref impl_source)) => {
                     // 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.
 
-                    if let Vtable::VtableImpl(VtableImplData { impl_def_id, .. }) = vtable {
+                    if let ImplSource::ImplSourceImpl(ImplSourceImplData { impl_def_id, .. }) =
+                        impl_source
+                    {
                         // Blame 'tidy' for the weird bracket placement.
                         if infcx.tcx.impl_polarity(*impl_def_id) == ty::ImplPolarity::Negative {
                             debug!(
@@ -320,7 +322,7 @@ fn evaluate_predicates(
                         }
                     }
 
-                    let obligations = vtable.clone().nested_obligations().into_iter();
+                    let obligations = impl_source.clone().nested_obligations().into_iter();
 
                     if !self.evaluate_nested_obligations(
                         ty,
index b2e46bc6da116bcddc9078ffc7fd53df9a199b1d..cf575d3eca9c226853e7481af7b0b728f180a0ae 100644 (file)
@@ -5,14 +5,14 @@
 
 use crate::infer::{InferCtxt, TyCtxtInferExt};
 use crate::traits::{
-    FulfillmentContext, Obligation, ObligationCause, SelectionContext, TraitEngine, Vtable,
+    FulfillmentContext, ImplSource, Obligation, ObligationCause, SelectionContext, TraitEngine,
 };
 use rustc_errors::ErrorReported;
 use rustc_middle::ty::fold::TypeFoldable;
 use rustc_middle::ty::{self, TyCtxt};
 
-/// Attempts to resolve an obligation to a vtable. The result is
-/// a shallow vtable resolution, meaning that we do not
+/// Attempts to resolve an obligation to a `ImplSource`. The result is
+/// a shallow `ImplSource` resolution, meaning that we do not
 /// (necessarily) resolve all nested obligations on the impl. Note
 /// that type check should guarantee to us that all nested
 /// obligations *could be* resolved if we wanted to.
@@ -20,7 +20,7 @@
 pub fn codegen_fulfill_obligation<'tcx>(
     ty: TyCtxt<'tcx>,
     (param_env, trait_ref): (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>),
-) -> Result<Vtable<'tcx, ()>, ErrorReported> {
+) -> Result<ImplSource<'tcx, ()>, ErrorReported> {
     // Remove any references to regions; this helps improve caching.
     let trait_ref = ty.erase_regions(&trait_ref);
 
@@ -69,14 +69,14 @@ pub fn codegen_fulfill_obligation<'tcx>(
         // all nested obligations. This is because they can inform the
         // inference of the impl's type parameters.
         let mut fulfill_cx = FulfillmentContext::new();
-        let vtable = selection.map(|predicate| {
+        let impl_source = selection.map(|predicate| {
             debug!("fulfill_obligation: register_predicate_obligation {:?}", predicate);
             fulfill_cx.register_predicate_obligation(&infcx, predicate);
         });
-        let vtable = drain_fulfillment_cx_or_panic(&infcx, &mut fulfill_cx, &vtable);
+        let impl_source = drain_fulfillment_cx_or_panic(&infcx, &mut fulfill_cx, &impl_source);
 
-        info!("Cache miss: {:?} => {:?}", trait_ref, vtable);
-        Ok(vtable)
+        info!("Cache miss: {:?} => {:?}", trait_ref, impl_source);
+        Ok(impl_source)
     })
 }
 
index 51c62dbb88c845194c00932dd523afeaef062e43..4a08a3426c1367941447e65d1afc074304dee99f 100644 (file)
@@ -334,12 +334,12 @@ fn process_obligation(
                 }
 
                 match self.selcx.select(&trait_obligation) {
-                    Ok(Some(vtable)) => {
+                    Ok(Some(impl_source)) => {
                         debug!(
                             "selecting trait `{:?}` at depth {} yielded Ok(Some)",
                             data, obligation.recursion_depth
                         );
-                        ProcessResult::Changed(mk_pending(vtable.nested_obligations()))
+                        ProcessResult::Changed(mk_pending(impl_source.nested_obligations()))
                     }
                     Ok(None) => {
                         debug!(
index 958ba69a8262c4b448eb87336769379e0a9de06b..6abea18ee296c90001caaaf286f417ac17549ff6 100644 (file)
@@ -38,9 +38,9 @@
 use std::fmt::Debug;
 
 pub use self::FulfillmentErrorCode::*;
+pub use self::ImplSource::*;
 pub use self::ObligationCauseCode::*;
 pub use self::SelectionError::*;
-pub use self::Vtable::*;
 
 pub use self::coherence::{add_placeholder_note, orphan_check, overlapping_impls};
 pub use self::coherence::{OrphanCheckErr, OverlapResult};
index 1126480b02a0d1239268d75a3a6ab832a3ec3cc4..8266f350e5655d98953bb184191a1322d6107ec6 100644 (file)
 use super::Selection;
 use super::SelectionContext;
 use super::SelectionError;
-use super::{Normalized, NormalizedTy, ProjectionCacheEntry, ProjectionCacheKey};
 use super::{
-    VtableClosureData, VtableDiscriminantKindData, VtableFnPointerData, VtableGeneratorData,
-    VtableImplData,
+    ImplSourceClosureData, ImplSourceDiscriminantKindData, ImplSourceFnPointerData,
+    ImplSourceGeneratorData, ImplSourceImplData,
 };
+use super::{Normalized, NormalizedTy, ProjectionCacheEntry, ProjectionCacheKey};
 
 use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
 use crate::infer::{InferCtxt, InferOk, LateBoundRegionConversionTime};
@@ -974,8 +974,8 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
     let poly_trait_ref = obligation_trait_ref.to_poly_trait_ref();
     let trait_obligation = obligation.with(poly_trait_ref.to_poly_trait_predicate());
     let _ = selcx.infcx().commit_if_ok(|_| {
-        let vtable = match selcx.select(&trait_obligation) {
-            Ok(Some(vtable)) => vtable,
+        let impl_source = match selcx.select(&trait_obligation) {
+            Ok(Some(impl_source)) => impl_source,
             Ok(None) => {
                 candidate_set.mark_ambiguous();
                 return Err(());
@@ -987,16 +987,16 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
             }
         };
 
-        let eligible = match &vtable {
-            super::VtableClosure(_)
-            | super::VtableGenerator(_)
-            | super::VtableFnPointer(_)
-            | super::VtableObject(_)
-            | super::VtableTraitAlias(_) => {
-                debug!("assemble_candidates_from_impls: vtable={:?}", vtable);
+        let eligible = match &impl_source {
+            super::ImplSourceClosure(_)
+            | super::ImplSourceGenerator(_)
+            | super::ImplSourceFnPointer(_)
+            | super::ImplSourceObject(_)
+            | super::ImplSourceTraitAlias(_) => {
+                debug!("assemble_candidates_from_impls: impl_source={:?}", impl_source);
                 true
             }
-            super::VtableImpl(impl_data) => {
+            super::ImplSourceImpl(impl_data) => {
                 // We have to be careful when projecting out of an
                 // impl because of specialization. If we are not in
                 // codegen (i.e., projection mode is not "any"), and the
@@ -1048,7 +1048,7 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
                     }
                 }
             }
-            super::VtableDiscriminantKind(..) => {
+            super::ImplSourceDiscriminantKind(..) => {
                 // While `DiscriminantKind` is automatically implemented for every type,
                 // the concrete discriminant may not be known yet.
                 //
@@ -1088,7 +1088,7 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
                     | ty::Error => false,
                 }
             }
-            super::VtableParam(..) => {
+            super::ImplSourceParam(..) => {
                 // This case tell us nothing about the value of an
                 // associated type. Consider:
                 //
@@ -1116,18 +1116,18 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
                 // in `assemble_candidates_from_param_env`.
                 false
             }
-            super::VtableAutoImpl(..) | super::VtableBuiltin(..) => {
+            super::ImplSourceAutoImpl(..) | super::ImplSourceBuiltin(..) => {
                 // These traits have no associated types.
                 span_bug!(
                     obligation.cause.span,
                     "Cannot project an associated type from `{:?}`",
-                    vtable
+                    impl_source
                 );
             }
         };
 
         if eligible {
-            if candidate_set.push_candidate(ProjectionTyCandidate::Select(vtable)) {
+            if candidate_set.push_candidate(ProjectionTyCandidate::Select(impl_source)) {
                 Ok(())
             } else {
                 Err(())
@@ -1152,8 +1152,8 @@ fn confirm_candidate<'cx, 'tcx>(
             confirm_param_env_candidate(selcx, obligation, poly_projection)
         }
 
-        ProjectionTyCandidate::Select(vtable) => {
-            confirm_select_candidate(selcx, obligation, obligation_trait_ref, vtable)
+        ProjectionTyCandidate::Select(impl_source) => {
+            confirm_select_candidate(selcx, obligation, obligation_trait_ref, impl_source)
         }
     }
 }
@@ -1162,26 +1162,29 @@ fn confirm_select_candidate<'cx, 'tcx>(
     selcx: &mut SelectionContext<'cx, 'tcx>,
     obligation: &ProjectionTyObligation<'tcx>,
     obligation_trait_ref: &ty::TraitRef<'tcx>,
-    vtable: Selection<'tcx>,
+    impl_source: Selection<'tcx>,
 ) -> Progress<'tcx> {
-    match vtable {
-        super::VtableImpl(data) => confirm_impl_candidate(selcx, obligation, data),
-        super::VtableGenerator(data) => confirm_generator_candidate(selcx, obligation, data),
-        super::VtableClosure(data) => confirm_closure_candidate(selcx, obligation, data),
-        super::VtableFnPointer(data) => confirm_fn_pointer_candidate(selcx, obligation, data),
-        super::VtableDiscriminantKind(data) => {
+    match impl_source {
+        super::ImplSourceImpl(data) => confirm_impl_candidate(selcx, obligation, data),
+        super::ImplSourceGenerator(data) => confirm_generator_candidate(selcx, obligation, data),
+        super::ImplSourceClosure(data) => confirm_closure_candidate(selcx, obligation, data),
+        super::ImplSourceFnPointer(data) => confirm_fn_pointer_candidate(selcx, obligation, data),
+        super::ImplSourceDiscriminantKind(data) => {
             confirm_discriminant_kind_candidate(selcx, obligation, data)
         }
-        super::VtableObject(_) => confirm_object_candidate(selcx, obligation, obligation_trait_ref),
-        super::VtableAutoImpl(..)
-        | super::VtableParam(..)
-        | super::VtableBuiltin(..)
-        | super::VtableTraitAlias(..) => {
-            // we don't create Select candidates with this kind of resolution
+        super::ImplSourceObject(_) => {
+            confirm_object_candidate(selcx, obligation, obligation_trait_ref)
+        }
+        super::ImplSourceAutoImpl(..)
+        | super::ImplSourceParam(..)
+        | super::ImplSourceBuiltin(..)
+        | super::ImplSourceTraitAlias(..) =>
+        // we don't create Select candidates with this kind of resolution
+        {
             span_bug!(
                 obligation.cause.span,
                 "Cannot project an associated type from `{:?}`",
-                vtable
+                impl_source
             )
         }
     }
@@ -1255,9 +1258,9 @@ fn confirm_object_candidate<'cx, 'tcx>(
 fn confirm_generator_candidate<'cx, 'tcx>(
     selcx: &mut SelectionContext<'cx, 'tcx>,
     obligation: &ProjectionTyObligation<'tcx>,
-    vtable: VtableGeneratorData<'tcx, PredicateObligation<'tcx>>,
+    impl_source: ImplSourceGeneratorData<'tcx, PredicateObligation<'tcx>>,
 ) -> Progress<'tcx> {
-    let gen_sig = vtable.substs.as_generator().poly_sig();
+    let gen_sig = impl_source.substs.as_generator().poly_sig();
     let Normalized { value: gen_sig, obligations } = normalize_with_depth(
         selcx,
         obligation.param_env,
@@ -1301,14 +1304,14 @@ fn confirm_generator_candidate<'cx, 'tcx>(
     });
 
     confirm_param_env_candidate(selcx, obligation, predicate)
-        .with_addl_obligations(vtable.nested)
+        .with_addl_obligations(impl_source.nested)
         .with_addl_obligations(obligations)
 }
 
 fn confirm_discriminant_kind_candidate<'cx, 'tcx>(
     selcx: &mut SelectionContext<'cx, 'tcx>,
     obligation: &ProjectionTyObligation<'tcx>,
-    _: VtableDiscriminantKindData,
+    _: ImplSourceDiscriminantKindData,
 ) -> Progress<'tcx> {
     let tcx = selcx.tcx();
 
@@ -1339,9 +1342,9 @@ fn confirm_discriminant_kind_candidate<'cx, 'tcx>(
 fn confirm_fn_pointer_candidate<'cx, 'tcx>(
     selcx: &mut SelectionContext<'cx, 'tcx>,
     obligation: &ProjectionTyObligation<'tcx>,
-    fn_pointer_vtable: VtableFnPointerData<'tcx, PredicateObligation<'tcx>>,
+    fn_pointer_impl_source: ImplSourceFnPointerData<'tcx, PredicateObligation<'tcx>>,
 ) -> Progress<'tcx> {
-    let fn_type = selcx.infcx().shallow_resolve(fn_pointer_vtable.fn_ty);
+    let fn_type = selcx.infcx().shallow_resolve(fn_pointer_impl_source.fn_ty);
     let sig = fn_type.fn_sig(selcx.tcx());
     let Normalized { value: sig, obligations } = normalize_with_depth(
         selcx,
@@ -1352,16 +1355,16 @@ fn confirm_fn_pointer_candidate<'cx, 'tcx>(
     );
 
     confirm_callable_candidate(selcx, obligation, sig, util::TupleArgumentsFlag::Yes)
-        .with_addl_obligations(fn_pointer_vtable.nested)
+        .with_addl_obligations(fn_pointer_impl_source.nested)
         .with_addl_obligations(obligations)
 }
 
 fn confirm_closure_candidate<'cx, 'tcx>(
     selcx: &mut SelectionContext<'cx, 'tcx>,
     obligation: &ProjectionTyObligation<'tcx>,
-    vtable: VtableClosureData<'tcx, PredicateObligation<'tcx>>,
+    impl_source: ImplSourceClosureData<'tcx, PredicateObligation<'tcx>>,
 ) -> Progress<'tcx> {
-    let closure_sig = vtable.substs.as_closure().sig();
+    let closure_sig = impl_source.substs.as_closure().sig();
     let Normalized { value: closure_sig, obligations } = normalize_with_depth(
         selcx,
         obligation.param_env,
@@ -1376,7 +1379,7 @@ fn confirm_closure_candidate<'cx, 'tcx>(
     );
 
     confirm_callable_candidate(selcx, obligation, closure_sig, util::TupleArgumentsFlag::No)
-        .with_addl_obligations(vtable.nested)
+        .with_addl_obligations(impl_source.nested)
         .with_addl_obligations(obligations)
 }
 
@@ -1446,11 +1449,11 @@ fn confirm_param_env_candidate<'cx, 'tcx>(
 fn confirm_impl_candidate<'cx, 'tcx>(
     selcx: &mut SelectionContext<'cx, 'tcx>,
     obligation: &ProjectionTyObligation<'tcx>,
-    impl_vtable: VtableImplData<'tcx, PredicateObligation<'tcx>>,
+    impl_impl_source: ImplSourceImplData<'tcx, PredicateObligation<'tcx>>,
 ) -> Progress<'tcx> {
     let tcx = selcx.tcx();
 
-    let VtableImplData { impl_def_id, substs, nested } = impl_vtable;
+    let ImplSourceImplData { impl_def_id, substs, nested } = impl_impl_source;
     let assoc_item_id = obligation.predicate.item_def_id;
     let trait_def_id = tcx.trait_id_of_impl(impl_def_id).unwrap();
 
index 65bb9b7cda93748338c5c9732b2f7a20d4302135..4de4c2ec3daac32f90903e5422d85b6d65b49d28 100644 (file)
 use crate::traits::Selection;
 use crate::traits::TraitNotObjectSafe;
 use crate::traits::{BuiltinDerivedObligation, ImplDerivedObligation};
-use crate::traits::{ObjectCastObligation, PredicateObligation, TraitObligation};
-use crate::traits::{Obligation, ObligationCause};
-use crate::traits::{SelectionError, Unimplemented};
 use crate::traits::{
-    VtableAutoImpl, VtableBuiltin, VtableClosure, VtableDiscriminantKind, VtableFnPointer,
-    VtableGenerator, VtableImpl, VtableObject, VtableParam, VtableTraitAlias,
+    ImplSourceAutoImpl, ImplSourceBuiltin, ImplSourceClosure, ImplSourceDiscriminantKind,
+    ImplSourceFnPointer, ImplSourceGenerator, ImplSourceImpl, ImplSourceObject, ImplSourceParam,
+    ImplSourceTraitAlias,
 };
 use crate::traits::{
-    VtableAutoImplData, VtableBuiltinData, VtableClosureData, VtableDiscriminantKindData,
-    VtableFnPointerData, VtableGeneratorData, VtableImplData, VtableObjectData,
-    VtableTraitAliasData,
+    ImplSourceAutoImplData, ImplSourceBuiltinData, ImplSourceClosureData,
+    ImplSourceDiscriminantKindData, ImplSourceFnPointerData, ImplSourceGeneratorData,
+    ImplSourceImplData, ImplSourceObjectData, ImplSourceTraitAliasData,
 };
+use crate::traits::{ObjectCastObligation, PredicateObligation, TraitObligation};
+use crate::traits::{Obligation, ObligationCause};
+use crate::traits::{SelectionError, Unimplemented};
 
 use super::BuiltinImplConditions;
 use super::SelectionCandidate::{self, *};
@@ -54,65 +55,67 @@ pub(super) fn confirm_candidate(
         match candidate {
             BuiltinCandidate { has_nested } => {
                 let data = self.confirm_builtin_candidate(obligation, has_nested);
-                Ok(VtableBuiltin(data))
+                Ok(ImplSourceBuiltin(data))
             }
 
             ParamCandidate(param) => {
                 let obligations = self.confirm_param_candidate(obligation, param);
-                Ok(VtableParam(obligations))
+                Ok(ImplSourceParam(obligations))
             }
 
             ImplCandidate(impl_def_id) => {
-                Ok(VtableImpl(self.confirm_impl_candidate(obligation, impl_def_id)))
+                Ok(ImplSourceImpl(self.confirm_impl_candidate(obligation, impl_def_id)))
             }
 
             AutoImplCandidate(trait_def_id) => {
                 let data = self.confirm_auto_impl_candidate(obligation, trait_def_id);
-                Ok(VtableAutoImpl(data))
+                Ok(ImplSourceAutoImpl(data))
             }
 
             ProjectionCandidate => {
                 self.confirm_projection_candidate(obligation);
-                Ok(VtableParam(Vec::new()))
+                Ok(ImplSourceParam(Vec::new()))
             }
 
             ClosureCandidate => {
                 let vtable_closure = self.confirm_closure_candidate(obligation)?;
-                Ok(VtableClosure(vtable_closure))
+                Ok(ImplSourceClosure(vtable_closure))
             }
 
             GeneratorCandidate => {
                 let vtable_generator = self.confirm_generator_candidate(obligation)?;
-                Ok(VtableGenerator(vtable_generator))
+                Ok(ImplSourceGenerator(vtable_generator))
             }
 
             FnPointerCandidate => {
                 let data = self.confirm_fn_pointer_candidate(obligation)?;
-                Ok(VtableFnPointer(data))
+                Ok(ImplSourceFnPointer(data))
             }
 
-            DiscriminantKindCandidate => Ok(VtableDiscriminantKind(VtableDiscriminantKindData)),
+            DiscriminantKindCandidate => {
+                Ok(ImplSourceDiscriminantKind(ImplSourceDiscriminantKindData))
+            }
 
             TraitAliasCandidate(alias_def_id) => {
                 let data = self.confirm_trait_alias_candidate(obligation, alias_def_id);
-                Ok(VtableTraitAlias(data))
+                Ok(ImplSourceTraitAlias(data))
             }
 
             ObjectCandidate => {
                 let data = self.confirm_object_candidate(obligation);
-                Ok(VtableObject(data))
+                Ok(ImplSourceObject(data))
             }
 
             BuiltinObjectCandidate => {
                 // 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
                 // no additional obligations to prove and no types in particular to unify, etc.
-                Ok(VtableParam(Vec::new()))
+                Ok(ImplSourceParam(Vec::new()))
             }
 
             BuiltinUnsizeCandidate => {
                 let data = self.confirm_builtin_unsize_candidate(obligation)?;
-                Ok(VtableBuiltin(data))
+                Ok(ImplSourceBuiltin(data))
             }
         }
     }
@@ -152,7 +155,7 @@ fn confirm_builtin_candidate(
         &mut self,
         obligation: &TraitObligation<'tcx>,
         has_nested: bool,
-    ) -> VtableBuiltinData<PredicateObligation<'tcx>> {
+    ) -> ImplSourceBuiltinData<PredicateObligation<'tcx>> {
         debug!("confirm_builtin_candidate({:?}, {:?})", obligation, has_nested);
 
         let lang_items = self.tcx().lang_items();
@@ -188,7 +191,7 @@ fn confirm_builtin_candidate(
 
         debug!("confirm_builtin_candidate: obligations={:?}", obligations);
 
-        VtableBuiltinData { nested: obligations }
+        ImplSourceBuiltinData { nested: obligations }
     }
 
     /// This handles the case where a `auto trait Foo` impl is being used.
@@ -200,7 +203,7 @@ fn confirm_auto_impl_candidate(
         &mut self,
         obligation: &TraitObligation<'tcx>,
         trait_def_id: DefId,
-    ) -> VtableAutoImplData<PredicateObligation<'tcx>> {
+    ) -> ImplSourceAutoImplData<PredicateObligation<'tcx>> {
         debug!("confirm_auto_impl_candidate({:?}, {:?})", obligation, trait_def_id);
 
         let types = obligation.predicate.map_bound(|inner| {
@@ -216,7 +219,7 @@ fn vtable_auto_impl(
         obligation: &TraitObligation<'tcx>,
         trait_def_id: DefId,
         nested: ty::Binder<Vec<Ty<'tcx>>>,
-    ) -> VtableAutoImplData<PredicateObligation<'tcx>> {
+    ) -> ImplSourceAutoImplData<PredicateObligation<'tcx>> {
         debug!("vtable_auto_impl: nested={:?}", nested);
         ensure_sufficient_stack(|| {
             let cause = obligation.derived_cause(BuiltinDerivedObligation);
@@ -249,7 +252,7 @@ fn vtable_auto_impl(
 
             debug!("vtable_auto_impl: obligations={:?}", obligations);
 
-            VtableAutoImplData { trait_def_id, nested: obligations }
+            ImplSourceAutoImplData { trait_def_id, nested: obligations }
         })
     }
 
@@ -257,7 +260,7 @@ fn confirm_impl_candidate(
         &mut self,
         obligation: &TraitObligation<'tcx>,
         impl_def_id: DefId,
-    ) -> VtableImplData<'tcx, PredicateObligation<'tcx>> {
+    ) -> ImplSourceImplData<'tcx, PredicateObligation<'tcx>> {
         debug!("confirm_impl_candidate({:?},{:?})", obligation, impl_def_id);
 
         // First, create the substitutions by matching the impl again,
@@ -285,7 +288,7 @@ fn vtable_impl(
         cause: ObligationCause<'tcx>,
         recursion_depth: usize,
         param_env: ty::ParamEnv<'tcx>,
-    ) -> VtableImplData<'tcx, PredicateObligation<'tcx>> {
+    ) -> ImplSourceImplData<'tcx, PredicateObligation<'tcx>> {
         debug!(
             "vtable_impl(impl_def_id={:?}, substs={:?}, recursion_depth={})",
             impl_def_id, substs, recursion_depth,
@@ -311,13 +314,13 @@ fn vtable_impl(
         // e.g., `impl<U: Tr, V: Iterator<Item=U>> Foo<<U as Tr>::T> for V`
         impl_obligations.append(&mut substs.obligations);
 
-        VtableImplData { impl_def_id, substs: substs.value, nested: impl_obligations }
+        ImplSourceImplData { impl_def_id, substs: substs.value, nested: impl_obligations }
     }
 
     fn confirm_object_candidate(
         &mut self,
         obligation: &TraitObligation<'tcx>,
-    ) -> VtableObjectData<'tcx, PredicateObligation<'tcx>> {
+    ) -> ImplSourceObjectData<'tcx, PredicateObligation<'tcx>> {
         debug!("confirm_object_candidate({:?})", obligation);
 
         // FIXME(nmatsakis) skipping binder here seems wrong -- we should
@@ -366,13 +369,14 @@ fn confirm_object_candidate(
             vtable_base = nonmatching.map(|t| super::util::count_own_vtable_entries(tcx, t)).sum();
         }
 
-        VtableObjectData { upcast_trait_ref: upcast_trait_ref.unwrap(), vtable_base, nested }
+        ImplSourceObjectData { upcast_trait_ref: upcast_trait_ref.unwrap(), vtable_base, nested }
     }
 
     fn confirm_fn_pointer_candidate(
         &mut self,
         obligation: &TraitObligation<'tcx>,
-    ) -> Result<VtableFnPointerData<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>> {
+    ) -> Result<ImplSourceFnPointerData<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>>
+    {
         debug!("confirm_fn_pointer_candidate({:?})", obligation);
 
         // Okay to skip binder; it is reintroduced below.
@@ -403,14 +407,14 @@ fn confirm_fn_pointer_candidate(
             obligation.predicate.to_poly_trait_ref(),
             trait_ref,
         )?;
-        Ok(VtableFnPointerData { fn_ty: self_ty, nested: obligations })
+        Ok(ImplSourceFnPointerData { fn_ty: self_ty, nested: obligations })
     }
 
     fn confirm_trait_alias_candidate(
         &mut self,
         obligation: &TraitObligation<'tcx>,
         alias_def_id: DefId,
-    ) -> VtableTraitAliasData<'tcx, PredicateObligation<'tcx>> {
+    ) -> ImplSourceTraitAliasData<'tcx, PredicateObligation<'tcx>> {
         debug!("confirm_trait_alias_candidate({:?}, {:?})", obligation, alias_def_id);
 
         self.infcx.commit_unconditionally(|_| {
@@ -433,14 +437,15 @@ fn confirm_trait_alias_candidate(
                 trait_def_id, trait_obligations
             );
 
-            VtableTraitAliasData { alias_def_id, substs, nested: trait_obligations }
+            ImplSourceTraitAliasData { alias_def_id, substs, nested: trait_obligations }
         })
     }
 
     fn confirm_generator_candidate(
         &mut self,
         obligation: &TraitObligation<'tcx>,
-    ) -> Result<VtableGeneratorData<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>> {
+    ) -> Result<ImplSourceGeneratorData<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>>
+    {
         // Okay to skip binder because the substs on generator types never
         // touch bound regions, they just capture the in-scope
         // type/region parameters.
@@ -476,13 +481,13 @@ fn confirm_generator_candidate(
             trait_ref,
         )?);
 
-        Ok(VtableGeneratorData { generator_def_id, substs, nested: obligations })
+        Ok(ImplSourceGeneratorData { generator_def_id, substs, nested: obligations })
     }
 
     fn confirm_closure_candidate(
         &mut self,
         obligation: &TraitObligation<'tcx>,
-    ) -> Result<VtableClosureData<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>> {
+    ) -> Result<ImplSourceClosureData<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>> {
         debug!("confirm_closure_candidate({:?})", obligation);
 
         let kind = self
@@ -533,7 +538,7 @@ fn confirm_closure_candidate(
             ));
         }
 
-        Ok(VtableClosureData { closure_def_id, substs, nested: obligations })
+        Ok(ImplSourceClosureData { closure_def_id, substs, nested: obligations })
     }
 
     /// In the case of closure types and fn pointers,
@@ -578,7 +583,7 @@ fn confirm_poly_trait_refs(
     fn confirm_builtin_unsize_candidate(
         &mut self,
         obligation: &TraitObligation<'tcx>,
-    ) -> Result<VtableBuiltinData<PredicateObligation<'tcx>>, SelectionError<'tcx>> {
+    ) -> Result<ImplSourceBuiltinData<PredicateObligation<'tcx>>, SelectionError<'tcx>> {
         let tcx = self.tcx();
 
         // `assemble_candidates_for_unsizing` should ensure there are no late-bound
@@ -815,6 +820,6 @@ fn confirm_builtin_unsize_candidate(
             _ => bug!(),
         };
 
-        Ok(VtableBuiltinData { nested })
+        Ok(ImplSourceBuiltinData { nested })
     }
 }
index f6f0c62c120f1c703f5e9c04636dd132b235b3ff..8b5b4128e6672e726248d98c7581b64daa23a82e 100644 (file)
@@ -297,7 +297,7 @@ pub fn count_own_vtable_entries(tcx: TyCtxt<'tcx>, trait_ref: ty::PolyTraitRef<'
 /// `object.upcast_trait_ref`) within the vtable for `object`.
 pub fn get_vtable_index_of_object_method<N>(
     tcx: TyCtxt<'tcx>,
-    object: &super::VtableObjectData<'tcx, N>,
+    object: &super::ImplSourceObjectData<'tcx, N>,
     method_def_id: DefId,
 ) -> usize {
     // Count number of methods preceding the one we are selecting and
index a793031d4025be48ba09fca9a4837d7dbaa47c50..2b4daad66101465c7a228130508cd2fd93c2384f 100644 (file)
@@ -84,9 +84,9 @@ fn resolve_associated_item<'tcx>(
     // Now that we know which impl is being used, we can dispatch to
     // the actual function:
     Ok(match vtbl {
-        traits::VtableImpl(impl_data) => {
+        traits::ImplSourceImpl(impl_data) => {
             debug!(
-                "resolving VtableImpl: {:?}, {:?}, {:?}, {:?}",
+                "resolving ImplSourceImpl: {:?}, {:?}, {:?}, {:?}",
                 param_env, trait_item, rcvr_substs, impl_data
             );
             assert!(!rcvr_substs.needs_infer());
@@ -181,11 +181,11 @@ fn resolve_associated_item<'tcx>(
 
             Some(ty::Instance::new(leaf_def.item.def_id, substs))
         }
-        traits::VtableGenerator(generator_data) => Some(Instance {
+        traits::ImplSourceGenerator(generator_data) => Some(Instance {
             def: ty::InstanceDef::Item(generator_data.generator_def_id),
             substs: generator_data.substs,
         }),
-        traits::VtableClosure(closure_data) => {
+        traits::ImplSourceClosure(closure_data) => {
             let trait_closure_kind = tcx.fn_trait_kind_from_lang_item(trait_id).unwrap();
             Some(Instance::resolve_closure(
                 tcx,
@@ -194,7 +194,7 @@ fn resolve_associated_item<'tcx>(
                 trait_closure_kind,
             ))
         }
-        traits::VtableFnPointer(ref data) => {
+        traits::ImplSourceFnPointer(ref data) => {
             // `FnPtrShim` requires a monomorphic aka concrete type.
             if data.fn_ty.needs_subst() {
                 return Ok(None);
@@ -205,11 +205,11 @@ fn resolve_associated_item<'tcx>(
                 substs: rcvr_substs,
             })
         }
-        traits::VtableObject(ref data) => {
+        traits::ImplSourceObject(ref data) => {
             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 })
         }
-        traits::VtableBuiltin(..) => {
+        traits::ImplSourceBuiltin(..) => {
             if Some(trait_ref.def_id) == tcx.lang_items().clone_trait() {
                 // FIXME(eddyb) use lang items for methods instead of names.
                 let name = tcx.item_name(def_id);
@@ -236,10 +236,10 @@ fn resolve_associated_item<'tcx>(
                 None
             }
         }
-        traits::VtableAutoImpl(..)
-        | traits::VtableParam(..)
-        | traits::VtableTraitAlias(..)
-        | traits::VtableDiscriminantKind(..) => None,
+        traits::ImplSourceAutoImpl(..)
+        | traits::ImplSourceParam(..)
+        | traits::ImplSourceTraitAlias(..)
+        | traits::ImplSourceDiscriminantKind(..) => None,
     })
 }
 
index a324bd03eca8f7f234c723254b1c30e33168cc29..efafb05c0409138ec4162480ac50c27253ce26fb 100644 (file)
@@ -657,7 +657,7 @@ fn coerce_unsized(&self, mut source: Ty<'tcx>, mut target: Ty<'tcx>) -> CoerceRe
                     // be silent, as it causes a type mismatch later.
                 }
 
-                Ok(Some(vtable)) => queue.extend(vtable.nested_obligations()),
+                Ok(Some(impl_source)) => queue.extend(impl_source.nested_obligations()),
             }
         }
 
index 91562d576ea809e3d34598fbe5e4b6f531f6d162..f533e1097c210825b866a5f9d49d8ae7a084d955 100644 (file)
@@ -1303,7 +1303,7 @@ fn candidate_source(&self, candidate: &Candidate<'tcx>, self_ty: Ty<'tcx>) -> Ca
                     .at(&ObligationCause::dummy(), self.param_env)
                     .sup(candidate.xform_self_ty, self_ty);
                 match self.select_trait_candidate(trait_ref) {
-                    Ok(Some(traits::Vtable::VtableImpl(ref impl_data))) => {
+                    Ok(Some(traits::ImplSource::ImplSourceImpl(ref impl_data))) => {
                         // If only a single impl matches, make the error message point
                         // to that impl.
                         ImplSource(impl_data.impl_def_id)
@@ -1384,10 +1384,10 @@ fn consider_probe(
                         if self.probe(|_| {
                             match self.select_trait_candidate(trait_ref) {
                                 Err(_) => return true,
-                                Ok(Some(vtable))
-                                    if !vtable.borrow_nested_obligations().is_empty() =>
+                                Ok(Some(impl_source))
+                                    if !impl_source.borrow_nested_obligations().is_empty() =>
                                 {
-                                    for obligation in vtable.borrow_nested_obligations() {
+                                    for obligation in impl_source.borrow_nested_obligations() {
                                         // Determine exactly which obligation wasn't met, so
                                         // that we can give more context in the error.
                                         if !self.predicate_may_hold(&obligation) {
index ba4bca8cd9981cfe85fca2ad5f10705299ccba4f..c3774f1d7965355dcc1f4dca09407db435f7e512 100644 (file)
@@ -31,9 +31,6 @@
   final assignments of the various region variables if there is some
   flexibility.
 
-- vtable: find and records the impls to use for each trait bound that
-  appears on a type parameter.
-
 - writeback: writes the final types within a function body, replacing
   type variables with their final inferred types.  These final types
   are written into the `tcx.node_types` table, which should *never* contain
@@ -4050,7 +4047,7 @@ fn check_argument_types(
             debug!("check_closures={}", check_closures);
 
             // More awful hacks: before we check argument types, try to do
-            // an "opportunistic" vtable resolution of any trait bounds on
+            // an "opportunistic" trait resolution of any trait bounds on
             // the call. This helps coercions.
             if check_closures {
                 self.select_obligations_where_possible(false, |errors| {