-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Ignore some warnings from rustc #3765
Comments
I'm not familiar with neomake but if you're only building one target, you can try using |
I get I obviously can't use rustc alone on the file because all the imports fail. |
Either I need the possibility to inform rustc of all the dependencies so that it doesn't fail on imports. Or I need the possibility to tell cargo to use rustc with some specific flags, without resorting to environment variables... |
Are you building a binary instead of a library? If you have a src/main.rs and no [[bin]] sections in your Cargo.toml file, then try this instead: Passing arbitrary flags to rustc was discussed in #60 but was closed in favor of per-project profiles. Unfortunately, that won't do what you want even if an appropriate field was available. I think the above command will work for your use case though. |
So you mean that I need to parse the toml file to figure out which flags to pass to cargo? I really want to be able to configure this once in my editor and still have it work with any rust file. If I didn't think that this is a usability problem I wouldn't have posted an issue about it. |
For a general solution that doesn't use environment variables, yes, as far as I know. But, if you're working on a project with one binary, then it's not something you have to change as your project grows and you add more source files. Where Maybe consider this as a temporary solution?
Sure, seems reasonable. I've had problems when environment variables were not available with build systems for other programming languages. An alternative might be nice but I'm not familiar with the decisions that lead to not allowing passing flags to rustc directly. Maybe @alexcrichton can chime in? |
As a temporary solution I will set |
One issue with using RUSTFLAGS is that it recompiles all the modules if I set/unset RUSTFLAGS... Is this an issue in rustc? should it recompile stuff if I change warnings that are emitted? |
@NickeZ that's intended behavior currentl, Cargo treats RUSTFLAGS opaquely and will recompile code when it changes (because that affects how code is compiled) |
@alexcrichton So there is no way to filter the warnings from rustc without affecting how the code is compiled? This blew my plan that I was going to compile with fewer warnings in vim and all warnings in the terminal. I'm sure the rust language server will be awesome when it is finished. But right now it would have been great if I could have filtered the warnings when neomake is compiling in the background so that I can focus on the real issues when I'm developing. |
AFAIK, yeah, there's no great way to do that right now short of writing your own rustc shim. |
Hmm you mean that I should have my own rustc shell script that calls rustc with/withut I guess that cargo will recompile everything if I switch between my shim and the real rustc? |
Yeah if you switch compilers Cargo will recompile, but you could have your own script read an env var and that'd subvert Cargo's caching mechanism. |
Great, I'll try something like this: #!/bin/sh
if [ -z "${NEOMAKE_CARGO}" ] ; then
"$HOME/.cargo/bin/rustc" "${@}"
else
"$HOME/.cargo/bin/rustc" -A dead_code "${@}"
fi edit: now I just have to implement environment variables in neomake... |
Yeah that'd do it! |
@alexcrichton I can't get it to work. How do I check which rustc is used by cargo? How do I override that?
|
OK it's working I had to set |
I would like to be able to ignore "dead_code" when I build with cargo with neomake inside neovim. I don't want to add exceptions to the sources because I want the warnings when I compile manually in the shell. I also don't think it is possible to set env vars in neomake so I can't use RUSTFLAGS. This is clearly a productivity issue since I'm distracted by irrelevant warnings when I'm in the exploration phase of a project.
The text was updated successfully, but these errors were encountered: