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

Improve the explicit_outlives_requirements lint #61172

Merged
merged 4 commits into from
Jun 19, 2019

Conversation

matthewjasper
Copy link
Contributor

@matthewjasper matthewjasper commented May 25, 2019

  • Don't use Strings to compare parameters
  • Extend the lint to lifetime bounds
  • Extend the lint to enums and unions
  • Use the correct span for where clauses in tuple structs
  • Try to early-out where possible
  • Remove unnecessary bounds in rustc crates

@rust-highfive

This comment has been minimized.

@cramertj
Copy link
Member

r? @varkor

@rust-highfive rust-highfive assigned varkor and unassigned cramertj May 28, 2019
Copy link
Member

@varkor varkor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! r=me with nits fixed.

src/librustc_lint/builtin.rs Outdated Show resolved Hide resolved
src/librustc_lint/builtin.rs Outdated Show resolved Hide resolved
src/librustc_lint/builtin.rs Outdated Show resolved Hide resolved
src/librustc_lint/builtin.rs Outdated Show resolved Hide resolved
src/librustc_lint/builtin.rs Outdated Show resolved Hide resolved
@matthewjasper
Copy link
Contributor Author

@bors r=varkor

@bors
Copy link
Contributor

bors commented May 31, 2019

📌 Commit 7a0db474769697b0f20bc6ace65bb48fbc421bfb has been approved by varkor

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label May 31, 2019
@bors
Copy link
Contributor

bors commented Jun 1, 2019

⌛ Testing commit 7a0db474769697b0f20bc6ace65bb48fbc421bfb with merge 7a0019311d0fdb9ce6f823189af1ca64b38ab4db...

@bors
Copy link
Contributor

bors commented Jun 1, 2019

💔 Test failed - checks-travis

