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

Rollup of 7 pull requests #65854

Closed
wants to merge 29 commits into from
Closed

Conversation

Centril
Copy link
Contributor

@Centril Centril commented Oct 26, 2019

Successful merges:

Failed merges:

r? @ghost

estebank and others added 29 commits October 22, 2019 12:42
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
This test was actually about the unreachable_code flag, not dead_code,
so I renamed it for clarity (to prepare for the next commit, where I
plan to move a bunch of the dead_code tests to a single folder)
This helps organize the tests better.  I also renamed several of the tests to remove redundant dead-code in the path, and better match what they're testing
This is leftover from a restructuring of lint registration for drivers;
it should now happen via the register_lints field on Config rather than
this function.
This allows us to directly pass in a lint buffer
According to @estebank, def_span scans forward on the line until it finds a {,
and if it can't find one, fallse back to the span for the whole item.  This
was apparently written before the identifier span was explicitly tracked on
each node.

This means that if an unused function signature spans multiple lines, the
entire function (potentially hundreds of lines) gets flagged as dead code.
This could, for example, cause IDEs to add error squiggly's to the whole
function.

By using the span from the ident instead, we narrow the scope of this in
most cases.  In a wider sense, it's probably safe to use ident.span
instead of def_span in most locations throughout the whole code base,
but since this is my first contribution, I kept it small.

Some interesting points that came up while I was working on this:
 - I reorganized the tests a bit to bring some of the dead code ones all
   into the same location
 - A few tests were for things unrelated to dead code (like the
   path-lookahead for parens), so I added #![allow(dead_code)] and
   cleaned up the stderr file to reduce noise in the future
 - The same fix doesn't apply to const and static declarations.  I tried
   adding these cases to the match expression, but that created a much
   wider change to tests and error messages, so I left it off until I
   could get some code review to validate the approach.
…omatsakis

Point at associated type for some obligations

Partially address rust-lang#57663.
…nikomatsakis

rustc: add `Span`s to `inferred_outlives_of` predicates.

This would simplify rust-lang#59789, and I suspect it has some potential in diagnostics (although we don't seem to use the predicate `Span`s much atm).
…low-fundamental-local, r=nikomatsakis

Coherence should allow fundamental types to impl traits when they are local

After rust-lang#64414, `impl<T> Remote for Box<T> { }` is disallowed, but it is also disallowed in liballoc, where `Box` is a local type!

Enabling `#![feature(re_rebalance_coherence)]` in `liballoc` results in:
```
error[E0210]: type parameter `F` must be used as the type parameter for some local type (e.g., `MyStruct<F>`)
    --> src\liballoc\boxed.rs:1098:1
     |
1098 | impl<F: ?Sized + Future + Unpin> Future for Box<F> {
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `F` must be used as the type parameter for some local type
```

This PR relaxes `uncover_fundamental_ty` to skip local fundamental types.
I didn't add a test since `liballoc` already fails to compile, but I can add one if needed.

r? @nikomatsakis

cc rust-lang#63599
…nsion, r=davidtwco

Don't ICE for completely unexpandable `impl Trait` types

Save the resolution of these types (to themselves) to the typeck tables so that they will eventually reach E0720.

closes rust-lang#65561
Use ident.span instead of def_span in dead-code pass

Hello! First time contributor! :)

This should fix rust-lang#58729.

According to @estebank in the duplicate rust-lang#63064, def_span scans forward on the line until it finds a {,
and if it can't find one, falls back to the span for the whole item. This
was apparently written before the identifier span was explicitly tracked on
each node.

This means that if an unused function signature spans multiple lines, the
entire function (potentially hundreds of lines) gets flagged as dead code.
This could, for example, cause IDEs to add error squiggly's to the whole
function.

By using the span from the ident instead, we narrow the scope of this in
most cases. In a wider sense, it's probably safe to use ident.span
instead of def_span in most locations throughout the whole code base,
but since this is my first contribution, I kept it small.

Some interesting points that came up while I was working on this:
- I reorganized the tests a bit to bring some of the dead code ones all
into the same location
- A few tests were for things unrelated to dead code (like the
path-lookahead for parens), so I added #![allow(dead_code)] and
cleaned up the stderr file to reduce noise in the future
- The same fix doesn't apply to const and static declarations. I tried
adding these cases to the match expression, but that created a much
wider change to tests and error messages, so I left it off until I
could get some code review to validate the approach.
…omatsakis

Remove lint callback from driver

This is leftover from a restructuring of lint registration for drivers; it should now happen via the register_lints field on Config rather than this function.

This is not used by anyone to my knowledge (including the compiler itself); it was introduced in an abandoned refactor in rust-lang#65193.
…, r=nikomatsakis

Remove LintBuffer from Session

This moves the `LintBuffer` from `Session` into the `Resolver`, where it is used until lowering is done and then consumed by early lint passes. This also happily removes the failure mode of buffering lints too late where it would have previously lead to ICEs; it is statically no longer possible to do so.

I suspect that with a bit more work a similar move could be done for the lint buffer inside `ParseSess`, but this PR doesn't touch it (in part to keep itself small).

The last commit is the "interesting" commit -- the ones before it don't work (though they compile) as they sort of prepare the various crates for the lint buffer to be passed in rather than accessed through Session.
@Centril
Copy link
Contributor Author

Centril commented Oct 26, 2019

