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

rustc_session: allow overriding lint level of individual lints from a group #67885

Open
wants to merge 4 commits into
base: master
from

Conversation

@tobithiel
Copy link

tobithiel commented Jan 5, 2020

Fixes #58211 and fixes rust-lang/rust-clippy#4778 and fixes rust-lang/rust-clippy#4091

Instead of hard-coding the lint level preferences (from lowest to highest precedence: lint::Allow -> lint::Warn -> lint::Deny -> lint::Forbid), the position of the argument in the command line gets taken into account.

Examples:

  1. Passing -D unused -A unused-variables denies everything in the lint group unused except unused-variables which is explicitly allowed.
  2. Passing -A unused-variables -D unused denies everything in the lint group unused including unused-variables since the allow is specified before the deny (and therefore overridden by the deny).

This matches the behavior that is already being used when specifying allow/deny in the source code.

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Jan 5, 2020

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @matthewjasper (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

rust-highfive commented Jan 5, 2020

The job x86_64-gnu-llvm-7 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2020-01-05T02:21:28.1724486Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-01-05T02:21:28.1951719Z ##[command]git config gc.auto 0
2020-01-05T02:21:28.2008494Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-01-05T02:21:29.1161891Z ##[command]git config --get-all http.proxy
2020-01-05T02:21:29.1170856Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/67885/merge:refs/remotes/pull/67885/merge
---
2020-01-05T03:17:53.7275856Z .................................................................................................... 1500/9475
2020-01-05T03:17:59.8798068Z .................................................................................................... 1600/9475
2020-01-05T03:18:05.0258176Z .................................................................................................... 1700/9475
2020-01-05T03:18:14.7579894Z .................................................................................................... 1800/9475
2020-01-05T03:18:23.4156013Z i...............................................................F................................... 1900/9475
2020-01-05T03:18:30.6069059Z ........................................................................................iiiii....... 2000/9475
2020-01-05T03:18:53.8254354Z .................................................................................................... 2200/9475
2020-01-05T03:18:56.3610329Z .................................................................................................... 2300/9475
2020-01-05T03:18:58.9272949Z .................................................................................................... 2400/9475
2020-01-05T03:19:05.4540760Z .................................................................................................... 2500/9475
---
2020-01-05T03:22:14.0231440Z ....................i...............i............................................................... 4900/9475
2020-01-05T03:22:24.6504003Z .................................................................................................... 5000/9475
2020-01-05T03:22:30.6975315Z .................................................................i.................................. 5100/9475
2020-01-05T03:22:39.1886509Z .................................................................................................... 5200/9475
2020-01-05T03:22:47.2519856Z ................................ii.ii...........i................................................... 5300/9475
2020-01-05T03:22:57.1021445Z .................................................................................................... 5500/9475
2020-01-05T03:23:07.2508261Z .................................................................................................... 5600/9475
2020-01-05T03:23:14.8856736Z ................i................................................................................... 5700/9475
2020-01-05T03:23:21.3534812Z ..F................................................................................................. 5800/9475
2020-01-05T03:23:21.3534812Z ..F................................................................................................. 5800/9475
2020-01-05T03:23:33.3007868Z .................................................................................................... 5900/9475
2020-01-05T03:23:45.6469369Z .....ii...i..ii...........i......................................................................... 6000/9475
2020-01-05T03:24:03.5595907Z .................................................................................................... 6200/9475
2020-01-05T03:24:11.7778237Z .................................................................................................... 6300/9475
2020-01-05T03:24:11.7778237Z .................................................................................................... 6300/9475
2020-01-05T03:24:25.8430448Z ................................i..ii............................................................... 6400/9475
2020-01-05T03:24:46.9861364Z .................................................................................................... 6600/9475
2020-01-05T03:24:49.2627055Z .......i............................................................................................ 6700/9475
2020-01-05T03:24:52.6616527Z .................................................................................................... 6800/9475
2020-01-05T03:24:54.4769055Z ........i........................................................................................... 6900/9475
---
2020-01-05T03:26:37.4472244Z .................................................................................................... 7500/9475
2020-01-05T03:26:41.8601328Z .................................................................................................... 7600/9475
2020-01-05T03:26:47.3992724Z .................................................................................................... 7700/9475
2020-01-05T03:26:58.5901995Z .................................................................................................... 7800/9475
2020-01-05T03:27:06.8630312Z ...........................................iiii..................................................... 7900/9475
2020-01-05T03:27:22.6467716Z .................................................................................................... 8100/9475
2020-01-05T03:27:31.2696622Z .................................................................................................... 8200/9475
2020-01-05T03:27:45.9160298Z .................................................................................................... 8300/9475
2020-01-05T03:27:54.0302535Z .................................................................................................... 8400/9475
---
2020-01-05T03:29:56.6201362Z 
2020-01-05T03:29:56.6202925Z ---- [ui] ui/derive-uninhabited-enum-38885.rs stdout ----
2020-01-05T03:29:56.6204554Z diff of stderr:
2020-01-05T03:29:56.6206094Z 
2020-01-05T03:29:56.6206701Z - warning: variant is never constructed: `Void`
2020-01-05T03:29:56.6207167Z -   --> $DIR/derive-uninhabited-enum-38885.rs:13:5
2020-01-05T03:29:56.6207621Z -    |
2020-01-05T03:29:56.6208028Z - LL |     Void(Void),
2020-01-05T03:29:56.6208838Z -    |
2020-01-05T03:29:56.6208838Z -    |
2020-01-05T03:29:56.6209276Z -    = note: `-W dead-code` implied by `-W unused`
2020-01-05T03:29:56.6210899Z - 
2020-01-05T03:29:56.6211146Z 
2020-01-05T03:29:56.6211344Z 
2020-01-05T03:29:56.6211344Z 
2020-01-05T03:29:56.6211970Z error: failed to delete `/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/derive-uninhabited-enum-38885/derive-uninhabited-enum-38885.stderr`: No such file or directory (os error 2)
2020-01-05T03:29:56.6212687Z [ERROR compiletest::runtest] fatal error, panic: "failed to delete `/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/derive-uninhabited-enum-38885/derive-uninhabited-enum-38885.stderr`: No such file or directory (os error 2)"
2020-01-05T03:29:56.6213738Z thread '[ui] ui/derive-uninhabited-enum-38885.rs' panicked at 'fatal error', src/tools/compiletest/src/runtest.rs:2122:9
2020-01-05T03:29:56.6214633Z 
2020-01-05T03:29:56.6215073Z ---- [ui] ui/macros/must-use-in-macro-55516.rs stdout ----
2020-01-05T03:29:56.6215446Z diff of stderr:
2020-01-05T03:29:56.6215668Z 
2020-01-05T03:29:56.6215668Z 
2020-01-05T03:29:56.6216596Z - warning: unused `std::result::Result` that must be used
2020-01-05T03:29:56.6217083Z -   --> $DIR/must-use-in-macro-55516.rs:9:5
2020-01-05T03:29:56.6217430Z -    |
2020-01-05T03:29:56.6217787Z - LL |     write!(&mut example, "{}", 42);
2020-01-05T03:29:56.6218115Z -    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2020-01-05T03:29:56.6218408Z -    |
2020-01-05T03:29:56.6218770Z -    = note: `-W unused-must-use` implied by `-W unused`
2020-01-05T03:29:56.6219128Z -    = note: this `Result` may be an `Err` variant, which should be handled
2020-01-05T03:29:56.6220768Z - 
2020-01-05T03:29:56.6221113Z - 
2020-01-05T03:29:56.6221290Z 
2020-01-05T03:29:56.6221417Z 
2020-01-05T03:29:56.6221417Z 
2020-01-05T03:29:56.6221931Z error: failed to delete `/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/macros/must-use-in-macro-55516/must-use-in-macro-55516.stderr`: No such file or directory (os error 2)
2020-01-05T03:29:56.6222550Z [ERROR compiletest::runtest] fatal error, panic: "failed to delete `/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/macros/must-use-in-macro-55516/must-use-in-macro-55516.stderr`: No such file or directory (os error 2)"
2020-01-05T03:29:56.6223416Z thread '[ui] ui/macros/must-use-in-macro-55516.rs' panicked at 'fatal error', src/tools/compiletest/src/runtest.rs:2122:9
2020-01-05T03:29:56.6223897Z ---- [ui] ui/warn-path-statement.rs stdout ----
2020-01-05T03:29:56.6224030Z 
2020-01-05T03:29:56.6224176Z error: ui test compiled successfully!
2020-01-05T03:29:56.6224317Z status: exit code: 0
2020-01-05T03:29:56.6224317Z status: exit code: 0
2020-01-05T03:29:56.6225227Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/warn-path-statement.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/warn-path-statement" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-D" "path-statements" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/warn-path-statement/auxiliary" "-A" "unused"
2020-01-05T03:29:56.6225971Z ------------------------------------------
2020-01-05T03:29:56.6226128Z 
2020-01-05T03:29:56.6226435Z ------------------------------------------
2020-01-05T03:29:56.6226585Z stderr:
---
2020-01-05T03:29:56.6231184Z 
2020-01-05T03:29:56.6255609Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:385:22
2020-01-05T03:29:56.6269362Z 
2020-01-05T03:29:56.6270207Z 
2020-01-05T03:29:56.6272351Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-7/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "7.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
2020-01-05T03:29:56.6272987Z 
2020-01-05T03:29:56.6273374Z 
2020-01-05T03:29:56.6282888Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2020-01-05T03:29:56.6283399Z Build completed unsuccessfully in 1:01:42
2020-01-05T03:29:56.6283399Z Build completed unsuccessfully in 1:01:42
2020-01-05T03:29:56.6336731Z == clock drift check ==
2020-01-05T03:29:56.6350572Z   local time: Sun Jan  5 03:29:56 UTC 2020
2020-01-05T03:29:56.9267149Z   network time: Sun, 05 Jan 2020 03:29:56 GMT
2020-01-05T03:29:56.9270458Z == end clock drift check ==
2020-01-05T03:29:58.2332395Z 
2020-01-05T03:29:58.2441868Z ##[error]Bash exited with code '1'.
2020-01-05T03:29:58.2477945Z ##[section]Starting: Checkout
2020-01-05T03:29:58.2480256Z ==============================================================================
2020-01-05T03:29:58.2480317Z Task         : Get sources
2020-01-05T03:29:58.2480381Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@matthewjasper

This comment has been minimized.

Copy link
Contributor

matthewjasper commented Jan 11, 2020

cc @rust-lang/compiler for opinions on this change
cc @Mark-Simulacrum for the compiletest changes

@Mark-Simulacrum

This comment has been minimized.

Copy link
Member

Mark-Simulacrum commented Jan 11, 2020

compiletest changes look fine to me; I guess since CI is passing we weren't relying on the unused to override custom flags (which is good! :)

I personally think this change also makes sense in general -- I think I've wanted something like it in the past, even. We should make sure that Clippy folks are on board (cc @Manishearth -- do you know who all to ping inside dev tools?)

@petrochenkov

This comment has been minimized.

Copy link
Contributor

petrochenkov commented Jan 11, 2020

I'm generally for command line options being overridable by later command line options, because the need to set them hierarchically like #58211 describes arises in various contexts.

@oli-obk

This comment has been minimized.

Copy link
Contributor

oli-obk commented Jan 12, 2020

@Manishearth

This comment has been minimized.

Copy link
Member

Manishearth commented Jan 12, 2020

Clippy is happy with this we've wanted this to work well forever 😄

@Mark-Simulacrum

This comment has been minimized.

Copy link
Member

Mark-Simulacrum commented Jan 12, 2020

Could someone from the compiler team kick off FCP here? Even though no objections have been raised yet, and indeed everyone seems enthusiastically on board, seems like we should do so as a stable API change.

@oli-obk oli-obk added the T-compiler label Jan 12, 2020
@oli-obk

This comment has been minimized.

Copy link
Contributor

oli-obk commented Jan 12, 2020

This change unifies the behaviour between the command line lint level flags and the in source lint level attributes in the presence of conflicting flags. The last flag is now always the one that makes the decision, overriding previous flags.

@rfcbot merge

@rfcbot

This comment has been minimized.

Copy link

rfcbot commented Jan 12, 2020

Team member @oli-obk has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Jan 13, 2020

Seems reasonable to me, but I would ask that we document it in the rustc book -- @tobithiel can you update https://github.com/rust-lang/rust/blob/master/src/doc/rustc/src/command-line-arguments.md to explain this behavior? (And perhaps add suitable note into https://github.com/rust-lang/rust/blob/master/src/doc/rustc/src/lints/index.md or elsewhere as you see fit)

@tobithiel

This comment has been minimized.

Copy link
Author

tobithiel commented Jan 14, 2020

@nikomatsakis I added some examples to the documentation where it seemed to fit well. Let me know if you had other locations in mind as well. I'm not very familiar with the different documentations.

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Jan 14, 2020

Thanks @tobithiel, that looks great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.