rust: migration: hide more warnings from call_func_with_field!

The call_func_with_field! macro uses dead code willingly to infer
the appropriate type.  This has started adding a new warning:

error: unused variable: `value__`
 79 |             break phantom__(&{ let value__: $typ; value__.$($field).+ })

So shut it up together with the existing unreachable_code warning.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini 2025-10-13 16:01:55 +02:00
parent 194dfadd66
commit ceda1563d6

View file

@ -72,6 +72,7 @@ macro_rules! call_func_with_field {
($func:expr, $typ:ty, $($field:tt).+) => {
$func(loop {
#![allow(unreachable_code)]
#![allow(unused_variables)]
const fn phantom__<T>(_: &T) -> ::core::marker::PhantomData<T> { ::core::marker::PhantomData }
// Unreachable code is exempt from checks on uninitialized values.
// Use that trick to infer the type of this PhantomData.