@bors r+ p=7 rollup=never

@bors
Copy link
Contributor

bors commented Oct 26, 2019

📌 Commit ee82c8c has been approved by Centril

@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 Oct 26, 2019
@Centril Centril added the rollup A PR which is a rollup label Oct 26, 2019
@bors
Copy link
Contributor

bors commented Oct 26, 2019

⌛ Testing commit ee82c8c with merge d9185c63e8ec818a9d8941abe087af5cda69ccd6...

@rust-highfive
Copy link
Collaborator

The job dist-i686-freebsd 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.
2019-10-26T23:35:28.9191158Z [RUSTC-TIMING] crossbeam_epoch test:false 1.367
2019-10-26T23:35:28.9221333Z    Compiling rand v0.7.0
2019-10-26T23:35:30.7689104Z [RUSTC-TIMING] parking_lot test:false 2.176
2019-10-26T23:35:30.7698955Z    Compiling rustc_macros v0.1.0 (/checkout/src/librustc_macros)
2019-10-26T23:35:31.2496151Z warning: function is never used: `query`
2019-10-26T23:35:31.2496913Z   --> src/librustc_macros/src/query.rs:16:26
2019-10-26T23:35:31.2497224Z    |
2019-10-26T23:35:31.2497983Z 16 |     syn::custom_keyword!(query);
2019-10-26T23:35:31.2498885Z    |
2019-10-26T23:35:31.2499191Z    = note: `#[warn(dead_code)]` on by default
2019-10-26T23:35:31.2499256Z 
2019-10-26T23:35:31.2499256Z 
2019-10-26T23:35:31.2516581Z warning: function is never used: `Keywords`
2019-10-26T23:35:31.2518208Z   --> src/librustc_macros/src/symbols.rs:13:26
2019-10-26T23:35:31.2518527Z    |
2019-10-26T23:35:31.2519125Z 13 |     syn::custom_keyword!(Keywords);
2019-10-26T23:35:31.2520062Z 
2019-10-26T23:35:31.2544026Z warning: function is never used: `Symbols`
2019-10-26T23:35:31.2544382Z   --> src/librustc_macros/src/symbols.rs:14:26
2019-10-26T23:35:31.2544633Z    |
2019-10-26T23:35:31.2544633Z    |
2019-10-26T23:35:31.2544908Z 14 |     syn::custom_keyword!(Symbols);
2019-10-26T23:35:31.2545266Z 
2019-10-26T23:35:33.1728586Z [RUSTC-TIMING] rand test:false 4.245
2019-10-26T23:35:33.1728586Z [RUSTC-TIMING] rand test:false 4.245
2019-10-26T23:35:33.6589240Z error: function is never used: `query`
2019-10-26T23:35:33.6589819Z   --> src/librustc_macros/src/query.rs:16:26
2019-10-26T23:35:33.6590187Z    |
2019-10-26T23:35:33.6590545Z 16 |     syn::custom_keyword!(query);
2019-10-26T23:35:33.6591252Z    |
2019-10-26T23:35:33.6591601Z    = note: `-D dead-code` implied by `-D warnings`
2019-10-26T23:35:33.6591681Z 
2019-10-26T23:35:33.6591681Z 
2019-10-26T23:35:33.6609334Z error: function is never used: `Keywords`
2019-10-26T23:35:33.6609802Z   --> src/librustc_macros/src/symbols.rs:13:26
2019-10-26T23:35:33.6610138Z    |
2019-10-26T23:35:33.6610551Z 13 |     syn::custom_keyword!(Keywords);
2019-10-26T23:35:33.6611071Z 
2019-10-26T23:35:33.6628448Z error: function is never used: `Symbols`
2019-10-26T23:35:33.6628942Z   --> src/librustc_macros/src/symbols.rs:14:26
2019-10-26T23:35:33.6629293Z    |
2019-10-26T23:35:33.6629293Z    |
2019-10-26T23:35:33.6629676Z 14 |     syn::custom_keyword!(Symbols);
2019-10-26T23:35:33.6630173Z 
2019-10-26T23:35:33.6726032Z error: aborting due to 3 previous errors
2019-10-26T23:35:33.6726172Z 
2019-10-26T23:35:33.6862861Z [RUSTC-TIMING] rustc_macros test:false 0.506
---
2019-10-26T23:35:40.5378272Z   local time: Sat Oct 26 23:35:40 UTC 2019
2019-10-26T23:35:41.0605701Z   network time: Sat, 26 Oct 2019 23:35:41 GMT
2019-10-26T23:35:41.0606700Z == end clock drift check ==
2019-10-26T23:35:42.3703076Z 
2019-10-26T23:35:42.3825789Z ##[error]Bash exited with code '1'.
2019-10-26T23:35:42.3862631Z ##[section]Starting: Upload CPU usage statistics
2019-10-26T23:35:42.3866617Z ==============================================================================
2019-10-26T23:35:42.3866735Z Task         : Bash
2019-10-26T23:35:42.3866848Z Description  : Run a Bash script on macOS, Linux, or Windows

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
Copy link
Contributor

bors commented Oct 26, 2019

💔 Test failed - checks-azure

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 26, 2019
@Centril Centril closed this Oct 27, 2019
@Centril Centril deleted the rollup-4peu0hs branch October 27, 2019 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rollup A PR which is a rollup S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants