Auto merge of #121926 - tgross35:f16-f128-step3-feature-gate, r=compiler-errors,petrochenkov
`f16` and `f128` step 3: compiler support & feature gate Continuation of https://github.com/rust-lang/rust/pull/121841, another portion of https://github.com/rust-lang/rust/pull/114607 This PR exposes the new types to the world and adds a feature gate. Marking this as a draft because I need some feedback on where I did the feature gate check. It also does not yet catch type via suffixed literals (so the feature gate test will fail, probably some others too because I haven't belssed). If there is a better place to check all types after resolution, I can do that. If not, I figure maybe I can add a second gate location in AST when it checks numeric suffixes. Unfortunately I still don't think there is much testing to be done for correctness (codegen tests or parsed value checks) until we have basic library support. I think that will be the next step. Tracking issue: https://github.com/rust-lang/rust/issues/116909 r? `@compiler-errors` cc `@Nilstrieb` `@rustbot` label +F-f16_and_f128
This commit is contained in:
@@ -27,6 +27,7 @@ use rustc_middle::middle::resolve_bound_vars::Set1;
|
||||
use rustc_middle::{bug, span_bug};
|
||||
use rustc_session::config::{CrateType, ResolveDocLinks};
|
||||
use rustc_session::lint;
|
||||
use rustc_session::parse::feature_err;
|
||||
use rustc_span::source_map::{respan, Spanned};
|
||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||
use rustc_span::{BytePos, Span, SyntaxContext};
|
||||
@@ -4138,6 +4139,25 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
||||
&& PrimTy::from_name(path[0].ident.name).is_some() =>
|
||||
{
|
||||
let prim = PrimTy::from_name(path[0].ident.name).unwrap();
|
||||
let tcx = self.r.tcx();
|
||||
|
||||
let gate_err_sym_msg = match prim {
|
||||
PrimTy::Float(FloatTy::F16) if !tcx.features().f16 => {
|
||||
Some((sym::f16, "the type `f16` is unstable"))
|
||||
}
|
||||
PrimTy::Float(FloatTy::F128) if !tcx.features().f128 => {
|
||||
Some((sym::f128, "the type `f128` is unstable"))
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
|
||||
if let Some((sym, msg)) = gate_err_sym_msg {
|
||||
let span = path[0].ident.span;
|
||||
if !span.allows_unstable(sym) {
|
||||
feature_err(tcx.sess, sym, span, msg).emit();
|
||||
}
|
||||
};
|
||||
|
||||
PartialRes::with_unresolved_segments(Res::PrimTy(prim), path.len() - 1)
|
||||
}
|
||||
PathResult::Module(ModuleOrUniformRoot::Module(module)) => {
|
||||
|
||||
Reference in New Issue
Block a user