Skip to content

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

Merged
merged 3 commits into from
Jul 9, 2025

Conversation

xizheyin
Copy link
Contributor

@xizheyin xizheyin commented Jun 29, 2025

Fixes #143134

In the first commit, I did some code-clean, moving suggest* to suggestions/ dir.
In the second, commit, I added ui test.
In the third, I change the code, and present the test result.

r? compiler

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 29, 2025
@lcnr lcnr added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 3, 2025
xizheyin added 2 commits July 3, 2025 23:11
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
@xizheyin xizheyin changed the title Suggest to rename self when it occur in let bindings Remove false label when self resolve failure does not relate to macro Jul 3, 2025
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
Copy link
Contributor Author

@xizheyin xizheyin left a 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 {
Copy link
Contributor Author

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.

Comment on lines +1186 to +1192

// 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;
}

Copy link
Contributor Author

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.

Comment on lines -43 to -44
LL | fn main () {
| ---- this function can't have a `self` parameter
Copy link
Contributor Author

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. :)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 3, 2025
@lcnr
Copy link
Contributor

lcnr commented Jul 8, 2025

thx

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Jul 8, 2025

📌 Commit 236b392 has been approved by lcnr

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 8, 2025
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 9, 2025
Remove false label when `self` resolve failure does not relate to macro

Fixes rust-lang#143134

In the first commit, I did some code-clean, moving `suggest*` to `suggestions/` dir.
In the second, commit, I added ui test.
In the third, I change the code, and present the test result.

r? compiler
bors added a commit that referenced this pull request Jul 9, 2025
Rollup of 11 pull requests

Successful merges:

 - #143177 (Remove false label when `self` resolve failure does not relate to macro)
 - #143339 (Respect endianness correctly in CheckEnums test suite)
 - #143426 (clippy fix: indentation)
 - #143499 (Don't call `predicates_of` on a dummy obligation cause's body id)
 - #143520 (Fix perf regression caused by tracing)
 - #143532 (More carefully consider span context when suggesting remove `&mut`)
 - #143606 (configure.py: Write last key in each section)
 - #143632 (fix: correct parameter names in LLVMRustBuildMinNum and LLVMRustBuildMaxNum FFI declarations)
 - #143644 (Add triagebot stdarch mention ping)
 - #143651 (Win: Use exceptions with empty data for SEH panic exception copies instead of a new panic)
 - #143660 (Disable docs for `compiler-builtins` and `sysroot`)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Jul 9, 2025
Rollup of 9 pull requests

Successful merges:

 - #142357 (Simplify LLVM bitcode linker in bootstrap and add tests for it)
 - #143177 (Remove false label when `self` resolve failure does not relate to macro)
 - #143339 (Respect endianness correctly in CheckEnums test suite)
 - #143426 (clippy fix: indentation)
 - #143475 (tests: Use `cfg_target_has_reliable_f16_f128` in `conv-bits-runtime-const`)
 - #143499 (Don't call `predicates_of` on a dummy obligation cause's body id)
 - #143520 (Fix perf regression caused by tracing)
 - #143532 (More carefully consider span context when suggesting remove `&mut`)
 - #143606 (configure.py: Write last key in each section)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit a71dbcd into rust-lang:master Jul 9, 2025
10 checks passed
@rustbot rustbot added this to the 1.90.0 milestone Jul 9, 2025
rust-timer added a commit that referenced this pull request Jul 9, 2025
Rollup merge of #143177 - xizheyin:143134, r=lcnr

Remove false label when `self` resolve failure does not relate to macro

Fixes #143134

In the first commit, I did some code-clean, moving `suggest*` to `suggestions/` dir.
In the second, commit, I added ui test.
In the third, I change the code, and present the test result.

r? compiler
github-actions bot pushed a commit to devnexen/miri that referenced this pull request Jul 10, 2025
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#142357 (Simplify LLVM bitcode linker in bootstrap and add tests for it)
 - rust-lang/rust#143177 (Remove false label when `self` resolve failure does not relate to macro)
 - rust-lang/rust#143339 (Respect endianness correctly in CheckEnums test suite)
 - rust-lang/rust#143426 (clippy fix: indentation)
 - rust-lang/rust#143475 (tests: Use `cfg_target_has_reliable_f16_f128` in `conv-bits-runtime-const`)
 - rust-lang/rust#143499 (Don't call `predicates_of` on a dummy obligation cause's body id)
 - rust-lang/rust#143520 (Fix perf regression caused by tracing)
 - rust-lang/rust#143532 (More carefully consider span context when suggesting remove `&mut`)
 - rust-lang/rust#143606 (configure.py: Write last key in each section)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

let self in method with receiver incorrectly complains about macro hygiene
4 participants