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

`filter_map_bool_then` should not show the macro definition in suggestions

Open profetia opened this issue 6 months ago • 3 comments

Summary

filter_map_bool_then wrongly showed the macro definition instead of its call site in suggestions

Reproducer

I tried this code:

    tokenize_with_text(&snippet)
        .filter_map(|(t, s, inner)| {
            matches!(t, TokenKind::Ident if s == keyword).then(|| {
                span.split_at(inner.start as u32)
                    .1
                    .split_at((inner.end - inner.start) as u32)
                    .0
            })
        })

I expected to see this happen:

.filter(|&(t, s, inner)| matches!(t, TokenKind::Ident if s == keyword))
.map(..)

Instead, this happened:

.filter(|&(t, s, inner)| match $expression {
    $pattern $(if $guard)? => true,
    _ => false
}).map(..)

Version


Additional Labels

@rustbot label + I-suggestion-causes-error

profetia avatar Jun 13 '25 14:06 profetia

Error: Parsing relabel command in comment failed: ...' label +' | error: empty label at >| ' I-suggest'...

Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #t-infra on Zulip.

rustbot avatar Jun 13 '25 14:06 rustbot

Looks like it can be fixed very quickly. I will take it myself then. @rustbot claim

profetia avatar Jun 13 '25 14:06 profetia

Error: Parsing relabel command in comment failed: ...' label +' | error: empty label at >| ' I-suggest'...

Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #t-infra on Zulip.

rustbot avatar Jun 13 '25 14:06 rustbot