@@ -2568,7 +2568,8 @@ impl<'a> Resolver<'a> {
25682568 let code = source. error_code ( def. is_some ( ) ) ;
25692569 let ( base_msg, fallback_label, base_span) = if let Some ( def) = def {
25702570 ( format ! ( "expected {}, found {} `{}`" , expected, def. kind_name( ) , path_str) ,
2571- format ! ( "not a {}" , expected) , span)
2571+ format ! ( "not a {}" , expected) ,
2572+ span)
25722573 } else {
25732574 let item_str = path[ path. len ( ) - 1 ] . node ;
25742575 let item_span = path[ path. len ( ) - 1 ] . span ;
@@ -2585,7 +2586,8 @@ impl<'a> Resolver<'a> {
25852586 ( mod_prefix, format ! ( "`{}`" , names_to_string( mod_path) ) )
25862587 } ;
25872588 ( 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)
25892591 } ;
25902592 let code = DiagnosticId :: Error ( code. into ( ) ) ;
25912593 let mut err = this. session . struct_span_err_with_code ( base_span, & base_msg, code) ;
@@ -2701,17 +2703,21 @@ impl<'a> Resolver<'a> {
27012703 return ( err, candidates) ;
27022704 } ,
27032705 _ if ns == ValueNS && is_struct_like ( def) => {
2706+ let mut accessible_ctor = true ;
27042707 if let Def :: Struct ( def_id) = def {
27052708 if let Some ( ( ctor_def, ctor_vis) )
27062709 = 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 {
27082712 err. span_label ( span, format ! ( "constructor is not visible \
27092713 here due to private fields") ) ;
27102714 }
27112715 }
27122716 }
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+ }
27152721 return ( err, candidates) ;
27162722 }
27172723 _ => { }
0 commit comments