@@ -580,20 +580,47 @@ pub fn rank_templates_aux<'t>(mut templates: HashMap<&'t str,
580580 severity : Some ( DiagnosticSeverity :: ERROR ) ,
581581 } ) ;
582582 } ,
583- inf => {
583+ InferiorVariant :: Is ( inf) => {
584584 if !BUILTIN_TEMPLATES . iter ( ) . any (
585585 |name|name==missing_template_name) {
586- report. push (
587- DMLError {
588- span : * inf. span ( ) ,
589- description : format ! (
590- "No template; '{}'" ,
591- missing_template_name) ,
592- related : vec ! [ ] ,
593- severity : Some ( DiagnosticSeverity :: ERROR ) ,
594- } ) ;
586+ // The 'is' may contain more names than we
587+ // are looking for, find the particular name
588+ // that matches and use that span
589+ // Because the same name could be used multiple
590+ // times, but this only causes inferior binding
591+ // report one error per such span
592+
593+ let spans: Vec < _ > = inf. obj . names . iter ( )
594+ . filter ( |dmlname|
595+ & dmlname. val == missing_template_name)
596+ . map ( |dmlname|dmlname. span ( ) )
597+ . collect ( ) ;
598+ if spans. is_empty ( ) {
599+ internal_error ! ( "Unexpectedly no name \
600+ matching missing template \
601+ in {:?} (wanted {})",
602+ inf, missing_template_name) ;
603+ continue ;
604+ }
605+ for span in spans {
606+ report. push (
607+ DMLError {
608+ span : * span,
609+ description : format ! (
610+ "No template; '{}'" ,
611+ missing_template_name) ,
612+ related : vec ! [ ] ,
613+ severity : Some (
614+ DiagnosticSeverity :: ERROR ) ,
615+ } ) ;
616+ }
595617 }
596- }
618+ } ,
619+ inf => {
620+ internal_error ! (
621+ "Unexpected template dependency through {:?}" ,
622+ inf) ;
623+ } ,
597624 }
598625 debug ! ( "Added dummy missing template {}" ,
599626 missing_template_name) ;
0 commit comments