@@ -305,7 +305,7 @@ pub struct TraitObject<'tcx> {
305305///
306306/// This would be represented by a trait-reference where the def-id is the
307307/// def-id for the trait `Foo` and the substs defines `T` as parameter 0 in the
308- /// `SelfSpace ` and `U` as parameter 0 in the `TypeSpace`.
308+ /// `TypeSpace ` and `U` as parameter 1 in the `TypeSpace`.
309309///
310310/// Trait references also appear in object types like `Foo<U>`, but in
311311/// that case the `Self` parameter is absent from the substitutions.
@@ -512,7 +512,7 @@ impl<'a, 'gcx, 'tcx> ParamTy {
512512 }
513513
514514 pub fn for_self ( ) -> ParamTy {
515- ParamTy :: new ( subst:: SelfSpace , 0 , keywords:: SelfType . name ( ) )
515+ ParamTy :: new ( subst:: TypeSpace , 0 , keywords:: SelfType . name ( ) )
516516 }
517517
518518 pub fn for_def ( def : & ty:: TypeParameterDef ) -> ParamTy {
@@ -524,7 +524,13 @@ impl<'a, 'gcx, 'tcx> ParamTy {
524524 }
525525
526526 pub fn is_self ( & self ) -> bool {
527- self . space == subst:: SelfSpace && self . idx == 0
527+ if self . name == keywords:: SelfType . name ( ) {
528+ assert_eq ! ( self . space, subst:: TypeSpace ) ;
529+ assert_eq ! ( self . idx, 0 ) ;
530+ true
531+ } else {
532+ false
533+ }
528534 }
529535}
530536
@@ -954,7 +960,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
954960
955961 pub fn is_self ( & self ) -> bool {
956962 match self . sty {
957- TyParam ( ref p) => p. space == subst :: SelfSpace ,
963+ TyParam ( ref p) => p. is_self ( ) ,
958964 _ => false
959965 }
960966 }
0 commit comments