-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add new disallowed_fields lint
#16218
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?
Conversation
48e76b6 to
73d1c63
Compare
| // Very round-about way to get the field `DefId` from the expr: first we get its | ||
| // parent `Ty`. Then we go through all its fields to find the one with the expected | ||
| // name and get the `DefId` from it. | ||
| if let Some(parent_ty) = cx.typeck_results().expr_ty_opt(e) |
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'm really not sure this is the best way to get the DefId from Expr::Field but couldn't find another way. I'd love to know if there is one!
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 needs to use the adjusted type.
| .filter_by_name_unhygienic(name) | ||
| .find(|assoc_item| ns.matches(Some(assoc_item.namespace()))) | ||
| .map(|assoc_item| assoc_item.def_id), | ||
| ItemKind::Struct(_, _, rustc_hir::VariantData::Struct { fields, .. }) => fields.iter().find_map(|field| { |
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.
Basically added support to look for fields in lookup_path (above in this file). it's used to check if the paths are valid in the config file.
So to link to a field (for example with struct X { y: u8 }: X::y.
73d1c63 to
eacd758
Compare
eacd758 to
d017b2c
Compare
|
Finally updated all things that needed to be updated. :') |
|
This doesn't prevent reading via destructuring. e.g. |
|
r? @Jarcho |
Fixes #9278.
This is something that we need for
cg_gcc(cc @antoyo). It's almost the same as #6674 (which I used as base).changelog: Add new
disallowed_fieldslintr? @samueltardieu