-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add help diag. for const = Enum
missing braces around Enum
#106283
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
Conversation
r? @cjgillot (rustbot has picked a reviewer for you, use r? to override) |
const = Enum
missing braces around Enum
55043fe
to
bb1a2a4
Compare
format!("{{ {path_str} }}"), | ||
Applicability::MaybeIncorrect, | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this suggestion correct in general?
AFAIK, disambiguating using braces only works for equality associated constraints.
The suggestion needs to be restricted to this case, doesn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean as opposed to other const generics? Disambiguating with braces also works for functions in generic const positions.
By this case, do you mean specifically for when the constraint is a const?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean as opposed to all the other places where one can put a type.
Does this suggestion fire with this?
fn foo() -> Mode::Cool { /* ... */ }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does fire, I'll try to see where to change to make it not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed it to be only for associated equality, but it's not so specific to enums.
Previously it was not clear why this errored or if it was even supported, as there was no diagnostic that suggested wrapping it in braces. Thus, add a simple diagnostic that suggests wrapping enum variants in braces.
@bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (d72b7d2): comparison URL. Overall result: ❌ regressions - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. |
Previously it was not clear why this errored or if it was even supported, as there was no diagnostic that suggested wrapping it in braces.
Thus, add a simple diagnostic that suggests wrapping enum variants in braces.
Fixes #105927