[`unnecessary_lazy_eval`] Do not lint in external macros
fix https://github.com/rust-lang/rust-clippy/issues/9485, fix https://github.com/rust-lang/rust-clippy/issues/9439
I didn't find a way to add a test since fps occur due to an external crate.
changelog: [unnecessary_lazy_eval] Do not lint in external macros
r? @giraffate
(rust-highfive has picked a reviewer for you, use r? to override)
@kraktus FYI, I've recently added a test for Derive macro FP here. Maybe we can do something similar?
Thanks, I've identified the source of the false positive in rocket codebase: https://github.com/SergioBenitez/Rocket/blob/707936177a7fea6d8eca103cf0b3601ca45fe657/core/codegen/src/derive/from_form.rs#L287
Following your example I've tried to reproduce the issue with a dummy derive macro
#[proc_macro_derive(LazyEvalDerive)]
pub fn unnecessary_lazy_eval(_: TokenStream) -> TokenStream {
quote!(
pub fn unnecessary_then() {
Some(1).unwrap_or_else(|| 2); // should not lint because in external macro
}
)
}
but it's not linting it even before my patch, so unlikely my fix is working as intended
The fix for this needs is_from_proc_macro. You can use the with_span! macro in tests using aux-build:proc_macro_with_span.rs.
:umbrella: The latest upstream changes (presumably #9551) made this pull request unmergeable. Please resolve the merge conflicts.
@bors r+
:pushpin: Commit 6ec7759c3bff136c1d39bbe0bc8a68ac8b438a55 has been approved by dswij
It is now in the queue for this repository.
:hourglass: Testing commit 6ec7759c3bff136c1d39bbe0bc8a68ac8b438a55 with merge 68408c583e5d300e22d911b5c5a60413b5391874...
:sunny: Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test Approved by: dswij Pushing 68408c583e5d300e22d911b5c5a60413b5391874 to master...