@@ -351,7 +351,8 @@ fn resolve_struct_error<'b, 'a: 'b, 'tcx: 'a>(resolver: &'b Resolver<'a, 'tcx>,
351351 if let Some ( sp) = resolver. ast_map . span_if_local ( did) {
352352 err. span_note ( sp, "constant defined here" ) ;
353353 }
354- if let Success ( binding) = resolver. current_module . resolve_name ( name, ValueNS , true ) {
354+ if let Some ( binding) = resolver. current_module
355+ . resolve_name_in_lexical_scope ( name, ValueNS ) {
355356 if binding. is_import ( ) {
356357 err. span_note ( binding. span . unwrap ( ) , "constant imported here" ) ;
357358 }
@@ -1575,13 +1576,17 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
15751576 module : Module < ' a > ,
15761577 name : Name ,
15771578 namespace : Namespace ,
1578- allow_private_imports : bool ,
1579+ use_lexical_scope : bool ,
15791580 record_used : bool )
15801581 -> ResolveResult < & ' a NameBinding < ' a > > {
15811582 debug ! ( "(resolving name in module) resolving `{}` in `{}`" , name, module_to_string( module) ) ;
15821583
15831584 build_reduced_graph:: populate_module_if_necessary ( self , module) ;
1584- module. resolve_name ( name, namespace, allow_private_imports) . and_then ( |binding| {
1585+ match use_lexical_scope {
1586+ true => module. resolve_name_in_lexical_scope ( name, namespace)
1587+ . map ( Success ) . unwrap_or ( Failed ( None ) ) ,
1588+ false => module. resolve_name ( name, namespace, false ) ,
1589+ } . and_then ( |binding| {
15851590 if record_used {
15861591 self . record_use ( name, namespace, binding) ;
15871592 }
@@ -3028,7 +3033,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
30283033 if name_path. len ( ) == 1 {
30293034 match this. primitive_type_table . primitive_types . get ( last_name) {
30303035 Some ( _) => None ,
3031- None => this. current_module . resolve_name ( * last_name, TypeNS , true ) . success ( )
3036+ None => this. current_module . resolve_name_in_lexical_scope ( * last_name, TypeNS )
30323037 . and_then ( NameBinding :: module)
30333038 }
30343039 } else {
@@ -3085,7 +3090,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
30853090
30863091 // Look for a method in the current self type's impl module.
30873092 if let Some ( module) = get_module ( self , path. span , & name_path) {
3088- if let Success ( binding) = module. resolve_name ( name, ValueNS , true ) {
3093+ if let Some ( binding) = module. resolve_name_in_lexical_scope ( name, ValueNS ) {
30893094 if let Some ( Def :: Method ( did) ) = binding. def ( ) {
30903095 if is_static_method ( self , did) {
30913096 return StaticMethod ( path_names_to_string ( & path, 0 ) ) ;
0 commit comments