-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesCategory: Enhancement of lints, like adding more cases or adding help messagesE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.Call for participation: Medium difficulty level problem and requires some initial experience.T-middleType: Probably requires verifiying typesType: Probably requires verifiying types
Description
I'm not sure that this is an issue, but it can be a little confusing.
I have the following situation: there is a function that works with panic::catch_unwind error (Box<Any + Send + 'static>):
fn foo(e: &Box<Any + Send>) {
if let Some(s) = e.as_ref().downcast_ref::<&str>() { ... }
...
}Clippy suggests the following:
warning: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> src/main.rs:4:11
|
4 | fn foo(e: &Box<Any + Send>) {
| ^^^^^^^^^^^^^^^^ help: try `&Any + Send`Functions becomes more generic, that for sure, but Any is a specific type: foo call site must be updated otherwise instead of Any that contains a panic error it will take Any that contains Box<Any + Send>.
Probably borrowed_box lint should be disabled for Any type?
Metadata
Metadata
Assignees
Labels
C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesCategory: Enhancement of lints, like adding more cases or adding help messagesE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.Call for participation: Medium difficulty level problem and requires some initial experience.T-middleType: Probably requires verifiying typesType: Probably requires verifiying types