@@ -351,7 +351,8 @@ fn resolve_struct_error<'b, 'a: 'b, 'tcx: 'a>(resolver: &'b Resolver<'a, 'tcx>,
351
351
if let Some ( sp) = resolver. ast_map . span_if_local ( did) {
352
352
err. span_note ( sp, "constant defined here" ) ;
353
353
}
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 ) {
355
356
if binding. is_import ( ) {
356
357
err. span_note ( binding. span . unwrap ( ) , "constant imported here" ) ;
357
358
}
@@ -1575,13 +1576,17 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1575
1576
module : Module < ' a > ,
1576
1577
name : Name ,
1577
1578
namespace : Namespace ,
1578
- allow_private_imports : bool ,
1579
+ use_lexical_scope : bool ,
1579
1580
record_used : bool )
1580
1581
-> ResolveResult < & ' a NameBinding < ' a > > {
1581
1582
debug ! ( "(resolving name in module) resolving `{}` in `{}`" , name, module_to_string( module) ) ;
1582
1583
1583
1584
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| {
1585
1590
if record_used {
1586
1591
self . record_use ( name, namespace, binding) ;
1587
1592
}
@@ -3028,7 +3033,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3028
3033
if name_path. len ( ) == 1 {
3029
3034
match this. primitive_type_table . primitive_types . get ( last_name) {
3030
3035
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 )
3032
3037
. and_then ( NameBinding :: module)
3033
3038
}
3034
3039
} else {
@@ -3085,7 +3090,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3085
3090
3086
3091
// Look for a method in the current self type's impl module.
3087
3092
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 ) {
3089
3094
if let Some ( Def :: Method ( did) ) = binding. def ( ) {
3090
3095
if is_static_method ( self , did) {
3091
3096
return StaticMethod ( path_names_to_string ( & path, 0 ) ) ;
0 commit comments