@@ -27,6 +27,7 @@ use rustc_middle::middle::resolve_bound_vars::Set1;
2727use rustc_middle:: { bug, span_bug} ;
2828use rustc_session:: config:: { CrateType , ResolveDocLinks } ;
2929use rustc_session:: lint;
30+ use rustc_session:: parse:: feature_err;
3031use rustc_span:: source_map:: { respan, Spanned } ;
3132use rustc_span:: symbol:: { kw, sym, Ident , Symbol } ;
3233use rustc_span:: { BytePos , Span , SyntaxContext } ;
@@ -4118,6 +4119,25 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
41184119 && PrimTy :: from_name ( path[ 0 ] . ident . name ) . is_some ( ) =>
41194120 {
41204121 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+
41214141 PartialRes :: with_unresolved_segments ( Res :: PrimTy ( prim) , path. len ( ) - 1 )
41224142 }
41234143 PathResult :: Module ( ModuleOrUniformRoot :: Module ( module) ) => {
0 commit comments