about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src/interpret/eval_context.rs
diff options
context:
space:
mode:
authorEduardo Sánchez Muñoz <eduardosm-dev@e64.io>2024-10-14 20:58:32 +0200
committerEduardo Sánchez Muñoz <eduardosm-dev@e64.io>2024-10-14 21:48:51 +0200
commitb73e613e008fd4a07a52ec7cef7c3af7db716b3d (patch)
tree0f6752319c75907a03e146d92fdc08e29f43ca49 /compiler/rustc_const_eval/src/interpret/eval_context.rs
parent8f8bee4f60d9d3769f75c70d558c27a95761c554 (diff)
downloadrust-b73e613e008fd4a07a52ec7cef7c3af7db716b3d.tar.gz
rust-b73e613e008fd4a07a52ec7cef7c3af7db716b3d.zip
De-duplicate and move `adjust_nan` to `InterpCx`
Diffstat (limited to 'compiler/rustc_const_eval/src/interpret/eval_context.rs')
-rw-r--r--compiler/rustc_const_eval/src/interpret/eval_context.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/eval_context.rs b/compiler/rustc_const_eval/src/interpret/eval_context.rs
index 5165f95afd5..02dd7821ef6 100644
--- a/compiler/rustc_const_eval/src/interpret/eval_context.rs
+++ b/compiler/rustc_const_eval/src/interpret/eval_context.rs
@@ -599,6 +599,14 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
     pub fn generate_stacktrace(&self) -> Vec<FrameInfo<'tcx>> {
         Frame::generate_stacktrace_from_stack(self.stack())
     }
+
+    pub fn adjust_nan<F1, F2>(&self, f: F2, inputs: &[F1]) -> F2
+    where
+        F1: rustc_apfloat::Float + rustc_apfloat::FloatConvert<F2>,
+        F2: rustc_apfloat::Float,
+    {
+        if f.is_nan() { M::generate_nan(self, inputs) } else { f }
+    }
 }
 
 #[doc(hidden)]