@@ -349,7 +349,8 @@ fn resolve_struct_error<'b, 'a: 'b, 'tcx: 'a>(resolver: &'b Resolver<'a, 'tcx>,
349349 if let Some ( sp) = resolver. ast_map . span_if_local ( did) {
350350 err. span_note ( sp, "constant defined here" ) ;
351351 }
352- if let Success ( binding) = resolver. current_module . resolve_name ( name, ValueNS , true ) {
352+ if let Some ( binding) = resolver. current_module
353+ . resolve_name_in_lexical_scope ( name, ValueNS ) {
353354 if binding. is_import ( ) {
354355 err. span_note ( binding. span . unwrap ( ) , "constant imported here" ) ;
355356 }
@@ -1536,13 +1537,17 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
15361537 module : Module < ' a > ,
15371538 name : Name ,
15381539 namespace : Namespace ,
1539- allow_private_imports : bool ,
1540+ use_lexical_scope : bool ,
15401541 record_used : bool )
15411542 -> ResolveResult < & ' a NameBinding < ' a > > {
15421543 debug ! ( "(resolving name in module) resolving `{}` in `{}`" , name, module_to_string( module) ) ;
15431544
15441545 build_reduced_graph:: populate_module_if_necessary ( self , module) ;
1545- module. resolve_name ( name, namespace, allow_private_imports) . and_then ( |binding| {
1546+ match use_lexical_scope {
1547+ true => module. resolve_name_in_lexical_scope ( name, namespace)
1548+ . map ( Success ) . unwrap_or ( Failed ( None ) ) ,
1549+ false => module. resolve_name ( name, namespace, false ) ,
1550+ } . and_then ( |binding| {
15461551 if record_used {
15471552 self . record_use ( name, namespace, binding) ;
15481553 }
@@ -2961,7 +2966,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
29612966 if name_path. len ( ) == 1 {
29622967 match this. primitive_type_table . primitive_types . get ( last_name) {
29632968 Some ( _) => None ,
2964- None => this. current_module . resolve_name ( * last_name, TypeNS , true ) . success ( )
2969+ None => this. current_module . resolve_name_in_lexical_scope ( * last_name, TypeNS )
29652970 . and_then ( NameBinding :: module)
29662971 }
29672972 } else {
@@ -3018,7 +3023,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
30183023
30193024 // Look for a method in the current self type's impl module.
30203025 if let Some ( module) = get_module ( self , path. span , & name_path) {
3021- if let Success ( binding) = module. resolve_name ( name, ValueNS , true ) {
3026+ if let Some ( binding) = module. resolve_name_in_lexical_scope ( name, ValueNS ) {
30223027 if let Some ( Def :: Method ( did) ) = binding. def ( ) {
30233028 if is_static_method ( self , did) {
30243029 return StaticMethod ( path_names_to_string ( & path, 0 ) ) ;
0 commit comments