-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Remove false label when self
resolve failure does not relate to macro
#143177
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
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
self
when it occur in let bindingsself
resolve failure does not relate to macro
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
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.
@rustbot ready
let is_assoc_fn = self.self_type_is_available(); | ||
let self_from_macro = "a `self` parameter, but a macro invocation can only \ | ||
access identifiers it receives from parameters"; | ||
if let Some((fn_kind, span)) = &self.diag_metadata.current_function { | ||
if let Some((fn_kind, fn_span)) = &self.diag_metadata.current_function { |
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 keep the fn_span
change because span
shadow make it confused.
|
||
// using `let self` is wrong even if we're not in an associated method or if we're in a macro expansion. | ||
// So, we should return early if we're in a pattern, see issue #143134. | ||
if matches!(source, PathSource::Pat) { | ||
return true; | ||
} | ||
|
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 return early when the source is Pat
.
LL | fn main () { | ||
| ---- this function can't have a `self` parameter |
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 indeed bring some benefits. :)
Fixes #143134
In the first commit, I did some code-clean, moving
suggest*
tosuggestions/
dir.In the second, commit, I added ui test.
In the third, I change the code, and present the test result.
r? compiler