rust-clippy icon indicating copy to clipboard operation
rust-clippy copied to clipboard

fix [`dbg_macro`] FN when `dbg` is inside some complex macros

Open J-ZhengLi opened this issue 1 year ago • 4 comments

fixes: #12131

It appears that [root_macro_call_first_node] only detects println! in the following example:

println!("{:?}", dbg!(s));

changelog: fix [dbg_macro] FN when dbg is inside some complex macros

J-ZhengLi avatar Jan 15 '24 09:01 J-ZhengLi

r? @Jarcho

(rustbot has picked a reviewer for you, use r? to override)

rustbot avatar Jan 15 '24 09:01 rustbot

Why are we even skipping nested calls in the first place? dbg!(foo(dbg!(bar))) should still lint multiple times like we do with every other lint.

Jarcho avatar Feb 07 '24 17:02 Jarcho

Why are we even skipping nested calls in the first place? dbg!(foo(dbg!(bar))) should still lint multiple times like we do with every other lint.

Idk, I guess the initial purpose was to warn the existence of dbg! macro thus linting the first one should suffice?

I didn't put that 'span.contains' check at first, instead it was 'macro_span = prev_macro_span', then I saw a lot additional warnings popping up, especially on line 28 of the test file.

Should I change it back to lint every nested calls?

J-ZhengLi avatar Feb 07 '24 22:02 J-ZhengLi

Looks like it was quirk that was kept when switching from an early pass to a late pass. check_mac only sees top level macro invocations and not anything from their expansion.

You can change it to lint all nested calls. You'll need to either split the test file in two since uitest only runs rustfix once, so nested macros won't pass testing. actual cargo fix will run multiple times to handle this.

Jarcho avatar Feb 10 '24 22:02 Jarcho

All looks good. Thank you. @bors r+

Jarcho avatar Mar 06 '24 03:03 Jarcho

:pushpin: Commit aa06d416793ab2519ad2a7383ba865dee5a63b1d has been approved by Jarcho

It is now in the queue for this repository.

bors avatar Mar 06 '24 03:03 bors

:hourglass: Testing commit aa06d416793ab2519ad2a7383ba865dee5a63b1d with merge 6e6dfd2fbb5a747188ca9334d307bfd2d800ec3e...

bors avatar Mar 06 '24 03:03 bors

:broken_heart: Test failed - checks-action_test

bors avatar Mar 06 '24 03:03 bors

You'll need to rebase to fix the test. How error patterns need to be placed when macros are used changed.

Jarcho avatar Mar 06 '24 04:03 Jarcho

@bors r+

Jarcho avatar Mar 06 '24 17:03 Jarcho

:pushpin: Commit b10159886828b0c5156f313b308aa48c7d05a68e has been approved by Jarcho

It is now in the queue for this repository.

bors avatar Mar 06 '24 17:03 bors

:hourglass: Testing commit b10159886828b0c5156f313b308aa48c7d05a68e with merge 2d1dc10e2212eec8bd5b52319eec78ec90d0f439...

bors avatar Mar 06 '24 17:03 bors

:sunny: Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test Approved by: Jarcho Pushing 2d1dc10e2212eec8bd5b52319eec78ec90d0f439 to master...

bors avatar Mar 06 '24 17:03 bors

:eyes: Test was successful, but fast-forwarding failed: 422 1 review requesting changes by reviewers with write access.

bors avatar Mar 06 '24 17:03 bors

One more time. @bors r+

Jarcho avatar Mar 07 '24 02:03 Jarcho

:bulb: This pull request was already approved, no need to approve it again.

  • This pull request previously failed. You should add more commits to fix the bug, or use retry to trigger a build again.

bors avatar Mar 07 '24 02:03 bors

:pushpin: Commit b10159886828b0c5156f313b308aa48c7d05a68e has been approved by Jarcho

It is now in the queue for this repository.

bors avatar Mar 07 '24 02:03 bors

:hourglass: Testing commit b10159886828b0c5156f313b308aa48c7d05a68e with merge b85eb7c5e158caebc47169e040adf8cfa24cd776...

bors avatar Mar 07 '24 02:03 bors

:sunny: Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test Approved by: Jarcho Pushing b85eb7c5e158caebc47169e040adf8cfa24cd776 to master...

bors avatar Mar 07 '24 02:03 bors

:eyes: Test was successful, but fast-forwarding failed: 422 1 review requesting changes by reviewers with write access.

bors avatar Mar 07 '24 02:03 bors

@bors retry

Jarcho avatar Mar 07 '24 03:03 Jarcho

:hourglass: Testing commit b10159886828b0c5156f313b308aa48c7d05a68e with merge 9991cb7f4d1e57eb72ef031db0b518b026fa2c51...

bors avatar Mar 07 '24 03:03 bors

:sunny: Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test Approved by: Jarcho Pushing 9991cb7f4d1e57eb72ef031db0b518b026fa2c51 to master...

bors avatar Mar 07 '24 03:03 bors

:eyes: Test was successful, but fast-forwarding failed: 422 1 review requesting changes by reviewers with write access.

bors avatar Mar 07 '24 03:03 bors

Looks like rust-lang/homu#75

@bors retry

Jarcho avatar Mar 07 '24 04:03 Jarcho

:hourglass: Testing commit b10159886828b0c5156f313b308aa48c7d05a68e with merge 7a72cdb12385b43e20294a083fbf89aa69f75c00...

bors avatar Mar 07 '24 04:03 bors

:sunny: Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test Approved by: Jarcho Pushing 7a72cdb12385b43e20294a083fbf89aa69f75c00 to master...

bors avatar Mar 07 '24 04:03 bors

:eyes: Test was successful, but fast-forwarding failed: 422 1 review requesting changes by reviewers with write access.

bors avatar Mar 07 '24 04:03 bors

Lets see if this works today. @bors retry

Jarcho avatar Mar 12 '24 04:03 Jarcho

:hourglass: Testing commit b10159886828b0c5156f313b308aa48c7d05a68e with merge 05570ade8ac6e75dd17b890b76f84e146ed61730...

bors avatar Mar 12 '24 04:03 bors