-
Couldn't load subscription status.
- Fork 13.9k
Don't suggest rewriting call if resolution was invalid #143014
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
|
rustbot has assigned @petrochenkov. Use |
| // this if there's no `Res`, since if there was a resolution but it | ||
| // was invalid, it's more likely not a typo of this form. | ||
| if let Some((call_span, args_span)) = self.call_has_self_arg(source) | ||
| && res.is_none() |
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 doesn't affect any other tests, so I just went with a simple heuristic here.
We could alternatively check if the path segment starts with a capitalized identifier, or match !matches!(res, Some(DefKind::Struct | DefKind::Variant)), or something? I think that's kinda overkill tho.
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 right condition here is probably res.is_none() || res.has_self_param().
Resolver already has the logic for res.has_self_param() in fn lookup_assoc_candidate in the same file, so it can probably be shared.
let has_self = match def_id.as_local() {
Some(def_id) => self
.r
.delegation_fn_sigs
.get(&def_id)
.is_some_and(|sig| sig.has_self),
None => {
self.r.tcx.fn_arg_idents(def_id).first().is_some_and(|&ident| {
matches!(ident, Some(Ident { name: kw::SelfLower, .. }))
})
}
};
This comment has been minimized.
This comment has been minimized.
a5bb82f to
26377fd
Compare
|
☔ The latest upstream changes (presumably #148167) made this pull request unmergeable. Please resolve the merge conflicts. |
Fixes #143008.
The suggestion to
"try calling{ident}as a method"was eating the more relevant suggestion to mark the tuple struct's fields aspubso its ctor is visible.See inline comment.