From 7b3e3ff39aa45103a6f8432466f8078970866142 Mon Sep 17 00:00:00 2001 From: Bastian Kauschke Date: Tue, 10 Mar 2020 12:46:22 +0100 Subject: [PATCH] explain the use of a custom identity function --- src/test/ui/consts/const_discriminant.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/ui/consts/const_discriminant.rs b/src/test/ui/consts/const_discriminant.rs index 55e2918c85f93..1ad5134e71c52 100644 --- a/src/test/ui/consts/const_discriminant.rs +++ b/src/test/ui/consts/const_discriminant.rs @@ -4,6 +4,9 @@ use std::mem::{discriminant, Discriminant}; +// `discriminant(const_expr)` may get const-propagated. +// As we want to check that const-eval is equal to ordinary exection, +// we wrap `const_expr` with a function which is not const to prevent this. #[inline(never)] fn identity(x: T) -> T { x }