@@ -2568,7 +2568,8 @@ impl<'a> Resolver<'a> {
2568
2568
let code = source. error_code ( def. is_some ( ) ) ;
2569
2569
let ( base_msg, fallback_label, base_span) = if let Some ( def) = def {
2570
2570
( format ! ( "expected {}, found {} `{}`" , expected, def. kind_name( ) , path_str) ,
2571
- format ! ( "not a {}" , expected) , span)
2571
+ format ! ( "not a {}" , expected) ,
2572
+ span)
2572
2573
} else {
2573
2574
let item_str = path[ path. len ( ) - 1 ] . node ;
2574
2575
let item_span = path[ path. len ( ) - 1 ] . span ;
@@ -2585,7 +2586,8 @@ impl<'a> Resolver<'a> {
2585
2586
( mod_prefix, format ! ( "`{}`" , names_to_string( mod_path) ) )
2586
2587
} ;
2587
2588
( format ! ( "cannot find {} `{}` in {}{}" , expected, item_str, mod_prefix, mod_str) ,
2588
- format ! ( "not found in {}" , mod_str) , item_span)
2589
+ format ! ( "not found in {}" , mod_str) ,
2590
+ item_span)
2589
2591
} ;
2590
2592
let code = DiagnosticId :: Error ( code. into ( ) ) ;
2591
2593
let mut err = this. session . struct_span_err_with_code ( base_span, & base_msg, code) ;
@@ -2701,17 +2703,21 @@ impl<'a> Resolver<'a> {
2701
2703
return ( err, candidates) ;
2702
2704
} ,
2703
2705
_ if ns == ValueNS && is_struct_like ( def) => {
2706
+ let mut accessible_ctor = true ;
2704
2707
if let Def :: Struct ( def_id) = def {
2705
2708
if let Some ( ( ctor_def, ctor_vis) )
2706
2709
= this. struct_constructors . get ( & def_id) . cloned ( ) {
2707
- if is_expected ( ctor_def) && !this. is_accessible ( ctor_vis) {
2710
+ accessible_ctor = this. is_accessible ( ctor_vis) ;
2711
+ if is_expected ( ctor_def) && !accessible_ctor {
2708
2712
err. span_label ( span, format ! ( "constructor is not visible \
2709
2713
here due to private fields") ) ;
2710
2714
}
2711
2715
}
2712
2716
}
2713
- err. span_label ( span, format ! ( "did you mean `{} {{ /* fields */ }}`?" ,
2714
- path_str) ) ;
2717
+ if accessible_ctor {
2718
+ err. span_label ( span, format ! ( "did you mean `{} {{ /* fields */ }}`?" ,
2719
+ path_str) ) ;
2720
+ }
2715
2721
return ( err, candidates) ;
2716
2722
}
2717
2723
_ => { }
0 commit comments