Closed
Description
… not on the type definition.
This warning started appearing in Servo recently:
warning: unreachable expression, #[warn(unreachable_code)] on by default
--> /home/simon/projects/servo1/components/script_traits/lib.rs:403:1
|
403 | pub enum Milliseconds {}
| ^^^^^^^^^^^^^^^^^^^^^^^^
warning: unreachable expression, #[warn(unreachable_code)] on by default
--> /home/simon/projects/servo1/components/script_traits/lib.rs:406:1
|
406 | pub enum Nanoseconds {}
| ^^^^^^^^^^^^^^^^^^^^^^^
It turns out that these types have #[derive(Clone, Copy, HeapSizeOf)]
, with a dependency defining #[proc_macro_derive(HeapSizeOf)]
. The warning is in code generated by this macro.
But at first I couldn’t figure it out. I had to ask on IRC and sfackler suggested it could be generated code.
It would have helped if the span of the error was not on the type definition, but on the attribute that caused code to be generated in the first place. Something like this:
405 | #[derive(Clone, Copy, HeapSizeOf)]
| ^^^^^^^^^^
The error message could also mention macros or generated code, like "unreachable expression in expansion of derive_HeapSizeOf
".