@@ -61,7 +61,7 @@ use rustc::util::lev_distance::lev_distance;
61
61
use syntax:: ast:: { Arm , BindByRef , BindByValue , BindingMode , Block , Crate , CrateNum } ;
62
62
use syntax:: ast:: { DefId , Expr , ExprAgain , ExprBreak , ExprField } ;
63
63
use syntax:: ast:: { ExprClosure , ExprForLoop , ExprLoop , ExprWhile , ExprMethodCall } ;
64
- use syntax:: ast:: { ExprPath , ExprStruct , FnDecl } ;
64
+ use syntax:: ast:: { ExprPath , ExprQPath , ExprStruct , FnDecl } ;
65
65
use syntax:: ast:: { ForeignItemFn , ForeignItemStatic , Generics } ;
66
66
use syntax:: ast:: { Ident , ImplItem , Item , ItemConst , ItemEnum , ItemFn } ;
67
67
use syntax:: ast:: { ItemForeignMod , ItemImpl , ItemMac , ItemMod , ItemStatic } ;
@@ -3169,7 +3169,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3169
3169
TraitImplementation => "implement" ,
3170
3170
TraitDerivation => "derive" ,
3171
3171
TraitObject => "reference" ,
3172
- TraitQPath => "extract an associated type from" ,
3172
+ TraitQPath => "extract an associated item from" ,
3173
3173
} ;
3174
3174
3175
3175
let msg = format ! ( "attempt to {} a nonexistent trait `{}`" , usage_str, path_str) ;
@@ -3565,31 +3565,17 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3565
3565
}
3566
3566
}
3567
3567
3568
- match result_def {
3569
- None => {
3570
- match self . resolve_path ( ty. id , path, TypeNS , true ) {
3571
- Some ( def) => {
3572
- debug ! ( "(resolving type) resolved `{:?}` to \
3573
- type {:?}",
3574
- token:: get_ident( path. segments. last( ) . unwrap( ) . identifier) ,
3575
- def) ;
3576
- result_def = Some ( def) ;
3577
- }
3578
- None => {
3579
- result_def = None ;
3580
- }
3581
- }
3582
- }
3583
- Some ( _) => { } // Continue.
3568
+ if let None = result_def {
3569
+ result_def = self . resolve_path ( ty. id , path, TypeNS , true ) ;
3584
3570
}
3585
3571
3586
3572
match result_def {
3587
3573
Some ( def) => {
3588
3574
// Write the result into the def map.
3589
3575
debug ! ( "(resolving type) writing resolution for `{}` \
3590
- (id {})",
3576
+ (id {}) = {:?} ",
3591
3577
self . path_names_to_string( path) ,
3592
- path_id) ;
3578
+ path_id, def ) ;
3593
3579
self . record_def ( path_id, def) ;
3594
3580
}
3595
3581
None => {
@@ -3609,6 +3595,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3609
3595
TyQPath ( ref qpath) => {
3610
3596
self . resolve_type ( & * qpath. self_type ) ;
3611
3597
self . resolve_trait_reference ( ty. id , & * qpath. trait_ref , TraitQPath ) ;
3598
+ for ty in qpath. item_path . parameters . types ( ) . into_iter ( ) {
3599
+ self . resolve_type ( & * * ty) ;
3600
+ }
3601
+ for binding in qpath. item_path . parameters . bindings ( ) . into_iter ( ) {
3602
+ self . resolve_type ( & * binding. ty ) ;
3603
+ }
3612
3604
}
3613
3605
3614
3606
TyPolyTraitRef ( ref bounds) => {
@@ -4400,15 +4392,25 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
4400
4392
// The interpretation of paths depends on whether the path has
4401
4393
// multiple elements in it or not.
4402
4394
4403
- ExprPath ( ref path) => {
4395
+ ExprPath ( _) | ExprQPath ( _) => {
4396
+ let mut path_from_qpath;
4397
+ let path = match expr. node {
4398
+ ExprPath ( ref path) => path,
4399
+ ExprQPath ( ref qpath) => {
4400
+ self . resolve_type ( & * qpath. self_type ) ;
4401
+ self . resolve_trait_reference ( expr. id , & * qpath. trait_ref , TraitQPath ) ;
4402
+ path_from_qpath = qpath. trait_ref . path . clone ( ) ;
4403
+ path_from_qpath. segments . push ( qpath. item_path . clone ( ) ) ;
4404
+ & path_from_qpath
4405
+ }
4406
+ _ => unreachable ! ( )
4407
+ } ;
4404
4408
// This is a local path in the value namespace. Walk through
4405
4409
// scopes looking for it.
4406
-
4407
- let path_name = self . path_names_to_string ( path) ;
4408
-
4409
4410
match self . resolve_path ( expr. id , path, ValueNS , true ) {
4410
4411
// Check if struct variant
4411
4412
Some ( ( DefVariant ( _, _, true ) , _) ) => {
4413
+ let path_name = self . path_names_to_string ( path) ;
4412
4414
self . resolve_error ( expr. span ,
4413
4415
format ! ( "`{}` is a struct variant name, but \
4414
4416
this expression \
@@ -4423,7 +4425,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
4423
4425
Some ( def) => {
4424
4426
// Write the result into the def map.
4425
4427
debug ! ( "(resolving expr) resolved `{}`" ,
4426
- path_name ) ;
4428
+ self . path_names_to_string ( path ) ) ;
4427
4429
4428
4430
self . record_def ( expr. id , def) ;
4429
4431
}
@@ -4432,6 +4434,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
4432
4434
// (The pattern matching def_tys where the id is in self.structs
4433
4435
// matches on regular structs while excluding tuple- and enum-like
4434
4436
// structs, which wouldn't result in this error.)
4437
+ let path_name = self . path_names_to_string ( path) ;
4435
4438
match self . with_no_errors ( |this|
4436
4439
this. resolve_path ( expr. id , path, TypeNS , false ) ) {
4437
4440
Some ( ( DefTy ( struct_id, _) , _) )
0 commit comments