@@ -1288,7 +1288,8 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
12881288 span : Span ,
12891289 ty : Ty < ' tcx > ,
12901290 ty_path_def : Def ,
1291- item_segment : & hir:: PathSegment )
1291+ item_segment : & hir:: PathSegment ,
1292+ permit_variants : bool )
12921293 -> ( Ty < ' tcx > , Def )
12931294 {
12941295 let tcx = self . tcx ( ) ;
@@ -1305,11 +1306,21 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
13051306 tcx. hygienic_eq ( assoc_name, vd. ident , adt_def. did )
13061307 } ) ;
13071308 if let Some ( variant_def) = variant_def {
1308- check_type_alias_enum_variants_enabled ( tcx, span) ;
1309+ if permit_variants {
1310+ check_type_alias_enum_variants_enabled ( tcx, span) ;
13091311
1310- let def = Def :: Variant ( variant_def. did ) ;
1311- tcx. check_stability ( def. def_id ( ) , Some ( ref_id) , span) ;
1312- return ( ty, def) ;
1312+ let def = Def :: Variant ( variant_def. did ) ;
1313+ tcx. check_stability ( def. def_id ( ) , Some ( ref_id) , span) ;
1314+ return ( ty, def) ;
1315+ } else {
1316+ use rustc:: lint:: builtin:: TYPE_VS_VARIANT_AMBIGUITY ;
1317+ tcx. lint_node (
1318+ TYPE_VS_VARIANT_AMBIGUITY ,
1319+ ref_id,
1320+ span,
1321+ "type vs variant ambiguity" ,
1322+ ) ;
1323+ }
13131324 }
13141325 } ,
13151326 _ => ( ) ,
@@ -1773,7 +1784,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
17731784 } else {
17741785 Def :: Err
17751786 } ;
1776- self . associated_path_def_to_ty ( ast_ty. id , ast_ty. span , ty, def, segment) . 0
1787+ self . associated_path_def_to_ty ( ast_ty. id , ast_ty. span , ty, def, segment, false ) . 0
17771788 }
17781789 hir:: TyKind :: Array ( ref ty, ref length) => {
17791790 let length_def_id = tcx. hir ( ) . local_def_id ( length. id ) ;
0 commit comments