@@ -1288,7 +1288,8 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
1288
1288
span : Span ,
1289
1289
ty : Ty < ' tcx > ,
1290
1290
ty_path_def : Def ,
1291
- item_segment : & hir:: PathSegment )
1291
+ item_segment : & hir:: PathSegment ,
1292
+ permit_variants : bool )
1292
1293
-> ( Ty < ' tcx > , Def )
1293
1294
{
1294
1295
let tcx = self . tcx ( ) ;
@@ -1305,11 +1306,21 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
1305
1306
tcx. hygienic_eq ( assoc_name, vd. ident , adt_def. did )
1306
1307
} ) ;
1307
1308
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) ;
1309
1311
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
+ }
1313
1324
}
1314
1325
} ,
1315
1326
_ => ( ) ,
@@ -1773,7 +1784,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
1773
1784
} else {
1774
1785
Def :: Err
1775
1786
} ;
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
1777
1788
}
1778
1789
hir:: TyKind :: Array ( ref ty, ref length) => {
1779
1790
let length_def_id = tcx. hir ( ) . local_def_id ( length. id ) ;
0 commit comments