@@ -1242,7 +1242,7 @@ impl<'a> Resolver<'a> {
1242
1242
mut search_module : Module < ' a > ,
1243
1243
module_path : & [ Name ] ,
1244
1244
index : usize ,
1245
- span : Span )
1245
+ span : Option < Span > )
1246
1246
-> ResolveResult < Module < ' a > > {
1247
1247
fn search_parent_externals < ' a > ( this : & mut Resolver < ' a > , needle : Name , module : Module < ' a > )
1248
1248
-> Option < Module < ' a > > {
@@ -1265,7 +1265,7 @@ impl<'a> Resolver<'a> {
1265
1265
// modules as we go.
1266
1266
while index < module_path_len {
1267
1267
let name = module_path[ index] ;
1268
- match self . resolve_name_in_module ( search_module, name, TypeNS , false , Some ( span) ) {
1268
+ match self . resolve_name_in_module ( search_module, name, TypeNS , false , span) {
1269
1269
Failed ( None ) => {
1270
1270
let segment_name = name. as_str ( ) ;
1271
1271
let module_name = module_to_string ( search_module) ;
@@ -1291,7 +1291,7 @@ impl<'a> Resolver<'a> {
1291
1291
format ! ( "Could not find `{}` in `{}`" , segment_name, module_name)
1292
1292
} ;
1293
1293
1294
- return Failed ( Some ( ( span, msg) ) ) ;
1294
+ return Failed ( span . map ( |span| ( span, msg) ) ) ;
1295
1295
}
1296
1296
Failed ( err) => return Failed ( err) ,
1297
1297
Indeterminate => {
@@ -1304,11 +1304,13 @@ impl<'a> Resolver<'a> {
1304
1304
// Check to see whether there are type bindings, and, if
1305
1305
// so, whether there is a module within.
1306
1306
if let Some ( module_def) = binding. module ( ) {
1307
- self . check_privacy ( name, binding, span) ;
1307
+ if let Some ( span) = span {
1308
+ self . check_privacy ( name, binding, span) ;
1309
+ }
1308
1310
search_module = module_def;
1309
1311
} else {
1310
1312
let msg = format ! ( "Not a module `{}`" , name) ;
1311
- return Failed ( Some ( ( span, msg) ) ) ;
1313
+ return Failed ( span . map ( |span| ( span, msg) ) ) ;
1312
1314
}
1313
1315
}
1314
1316
}
@@ -1324,7 +1326,7 @@ impl<'a> Resolver<'a> {
1324
1326
fn resolve_module_path ( & mut self ,
1325
1327
module_path : & [ Name ] ,
1326
1328
use_lexical_scope : UseLexicalScopeFlag ,
1327
- span : Span )
1329
+ span : Option < Span > )
1328
1330
-> ResolveResult < Module < ' a > > {
1329
1331
if module_path. len ( ) == 0 {
1330
1332
return Success ( self . graph_root ) // Use the crate root
@@ -1361,7 +1363,7 @@ impl<'a> Resolver<'a> {
1361
1363
// first component of the path in the current lexical
1362
1364
// scope and then proceed to resolve below that.
1363
1365
let ident = ast:: Ident :: with_empty_ctxt ( module_path[ 0 ] ) ;
1364
- match self . resolve_ident_in_lexical_scope ( ident, TypeNS , Some ( span) )
1366
+ match self . resolve_ident_in_lexical_scope ( ident, TypeNS , span)
1365
1367
. and_then ( LexicalScopeBinding :: module) {
1366
1368
None => return Failed ( None ) ,
1367
1369
Some ( containing_module) => {
@@ -1378,10 +1380,7 @@ impl<'a> Resolver<'a> {
1378
1380
}
1379
1381
}
1380
1382
1381
- self . resolve_module_path_from_root ( search_module,
1382
- module_path,
1383
- start_index,
1384
- span)
1383
+ self . resolve_module_path_from_root ( search_module, module_path, start_index, span)
1385
1384
}
1386
1385
1387
1386
/// This resolves the identifier `ident` in the namespace `ns` in the current lexical scope.
@@ -1485,7 +1484,7 @@ impl<'a> Resolver<'a> {
1485
1484
/// Resolves a "module prefix". A module prefix is one or both of (a) `self::`;
1486
1485
/// (b) some chain of `super::`.
1487
1486
/// grammar: (SELF MOD_SEP ) ? (SUPER MOD_SEP) *
1488
- fn resolve_module_prefix ( & mut self , module_path : & [ Name ] , span : Span )
1487
+ fn resolve_module_prefix ( & mut self , module_path : & [ Name ] , span : Option < Span > )
1489
1488
-> ResolveResult < ModulePrefixResult < ' a > > {
1490
1489
// Start at the current module if we see `self` or `super`, or at the
1491
1490
// top of the crate otherwise.
@@ -1504,7 +1503,7 @@ impl<'a> Resolver<'a> {
1504
1503
match self . get_nearest_normal_module_parent ( containing_module) {
1505
1504
None => {
1506
1505
let msg = "There are too many initial `super`s." . into ( ) ;
1507
- return Failed ( Some ( ( span, msg) ) ) ;
1506
+ return Failed ( span . map ( |span| ( span, msg) ) ) ;
1508
1507
}
1509
1508
Some ( new_module) => {
1510
1509
containing_module = new_module;
@@ -2592,7 +2591,7 @@ impl<'a> Resolver<'a> {
2592
2591
. collect :: < Vec < _ > > ( ) ;
2593
2592
2594
2593
let containing_module;
2595
- match self . resolve_module_path ( & module_path, UseLexicalScope , span) {
2594
+ match self . resolve_module_path ( & module_path, UseLexicalScope , Some ( span) ) {
2596
2595
Failed ( err) => {
2597
2596
let ( span, msg) = match err {
2598
2597
Some ( ( span, msg) ) => ( span, msg) ,
@@ -2632,10 +2631,7 @@ impl<'a> Resolver<'a> {
2632
2631
let root_module = self . graph_root ;
2633
2632
2634
2633
let containing_module;
2635
- match self . resolve_module_path_from_root ( root_module,
2636
- & module_path,
2637
- 0 ,
2638
- span) {
2634
+ match self . resolve_module_path_from_root ( root_module, & module_path, 0 , Some ( span) ) {
2639
2635
Failed ( err) => {
2640
2636
let ( span, msg) = match err {
2641
2637
Some ( ( span, msg) ) => ( span, msg) ,
@@ -2915,7 +2911,7 @@ impl<'a> Resolver<'a> {
2915
2911
2916
2912
match self . resolve_module_path ( & name_path[ ..] ,
2917
2913
UseLexicalScope ,
2918
- expr. span ) {
2914
+ Some ( expr. span ) ) {
2919
2915
Success ( e) => {
2920
2916
if let Some ( def_type) = e. def {
2921
2917
def = def_type;
@@ -3253,7 +3249,7 @@ impl<'a> Resolver<'a> {
3253
3249
3254
3250
let segments: Vec < _ > = path. segments . iter ( ) . map ( |seg| seg. identifier . name ) . collect ( ) ;
3255
3251
let mut path_resolution = err_path_resolution ( ) ;
3256
- let vis = match self . resolve_module_path ( & segments, DontUseLexicalScope , path. span ) {
3252
+ let vis = match self . resolve_module_path ( & segments, DontUseLexicalScope , Some ( path. span ) ) {
3257
3253
Success ( module) => {
3258
3254
let def = module. def . unwrap ( ) ;
3259
3255
path_resolution = PathResolution :: new ( def) ;
0 commit comments