@@ -1382,28 +1382,11 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
13821382 module_to_string( self . current_module) ) ;
13831383
13841384 // 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 ) ;
13861386
13871387 let search_module;
13881388 let start_index;
13891389 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- }
14071390 Failed ( err) => return Failed ( err) ,
14081391 Indeterminate => {
14091392 debug ! ( "(resolving module path for import) indeterminate; bailing" ) ;
@@ -1531,7 +1514,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
15311514 /// Resolves a "module prefix". A module prefix is one or both of (a) `self::`;
15321515 /// (b) some chain of `super::`.
15331516 /// 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 )
15351518 -> ResolveResult < ModulePrefixResult < ' a > > {
15361519 // Start at the current module if we see `self` or `super`, or at the
15371520 // top of the crate otherwise.
@@ -1548,7 +1531,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
15481531 debug ! ( "(resolving module prefix) resolving `super` at {}" ,
15491532 module_to_string( & containing_module) ) ;
15501533 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+ }
15521538 Some ( new_module) => {
15531539 containing_module = new_module;
15541540 i += 1 ;
0 commit comments