-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 6 pull requests #65851
Rollup of 6 pull requests #65851
Conversation
When detecting a possible `=` -> `:` typo in a `let` binding, suggest assigning instead of setting the type.
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.
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.
…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).
Use heuristics to suggest assignment When detecting a possible `=` -> `:` typo in a `let` binding, suggest assigning instead of setting the type. Partially address rust-lang#57828.
…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.
@bors r+ p=6 rollup=never |
📌 Commit c9d17b1 has been approved by |
The job Click to expand the log.
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 |
Successful merges:
Span
s toinferred_outlives_of
predicates. #65541 (rustc: addSpan
s toinferred_outlives_of
predicates.)impl Trait
types #65777 (Don't ICE for completely unexpandableimpl Trait
types)Failed merges:
r? @ghost