Relax clippy_utils::consts::miri_to_const pointer type restrictiveness

This commit is contained in:
Niki4tap
2022-12-18 02:14:09 +03:00
parent 6afe5471cf
commit 3cc67d0856
2 changed files with 3 additions and 6 deletions

View File

@@ -125,6 +125,7 @@ mod explicit_write;
mod fallible_impl_from; mod fallible_impl_from;
mod float_literal; mod float_literal;
mod floating_point_arithmetic; mod floating_point_arithmetic;
mod fn_null_check;
mod format; mod format;
mod format_args; mod format_args;
mod format_impl; mod format_impl;
@@ -902,6 +903,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
store.register_late_pass(|_| Box::new(suspicious_xor_used_as_pow::ConfusingXorAndPow)); store.register_late_pass(|_| Box::new(suspicious_xor_used_as_pow::ConfusingXorAndPow));
store.register_late_pass(move |_| Box::new(manual_is_ascii_check::ManualIsAsciiCheck::new(msrv()))); store.register_late_pass(move |_| Box::new(manual_is_ascii_check::ManualIsAsciiCheck::new(msrv())));
store.register_late_pass(|_| Box::new(semicolon_block::SemicolonBlock)); store.register_late_pass(|_| Box::new(semicolon_block::SemicolonBlock));
store.register_late_pass(|_| Box::new(fn_null_check::FnNullCheck));
// add lints here, do not remove this comment, it's used in `new_lint` // add lints here, do not remove this comment, it's used in `new_lint`
} }

View File

@@ -620,12 +620,7 @@ pub fn miri_to_const<'tcx>(tcx: TyCtxt<'tcx>, result: mir::ConstantKind<'tcx>) -
ty::Float(FloatTy::F64) => Some(Constant::F64(f64::from_bits( ty::Float(FloatTy::F64) => Some(Constant::F64(f64::from_bits(
int.try_into().expect("invalid f64 bit representation"), int.try_into().expect("invalid f64 bit representation"),
))), ))),
ty::RawPtr(type_and_mut) => { ty::RawPtr(_) => Some(Constant::RawPtr(int.assert_bits(int.size()))),
if let ty::Uint(_) = type_and_mut.ty.kind() {
return Some(Constant::RawPtr(int.assert_bits(int.size())));
}
None
},
// FIXME: implement other conversions. // FIXME: implement other conversions.
_ => None, _ => None,
} }