@@ -349,7 +349,8 @@ fn resolve_struct_error<'b, 'a: 'b, 'tcx: 'a>(resolver: &'b Resolver<'a, 'tcx>,
349
349
if let Some ( sp) = resolver. ast_map . span_if_local ( did) {
350
350
err. span_note ( sp, "constant defined here" ) ;
351
351
}
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 ) {
353
354
if binding. is_import ( ) {
354
355
err. span_note ( binding. span . unwrap ( ) , "constant imported here" ) ;
355
356
}
@@ -1536,13 +1537,17 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1536
1537
module : Module < ' a > ,
1537
1538
name : Name ,
1538
1539
namespace : Namespace ,
1539
- allow_private_imports : bool ,
1540
+ use_lexical_scope : bool ,
1540
1541
record_used : bool )
1541
1542
-> ResolveResult < & ' a NameBinding < ' a > > {
1542
1543
debug ! ( "(resolving name in module) resolving `{}` in `{}`" , name, module_to_string( module) ) ;
1543
1544
1544
1545
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| {
1546
1551
if record_used {
1547
1552
self . record_use ( name, namespace, binding) ;
1548
1553
}
@@ -2961,7 +2966,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2961
2966
if name_path. len ( ) == 1 {
2962
2967
match this. primitive_type_table . primitive_types . get ( last_name) {
2963
2968
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 )
2965
2970
. and_then ( NameBinding :: module)
2966
2971
}
2967
2972
} else {
@@ -3018,7 +3023,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3018
3023
3019
3024
// Look for a method in the current self type's impl module.
3020
3025
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 ) {
3022
3027
if let Some ( Def :: Method ( did) ) = binding. def ( ) {
3023
3028
if is_static_method ( self , did) {
3024
3029
return StaticMethod ( path_names_to_string ( & path, 0 ) ) ;
0 commit comments