@@ -2702,7 +2702,7 @@ impl<'a> Resolver<'a> {
27022702 }
27032703 return ( err, candidates) ;
27042704 } ,
2705- ( Def :: Struct ( def_id) , _) if ns == ValueNS && is_struct_like ( def ) => {
2705+ ( Def :: Struct ( def_id) , _) if ns == ValueNS => {
27062706 if let Some ( ( ctor_def, ctor_vis) )
27072707 = this. struct_constructors . get ( & def_id) . cloned ( ) {
27082708 let accessible_ctor = this. is_accessible ( ctor_vis) ;
@@ -2711,14 +2711,10 @@ impl<'a> Resolver<'a> {
27112711 here due to private fields") ) ;
27122712 } else if accessible_ctor {
27132713 let block = match ctor_def {
2714- Def :: StructCtor ( _, CtorKind :: Fn ) |
2715- Def :: VariantCtor ( _, CtorKind :: Fn ) => "(/* fields */)" ,
2716- Def :: StructCtor ( _, CtorKind :: Fictive ) |
2717- Def :: VariantCtor ( _, CtorKind :: Fictive ) => {
2718- " { /* fields */ }"
2719- }
2720- def => bug ! ( "found def `{:?}` when looking for a ctor" ,
2721- def) ,
2714+ Def :: StructCtor ( _, CtorKind :: Fn ) => "(/* fields */)" ,
2715+ Def :: StructCtor ( _, CtorKind :: Const ) => "" ,
2716+ Def :: Struct ( ..) => " { /* fields */ }" ,
2717+ def => bug ! ( "found def `{:?}` when looking for a ctor" , def) ,
27222718 } ;
27232719 err. span_label ( span, format ! ( "did you mean `{}{}`?" ,
27242720 path_str,
@@ -2730,9 +2726,10 @@ impl<'a> Resolver<'a> {
27302726 }
27312727 return ( err, candidates) ;
27322728 }
2733- ( Def :: VariantCtor ( _, ctor_kind ) , _) if ns == ValueNS && is_struct_like ( def ) => {
2729+ ( Def :: VariantCtor ( _, CtorKind :: Fictive ) , _) if ns == ValueNS => {
27342730 let block = match ctor_kind {
27352731 CtorKind :: Fn => "(/* fields */)" ,
2732+ CtorKind :: Const => "" ,
27362733 CtorKind :: Fictive => " { /* fields */ }" ,
27372734 def => bug ! ( "found def `{:?}` when looking for a ctor" ,
27382735 def) ,
@@ -2742,9 +2739,9 @@ impl<'a> Resolver<'a> {
27422739 block) ) ;
27432740 return ( err, candidates) ;
27442741 }
2745- ( Def :: SelfTy ( _ , _ ) , _) if ns == ValueNS && is_struct_like ( def ) => {
2746- err. note ( "can't instantiate `Self`, you must use the implemented struct \
2747- directly ") ;
2742+ ( Def :: SelfTy ( .. ) , _) if ns == ValueNS {
2743+ err. note ( "can't use `Self` as a constructor , you must use the \
2744+ implemented struct ") ;
27482745 }
27492746 _ => { }
27502747 }
0 commit comments