-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
A-documentationArea: Adding or improving documentationArea: Adding or improving documentationC-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesCategory: Enhancement of lints, like adding more cases or adding help messagesL-suggestionLint: Improving, adding or fixing lint suggestionsLint: Improving, adding or fixing lint suggestions
Description
Clippy will suggest replacing:
Err::<(), _>("foo").expect(&format!("bar"))
with
Err:<(), _>("foo").unwrap_or_else(|_| panic!("bar"))
However, these are not equivalent. The first outputs foo: "bar"
, while the second will only output bar
. Clippy could recommend doing the same formatting as expect, now we're literally recommending replacing expect
with the exact body of that function. While it does of course avoid a single string allocation, it seems like a very aggressive lint to have on by default to avoid a case that is insignificant performance-wise for the vast majority of programs. format!
should be white listed here IMO
Venryx, cyril-marpaud, aquacash5, CJKay and nilsb99
Metadata
Metadata
Assignees
Labels
A-documentationArea: Adding or improving documentationArea: Adding or improving documentationC-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesCategory: Enhancement of lints, like adding more cases or adding help messagesL-suggestionLint: Improving, adding or fixing lint suggestionsLint: Improving, adding or fixing lint suggestions