@@ -27,6 +27,7 @@ use rustc_middle::middle::resolve_bound_vars::Set1;
27
27
use rustc_middle:: { bug, span_bug} ;
28
28
use rustc_session:: config:: { CrateType , ResolveDocLinks } ;
29
29
use rustc_session:: lint;
30
+ use rustc_session:: parse:: feature_err;
30
31
use rustc_span:: source_map:: { respan, Spanned } ;
31
32
use rustc_span:: symbol:: { kw, sym, Ident , Symbol } ;
32
33
use rustc_span:: { BytePos , Span , SyntaxContext } ;
@@ -4118,6 +4119,25 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
4118
4119
&& PrimTy :: from_name ( path[ 0 ] . ident . name ) . is_some ( ) =>
4119
4120
{
4120
4121
let prim = PrimTy :: from_name ( path[ 0 ] . ident . name ) . unwrap ( ) ;
4122
+ let tcx = self . r . tcx ( ) ;
4123
+
4124
+ let gate_err_sym_msg = match prim {
4125
+ PrimTy :: Float ( FloatTy :: F16 ) if !tcx. features ( ) . f16 => {
4126
+ Some ( ( sym:: f16, "the type `f16` is unstable" ) )
4127
+ }
4128
+ PrimTy :: Float ( FloatTy :: F128 ) if !tcx. features ( ) . f128 => {
4129
+ Some ( ( sym:: f128, "the type `f128` is unstable" ) )
4130
+ }
4131
+ _ => None ,
4132
+ } ;
4133
+
4134
+ if let Some ( ( sym, msg) ) = gate_err_sym_msg {
4135
+ let span = path[ 0 ] . ident . span ;
4136
+ if !span. allows_unstable ( sym) {
4137
+ feature_err ( tcx. sess , sym, span, msg) . emit ( ) ;
4138
+ }
4139
+ } ;
4140
+
4121
4141
PartialRes :: with_unresolved_segments ( Res :: PrimTy ( prim) , path. len ( ) - 1 )
4122
4142
}
4123
4143
PathResult :: Module ( ModuleOrUniformRoot :: Module ( module) ) => {
0 commit comments