@@ -2702,7 +2702,7 @@ impl<'a> Resolver<'a> {
2702
2702
}
2703
2703
return ( err, candidates) ;
2704
2704
} ,
2705
- ( Def :: Struct ( def_id) , _) if ns == ValueNS && is_struct_like ( def ) => {
2705
+ ( Def :: Struct ( def_id) , _) if ns == ValueNS => {
2706
2706
if let Some ( ( ctor_def, ctor_vis) )
2707
2707
= this. struct_constructors . get ( & def_id) . cloned ( ) {
2708
2708
let accessible_ctor = this. is_accessible ( ctor_vis) ;
@@ -2711,14 +2711,10 @@ impl<'a> Resolver<'a> {
2711
2711
here due to private fields") ) ;
2712
2712
} else if accessible_ctor {
2713
2713
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) ,
2722
2718
} ;
2723
2719
err. span_label ( span, format ! ( "did you mean `{}{}`?" ,
2724
2720
path_str,
@@ -2730,9 +2726,10 @@ impl<'a> Resolver<'a> {
2730
2726
}
2731
2727
return ( err, candidates) ;
2732
2728
}
2733
- ( Def :: VariantCtor ( _, ctor_kind ) , _) if ns == ValueNS && is_struct_like ( def ) => {
2729
+ ( Def :: VariantCtor ( _, CtorKind :: Fictive ) , _) if ns == ValueNS => {
2734
2730
let block = match ctor_kind {
2735
2731
CtorKind :: Fn => "(/* fields */)" ,
2732
+ CtorKind :: Const => "" ,
2736
2733
CtorKind :: Fictive => " { /* fields */ }" ,
2737
2734
def => bug ! ( "found def `{:?}` when looking for a ctor" ,
2738
2735
def) ,
@@ -2742,9 +2739,9 @@ impl<'a> Resolver<'a> {
2742
2739
block) ) ;
2743
2740
return ( err, candidates) ;
2744
2741
}
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 ") ;
2748
2745
}
2749
2746
_ => { }
2750
2747
}
0 commit comments