-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingC-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesCategory: Enhancement of lints, like adding more cases or adding help messagesT-macrosType: Issues with macros and macro expansionType: Issues with macros and macro expansion
Description
I have this code:
r.view_args
.get(name)
.ok_or(format!("{} not given", name))
Clippy reports:
src/app/app_server.rs:259:5: 261:43 warning: use of `ok_or` followed by a function call, #[warn(or_fun_call)] on by default
src/app/app_server.rs:259 r.view_args
^
src/app/app_server.rs:259:5: 261:43 help: for further information visit https://github.com/Manishearth/rust-clippy/wiki#or_fun_call
src/app/app_server.rs:259:5: 261:43 help: try this
src/app/app_server.rs: r.view_args
src/app/app_server.rs: .get(name).ok_or_else(|| $ crate :: fmt :: format ( format_args ! ( $ ( $ arg ) * ) ))
Perhaps Clippy should ignore .ok_or(macro!())
constructs?
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingC-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesCategory: Enhancement of lints, like adding more cases or adding help messagesT-macrosType: Issues with macros and macro expansionType: Issues with macros and macro expansion
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
mcarton commentedon Jun 16, 2016
The suggestion is badly formatted but
ok_or_else
would still be a better choice here.llogiq commentedon Jun 16, 2016
Is this a problem with
snippet(..)
?mcarton commentedon Jun 16, 2016
Yes, it's been there since #944 with some macro spans.
lrbalt commentedon Jun 16, 2016
Do you mean that
is better here?
mcarton commentedon Jun 16, 2016
It avoids building the string when it is not necessary.
lrbalt commentedon Jun 16, 2016
ok, thanks
[-]or-fun-call false positive[/-][+]or-fun-call macro suggestion bug[/+]Add test for or_fun_call macro suggestion
Auto merge of #4023 - phansch:add_test, r=flip1995
Auto merge of #4023 - phansch:add_test, r=flip1995
Auto merge of #4023 - phansch:add_test, r=flip1995