-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add global_variables
lint
#14657
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
base: master
Are you sure you want to change the base?
Add global_variables
lint
#14657
Conversation
e1e98ac
to
2c457fd
Compare
This looks like it's the same lint as |
3ce5790
to
75b29dd
Compare
@Jarcho: I have moved the implementation together with Also, I am not able to exclude statics with interior mutability but with “frozen” initializers. For example: A static using
|
This comment has been minimized.
This comment has been minimized.
@EFanZh Sorry for the delay. The lint pass has been completely rewritten so you will need to rebase. You still won't be able to use the MIR value, but you can now use |
75b29dd
to
318f6fa
Compare
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
Lintcheck changes for 7638b39
This comment will be updated if you push new changes |
318f6fa
to
7638b39
Compare
}, | ||
} | ||
&& !item.span.in_external_macro(cx.sess().source_map()) | ||
let ty = || cx.tcx.type_of(item.owner_id).instantiate_identity(); |
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 shouldn't be too expensive, feel free to evaluate it eagerly
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 type can only be queried when the item is of certain types, like const
or static
, evaluating it unconditionally will cause crashes.
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.
Oh, that's subtle! That would be nice to have as a comment:)
changelog: [
global_variables
]: check static variables with interior mutability.