@bors bors removed the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jun 1, 2019
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-aux of your PR failed on Travis (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.
[01:29:44]    Compiling cargo v0.38.0 (/checkout/src/tools/cargo)
[01:30:00] warning: outlives requirements can be inferred
[01:30:00]   --> src/tools/cargo/src/cargo/core/compiler/build_context/mod.rs:19:33
[01:30:00]    |
[01:30:00] 19 | pub struct BuildContext<'a, 'cfg: 'a> {
[01:30:00]    |
[01:30:00] note: lint level defined here
[01:30:00]   --> src/tools/cargo/src/cargo/lib.rs:3:9
[01:30:00]    |
[01:30:00]    |
[01:30:00] 3  | #![warn(rust_2018_idioms)]
[01:30:00]    |         ^^^^^^^^^^^^^^^^
[01:30:00]    = note: #[warn(explicit_outlives_requirements)] implied by #[warn(rust_2018_idioms)]
[01:30:00] warning: outlives requirements can be inferred
[01:30:00]   --> src/tools/cargo/src/cargo/core/compiler/context/mod.rs:30:28
[01:30:00]    |
[01:30:00]    |
[01:30:00] 30 | pub struct Context<'a, 'cfg: 'a> {
[01:30:00] 
[01:30:00] warning: outlives requirements can be inferred
[01:30:00]   --> src/tools/cargo/src/cargo/core/compiler/context/unit_dependencies.rs:28:16
[01:30:00]    |
[01:30:00]    |
[01:30:00] 28 | struct State<'a: 'tmp, 'cfg: 'a, 'tmp> {
[01:30:00] help: remove these bounds
[01:30:00]    |
[01:30:00]    |
[01:30:00] 28 | struct State<'a, 'cfg, 'tmp> {
[01:30:00] 
[01:30:00] warning: outlives requirements can be inferred
[01:30:00]   --> src/tools/cargo/src/cargo/core/compiler/context/compilation_files.rs:53:37
[01:30:00]    |
[01:30:00]    |
[01:30:00] 53 | pub struct CompilationFiles<'a, 'cfg: 'a> {
[01:30:00] 
[01:30:00] warning: outlives requirements can be inferred
[01:30:00]    --> src/tools/cargo/src/cargo/core/package.rs:293:30
[01:30:00]     |
[01:30:00]     |
[01:30:00] 293 | pub struct Downloads<'a, 'cfg: 'a> {
[01:30:00] 
[01:30:00] warning: outlives requirements can be inferred
[01:30:00] warning: outlives requirements can be inferred
[01:30:00]    --> src/tools/cargo/src/cargo/core/resolver/encode.rs:328:37
[01:30:00]     |
[01:30:00] 328 | pub struct WorkspaceResolve<'a, 'cfg: 'a> {
[01:30:00] 
[01:30:00] warning: outlives requirements can be inferred
[01:30:00]    --> src/tools/cargo/src/cargo/core/workspace.rs:128:28
[01:30:00]     |
[01:30:00]     |
[01:30:00] 128 | pub struct Members<'a, 'cfg: 'a> {
[01:30:00] 
[01:33:39] [RUSTC-TIMING] cargo test:false 235.634
[01:34:07] [RUSTC-TIMING] cargo test:false 28.168
[01:34:07]     Finished release [optimized] target(s) in 10m 39s
---
[01:38:14]    Compiling cargo v0.38.0 (/checkout/src/tools/cargo)
[01:38:31] error: outlives requirements can be inferred
[01:38:31]   --> src/tools/cargo/src/cargo/core/compiler/build_context/mod.rs:19:33
[01:38:31]    |
[01:38:31] 19 | pub struct BuildContext<'a, 'cfg: 'a> {
[01:38:31]    |
[01:38:31] note: lint level defined here
[01:38:31]   --> src/tools/cargo/src/cargo/lib.rs:1:24
[01:38:31]    |
[01:38:31]    |
[01:38:31] 1  | #![cfg_attr(test, deny(warnings))]
[01:38:31]    |                        ^^^^^^^^
[01:38:31]    = note: #[deny(explicit_outlives_requirements)] implied by #[deny(warnings)]
[01:38:31] 
[01:38:31] error: outlives requirements can be inferred
[01:38:31]   --> src/tools/cargo/src/cargo/core/compiler/context/mod.rs:30:28
[01:38:31]    |
[01:38:31] 30 | pub struct Context<'a, 'cfg: 'a> {
[01:38:31] 
[01:38:31] error: outlives requirements can be inferred
[01:38:31]   --> src/tools/cargo/src/cargo/core/compiler/context/unit_dependencies.rs:28:16
[01:38:31]    |
[01:38:31]    |
[01:38:31] 28 | struct State<'a: 'tmp, 'cfg: 'a, 'tmp> {
[01:38:31] help: remove these bounds
[01:38:31]    |
[01:38:31]    |
[01:38:31] 28 | struct State<'a, 'cfg, 'tmp> {
[01:38:31] 
[01:38:31] error: outlives requirements can be inferred
[01:38:31]   --> src/tools/cargo/src/cargo/core/compiler/context/compilation_files.rs:53:37
[01:38:31]    |
[01:38:31]    |
[01:38:31] 53 | pub struct CompilationFiles<'a, 'cfg: 'a> {
[01:38:31] 
[01:38:31] error: outlives requirements can be inferred
[01:38:31]    --> src/tools/cargo/src/cargo/core/package.rs:293:30
[01:38:31]     |
[01:38:31]     |
[01:38:31] 293 | pub struct Downloads<'a, 'cfg: 'a> {
[01:38:31] 
[01:38:31] error: outlives requirements can be inferred
[01:38:31] error: outlives requirements can be inferred
[01:38:31]    --> src/tools/cargo/src/cargo/core/resolver/encode.rs:328:37
[01:38:31]     |
[01:38:31] 328 | pub struct WorkspaceResolve<'a, 'cfg: 'a> {
[01:38:31] 
[01:38:31] error: outlives requirements can be inferred
[01:38:31]    --> src/tools/cargo/src/cargo/core/workspace.rs:128:28
[01:38:31]     |
[01:38:31]     |
[01:38:31] 128 | pub struct Members<'a, 'cfg: 'a> {
[01:38:31] 
[01:38:31] error: aborting due to 7 previous errors
[01:38:31] 
[01:38:32] [RUSTC-TIMING] cargo test:true 17.842
---
[01:39:48] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "test" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--locked" "--color" "always" "--manifest-path" "/checkout/src/tools/cargo/Cargo.toml" "--features" "rustc-workspace-hack/all-static"
[01:39:48] expected success, got: exit code: 101
[01:39:48] 
[01:39:48] 
[01:39:48] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/test/run-pass/pretty src/test/run-fail/pretty src/test/run-pass-valgrind/pretty src/test/run-pass-fulldeps/pretty src/tools/cargo src/tools/cargotest
[01:39:48] Build completed unsuccessfully in 1:36:19
[01:39:48] make: *** [check-aux] Error 1
[01:39:48] Makefile:50: recipe for target 'check-aux' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:1284ab68
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Sat Jun  1 11:09:05 UTC 2019
---
travis_time:end:2ea3428e:start=1559387346501309046,finish=1559387346515869624,duration=14560578
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0b855920
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:145f8b0f
travis_time:start:145f8b0f
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:00fe0b8c
$ dmesg | grep -i kill

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)

