@@ -348,7 +348,7 @@ impl<'a> LateResolutionVisitor<'a, '_> {
348348 _ => false ,
349349 } ;
350350
351- let mut bad_struct_syntax_suggestion = || {
351+ let mut bad_struct_syntax_suggestion = |def_id : DefId | {
352352 let ( followed_by_brace, closing_brace) = self . followed_by_brace ( span) ;
353353 let mut suggested = false ;
354354 match source {
@@ -374,6 +374,9 @@ impl<'a> LateResolutionVisitor<'a, '_> {
374374 _ => { }
375375 }
376376 if !suggested {
377+ if let Some ( span) = self . r . definitions . opt_span ( def_id) {
378+ err. span_label ( span, & format ! ( "`{}` defined here" , path_str) ) ;
379+ }
377380 err. span_label (
378381 span,
379382 format ! ( "did you mean `{} {{ /* fields */ }}`?" , path_str) ,
@@ -437,18 +440,21 @@ impl<'a> LateResolutionVisitor<'a, '_> {
437440 ) ;
438441 }
439442 } else {
440- bad_struct_syntax_suggestion ( ) ;
443+ bad_struct_syntax_suggestion ( def_id ) ;
441444 }
442445 }
443- ( Res :: Def ( DefKind :: Union , _ ) , _) |
444- ( Res :: Def ( DefKind :: Variant , _ ) , _) |
445- ( Res :: Def ( DefKind :: Ctor ( _, CtorKind :: Fictive ) , _ ) , _) if ns == ValueNS => {
446- bad_struct_syntax_suggestion ( ) ;
446+ ( Res :: Def ( DefKind :: Union , def_id ) , _) |
447+ ( Res :: Def ( DefKind :: Variant , def_id ) , _) |
448+ ( Res :: Def ( DefKind :: Ctor ( _, CtorKind :: Fictive ) , def_id ) , _) if ns == ValueNS => {
449+ bad_struct_syntax_suggestion ( def_id ) ;
447450 }
448- ( Res :: Def ( DefKind :: Ctor ( _, CtorKind :: Fn ) , _) , _) if ns == ValueNS => {
451+ ( Res :: Def ( DefKind :: Ctor ( _, CtorKind :: Fn ) , def_id) , _) if ns == ValueNS => {
452+ if let Some ( span) = self . r . definitions . opt_span ( def_id) {
453+ err. span_label ( span, & format ! ( "`{}` defined here" , path_str) ) ;
454+ }
449455 err. span_label (
450456 span,
451- format ! ( "did you mean `{} ( /* fields */ )`?" , path_str) ,
457+ format ! ( "did you mean `{}( /* fields */ )`?" , path_str) ,
452458 ) ;
453459 }
454460 ( Res :: SelfTy ( ..) , _) if ns == ValueNS => {
0 commit comments