-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix and improve match_type_on_diagnostic_item
#7962
Fix and improve match_type_on_diagnostic_item
#7962
Conversation
r? @giraffate (rust-highfive has picked a reviewer for you, use r? to override) |
Hmm now there are two functions named |
I added them so the automated switch from The distinction between the two is also useless in clippy. They could be named |
☔ The latest upstream changes (presumably #7639) made this pull request unmergeable. Please resolve the merge conflicts. |
I don't think we have any cases where generality over the two (ctor or not) is actually needed. We are always expecting one or the other depending on context. And the ctor cases are much less common. So we can put in
That is maybe true, but we still have to deal with the distinction. If we "cover up" the ctor DefIds, making it look like it is the diagnostic item id when it is not, that will lead to surprises when you go to use the DefId with other queries. |
I was referring to the lint suggestion in this case. At the point |
Ah right. Maybe you could query whether the item has a public constructor to at least narrow down some cases. |
The lint has to look up the |
e7682a4
to
2c8c60e
Compare
First attempt at handling ctor suggestions differently.
|
☔ The latest upstream changes (presumably #8219) made this pull request unmergeable. Please resolve the merge conflicts. |
af141d2
to
d588291
Compare
☔ The latest upstream changes (presumably #8468) made this pull request unmergeable. Please resolve the merge conflicts. |
5e63922
to
296385d
Compare
☔ The latest upstream changes (presumably #8939) made this pull request unmergeable. Please resolve the merge conflicts. |
35380be
to
4dd60d1
Compare
The only extra function introduced now is |
☔ The latest upstream changes (presumably #8666) made this pull request unmergeable. Please resolve the merge conflicts. |
6213b20
to
48a8aa3
Compare
☔ The latest upstream changes (presumably #9279) made this pull request unmergeable. Please resolve the merge conflicts. |
c9f3354
to
6b003cc
Compare
☔ The latest upstream changes (presumably #8696) made this pull request unmergeable. Please resolve the merge conflicts. |
1d59045
to
9834da1
Compare
☔ The latest upstream changes (presumably #9573) made this pull request unmergeable. Please resolve the merge conflicts. |
9834da1
to
6b961f2
Compare
r? @llogiq It looks like @giraffate is either busy or forgot about this. |
Dogfood says no:
|
Oops. Looks like I didn't push when I fixed that. |
6b961f2
to
cc86097
Compare
* Check for `const`s and `static`s from external crates * Check for `LangItem`s * Handle inherent functions which have the same name as a field * Also check the following functions: * `match_trait_method` * `match_def_path` * `is_expr_path_def_path` * `is_qpath_def_path` * Handle checking for a constructor to a diagnostic item or `LangItem`
cc86097
to
162aa19
Compare
LGTM. Thank you, this approach seems a clear improvement. @bors r+ |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
This extracts the fix for the lint out of #7647. There's still a couple of other functions to check, but at least this will get lint working again.
The two added util functions (
is_diagnostic_item
andis_lang_item
) are needed to handleDefId
for unit and tuple struct/variant constructors. Therustc_diagnostic_item
andlang
attributes are attached to the struct/variantDefId
, but most of the time they are used through their constructors which have a differentDefId
. The two utility functions will check if theDefId
is for a constructor and switch to the associated struct/variantDefId
.There does seem to be a bug on rustc's side where constructor
DefId
s from external crates seem to be returningDefKind::Variant
instead ofDefKind::Ctor()
. There's a workaround put in right.changelog: None