Skip to content
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

Use macro callsite when creating Sugg helper #9410

Merged
merged 1 commit into from
Sep 11, 2022
Merged

Conversation

dswij
Copy link
Member

@dswij dswij commented Sep 1, 2022

Closes #9375

changelog: Improvement: [collapsible_if]: Suggestions now work with macros, by taking the call site into account.

@rust-highfive
Copy link

r? @xFrednet

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Sep 1, 2022
@xFrednet
Copy link
Member

xFrednet commented Sep 3, 2022

@rustbot author (Since this is still a draft PR :))

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Sep 3, 2022
let get_whole_snippet = || {
if expr.span.from_expansion() {
snippet_with_macro_callsite(cx, expr.span, default)
let snippet_without_expansion = |cx, span: Span, default| {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we want this in clippy utils

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, I would keep it local to this function. Macros are not the simplest thing to deal with, and I prefer contributors to ignore them rather than trying to add suggestions for them. But that is mostly my personal preference, you can extract it if you want 🙃

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair. I'll leave it as it is then

@dswij dswij changed the title Use macro source when creating Sugg helper Use macro callsite when creating Sugg helper Sep 4, 2022
@dswij dswij marked this pull request as ready for review September 4, 2022 12:01
@dswij dswij 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 from the author. (Use `@rustbot ready` to update this status) labels Sep 4, 2022
Copy link
Member

@xFrednet xFrednet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thank you for the bug fix.

I left an answer to your question. You can resolve it or extract the function, either is fine. And then you can r=me 🙃

let get_whole_snippet = || {
if expr.span.from_expansion() {
snippet_with_macro_callsite(cx, expr.span, default)
let snippet_without_expansion = |cx, span: Span, default| {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, I would keep it local to this function. Macros are not the simplest thing to deal with, and I prefer contributors to ignore them rather than trying to add suggestions for them. But that is mostly my personal preference, you can extract it if you want 🙃

@dswij
Copy link
Member Author

dswij commented Sep 11, 2022

Thanks for the review! @bors r=@xFrednet

@bors
Copy link
Collaborator

bors commented Sep 11, 2022

📌 Commit f0d642e has been approved by xFrednet

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Sep 11, 2022

⌛ Testing commit f0d642e with merge 69f6009...

@bors
Copy link
Collaborator

bors commented Sep 11, 2022

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: xFrednet
Pushing 69f6009 to master...

@bors bors merged commit 69f6009 into rust-lang:master Sep 11, 2022
@dswij dswij deleted the issue-9375 branch September 12, 2022 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

collapsible_if fix suggestion breaks in the presence of match!
5 participants