@@ -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 } ;
@@ -4123,6 +4124,25 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
41234124 && PrimTy :: from_name ( path[ 0 ] . ident . name ) . is_some ( ) =>
41244125 {
41254126 let prim = PrimTy :: from_name ( path[ 0 ] . ident . name ) . unwrap ( ) ;
4127+ let tcx = self . r . tcx ( ) ;
4128+
4129+ let gate_err_sym_msg = match prim {
4130+ PrimTy :: Float ( FloatTy :: F16 ) if !tcx. features ( ) . f16 => {
4131+ Some ( ( sym:: f16, "the type `f16` is unstable" ) )
4132+ }
4133+ PrimTy :: Float ( FloatTy :: F128 ) if !tcx. features ( ) . f128 => {
4134+ Some ( ( sym:: f128, "the type `f128` is unstable" ) )
4135+ }
4136+ _ => None ,
4137+ } ;
4138+
4139+ if let Some ( ( sym, msg) ) = gate_err_sym_msg {
4140+ let span = path[ 0 ] . ident . span ;
4141+ if !span. allows_unstable ( sym) {
4142+ feature_err ( tcx. sess , sym, span, msg) . emit ( ) ;
4143+ }
4144+ } ;
4145+
41264146 PartialRes :: with_unresolved_segments ( Res :: PrimTy ( prim) , path. len ( ) - 1 )
41274147 }
41284148 PathResult :: Module ( ModuleOrUniformRoot :: Module ( module) ) => {
0 commit comments