MCPcopy Create free account
hub / github.com/Rust-GPU/rust-gpu / const_int_value

Function const_int_value

crates/rustc_codegen_spirv/src/abi.rs:861–874  ·  view source on GitHub ↗
(
                cx: &CodegenCx<'tcx>,
                const_: Const<'tcx>,
            )

Source from the content-addressed store, hash-verified

859 // type_from_variant_discriminant(cx, substs.const_at(6));
860
861 fn const_int_value<'tcx, P: FromPrimitive>(
862 cx: &CodegenCx<'tcx>,
863 const_: Const<'tcx>,
864 ) -> Result<P, ErrorGuaranteed> {
865 assert!(const_.ty().is_integral());
866 let value = const_.eval_bits(cx.tcx, ParamEnv::reveal_all(), const_.ty());
867 match P::from_u128(value) {
868 Some(v) => Ok(v),
869 None => Err(cx
870 .tcx
871 .sess
872 .err(format!("Invalid value for Image const generic: {value}"))),
873 }
874 }
875
876 let dim = const_int_value(cx, substs.const_at(1))?;
877 let depth = const_int_value(cx, substs.const_at(2))?;

Callers 1

trans_intrinsic_typeFunction · 0.85

Calls 2

tyMethod · 0.80
errMethod · 0.80

Tested by

no test coverage detected