@@ -266,8 +266,8 @@ enum RibKind {
266
266
// parent; method itself
267
267
MethodRibKind ( NodeId , MethodSort ) ,
268
268
269
- // We passed through a function * item* scope. Disallow upvars.
270
- OpaqueFunctionRibKind ,
269
+ // We passed through an item scope. Disallow upvars.
270
+ ItemRibKind ,
271
271
272
272
// We're in a constant item. Can't refer to dynamic stuff.
273
273
ConstantItemRibKind
@@ -3418,7 +3418,8 @@ impl<'a> Resolver<'a> {
3418
3418
def = d;
3419
3419
is_ty_param = false ;
3420
3420
}
3421
- DlDef ( d @ DefTyParam ( ..) ) => {
3421
+ DlDef ( d @ DefTyParam ( ..) ) |
3422
+ DlDef ( d @ DefSelfTy ( ..) ) => {
3422
3423
def = d;
3423
3424
is_ty_param = true ;
3424
3425
}
@@ -3451,6 +3452,13 @@ impl<'a> Resolver<'a> {
3451
3452
} => {
3452
3453
// ok
3453
3454
}
3455
+
3456
+ DefSelfTy ( did) if {
3457
+ did == item_id
3458
+ } => {
3459
+ // ok
3460
+ }
3461
+
3454
3462
_ => {
3455
3463
if !is_ty_param {
3456
3464
// This was an attempt to access an upvar inside a
@@ -3475,7 +3483,7 @@ impl<'a> Resolver<'a> {
3475
3483
}
3476
3484
}
3477
3485
}
3478
- OpaqueFunctionRibKind => {
3486
+ ItemRibKind => {
3479
3487
if !is_ty_param {
3480
3488
// This was an attempt to access an upvar inside a
3481
3489
// named function item. This is not allowed, so we
@@ -3575,7 +3583,7 @@ impl<'a> Resolver<'a> {
3575
3583
self . with_type_parameter_rib ( HasTypeParameters ( generics,
3576
3584
item. id ,
3577
3585
0 ,
3578
- NormalRibKind ) ,
3586
+ ItemRibKind ) ,
3579
3587
|this| {
3580
3588
visit:: walk_item ( this, item, ( ) ) ;
3581
3589
} ) ;
@@ -3585,7 +3593,7 @@ impl<'a> Resolver<'a> {
3585
3593
self . with_type_parameter_rib ( HasTypeParameters ( generics,
3586
3594
item. id ,
3587
3595
0 ,
3588
- NormalRibKind ) ,
3596
+ ItemRibKind ) ,
3589
3597
|this| {
3590
3598
visit:: walk_item ( this, item, ( ) ) ;
3591
3599
} ) ;
@@ -3604,7 +3612,8 @@ impl<'a> Resolver<'a> {
3604
3612
3605
3613
ItemTrait ( ref generics, _, ref traits, ref methods) => {
3606
3614
// Create a new rib for the self type.
3607
- let self_type_rib = Rib :: new ( NormalRibKind ) ;
3615
+ let self_type_rib = Rib :: new ( ItemRibKind ) ;
3616
+
3608
3617
// plain insert (no renaming)
3609
3618
let name = self . type_self_ident . name ;
3610
3619
self_type_rib. bindings . borrow_mut ( )
@@ -3686,7 +3695,7 @@ impl<'a> Resolver<'a> {
3686
3695
this. with_type_parameter_rib (
3687
3696
HasTypeParameters (
3688
3697
generics, foreign_item. id , 0 ,
3689
- NormalRibKind ) ,
3698
+ ItemRibKind ) ,
3690
3699
|this| visit:: walk_foreign_item ( this,
3691
3700
* foreign_item,
3692
3701
( ) ) ) ;
@@ -3702,13 +3711,13 @@ impl<'a> Resolver<'a> {
3702
3711
}
3703
3712
3704
3713
ItemFn ( fn_decl, _, _, ref generics, block) => {
3705
- self . resolve_function ( OpaqueFunctionRibKind ,
3714
+ self . resolve_function ( ItemRibKind ,
3706
3715
Some ( fn_decl) ,
3707
3716
HasTypeParameters
3708
3717
( generics,
3709
3718
item. id ,
3710
3719
0 ,
3711
- OpaqueFunctionRibKind ) ,
3720
+ ItemRibKind ) ,
3712
3721
block) ;
3713
3722
}
3714
3723
@@ -3890,7 +3899,7 @@ impl<'a> Resolver<'a> {
3890
3899
self . with_type_parameter_rib ( HasTypeParameters ( generics,
3891
3900
id,
3892
3901
0 ,
3893
- OpaqueFunctionRibKind ) ,
3902
+ ItemRibKind ) ,
3894
3903
|this| {
3895
3904
// Resolve the type parameters.
3896
3905
this. resolve_type_parameters ( & generics. ty_params ) ;
@@ -5119,7 +5128,7 @@ impl<'a> Resolver<'a> {
5119
5128
self . value_ribs . borrow ( ) . iter ( ) . rev ( ) . advance ( |rib| {
5120
5129
let res = match * rib {
5121
5130
Rib { bindings : _, kind : MethodRibKind ( _, _) } => true ,
5122
- Rib { bindings : _, kind : OpaqueFunctionRibKind } => false ,
5131
+ Rib { bindings : _, kind : ItemRibKind } => false ,
5123
5132
_ => return true , // Keep advancing
5124
5133
} ;
5125
5134
0 commit comments