How can I only show warnings if there are no errors?
Often during development, I have a bunch of unused imports and variables. I like to fix those after I have correctly working code. The warnings these generate cause me to scroll though the cargo build
output to find errors among all the warnings.
Is that possible to only show the warnings if compilation succeeds?
I don't want to ignore the warnings entirely, since I do want to solve them before committing the code.
compiler-errors rust compiler-warnings rust-cargo
add a comment |
Often during development, I have a bunch of unused imports and variables. I like to fix those after I have correctly working code. The warnings these generate cause me to scroll though the cargo build
output to find errors among all the warnings.
Is that possible to only show the warnings if compilation succeeds?
I don't want to ignore the warnings entirely, since I do want to solve them before committing the code.
compiler-errors rust compiler-warnings rust-cargo
add a comment |
Often during development, I have a bunch of unused imports and variables. I like to fix those after I have correctly working code. The warnings these generate cause me to scroll though the cargo build
output to find errors among all the warnings.
Is that possible to only show the warnings if compilation succeeds?
I don't want to ignore the warnings entirely, since I do want to solve them before committing the code.
compiler-errors rust compiler-warnings rust-cargo
Often during development, I have a bunch of unused imports and variables. I like to fix those after I have correctly working code. The warnings these generate cause me to scroll though the cargo build
output to find errors among all the warnings.
Is that possible to only show the warnings if compilation succeeds?
I don't want to ignore the warnings entirely, since I do want to solve them before committing the code.
compiler-errors rust compiler-warnings rust-cargo
compiler-errors rust compiler-warnings rust-cargo
edited Nov 17 '18 at 20:51
Shepmaster
150k13292430
150k13292430
asked Nov 17 '18 at 20:27
MarkMark
8,67046491
8,67046491
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You can suppress warnings in your compilation using the -Awarnings
flags. If you use Cargo, you can add it with:
cargo rustc -- -Awarnings
That will compile your crate with warnings disabled, so only errors will show up. When you get a successful compilation, you can switch back to:
cargo build
And your crate will compile again (because the flags have changed, the target is no longer up to date) and you will get the detailed warnings.
You can try automating them by running:
cargo rustc -- -Awarnings && cargo build
This has the drawback of compiling the crate twice if there are no errors and that can take some extra time.
If you want to compile all the dependencies without the warnings, you can run instead:
RUSTFLAGS=-Awarnings cargo build
But then, the double compilation issue is quite more relevant.
As as side note, I think that some IDEs (VSCode?) are able to do that: sort the compiler messages and filter out the ones you are not interested in.
You may usecargo check -- -Awarnings
? I haven't tried, but it can save you some time.
– hellow
Nov 18 '18 at 13:55
1
@hellow: I tried, but unfortunatelycargo check
is not able to userustc
flags... at least I don't know how. You can use it with theRUSTFLAGS
trick, though.
– rodrigo
Nov 18 '18 at 13:57
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53355265%2fhow-can-i-only-show-warnings-if-there-are-no-errors%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can suppress warnings in your compilation using the -Awarnings
flags. If you use Cargo, you can add it with:
cargo rustc -- -Awarnings
That will compile your crate with warnings disabled, so only errors will show up. When you get a successful compilation, you can switch back to:
cargo build
And your crate will compile again (because the flags have changed, the target is no longer up to date) and you will get the detailed warnings.
You can try automating them by running:
cargo rustc -- -Awarnings && cargo build
This has the drawback of compiling the crate twice if there are no errors and that can take some extra time.
If you want to compile all the dependencies without the warnings, you can run instead:
RUSTFLAGS=-Awarnings cargo build
But then, the double compilation issue is quite more relevant.
As as side note, I think that some IDEs (VSCode?) are able to do that: sort the compiler messages and filter out the ones you are not interested in.
You may usecargo check -- -Awarnings
? I haven't tried, but it can save you some time.
– hellow
Nov 18 '18 at 13:55
1
@hellow: I tried, but unfortunatelycargo check
is not able to userustc
flags... at least I don't know how. You can use it with theRUSTFLAGS
trick, though.
– rodrigo
Nov 18 '18 at 13:57
add a comment |
You can suppress warnings in your compilation using the -Awarnings
flags. If you use Cargo, you can add it with:
cargo rustc -- -Awarnings
That will compile your crate with warnings disabled, so only errors will show up. When you get a successful compilation, you can switch back to:
cargo build
And your crate will compile again (because the flags have changed, the target is no longer up to date) and you will get the detailed warnings.
You can try automating them by running:
cargo rustc -- -Awarnings && cargo build
This has the drawback of compiling the crate twice if there are no errors and that can take some extra time.
If you want to compile all the dependencies without the warnings, you can run instead:
RUSTFLAGS=-Awarnings cargo build
But then, the double compilation issue is quite more relevant.
As as side note, I think that some IDEs (VSCode?) are able to do that: sort the compiler messages and filter out the ones you are not interested in.
You may usecargo check -- -Awarnings
? I haven't tried, but it can save you some time.
– hellow
Nov 18 '18 at 13:55
1
@hellow: I tried, but unfortunatelycargo check
is not able to userustc
flags... at least I don't know how. You can use it with theRUSTFLAGS
trick, though.
– rodrigo
Nov 18 '18 at 13:57
add a comment |
You can suppress warnings in your compilation using the -Awarnings
flags. If you use Cargo, you can add it with:
cargo rustc -- -Awarnings
That will compile your crate with warnings disabled, so only errors will show up. When you get a successful compilation, you can switch back to:
cargo build
And your crate will compile again (because the flags have changed, the target is no longer up to date) and you will get the detailed warnings.
You can try automating them by running:
cargo rustc -- -Awarnings && cargo build
This has the drawback of compiling the crate twice if there are no errors and that can take some extra time.
If you want to compile all the dependencies without the warnings, you can run instead:
RUSTFLAGS=-Awarnings cargo build
But then, the double compilation issue is quite more relevant.
As as side note, I think that some IDEs (VSCode?) are able to do that: sort the compiler messages and filter out the ones you are not interested in.
You can suppress warnings in your compilation using the -Awarnings
flags. If you use Cargo, you can add it with:
cargo rustc -- -Awarnings
That will compile your crate with warnings disabled, so only errors will show up. When you get a successful compilation, you can switch back to:
cargo build
And your crate will compile again (because the flags have changed, the target is no longer up to date) and you will get the detailed warnings.
You can try automating them by running:
cargo rustc -- -Awarnings && cargo build
This has the drawback of compiling the crate twice if there are no errors and that can take some extra time.
If you want to compile all the dependencies without the warnings, you can run instead:
RUSTFLAGS=-Awarnings cargo build
But then, the double compilation issue is quite more relevant.
As as side note, I think that some IDEs (VSCode?) are able to do that: sort the compiler messages and filter out the ones you are not interested in.
edited Nov 18 '18 at 13:53
Shepmaster
150k13292430
150k13292430
answered Nov 18 '18 at 13:39
rodrigorodrigo
63.4k492129
63.4k492129
You may usecargo check -- -Awarnings
? I haven't tried, but it can save you some time.
– hellow
Nov 18 '18 at 13:55
1
@hellow: I tried, but unfortunatelycargo check
is not able to userustc
flags... at least I don't know how. You can use it with theRUSTFLAGS
trick, though.
– rodrigo
Nov 18 '18 at 13:57
add a comment |
You may usecargo check -- -Awarnings
? I haven't tried, but it can save you some time.
– hellow
Nov 18 '18 at 13:55
1
@hellow: I tried, but unfortunatelycargo check
is not able to userustc
flags... at least I don't know how. You can use it with theRUSTFLAGS
trick, though.
– rodrigo
Nov 18 '18 at 13:57
You may use
cargo check -- -Awarnings
? I haven't tried, but it can save you some time.– hellow
Nov 18 '18 at 13:55
You may use
cargo check -- -Awarnings
? I haven't tried, but it can save you some time.– hellow
Nov 18 '18 at 13:55
1
1
@hellow: I tried, but unfortunately
cargo check
is not able to use rustc
flags... at least I don't know how. You can use it with the RUSTFLAGS
trick, though.– rodrigo
Nov 18 '18 at 13:57
@hellow: I tried, but unfortunately
cargo check
is not able to use rustc
flags... at least I don't know how. You can use it with the RUSTFLAGS
trick, though.– rodrigo
Nov 18 '18 at 13:57
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53355265%2fhow-can-i-only-show-warnings-if-there-are-no-errors%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown