Propegate HIR and AST f16
and f128
types to clippy
This commit is contained in:
parent
fb18033b83
commit
2c8f47105a
@ -75,9 +75,12 @@ pub fn new(msrv: Msrv) -> Self {
|
|||||||
fn check_lit(&self, cx: &LateContext<'_>, lit: &LitKind, e: &Expr<'_>) {
|
fn check_lit(&self, cx: &LateContext<'_>, lit: &LitKind, e: &Expr<'_>) {
|
||||||
match *lit {
|
match *lit {
|
||||||
LitKind::Float(s, LitFloatType::Suffixed(fty)) => match fty {
|
LitKind::Float(s, LitFloatType::Suffixed(fty)) => match fty {
|
||||||
|
FloatTy::F16 => self.check_known_consts(cx, e, s, "f16"),
|
||||||
FloatTy::F32 => self.check_known_consts(cx, e, s, "f32"),
|
FloatTy::F32 => self.check_known_consts(cx, e, s, "f32"),
|
||||||
FloatTy::F64 => self.check_known_consts(cx, e, s, "f64"),
|
FloatTy::F64 => self.check_known_consts(cx, e, s, "f64"),
|
||||||
|
FloatTy::F128 => self.check_known_consts(cx, e, s, "f128"),
|
||||||
},
|
},
|
||||||
|
// FIXME(f16_f128): add `f16` and `f128` when these types become stable.
|
||||||
LitKind::Float(s, LitFloatType::Unsuffixed) => self.check_known_consts(cx, e, s, "f{32, 64}"),
|
LitKind::Float(s, LitFloatType::Unsuffixed) => self.check_known_consts(cx, e, s, "f{32, 64}"),
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
@ -76,8 +76,10 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
|
|||||||
let digits = count_digits(sym_str);
|
let digits = count_digits(sym_str);
|
||||||
let max = max_digits(fty);
|
let max = max_digits(fty);
|
||||||
let type_suffix = match lit_float_ty {
|
let type_suffix = match lit_float_ty {
|
||||||
|
LitFloatType::Suffixed(ast::FloatTy::F16) => Some("f16"),
|
||||||
LitFloatType::Suffixed(ast::FloatTy::F32) => Some("f32"),
|
LitFloatType::Suffixed(ast::FloatTy::F32) => Some("f32"),
|
||||||
LitFloatType::Suffixed(ast::FloatTy::F64) => Some("f64"),
|
LitFloatType::Suffixed(ast::FloatTy::F64) => Some("f64"),
|
||||||
|
LitFloatType::Suffixed(ast::FloatTy::F128) => Some("f128"),
|
||||||
LitFloatType::Unsuffixed => None,
|
LitFloatType::Unsuffixed => None,
|
||||||
};
|
};
|
||||||
let (is_whole, is_inf, mut float_str) = match fty {
|
let (is_whole, is_inf, mut float_str) = match fty {
|
||||||
|
@ -277,12 +277,16 @@ pub fn lit_to_mir_constant<'tcx>(lit: &LitKind, ty: Option<Ty<'tcx>>) -> Constan
|
|||||||
LitKind::Char(c) => Constant::Char(c),
|
LitKind::Char(c) => Constant::Char(c),
|
||||||
LitKind::Int(n, _) => Constant::Int(n.get()),
|
LitKind::Int(n, _) => Constant::Int(n.get()),
|
||||||
LitKind::Float(ref is, LitFloatType::Suffixed(fty)) => match fty {
|
LitKind::Float(ref is, LitFloatType::Suffixed(fty)) => match fty {
|
||||||
|
ast::FloatTy::F16 => unimplemented!("f16_f128"),
|
||||||
ast::FloatTy::F32 => Constant::F32(is.as_str().parse().unwrap()),
|
ast::FloatTy::F32 => Constant::F32(is.as_str().parse().unwrap()),
|
||||||
ast::FloatTy::F64 => Constant::F64(is.as_str().parse().unwrap()),
|
ast::FloatTy::F64 => Constant::F64(is.as_str().parse().unwrap()),
|
||||||
|
ast::FloatTy::F128 => unimplemented!("f16_f128"),
|
||||||
},
|
},
|
||||||
LitKind::Float(ref is, LitFloatType::Unsuffixed) => match ty.expect("type of float is known").kind() {
|
LitKind::Float(ref is, LitFloatType::Unsuffixed) => match ty.expect("type of float is known").kind() {
|
||||||
|
ty::Float(FloatTy::F16) => unimplemented!("f16_f128"),
|
||||||
ty::Float(FloatTy::F32) => Constant::F32(is.as_str().parse().unwrap()),
|
ty::Float(FloatTy::F32) => Constant::F32(is.as_str().parse().unwrap()),
|
||||||
ty::Float(FloatTy::F64) => Constant::F64(is.as_str().parse().unwrap()),
|
ty::Float(FloatTy::F64) => Constant::F64(is.as_str().parse().unwrap()),
|
||||||
|
ty::Float(FloatTy::F128) => unimplemented!("f16_f128"),
|
||||||
_ => bug!(),
|
_ => bug!(),
|
||||||
},
|
},
|
||||||
LitKind::Bool(b) => Constant::Bool(b),
|
LitKind::Bool(b) => Constant::Bool(b),
|
||||||
|
Loading…
Reference in New Issue
Block a user