@@ -1382,28 +1382,11 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1382
1382
module_to_string( self . current_module) ) ;
1383
1383
1384
1384
// Resolve the module prefix, if any.
1385
- let module_prefix_result = self . resolve_module_prefix ( module_path) ;
1385
+ let module_prefix_result = self . resolve_module_prefix ( module_path, span ) ;
1386
1386
1387
1387
let search_module;
1388
1388
let start_index;
1389
1389
match module_prefix_result {
1390
- Failed ( None ) => {
1391
- let mpath = names_to_string ( module_path) ;
1392
- let mpath = & mpath[ ..] ;
1393
- match mpath. rfind ( ':' ) {
1394
- Some ( idx) => {
1395
- let msg = format ! ( "Could not find `{}` in `{}`" ,
1396
- // idx +- 1 to account for the
1397
- // colons on either side
1398
- & mpath[ idx + 1 ..] ,
1399
- & mpath[ ..idx - 1 ] ) ;
1400
- return Failed ( Some ( ( span, msg) ) ) ;
1401
- }
1402
- None => {
1403
- return Failed ( None ) ;
1404
- }
1405
- }
1406
- }
1407
1390
Failed ( err) => return Failed ( err) ,
1408
1391
Indeterminate => {
1409
1392
debug ! ( "(resolving module path for import) indeterminate; bailing" ) ;
@@ -1531,7 +1514,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1531
1514
/// Resolves a "module prefix". A module prefix is one or both of (a) `self::`;
1532
1515
/// (b) some chain of `super::`.
1533
1516
/// grammar: (SELF MOD_SEP ) ? (SUPER MOD_SEP) *
1534
- fn resolve_module_prefix ( & mut self , module_path : & [ Name ] )
1517
+ fn resolve_module_prefix ( & mut self , module_path : & [ Name ] , span : Span )
1535
1518
-> ResolveResult < ModulePrefixResult < ' a > > {
1536
1519
// Start at the current module if we see `self` or `super`, or at the
1537
1520
// top of the crate otherwise.
@@ -1548,7 +1531,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1548
1531
debug ! ( "(resolving module prefix) resolving `super` at {}" ,
1549
1532
module_to_string( & containing_module) ) ;
1550
1533
match self . get_nearest_normal_module_parent ( containing_module) {
1551
- None => return Failed ( None ) ,
1534
+ None => {
1535
+ let msg = "There are too many initial `super`s." . into ( ) ;
1536
+ return Failed ( Some ( ( span, msg) ) ) ;
1537
+ }
1552
1538
Some ( new_module) => {
1553
1539
containing_module = new_module;
1554
1540
i += 1 ;
0 commit comments