@@ -26,8 +26,8 @@ use rustc_middle::ty::GenericParamDefKind;
26
26
use rustc_middle:: ty:: { self , Const , DefIdTree , Ty , TyCtxt , TypeFoldable } ;
27
27
use rustc_session:: lint:: builtin:: AMBIGUOUS_ASSOCIATED_ITEMS ;
28
28
use rustc_span:: lev_distance:: find_best_match_for_name;
29
- use rustc_span:: symbol:: { Ident , Symbol } ;
30
- use rustc_span:: { Span , DUMMY_SP } ;
29
+ use rustc_span:: symbol:: { sym , Ident , Symbol } ;
30
+ use rustc_span:: { edition , Span , DUMMY_SP } ;
31
31
use rustc_target:: spec:: abi;
32
32
use rustc_trait_selection:: traits;
33
33
use rustc_trait_selection:: traits:: astconv_object_safety_violations;
@@ -2053,12 +2053,34 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
2053
2053
let substs = self . ast_path_substs_for_ty ( span, did, item_segment. 0 ) ;
2054
2054
self . normalize_ty ( span, tcx. mk_opaque ( did, substs) )
2055
2055
}
2056
+ Res :: Def ( DefKind :: TyAlias , did) => {
2057
+ assert_eq ! ( opt_self_ty, None ) ;
2058
+ self . prohibit_generics ( path. segments . split_last ( ) . unwrap ( ) . 1 ) ;
2059
+ let ty = self . ast_path_to_ty ( span, did, path. segments . last ( ) . unwrap ( ) ) ;
2060
+ if self . tcx ( ) . has_attr ( did, sym:: rustc_per_edition) {
2061
+ let ty = if let ty:: Tuple ( ..) = ty. kind ( ) {
2062
+ let mut fields = ty. tuple_fields ( ) ;
2063
+ let edition = span. edition ( ) ;
2064
+ edition:: ALL_EDITIONS
2065
+ . iter ( )
2066
+ . take_while ( |& & e| e != edition)
2067
+ . fold ( fields. next ( ) , |ty, _| fields. next ( ) . or ( ty) )
2068
+ } else {
2069
+ None
2070
+ } ;
2071
+ ty. unwrap_or_else ( || {
2072
+ self . tcx ( ) . sess . span_err (
2073
+ self . tcx ( ) . def_span ( did) ,
2074
+ "#[rustc_per_edition] type alias needs to be a tuple of at least one field" ,
2075
+ ) ;
2076
+ tcx. ty_error ( )
2077
+ } )
2078
+ } else {
2079
+ ty
2080
+ }
2081
+ }
2056
2082
Res :: Def (
2057
- DefKind :: Enum
2058
- | DefKind :: TyAlias
2059
- | DefKind :: Struct
2060
- | DefKind :: Union
2061
- | DefKind :: ForeignTy ,
2083
+ DefKind :: Enum | DefKind :: Struct | DefKind :: Union | DefKind :: ForeignTy ,
2062
2084
did,
2063
2085
) => {
2064
2086
assert_eq ! ( opt_self_ty, None ) ;
0 commit comments