Stream: t-compiler/wg-prioritization/alerts

Topic: I-prioritize #78747 unused_parens false positive on braced …


triagebot (Nov 04 2020 at 21:12, on Zulip):

@WG-prioritization/alerts issue #78747 has been requested for prioritization.

Procedure

Joshua Nelson (Nov 04 2020 at 21:13, on Zulip):

P-medium I think - if we didn't count P-low as effectively 'wontfix' I'd say p-low

Camelid (Nov 04 2020 at 21:15, on Zulip):

That's weird: why are parens required here?

Camelid (Nov 04 2020 at 21:15, on Zulip):

The code is:

macro_rules! x {
    {} => { "q" };
}

fn f() -> String {
    (x! {}.to_string())
}

fn main() {}
Camelid (Nov 04 2020 at 21:16, on Zulip):

I would understand if having parens around x! {} was required, but how does surrounding the entire expression help?

Camelid (Nov 04 2020 at 21:16, on Zulip):

Seems like weird parser behavior

apiraino (Nov 05 2020 at 10:03, on Zulip):

I'm ok with a P-low if the implications are not impacting (I cant tell at a glance). @Joshua Nelson also curious about the wontfix suggestion: is it because of the strange syntax that triggers the warning, right?

lcnr (Nov 05 2020 at 10:10, on Zulip):

parens are required because by using them we are in an expression context or however it's called

lcnr (Nov 05 2020 at 10:10, on Zulip):

without parens we parse x! {} as a statement

lcnr (Nov 05 2020 at 10:11, on Zulip):

allowing for

fn test() -> usize {
    x! {}
    4
}
lcnr (Nov 05 2020 at 10:12, on Zulip):

I think P-medium is good here as we shouldn't emit incorrect lints

lcnr (Nov 05 2020 at 10:14, on Zulip):

lcnr said:

parens are required because by using them we are in an expression context or however it's called

This is the reason that

if cond { value } else { other_value } + 3

fails to compile
but the following works

let x = if cond { value } else { other_value } + 3
apiraino (Nov 05 2020 at 10:22, on Zulip):

wow thanks @lcnr interesting :thumbs_up:

apiraino (Nov 05 2020 at 10:22, on Zulip):

P-medium then

triagebot (Nov 05 2020 at 10:23, on Zulip):

Issue #78747's prioritization request has been removed.

Joshua Nelson (Nov 05 2020 at 16:43, on Zulip):

apiraino said:

I'm ok with a P-low if the implications are not impacting (I cant tell at a glance). Joshua Nelson also curious about the wontfix suggestion: is it because of the strange syntax that triggers the warning, right?

no, I'm saying I'd like to put it between p-medium and 'wontfix'

Joshua Nelson (Nov 05 2020 at 16:43, on Zulip):

and in the past people have said that p-low is effectively the same as 'wontfix'

Camelid (Nov 05 2020 at 19:53, on Zulip):

Thanks lcnr by the way for the explanation!

Last update: Apr 11 2021 at 19:15UTC