@@ -26,11 +26,11 @@ use rustc_middle::ty::{
26
26
self , AdtKind , CanonicalUserType , DefIdTree , GenericParamDefKind , ToPolyTraitRef , ToPredicate ,
27
27
Ty , UserType ,
28
28
} ;
29
- use rustc_session:: lint;
30
- use rustc_span:: hygiene:: DesugaringKind ;
29
+ use rustc_session:: { lint, parse:: feature_err} ;
31
30
use rustc_span:: source_map:: { original_sp, DUMMY_SP } ;
32
31
use rustc_span:: symbol:: { kw, sym, Ident } ;
33
32
use rustc_span:: { self , BytePos , MultiSpan , Span } ;
33
+ use rustc_span:: { hygiene:: DesugaringKind , Symbol } ;
34
34
use rustc_trait_selection:: infer:: InferCtxtExt as _;
35
35
use rustc_trait_selection:: opaque_types:: InferCtxtExt as _;
36
36
use rustc_trait_selection:: traits:: error_reporting:: InferCtxtExt as _;
@@ -362,6 +362,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
362
362
parent_id : hir:: HirId ,
363
363
value : T ,
364
364
value_span : Span ,
365
+ feature : Option < Symbol > ,
365
366
) -> T {
366
367
let parent_def_id = self . tcx . hir ( ) . local_def_id ( parent_id) ;
367
368
debug ! (
@@ -380,7 +381,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
380
381
381
382
let mut opaque_types = self . opaque_types . borrow_mut ( ) ;
382
383
let mut opaque_types_vars = self . opaque_types_vars . borrow_mut ( ) ;
384
+
383
385
for ( ty, decl) in opaque_type_map {
386
+ if let Some ( feature) = feature {
387
+ if let hir:: OpaqueTyOrigin :: TyAlias = decl. origin {
388
+ if !self . tcx . features ( ) . enabled ( feature) {
389
+ feature_err (
390
+ & self . tcx . sess . parse_sess ,
391
+ feature,
392
+ value_span,
393
+ "type alias impl trait is not permitted here" ,
394
+ )
395
+ . emit ( ) ;
396
+ }
397
+ }
398
+ }
384
399
let _ = opaque_types. insert ( ty, decl) ;
385
400
let _ = opaque_types_vars. insert ( decl. concrete_ty , decl. opaque_type ) ;
386
401
}
0 commit comments