Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to suppress unused variable warnings #6

Closed
ghost opened this issue Nov 4, 2017 · 3 comments
Closed

Option to suppress unused variable warnings #6

ghost opened this issue Nov 4, 2017 · 3 comments

Comments

@ghost
Copy link

ghost commented Nov 4, 2017

I'm using built to get a few values, but even with the options tweaked to where I want them, I still get a lot of unused const warnings. (Especially when using Options{ env: true }...)

I'd appreciate it if there were an option to enable allow(unused_variables) without having to edit the file manually in build.rs.

I want to keep warnings enabled for my code, and most warnings for library code as well. But I'm well aware that I'm not using NUM_JOBS, I don't need to see that every time I build.

@lukaslueg
Copy link
Owner

Does it help if you use #[allow(unused_variables)] ?

#[allow(unused_variables)]
pub mod built_info {
    include!(concat!(env!("OUT_DIR"), "/built.rs"));
}

@ghost
Copy link
Author

ghost commented Nov 4, 2017

Earlier today hcpl on irc.mozilla.org#rust pointed out that my proposed solution would likely cause problems due to this issue: rust-lang/rust#18810

They also helped me solve the problem, and it turned out to be easier than I thought. I had the following file:

# build_info.rs
#![allow(unused_variables)]

include!(concat!(env!("OUT_DIR"), "/built.rs"));

However it still produced errors, and it blamed the errors on built.rs instead of build_info.rs. It turns out that allow(unused_variables) is the wrong attribute to use for const warnings, and instead using allow(dead_code) will silence them.

# build_info.rs
#![allow(dead_code)]

include!(concat!(env!("OUT_DIR"), "/built.rs"));

With that understanding, I'm completely fine with the way things work now. If anything I'd suggest a note in the documentation.

@lukaslueg
Copy link
Owner

I'm closing this for now, please re-open is this is still a problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant