@@ -27,9 +27,9 @@ pub use self::select::{EvaluationCache, EvaluationResult, OverflowError, Selecti
2727
2828pub type ChalkCanonicalGoal < ' tcx > = Canonical < ' tcx , ChalkEnvironmentAndGoal < ' tcx > > ;
2929
30+ pub use self :: ImplSource :: * ;
3031pub use self :: ObligationCauseCode :: * ;
3132pub use self :: SelectionError :: * ;
32- pub use self :: Vtable :: * ;
3333
3434pub use self :: chalk:: {
3535 ChalkEnvironmentAndGoal , ChalkEnvironmentClause , RustDefId as ChalkRustDefId ,
@@ -343,15 +343,10 @@ pub enum SelectionError<'tcx> {
343343/// - `Err(e)`: error `e` occurred
344344pub type SelectionResult < ' tcx , T > = Result < Option < T > , SelectionError < ' tcx > > ;
345345
346- /// Given the successful resolution of an obligation, the `Vtable`
347- /// indicates where the vtable comes from. Note that while we call this
348- /// a "vtable", it does not necessarily indicate dynamic dispatch at
349- /// runtime. `Vtable` instances just tell the compiler where to find
350- /// methods, but in generic code those methods are typically statically
351- /// dispatched -- only when an object is constructed is a `Vtable`
352- /// instance reified into an actual vtable.
346+ /// Given the successful resolution of an obligation, the `ImplSource`
347+ /// indicates where the impl comes from.
353348///
354- /// For example, the vtable may be tied to a specific impl (case A),
349+ /// For example, the obligation may be satisfied by a specific impl (case A),
355350/// or it may be relative to some bound that is in scope (case B).
356351///
357352/// ```
@@ -363,136 +358,136 @@ pub type SelectionResult<'tcx, T> = Result<Option<T>, SelectionError<'tcx>>;
363358/// param: T,
364359/// mixed: Option<T>) {
365360///
366- /// // Case A: Vtable points at a specific impl. Only possible when
361+ /// // Case A: ImplSource points at a specific impl. Only possible when
367362/// // type is concretely known. If the impl itself has bounded
368- /// // type parameters, Vtable will carry resolutions for those as well:
369- /// concrete.clone(); // Vtable (Impl_1, [Vtable (Impl_2, [Vtable (Impl_3)])])
363+ /// // type parameters, ImplSource will carry resolutions for those as well:
364+ /// concrete.clone(); // ImplSource (Impl_1, [ImplSource (Impl_2, [ImplSource (Impl_3)])])
370365///
371- /// // Case B: Vtable must be provided by caller. This applies when
366+ /// // Case B: ImplSource must be provided by caller. This applies when
372367/// // type is a type parameter.
373- /// param.clone(); // VtableParam
368+ /// param.clone(); // ImplSourceParam
374369///
375370/// // Case C: A mix of cases A and B.
376- /// mixed.clone(); // Vtable (Impl_1, [VtableParam ])
371+ /// mixed.clone(); // ImplSource (Impl_1, [ImplSourceParam ])
377372/// }
378373/// ```
379374///
380375/// ### The type parameter `N`
381376///
382- /// See explanation on `VtableImplData `.
377+ /// See explanation on `ImplSourceUserDefinedData `.
383378#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , HashStable , TypeFoldable ) ]
384- pub enum Vtable < ' tcx , N > {
385- /// Vtable identifying a particular impl.
386- VtableImpl ( VtableImplData < ' tcx , N > ) ,
379+ pub enum ImplSource < ' tcx , N > {
380+ /// ImplSource identifying a particular impl.
381+ ImplSourceUserDefined ( ImplSourceUserDefinedData < ' tcx , N > ) ,
387382
388- /// Vtable for auto trait implementations.
383+ /// ImplSource for auto trait implementations.
389384 /// This carries the information and nested obligations with regards
390385 /// to an auto implementation for a trait `Trait`. The nested obligations
391386 /// ensure the trait implementation holds for all the constituent types.
392- VtableAutoImpl ( VtableAutoImplData < N > ) ,
387+ ImplSourceAutoImpl ( ImplSourceAutoImplData < N > ) ,
393388
394389 /// Successful resolution to an obligation provided by the caller
395390 /// for some type parameter. The `Vec<N>` represents the
396391 /// obligations incurred from normalizing the where-clause (if
397392 /// any).
398- VtableParam ( Vec < N > ) ,
393+ ImplSourceParam ( Vec < N > ) ,
399394
400395 /// Virtual calls through an object.
401- VtableObject ( VtableObjectData < ' tcx , N > ) ,
396+ ImplSourceObject ( ImplSourceObjectData < ' tcx , N > ) ,
402397
403398 /// Successful resolution for a builtin trait.
404- VtableBuiltin ( VtableBuiltinData < N > ) ,
399+ ImplSourceBuiltin ( ImplSourceBuiltinData < N > ) ,
405400
406- /// Vtable automatically generated for a closure. The `DefId` is the ID
407- /// of the closure expression. This is a `VtableImpl ` in spirit, but the
401+ /// ImplSource automatically generated for a closure. The `DefId` is the ID
402+ /// of the closure expression. This is a `ImplSourceUserDefined ` in spirit, but the
408403 /// impl is generated by the compiler and does not appear in the source.
409- VtableClosure ( VtableClosureData < ' tcx , N > ) ,
404+ ImplSourceClosure ( ImplSourceClosureData < ' tcx , N > ) ,
410405
411406 /// Same as above, but for a function pointer type with the given signature.
412- VtableFnPointer ( VtableFnPointerData < ' tcx , N > ) ,
407+ ImplSourceFnPointer ( ImplSourceFnPointerData < ' tcx , N > ) ,
413408
414- /// Vtable for a builtin `DeterminantKind` trait implementation.
415- VtableDiscriminantKind ( VtableDiscriminantKindData ) ,
409+ /// ImplSource for a builtin `DeterminantKind` trait implementation.
410+ ImplSourceDiscriminantKind ( ImplSourceDiscriminantKindData ) ,
416411
417- /// Vtable automatically generated for a generator.
418- VtableGenerator ( VtableGeneratorData < ' tcx , N > ) ,
412+ /// ImplSource automatically generated for a generator.
413+ ImplSourceGenerator ( ImplSourceGeneratorData < ' tcx , N > ) ,
419414
420- /// Vtable for a trait alias.
421- VtableTraitAlias ( VtableTraitAliasData < ' tcx , N > ) ,
415+ /// ImplSource for a trait alias.
416+ ImplSourceTraitAlias ( ImplSourceTraitAliasData < ' tcx , N > ) ,
422417}
423418
424- impl < ' tcx , N > Vtable < ' tcx , N > {
419+ impl < ' tcx , N > ImplSource < ' tcx , N > {
425420 pub fn nested_obligations ( self ) -> Vec < N > {
426421 match self {
427- VtableImpl ( i) => i. nested ,
428- VtableParam ( n) => n,
429- VtableBuiltin ( i) => i. nested ,
430- VtableAutoImpl ( d) => d. nested ,
431- VtableClosure ( c) => c. nested ,
432- VtableGenerator ( c) => c. nested ,
433- VtableObject ( d) => d. nested ,
434- VtableFnPointer ( d) => d. nested ,
435- VtableDiscriminantKind ( VtableDiscriminantKindData ) => Vec :: new ( ) ,
436- VtableTraitAlias ( d) => d. nested ,
422+ ImplSourceUserDefined ( i) => i. nested ,
423+ ImplSourceParam ( n) => n,
424+ ImplSourceBuiltin ( i) => i. nested ,
425+ ImplSourceAutoImpl ( d) => d. nested ,
426+ ImplSourceClosure ( c) => c. nested ,
427+ ImplSourceGenerator ( c) => c. nested ,
428+ ImplSourceObject ( d) => d. nested ,
429+ ImplSourceFnPointer ( d) => d. nested ,
430+ ImplSourceDiscriminantKind ( ImplSourceDiscriminantKindData ) => Vec :: new ( ) ,
431+ ImplSourceTraitAlias ( d) => d. nested ,
437432 }
438433 }
439434
440435 pub fn borrow_nested_obligations ( & self ) -> & [ N ] {
441436 match & self {
442- VtableImpl ( i) => & i. nested [ ..] ,
443- VtableParam ( n) => & n[ ..] ,
444- VtableBuiltin ( i) => & i. nested [ ..] ,
445- VtableAutoImpl ( d) => & d. nested [ ..] ,
446- VtableClosure ( c) => & c. nested [ ..] ,
447- VtableGenerator ( c) => & c. nested [ ..] ,
448- VtableObject ( d) => & d. nested [ ..] ,
449- VtableFnPointer ( d) => & d. nested [ ..] ,
450- VtableDiscriminantKind ( VtableDiscriminantKindData ) => & [ ] ,
451- VtableTraitAlias ( d) => & d. nested [ ..] ,
437+ ImplSourceUserDefined ( i) => & i. nested [ ..] ,
438+ ImplSourceParam ( n) => & n[ ..] ,
439+ ImplSourceBuiltin ( i) => & i. nested [ ..] ,
440+ ImplSourceAutoImpl ( d) => & d. nested [ ..] ,
441+ ImplSourceClosure ( c) => & c. nested [ ..] ,
442+ ImplSourceGenerator ( c) => & c. nested [ ..] ,
443+ ImplSourceObject ( d) => & d. nested [ ..] ,
444+ ImplSourceFnPointer ( d) => & d. nested [ ..] ,
445+ ImplSourceDiscriminantKind ( ImplSourceDiscriminantKindData ) => & [ ] ,
446+ ImplSourceTraitAlias ( d) => & d. nested [ ..] ,
452447 }
453448 }
454449
455- pub fn map < M , F > ( self , f : F ) -> Vtable < ' tcx , M >
450+ pub fn map < M , F > ( self , f : F ) -> ImplSource < ' tcx , M >
456451 where
457452 F : FnMut ( N ) -> M ,
458453 {
459454 match self {
460- VtableImpl ( i) => VtableImpl ( VtableImplData {
455+ ImplSourceUserDefined ( i) => ImplSourceUserDefined ( ImplSourceUserDefinedData {
461456 impl_def_id : i. impl_def_id ,
462457 substs : i. substs ,
463458 nested : i. nested . into_iter ( ) . map ( f) . collect ( ) ,
464459 } ) ,
465- VtableParam ( n) => VtableParam ( n. into_iter ( ) . map ( f) . collect ( ) ) ,
466- VtableBuiltin ( i) => {
467- VtableBuiltin ( VtableBuiltinData { nested : i. nested . into_iter ( ) . map ( f) . collect ( ) } )
468- }
469- VtableObject ( o) => VtableObject ( VtableObjectData {
460+ ImplSourceParam ( n) => ImplSourceParam ( n. into_iter ( ) . map ( f) . collect ( ) ) ,
461+ ImplSourceBuiltin ( i) => ImplSourceBuiltin ( ImplSourceBuiltinData {
462+ nested : i. nested . into_iter ( ) . map ( f) . collect ( ) ,
463+ } ) ,
464+ ImplSourceObject ( o) => ImplSourceObject ( ImplSourceObjectData {
470465 upcast_trait_ref : o. upcast_trait_ref ,
471466 vtable_base : o. vtable_base ,
472467 nested : o. nested . into_iter ( ) . map ( f) . collect ( ) ,
473468 } ) ,
474- VtableAutoImpl ( d) => VtableAutoImpl ( VtableAutoImplData {
469+ ImplSourceAutoImpl ( d) => ImplSourceAutoImpl ( ImplSourceAutoImplData {
475470 trait_def_id : d. trait_def_id ,
476471 nested : d. nested . into_iter ( ) . map ( f) . collect ( ) ,
477472 } ) ,
478- VtableClosure ( c) => VtableClosure ( VtableClosureData {
473+ ImplSourceClosure ( c) => ImplSourceClosure ( ImplSourceClosureData {
479474 closure_def_id : c. closure_def_id ,
480475 substs : c. substs ,
481476 nested : c. nested . into_iter ( ) . map ( f) . collect ( ) ,
482477 } ) ,
483- VtableGenerator ( c) => VtableGenerator ( VtableGeneratorData {
478+ ImplSourceGenerator ( c) => ImplSourceGenerator ( ImplSourceGeneratorData {
484479 generator_def_id : c. generator_def_id ,
485480 substs : c. substs ,
486481 nested : c. nested . into_iter ( ) . map ( f) . collect ( ) ,
487482 } ) ,
488- VtableFnPointer ( p) => VtableFnPointer ( VtableFnPointerData {
483+ ImplSourceFnPointer ( p) => ImplSourceFnPointer ( ImplSourceFnPointerData {
489484 fn_ty : p. fn_ty ,
490485 nested : p. nested . into_iter ( ) . map ( f) . collect ( ) ,
491486 } ) ,
492- VtableDiscriminantKind ( VtableDiscriminantKindData ) => {
493- VtableDiscriminantKind ( VtableDiscriminantKindData )
487+ ImplSourceDiscriminantKind ( ImplSourceDiscriminantKindData ) => {
488+ ImplSourceDiscriminantKind ( ImplSourceDiscriminantKindData )
494489 }
495- VtableTraitAlias ( d) => VtableTraitAlias ( VtableTraitAliasData {
490+ ImplSourceTraitAlias ( d) => ImplSourceTraitAlias ( ImplSourceTraitAliasData {
496491 alias_def_id : d. alias_def_id ,
497492 substs : d. substs ,
498493 nested : d. nested . into_iter ( ) . map ( f) . collect ( ) ,
@@ -512,14 +507,14 @@ impl<'tcx, N> Vtable<'tcx, N> {
512507/// is `()`, because codegen only requires a shallow resolution of an
513508/// impl, and nested obligations are satisfied later.
514509#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , HashStable , TypeFoldable ) ]
515- pub struct VtableImplData < ' tcx , N > {
510+ pub struct ImplSourceUserDefinedData < ' tcx , N > {
516511 pub impl_def_id : DefId ,
517512 pub substs : SubstsRef < ' tcx > ,
518513 pub nested : Vec < N > ,
519514}
520515
521516#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , HashStable , TypeFoldable ) ]
522- pub struct VtableGeneratorData < ' tcx , N > {
517+ pub struct ImplSourceGeneratorData < ' tcx , N > {
523518 pub generator_def_id : DefId ,
524519 pub substs : SubstsRef < ' tcx > ,
525520 /// Nested obligations. This can be non-empty if the generator
@@ -528,7 +523,7 @@ pub struct VtableGeneratorData<'tcx, N> {
528523}
529524
530525#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , HashStable , TypeFoldable ) ]
531- pub struct VtableClosureData < ' tcx , N > {
526+ pub struct ImplSourceClosureData < ' tcx , N > {
532527 pub closure_def_id : DefId ,
533528 pub substs : SubstsRef < ' tcx > ,
534529 /// Nested obligations. This can be non-empty if the closure
@@ -537,20 +532,18 @@ pub struct VtableClosureData<'tcx, N> {
537532}
538533
539534#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , HashStable , TypeFoldable ) ]
540- pub struct VtableAutoImplData < N > {
535+ pub struct ImplSourceAutoImplData < N > {
541536 pub trait_def_id : DefId ,
542537 pub nested : Vec < N > ,
543538}
544539
545540#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , HashStable , TypeFoldable ) ]
546- pub struct VtableBuiltinData < N > {
541+ pub struct ImplSourceBuiltinData < N > {
547542 pub nested : Vec < N > ,
548543}
549544
550- /// A vtable for some object-safe trait `Foo` automatically derived
551- /// for the object type `Foo`.
552545#[ derive( PartialEq , Eq , Clone , RustcEncodable , RustcDecodable , HashStable , TypeFoldable ) ]
553- pub struct VtableObjectData < ' tcx , N > {
546+ pub struct ImplSourceObjectData < ' tcx , N > {
554547 /// `Foo` upcast to the obligation trait. This will be some supertrait of `Foo`.
555548 pub upcast_trait_ref : ty:: PolyTraitRef < ' tcx > ,
556549
@@ -563,17 +556,17 @@ pub struct VtableObjectData<'tcx, N> {
563556}
564557
565558#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , HashStable , TypeFoldable ) ]
566- pub struct VtableFnPointerData < ' tcx , N > {
559+ pub struct ImplSourceFnPointerData < ' tcx , N > {
567560 pub fn_ty : Ty < ' tcx > ,
568561 pub nested : Vec < N > ,
569562}
570563
571564// FIXME(@lcnr): This should be refactored and merged with other builtin vtables.
572565#[ derive( Clone , Debug , PartialEq , Eq , RustcEncodable , RustcDecodable , HashStable , TypeFoldable ) ]
573- pub struct VtableDiscriminantKindData ;
566+ pub struct ImplSourceDiscriminantKindData ;
574567
575568#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , HashStable , TypeFoldable ) ]
576- pub struct VtableTraitAliasData < ' tcx , N > {
569+ pub struct ImplSourceTraitAliasData < ' tcx , N > {
577570 pub alias_def_id : DefId ,
578571 pub substs : SubstsRef < ' tcx > ,
579572 pub nested : Vec < N > ,
0 commit comments