@@ -61,7 +61,7 @@ use rustc::util::lev_distance::lev_distance;
6161use syntax:: ast:: { Arm , BindByRef , BindByValue , BindingMode , Block , Crate , CrateNum } ;
6262use syntax:: ast:: { DefId , Expr , ExprAgain , ExprBreak , ExprField } ;
6363use syntax:: ast:: { ExprClosure , ExprForLoop , ExprLoop , ExprWhile , ExprMethodCall } ;
64- use syntax:: ast:: { ExprPath , ExprStruct , FnDecl } ;
64+ use syntax:: ast:: { ExprPath , ExprQPath , ExprStruct , FnDecl } ;
6565use syntax:: ast:: { ForeignItemFn , ForeignItemStatic , Generics } ;
6666use syntax:: ast:: { Ident , ImplItem , Item , ItemConst , ItemEnum , ItemFn } ;
6767use syntax:: ast:: { ItemForeignMod , ItemImpl , ItemMac , ItemMod , ItemStatic } ;
@@ -3169,7 +3169,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
31693169 TraitImplementation => "implement" ,
31703170 TraitDerivation => "derive" ,
31713171 TraitObject => "reference" ,
3172- TraitQPath => "extract an associated type from" ,
3172+ TraitQPath => "extract an associated item from" ,
31733173 } ;
31743174
31753175 let msg = format ! ( "attempt to {} a nonexistent trait `{}`" , usage_str, path_str) ;
@@ -3565,31 +3565,17 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
35653565 }
35663566 }
35673567
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 ) ;
35843570 }
35853571
35863572 match result_def {
35873573 Some ( def) => {
35883574 // Write the result into the def map.
35893575 debug ! ( "(resolving type) writing resolution for `{}` \
3590- (id {})",
3576+ (id {}) = {:?} ",
35913577 self . path_names_to_string( path) ,
3592- path_id) ;
3578+ path_id, def ) ;
35933579 self . record_def ( path_id, def) ;
35943580 }
35953581 None => {
@@ -3609,6 +3595,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
36093595 TyQPath ( ref qpath) => {
36103596 self . resolve_type ( & * qpath. self_type ) ;
36113597 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+ }
36123604 }
36133605
36143606 TyPolyTraitRef ( ref bounds) => {
@@ -4400,15 +4392,25 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
44004392 // The interpretation of paths depends on whether the path has
44014393 // multiple elements in it or not.
44024394
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+ } ;
44044408 // This is a local path in the value namespace. Walk through
44054409 // scopes looking for it.
4406-
4407- let path_name = self . path_names_to_string ( path) ;
4408-
44094410 match self . resolve_path ( expr. id , path, ValueNS , true ) {
44104411 // Check if struct variant
44114412 Some ( ( DefVariant ( _, _, true ) , _) ) => {
4413+ let path_name = self . path_names_to_string ( path) ;
44124414 self . resolve_error ( expr. span ,
44134415 format ! ( "`{}` is a struct variant name, but \
44144416 this expression \
@@ -4423,7 +4425,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
44234425 Some ( def) => {
44244426 // Write the result into the def map.
44254427 debug ! ( "(resolving expr) resolved `{}`" ,
4426- path_name ) ;
4428+ self . path_names_to_string ( path ) ) ;
44274429
44284430 self . record_def ( expr. id , def) ;
44294431 }
@@ -4432,6 +4434,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
44324434 // (The pattern matching def_tys where the id is in self.structs
44334435 // matches on regular structs while excluding tuple- and enum-like
44344436 // structs, which wouldn't result in this error.)
4437+ let path_name = self . path_names_to_string ( path) ;
44354438 match self . with_no_errors ( |this|
44364439 this. resolve_path ( expr. id , path, TypeNS , false ) ) {
44374440 Some ( ( DefTy ( struct_id, _) , _) )
0 commit comments