(Includes a regression test, which needed to go into `compile-fail/` due to weaknesses when combining `#[deny(warnings)]` with `tcx.sess.span_warn(..)`) (updated with review feedback from arielb1.)