How can I only show warnings if there are no errors?












3















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.










share|improve this question





























    3















    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.










    share|improve this question



























      3












      3








      3








      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.










      share|improve this question
















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 17 '18 at 20:51









      Shepmaster

      150k13292430




      150k13292430










      asked Nov 17 '18 at 20:27









      MarkMark

      8,67046491




      8,67046491
























          1 Answer
          1






          active

          oldest

          votes


















          2














          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.






          share|improve this answer


























          • 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





            @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













          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
          });


          }
          });














          draft saved

          draft discarded


















          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









          2














          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.






          share|improve this answer


























          • 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





            @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


















          2














          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.






          share|improve this answer


























          • 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





            @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
















          2












          2








          2







          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.






          share|improve this answer















          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.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 18 '18 at 13:53









          Shepmaster

          150k13292430




          150k13292430










          answered Nov 18 '18 at 13:39









          rodrigorodrigo

          63.4k492129




          63.4k492129













          • 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





            @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





















          • 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





            @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



















          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




















          draft saved

          draft discarded




















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Guess what letter conforming each word

          Port of Spain

          Run scheduled task as local user group (not BUILTIN)