@@ -29,13 +29,14 @@ pub fn is_min_const_fn<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, msrv: &Msrv)
29
29
let def_id = body. source . def_id ( ) ;
30
30
31
31
for local in & body. local_decls {
32
- check_ty ( tcx, local. ty , local. source_info . span ) ?;
32
+ check_ty ( tcx, local. ty , local. source_info . span , msrv ) ?;
33
33
}
34
34
// impl trait is gone in MIR, so check the return type manually
35
35
check_ty (
36
36
tcx,
37
37
tcx. fn_sig ( def_id) . instantiate_identity ( ) . output ( ) . skip_binder ( ) ,
38
38
body. local_decls . iter ( ) . next ( ) . unwrap ( ) . source_info . span ,
39
+ msrv,
39
40
) ?;
40
41
41
42
for bb in & * body. basic_blocks {
@@ -51,7 +52,7 @@ pub fn is_min_const_fn<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, msrv: &Msrv)
51
52
Ok ( ( ) )
52
53
}
53
54
54
- fn check_ty < ' tcx > ( tcx : TyCtxt < ' tcx > , ty : Ty < ' tcx > , span : Span ) -> McfResult {
55
+ fn check_ty < ' tcx > ( tcx : TyCtxt < ' tcx > , ty : Ty < ' tcx > , span : Span , msrv : & Msrv ) -> McfResult {
55
56
for arg in ty. walk ( ) {
56
57
let ty = match arg. unpack ( ) {
57
58
GenericArgKind :: Type ( ty) => ty,
@@ -62,7 +63,7 @@ fn check_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, span: Span) -> McfResult {
62
63
} ;
63
64
64
65
match ty. kind ( ) {
65
- ty:: Ref ( _, _, hir:: Mutability :: Mut ) => {
66
+ ty:: Ref ( _, _, hir:: Mutability :: Mut ) if !msrv . meets ( msrvs :: CONST_MUT_REFS ) => {
66
67
return Err ( ( span, "mutable references in const fn are unstable" . into ( ) ) ) ;
67
68
} ,
68
69
ty:: Alias ( ty:: Opaque , ..) => return Err ( ( span, "`impl Trait` in const fn is unstable" . into ( ) ) ) ,
0 commit comments