@bors bors added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 1, 2019
@varkor varkor added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 1, 2019
@bors

This comment has been minimized.

bors added a commit to rust-lang/cargo that referenced this pull request Jun 3, 2019
…s, r=alexcrichton

Remove unnecessary outlives bounds

cc rust-lang/rust#61172
Also give them a span in the HIR
* Don't use Strings to compare parameters
* Extend the lint to lifetime bounds
* Extend the lint to enums and unions
* Use the correct span for where clauses in tuple structs
* Try to early-out where possible
@matthewjasper
Copy link
Contributor Author

@bors r=varkor

@bors
Copy link
Contributor

bors commented Jun 19, 2019

📌 Commit fdeb581 has been approved by varkor

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 19, 2019
@bors
Copy link
Contributor

bors commented Jun 19, 2019

⌛ Testing commit fdeb581 with merge f30160a6afbbf2e575aeb27f8a6ebecb6534f844...

@Centril
Copy link
Contributor

Centril commented Jun 19, 2019

@bors retry yielding to r0llup

@rust-lang rust-lang deleted a comment from rust-highfive Jun 19, 2019
@Centril
Copy link
Contributor

Centril commented Jun 19, 2019

@bors p=2 rollup=never

@bors
Copy link
Contributor

bors commented Jun 19, 2019

⌛ Testing commit fdeb581 with merge e79b2a1...

bors added a commit that referenced this pull request Jun 19, 2019
…arkor

Improve the explicit_outlives_requirements lint

* Don't use Strings to compare parameters
* Extend the lint to lifetime bounds
* Extend the lint to enums and unions
* Use the correct span for where clauses in tuple structs
* Try to early-out where possible
* Remove unnecessary bounds in rustc crates
@bors
Copy link
Contributor

bors commented Jun 19, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: varkor
Pushing e79b2a1 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 19, 2019
@bors bors merged commit fdeb581 into rust-lang:master Jun 19, 2019
@matthewjasper matthewjasper deleted the cleanup-implied-bounds-lint branch June 19, 2019 15:34
tesuji added a commit to tesuji/rust-clippy that referenced this pull request Jun 19, 2019
tesuji added a commit to tesuji/rust-clippy that referenced this pull request Jun 19, 2019
bors added a commit to rust-lang/rust-clippy that referenced this pull request Jun 19, 2019
Fix warnings about unnecessary lifetime bounds

Rustup rust-lang/rust#61172

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants