rust-lang-nursery / lazy-static.rs

A small macro for defining lazy evaluated static variables in Rust.
Apache License 2.0
1.91k stars 111 forks source link

Compiletest is not passing #110

Closed dtolnay closed 5 years ago

dtolnay commented 6 years ago

One of our compile-fail test cases is no longer failing to compile.

$ cd compiletest
$ cargo clean
$ cargo update
$ cargo test

test [compile-fail] compile-fail/static_never_used.rs ... FAILED

failures:

---- [compile-fail] compile-fail/static_never_used.rs stdout ----

------stdout------------------------------

------stderr------------------------------

------------------------------------------

error: compile-fail test compiled successfully!
KodrAus commented 6 years ago

Hmm, looks like there are some changes to how warnings are surfaced in external macros in a recent nightly? As an example, in a quick local test I've got a binary main that depends on a library lib. Both define a macro containing dead code, but only the local macro actually raises a warning:

// lib/lib.rs

#[macro_export]
macro_rules! lib_make_unused {
    () => { static LIB_UNUSED: () = (); }
}
// main/main.rs

#[macro_use]
extern crate lib;

macro_rules! make_unused {
    () => { static UNUSED: () = (); }
}

lib_make_unused! {}
make_unused! {}

fn main() { }

Which on my (fairly recent) nightly rustc 1.29.0-nightly (97085f9fb 2018-08-01) results in:

warning: static item is never used: `UNUSED`
 --> src/main.rs:5:13
  |
5 |     () => { static UNUSED: () = (); }
  |             ^^^^^^^^^^^^^^^^^^^^^^^
...
9 | make_unused! {}
  | --------------- in this macro invocation
KodrAus commented 6 years ago

I'm wondering if it's really worth keeping this compile test since it's only dealing with a warn-by-default lint anyway.

KodrAus commented 6 years ago

Ok I've gone ahead and removed this test so folks have a green build to work with, but thought we could leave this issue open until we decide whether we want to find a way to restore the previous behaviour.