Rollup merge of #108047 - oli-obk:machine->🞋, r=RalfJung
Use `target` instead of `machine` for mir interpreter integer handling. The naming of `machine` only makes sense from a mir interpreter internals perspective, but outside users talk about the `target` platform. As per https://github.com/rust-lang/rust/pull/108029#issuecomment-1429791015 r? `@RalfJung`
This commit is contained in:
commit
dd6534ae87
@ -54,7 +54,7 @@ impl<'tcx> LateLintPass<'tcx> for LargeConstArrays {
|
|||||||
let ty = hir_ty_to_ty(cx.tcx, hir_ty);
|
let ty = hir_ty_to_ty(cx.tcx, hir_ty);
|
||||||
if let ty::Array(element_type, cst) = ty.kind();
|
if let ty::Array(element_type, cst) = ty.kind();
|
||||||
if let ConstKind::Value(ty::ValTree::Leaf(element_count)) = cst.kind();
|
if let ConstKind::Value(ty::ValTree::Leaf(element_count)) = cst.kind();
|
||||||
if let Ok(element_count) = element_count.try_to_machine_usize(cx.tcx);
|
if let Ok(element_count) = element_count.try_to_target_usize(cx.tcx);
|
||||||
if let Ok(element_size) = cx.layout_of(*element_type).map(|l| l.size.bytes());
|
if let Ok(element_size) = cx.layout_of(*element_type).map(|l| l.size.bytes());
|
||||||
if self.maximum_allowed_size < u128::from(element_count) * u128::from(element_size);
|
if self.maximum_allowed_size < u128::from(element_count) * u128::from(element_size);
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ impl<'tcx> LateLintPass<'tcx> for LargeStackArrays {
|
|||||||
if let ExprKind::Repeat(_, _) = expr.kind
|
if let ExprKind::Repeat(_, _) = expr.kind
|
||||||
&& let ty::Array(element_type, cst) = cx.typeck_results().expr_ty(expr).kind()
|
&& let ty::Array(element_type, cst) = cx.typeck_results().expr_ty(expr).kind()
|
||||||
&& let ConstKind::Value(ty::ValTree::Leaf(element_count)) = cst.kind()
|
&& let ConstKind::Value(ty::ValTree::Leaf(element_count)) = cst.kind()
|
||||||
&& let Ok(element_count) = element_count.try_to_machine_usize(cx.tcx)
|
&& let Ok(element_count) = element_count.try_to_target_usize(cx.tcx)
|
||||||
&& let Ok(element_size) = cx.layout_of(*element_type).map(|l| l.size.bytes())
|
&& let Ok(element_size) = cx.layout_of(*element_type).map(|l| l.size.bytes())
|
||||||
&& !cx.tcx.hir().parent_iter(expr.hir_id)
|
&& !cx.tcx.hir().parent_iter(expr.hir_id)
|
||||||
.any(|(_, node)| matches!(node, Node::Item(Item { kind: ItemKind::Static(..), .. })))
|
.any(|(_, node)| matches!(node, Node::Item(Item { kind: ItemKind::Static(..), .. })))
|
||||||
|
@ -640,7 +640,7 @@ pub fn miri_to_const<'tcx>(tcx: TyCtxt<'tcx>, result: mir::ConstantKind<'tcx>) -
|
|||||||
},
|
},
|
||||||
mir::ConstantKind::Val(ConstValue::ByRef { alloc, offset: _ }, _) => match result.ty().kind() {
|
mir::ConstantKind::Val(ConstValue::ByRef { alloc, offset: _ }, _) => match result.ty().kind() {
|
||||||
ty::Array(sub_type, len) => match sub_type.kind() {
|
ty::Array(sub_type, len) => match sub_type.kind() {
|
||||||
ty::Float(FloatTy::F32) => match len.kind().try_to_machine_usize(tcx) {
|
ty::Float(FloatTy::F32) => match len.kind().try_to_target_usize(tcx) {
|
||||||
Some(len) => alloc
|
Some(len) => alloc
|
||||||
.inner()
|
.inner()
|
||||||
.inspect_with_uninit_and_ptr_outside_interpreter(0..(4 * usize::try_from(len).unwrap()))
|
.inspect_with_uninit_and_ptr_outside_interpreter(0..(4 * usize::try_from(len).unwrap()))
|
||||||
@ -651,7 +651,7 @@ pub fn miri_to_const<'tcx>(tcx: TyCtxt<'tcx>, result: mir::ConstantKind<'tcx>) -
|
|||||||
.map(Constant::Vec),
|
.map(Constant::Vec),
|
||||||
_ => None,
|
_ => None,
|
||||||
},
|
},
|
||||||
ty::Float(FloatTy::F64) => match len.kind().try_to_machine_usize(tcx) {
|
ty::Float(FloatTy::F64) => match len.kind().try_to_target_usize(tcx) {
|
||||||
Some(len) => alloc
|
Some(len) => alloc
|
||||||
.inner()
|
.inner()
|
||||||
.inspect_with_uninit_and_ptr_outside_interpreter(0..(8 * usize::try_from(len).unwrap()))
|
.inspect_with_uninit_and_ptr_outside_interpreter(0..(8 * usize::try_from(len).unwrap()))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user