-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Compute is_late_bound_map
query separately from lifetime resolution
#97415
Conversation
Some changes occurred in src/tools/clippy. cc @rust-lang/clippy |
r? @estebank (rust-highfive has picked a reviewer for you, use r? to override) |
This is a good candidate to split out independently, if you can. I'd r+ quickly. |
'x: loop { $e } | ||
//~^ WARNING shadows a label name that is already in scope | ||
//~| WARNING shadows a label name that is already in scope | ||
//~| WARNING shadows a label name that is already in scope | ||
//~| WARNING shadows a label name that is already in scope |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, this isn't a regression? The new behavior is what this should have always been, right?
If so, let's change these files to be // check-build
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is explicitly proposed to lang team in #96296.
warning: label name `'a` shadows a label name that is already in scope | ||
--> $DIR/label_break_value_invalid.rs:22:13 | ||
| | ||
LL | let x: u8 = 'a: { | ||
| -- first declared here | ||
... | ||
LL | 'a: { | ||
| ^^ label `'a` already in scope | ||
... | ||
LL | let x: u8 = mac3!('b: { | ||
| _________________- | ||
LL | | if true { | ||
LL | | break 'a 3; | ||
LL | | } | ||
LL | | 0 | ||
LL | | }); | ||
| |______- in this macro invocation | ||
| | ||
= note: this warning originates in the macro `mac3` (in Nightly builds, run with -Z macro-backtrace for more info) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These on the other hand, are a regression, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise.
error[E0392]: parameter `'a` is never used | ||
--> $DIR/regions-name-duplicated.rs:1:12 | ||
| | ||
LL | struct Foo<'a, 'a> { | ||
| ^^ unused parameter | ||
| | ||
= help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd take this to be a regression... Could we expand E0392 to check for the duplicated case so that we don't emit this redundant error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change needs to be in a totally different place. I'll do that in a follow-up PR.
OwnerNode::ForeignItem(ForeignItem { | ||
kind: ForeignItemKind::Fn(_, _, generics), | ||
.. | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this potentially break existing (invalid) code? Likely worth it to land anyways, but might need a crater run to gauge the fallout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an inconsistency here between hir().get_generics
and the custom implementation in generics_of
. I am tempted to correct it by adding more cases to get_generics
and use it in generics_of
. I don't see how it could break code, but I'll need to review the calls before giving an definite answer.
@@ -128,8 +128,8 @@ fn label_break_macro() { | |||
0 | |||
}; | |||
assert_eq!(x, 0); | |||
let x: u8 = 'a: { //~ WARNING `'a` shadows a label | |||
'b: { //~ WARNING `'b` shadows a label |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Marc file as check-pass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is already run-pass
because it checks that the correct labels are selected in case of hygienic shadowing.
@@ -20,14 +20,11 @@ fn lbv_macro_test_hygiene_respected() { | |||
macro_rules! mac3 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mark file as check-pass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file still errs on undeclared labels at lines 7 and 29.
let name = self.tcx.item_name(def_id.to_def_id()); | ||
let span = self.tcx.def_ident_span(def_id.to_def_id())?; | ||
Some((name, span)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this be the same as getting the ident and passing that through?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point of this commit was to stop storing the ident of parameters in the ribs. As we only need them in the case of diagnostics, we fetch them at the last moment.
Anyway, this code will go away with #97313.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me with confirmation that all the tests that should be check-pass, are
8470fca
to
0385024
Compare
r=me after making CI happy |
☔ The latest upstream changes (presumably #97644) made this pull request unmergeable. Please resolve the merge conflicts. |
The computation is actually much simpler, and can be done by directly fetching the HIR for the `FnDecl` and its generics.
0385024
to
ba40fe9
Compare
@bors r=estebank |
📌 Commit ba40fe9 has been approved by |
…bank Compute `is_late_bound_map` query separately from lifetime resolution This query is actually very simple, and is only useful for functions and method. It can be computed directly by fetching the HIR, with no need to embed it within the lifetime resolution visitor. Based on rust-lang#96296
Rollup of 3 pull requests Successful merges: - rust-lang#97415 (Compute `is_late_bound_map` query separately from lifetime resolution) - rust-lang#97471 (Provide more context when denying invalid type params ) - rust-lang#97681 (Add more eslint checks) Failed merges: - rust-lang#97446 (Make hir().get_generics and generics_of consistent.) r? `@ghost` `@rustbot` modify labels: rollup
…bank Compute `is_late_bound_map` query separately from lifetime resolution This query is actually very simple, and is only useful for functions and method. It can be computed directly by fetching the HIR, with no need to embed it within the lifetime resolution visitor. Based on rust-lang#96296
Fail gracefully when encountering an HRTB in APIT. Fixes rust-lang#96954 ~The first commit will be merged as part of rust-lang#97415
Fail gracefully when encountering an HRTB in APIT. Fixes rust-lang#96954 ~The first commit will be merged as part of rust-lang#97415
This query is actually very simple, and is only useful for functions and method. It can be computed directly by fetching the HIR, with no need to embed it within the lifetime resolution visitor.
Based on #96296