@@ -3018,7 +3018,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3018
3018
}
3019
3019
3020
3020
fn resolve_generics ( & mut self , generics : & Generics ) {
3021
- for type_parameter in & generics. ty_params {
3021
+ for type_parameter in & * generics. ty_params {
3022
3022
self . check_if_primitive_type_name ( type_parameter. ident . name , type_parameter. span ) ;
3023
3023
}
3024
3024
for predicate in & generics. where_clause . predicates {
@@ -4083,16 +4083,35 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
4083
4083
// multiple elements in it or not.
4084
4084
4085
4085
ExprPath ( ref path) | ExprQPath ( ast:: QPath { ref path, .. } ) => {
4086
- if let ExprQPath ( _) = expr. node {
4086
+ let max_assoc_types = if let ExprQPath ( _) = expr. node {
4087
4087
// Make sure the trait is valid.
4088
4088
let _ = self . resolve_trait_reference ( expr. id , path, 1 ) ;
4089
+ 1
4090
+ } else {
4091
+ path. segments . len ( )
4092
+ } ;
4093
+
4094
+ let mut result = self . with_no_errors ( |this| {
4095
+ this. resolve_path ( expr. id , path, 0 , ValueNS , true )
4096
+ } ) ;
4097
+ for depth in 1 ..max_assoc_types {
4098
+ if result. is_some ( ) {
4099
+ break ;
4100
+ }
4101
+ self . with_no_errors ( |this| {
4102
+ result = this. resolve_path ( expr. id , path, depth, TypeNS , true ) ;
4103
+ } ) ;
4104
+ }
4105
+ if let Some ( ( DefMod ( _) , _, _) ) = result {
4106
+ // A module is not a valid type or value.
4107
+ result = None ;
4089
4108
}
4090
4109
4091
4110
// This is a local path in the value namespace. Walk through
4092
4111
// scopes looking for it.
4093
- match self . resolve_path ( expr . id , path , 0 , ValueNS , true ) {
4112
+ match result {
4094
4113
// Check if struct variant
4095
- Some ( ( DefVariant ( _, _, true ) , _, _ ) ) => {
4114
+ Some ( ( DefVariant ( _, _, true ) , _, 0 ) ) => {
4096
4115
let path_name = self . path_names_to_string ( path, 0 ) ;
4097
4116
self . resolve_error ( expr. span ,
4098
4117
& format ! ( "`{}` is a struct variant name, but \
@@ -4110,6 +4129,14 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
4110
4129
debug ! ( "(resolving expr) resolved `{}`" ,
4111
4130
self . path_names_to_string( path, 0 ) ) ;
4112
4131
4132
+ // Partial resolutions will need the set of traits in scope,
4133
+ // so they can be completed during typeck.
4134
+ if def. 2 != 0 {
4135
+ let method_name = path. segments . last ( ) . unwrap ( ) . identifier . name ;
4136
+ let traits = self . search_for_traits_containing_method ( method_name) ;
4137
+ self . trait_map . insert ( expr. id , traits) ;
4138
+ }
4139
+
4113
4140
self . record_def ( expr. id , def) ;
4114
4141
}
4115
4142
None => {
@@ -4135,6 +4162,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
4135
4162
4136
4163
}
4137
4164
_ => {
4165
+ // Keep reporting some errors even if they're ignored above.
4166
+ self . resolve_path ( expr. id , path, 0 , ValueNS , true ) ;
4167
+
4138
4168
let mut method_scope = false ;
4139
4169
self . value_ribs . iter ( ) . rev ( ) . all ( |rib| {
4140
4170
method_scope = match rib. kind {
0 commit comments