@@ -17,6 +17,8 @@ use util::nodemap::FxHashMap;
17
17
use std:: collections:: hash_map:: Entry :: { Occupied , Vacant } ;
18
18
use std:: cmp;
19
19
20
+ use super :: report_unexpected_variant_def;
21
+
20
22
impl < ' a , ' gcx , ' tcx > FnCtxt < ' a , ' gcx , ' tcx > {
21
23
/// The `is_arg` argument indicates whether this pattern is the
22
24
/// *outermost* pattern in an argument (e.g., in `fn foo(&x:
@@ -736,12 +738,6 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
736
738
expected : Ty < ' tcx > ) -> Ty < ' tcx >
737
739
{
738
740
let tcx = self . tcx ;
739
- let report_unexpected_def = |def : Def | {
740
- span_err ! ( tcx. sess, pat. span, E0533 ,
741
- "expected unit struct/variant or constant, found {} `{}`" ,
742
- def. kind_name( ) ,
743
- hir:: print:: to_string( tcx. hir( ) , |s| s. print_qpath( qpath, false ) ) ) ;
744
- } ;
745
741
746
742
// Resolve the path and check the definition for errors.
747
743
let ( def, opt_ty, segments) = self . resolve_ty_and_def_ufcs ( qpath, pat. id , pat. span ) ;
@@ -751,7 +747,11 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
751
747
return tcx. types . err ;
752
748
}
753
749
Def :: Method ( ..) => {
754
- report_unexpected_def ( def) ;
750
+ report_unexpected_variant_def ( tcx, & def, pat. span , qpath) ;
751
+ return tcx. types . err ;
752
+ }
753
+ Def :: VariantCtor ( _, CtorKind :: Fictive ) => {
754
+ report_unexpected_variant_def ( tcx, & def, pat. span , qpath) ;
755
755
return tcx. types . err ;
756
756
}
757
757
Def :: VariantCtor ( _, CtorKind :: Const ) |
0 commit comments