@@ -27,9 +27,9 @@ pub use self::select::{EvaluationCache, EvaluationResult, OverflowError, Selecti
27
27
28
28
pub type ChalkCanonicalGoal < ' tcx > = Canonical < ' tcx , ChalkEnvironmentAndGoal < ' tcx > > ;
29
29
30
+ pub use self :: ImplSource :: * ;
30
31
pub use self :: ObligationCauseCode :: * ;
31
32
pub use self :: SelectionError :: * ;
32
- pub use self :: Vtable :: * ;
33
33
34
34
pub use self :: chalk:: {
35
35
ChalkEnvironmentAndGoal , ChalkEnvironmentClause , RustDefId as ChalkRustDefId ,
@@ -343,15 +343,10 @@ pub enum SelectionError<'tcx> {
343
343
/// - `Err(e)`: error `e` occurred
344
344
pub type SelectionResult < ' tcx , T > = Result < Option < T > , SelectionError < ' tcx > > ;
345
345
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.
353
348
///
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),
355
350
/// or it may be relative to some bound that is in scope (case B).
356
351
///
357
352
/// ```
@@ -363,136 +358,136 @@ pub type SelectionResult<'tcx, T> = Result<Option<T>, SelectionError<'tcx>>;
363
358
/// param: T,
364
359
/// mixed: Option<T>) {
365
360
///
366
- /// // Case A: Vtable points at a specific impl. Only possible when
361
+ /// // Case A: ImplSource points at a specific impl. Only possible when
367
362
/// // 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)])])
370
365
///
371
- /// // Case B: Vtable must be provided by caller. This applies when
366
+ /// // Case B: ImplSource must be provided by caller. This applies when
372
367
/// // type is a type parameter.
373
- /// param.clone(); // VtableParam
368
+ /// param.clone(); // ImplSourceParam
374
369
///
375
370
/// // Case C: A mix of cases A and B.
376
- /// mixed.clone(); // Vtable (Impl_1, [VtableParam ])
371
+ /// mixed.clone(); // ImplSource (Impl_1, [ImplSourceParam ])
377
372
/// }
378
373
/// ```
379
374
///
380
375
/// ### The type parameter `N`
381
376
///
382
- /// See explanation on `VtableImplData `.
377
+ /// See explanation on `ImplSourceUserDefinedData `.
383
378
#[ 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 > ) ,
387
382
388
- /// Vtable for auto trait implementations.
383
+ /// ImplSource for auto trait implementations.
389
384
/// This carries the information and nested obligations with regards
390
385
/// to an auto implementation for a trait `Trait`. The nested obligations
391
386
/// ensure the trait implementation holds for all the constituent types.
392
- VtableAutoImpl ( VtableAutoImplData < N > ) ,
387
+ ImplSourceAutoImpl ( ImplSourceAutoImplData < N > ) ,
393
388
394
389
/// Successful resolution to an obligation provided by the caller
395
390
/// for some type parameter. The `Vec<N>` represents the
396
391
/// obligations incurred from normalizing the where-clause (if
397
392
/// any).
398
- VtableParam ( Vec < N > ) ,
393
+ ImplSourceParam ( Vec < N > ) ,
399
394
400
395
/// Virtual calls through an object.
401
- VtableObject ( VtableObjectData < ' tcx , N > ) ,
396
+ ImplSourceObject ( ImplSourceObjectData < ' tcx , N > ) ,
402
397
403
398
/// Successful resolution for a builtin trait.
404
- VtableBuiltin ( VtableBuiltinData < N > ) ,
399
+ ImplSourceBuiltin ( ImplSourceBuiltinData < N > ) ,
405
400
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
408
403
/// impl is generated by the compiler and does not appear in the source.
409
- VtableClosure ( VtableClosureData < ' tcx , N > ) ,
404
+ ImplSourceClosure ( ImplSourceClosureData < ' tcx , N > ) ,
410
405
411
406
/// Same as above, but for a function pointer type with the given signature.
412
- VtableFnPointer ( VtableFnPointerData < ' tcx , N > ) ,
407
+ ImplSourceFnPointer ( ImplSourceFnPointerData < ' tcx , N > ) ,
413
408
414
- /// Vtable for a builtin `DeterminantKind` trait implementation.
415
- VtableDiscriminantKind ( VtableDiscriminantKindData ) ,
409
+ /// ImplSource for a builtin `DeterminantKind` trait implementation.
410
+ ImplSourceDiscriminantKind ( ImplSourceDiscriminantKindData ) ,
416
411
417
- /// Vtable automatically generated for a generator.
418
- VtableGenerator ( VtableGeneratorData < ' tcx , N > ) ,
412
+ /// ImplSource automatically generated for a generator.
413
+ ImplSourceGenerator ( ImplSourceGeneratorData < ' tcx , N > ) ,
419
414
420
- /// Vtable for a trait alias.
421
- VtableTraitAlias ( VtableTraitAliasData < ' tcx , N > ) ,
415
+ /// ImplSource for a trait alias.
416
+ ImplSourceTraitAlias ( ImplSourceTraitAliasData < ' tcx , N > ) ,
422
417
}
423
418
424
- impl < ' tcx , N > Vtable < ' tcx , N > {
419
+ impl < ' tcx , N > ImplSource < ' tcx , N > {
425
420
pub fn nested_obligations ( self ) -> Vec < N > {
426
421
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 ,
437
432
}
438
433
}
439
434
440
435
pub fn borrow_nested_obligations ( & self ) -> & [ N ] {
441
436
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 [ ..] ,
452
447
}
453
448
}
454
449
455
- pub fn map < M , F > ( self , f : F ) -> Vtable < ' tcx , M >
450
+ pub fn map < M , F > ( self , f : F ) -> ImplSource < ' tcx , M >
456
451
where
457
452
F : FnMut ( N ) -> M ,
458
453
{
459
454
match self {
460
- VtableImpl ( i) => VtableImpl ( VtableImplData {
455
+ ImplSourceUserDefined ( i) => ImplSourceUserDefined ( ImplSourceUserDefinedData {
461
456
impl_def_id : i. impl_def_id ,
462
457
substs : i. substs ,
463
458
nested : i. nested . into_iter ( ) . map ( f) . collect ( ) ,
464
459
} ) ,
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 {
470
465
upcast_trait_ref : o. upcast_trait_ref ,
471
466
vtable_base : o. vtable_base ,
472
467
nested : o. nested . into_iter ( ) . map ( f) . collect ( ) ,
473
468
} ) ,
474
- VtableAutoImpl ( d) => VtableAutoImpl ( VtableAutoImplData {
469
+ ImplSourceAutoImpl ( d) => ImplSourceAutoImpl ( ImplSourceAutoImplData {
475
470
trait_def_id : d. trait_def_id ,
476
471
nested : d. nested . into_iter ( ) . map ( f) . collect ( ) ,
477
472
} ) ,
478
- VtableClosure ( c) => VtableClosure ( VtableClosureData {
473
+ ImplSourceClosure ( c) => ImplSourceClosure ( ImplSourceClosureData {
479
474
closure_def_id : c. closure_def_id ,
480
475
substs : c. substs ,
481
476
nested : c. nested . into_iter ( ) . map ( f) . collect ( ) ,
482
477
} ) ,
483
- VtableGenerator ( c) => VtableGenerator ( VtableGeneratorData {
478
+ ImplSourceGenerator ( c) => ImplSourceGenerator ( ImplSourceGeneratorData {
484
479
generator_def_id : c. generator_def_id ,
485
480
substs : c. substs ,
486
481
nested : c. nested . into_iter ( ) . map ( f) . collect ( ) ,
487
482
} ) ,
488
- VtableFnPointer ( p) => VtableFnPointer ( VtableFnPointerData {
483
+ ImplSourceFnPointer ( p) => ImplSourceFnPointer ( ImplSourceFnPointerData {
489
484
fn_ty : p. fn_ty ,
490
485
nested : p. nested . into_iter ( ) . map ( f) . collect ( ) ,
491
486
} ) ,
492
- VtableDiscriminantKind ( VtableDiscriminantKindData ) => {
493
- VtableDiscriminantKind ( VtableDiscriminantKindData )
487
+ ImplSourceDiscriminantKind ( ImplSourceDiscriminantKindData ) => {
488
+ ImplSourceDiscriminantKind ( ImplSourceDiscriminantKindData )
494
489
}
495
- VtableTraitAlias ( d) => VtableTraitAlias ( VtableTraitAliasData {
490
+ ImplSourceTraitAlias ( d) => ImplSourceTraitAlias ( ImplSourceTraitAliasData {
496
491
alias_def_id : d. alias_def_id ,
497
492
substs : d. substs ,
498
493
nested : d. nested . into_iter ( ) . map ( f) . collect ( ) ,
@@ -512,14 +507,14 @@ impl<'tcx, N> Vtable<'tcx, N> {
512
507
/// is `()`, because codegen only requires a shallow resolution of an
513
508
/// impl, and nested obligations are satisfied later.
514
509
#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , HashStable , TypeFoldable ) ]
515
- pub struct VtableImplData < ' tcx , N > {
510
+ pub struct ImplSourceUserDefinedData < ' tcx , N > {
516
511
pub impl_def_id : DefId ,
517
512
pub substs : SubstsRef < ' tcx > ,
518
513
pub nested : Vec < N > ,
519
514
}
520
515
521
516
#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , HashStable , TypeFoldable ) ]
522
- pub struct VtableGeneratorData < ' tcx , N > {
517
+ pub struct ImplSourceGeneratorData < ' tcx , N > {
523
518
pub generator_def_id : DefId ,
524
519
pub substs : SubstsRef < ' tcx > ,
525
520
/// Nested obligations. This can be non-empty if the generator
@@ -528,7 +523,7 @@ pub struct VtableGeneratorData<'tcx, N> {
528
523
}
529
524
530
525
#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , HashStable , TypeFoldable ) ]
531
- pub struct VtableClosureData < ' tcx , N > {
526
+ pub struct ImplSourceClosureData < ' tcx , N > {
532
527
pub closure_def_id : DefId ,
533
528
pub substs : SubstsRef < ' tcx > ,
534
529
/// Nested obligations. This can be non-empty if the closure
@@ -537,20 +532,18 @@ pub struct VtableClosureData<'tcx, N> {
537
532
}
538
533
539
534
#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , HashStable , TypeFoldable ) ]
540
- pub struct VtableAutoImplData < N > {
535
+ pub struct ImplSourceAutoImplData < N > {
541
536
pub trait_def_id : DefId ,
542
537
pub nested : Vec < N > ,
543
538
}
544
539
545
540
#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , HashStable , TypeFoldable ) ]
546
- pub struct VtableBuiltinData < N > {
541
+ pub struct ImplSourceBuiltinData < N > {
547
542
pub nested : Vec < N > ,
548
543
}
549
544
550
- /// A vtable for some object-safe trait `Foo` automatically derived
551
- /// for the object type `Foo`.
552
545
#[ derive( PartialEq , Eq , Clone , RustcEncodable , RustcDecodable , HashStable , TypeFoldable ) ]
553
- pub struct VtableObjectData < ' tcx , N > {
546
+ pub struct ImplSourceObjectData < ' tcx , N > {
554
547
/// `Foo` upcast to the obligation trait. This will be some supertrait of `Foo`.
555
548
pub upcast_trait_ref : ty:: PolyTraitRef < ' tcx > ,
556
549
@@ -563,17 +556,17 @@ pub struct VtableObjectData<'tcx, N> {
563
556
}
564
557
565
558
#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , HashStable , TypeFoldable ) ]
566
- pub struct VtableFnPointerData < ' tcx , N > {
559
+ pub struct ImplSourceFnPointerData < ' tcx , N > {
567
560
pub fn_ty : Ty < ' tcx > ,
568
561
pub nested : Vec < N > ,
569
562
}
570
563
571
564
// FIXME(@lcnr): This should be refactored and merged with other builtin vtables.
572
565
#[ derive( Clone , Debug , PartialEq , Eq , RustcEncodable , RustcDecodable , HashStable , TypeFoldable ) ]
573
- pub struct VtableDiscriminantKindData ;
566
+ pub struct ImplSourceDiscriminantKindData ;
574
567
575
568
#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , HashStable , TypeFoldable ) ]
576
- pub struct VtableTraitAliasData < ' tcx , N > {
569
+ pub struct ImplSourceTraitAliasData < ' tcx , N > {
577
570
pub alias_def_id : DefId ,
578
571
pub substs : SubstsRef < ' tcx > ,
579
572
pub nested : Vec < N > ,
0 commit comments