-
Notifications
You must be signed in to change notification settings - Fork 14k
Closed
Labels
A-type-systemArea: Type systemArea: Type systemC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-langRelevant to the language teamRelevant to the language team
Description
The following code fails:
#[derive(Debug)]
struct Error {
cause: Option<Box<std::error::Error + Send + Sync>>,
}
impl Error {
fn cause(&self) -> Option<&::std::error::Error> {
self.cause.as_ref().map(|e| e.as_ref())
}
}
fn main() {}Error:
error[E0308]: mismatched types
--> sendsyncerror.rs:8:9
|
8 | self.cause.as_ref().map(|e| e.as_ref())
| ^^^^^^^^^^^^^^^^^^^^^^^ expected trait `std::error::Error`, found trait `std::error::Error + std::marker::Sync + std::marker::Send`
|
= note: expected type `std::option::Option<&std::error::Error>`
found type `std::option::Option<&std::error::Error + std::marker::Sync + std::marker::Send>`
error: aborting due to previous error
Surely automatic type coercion is possible here?
Metadata
Metadata
Assignees
Labels
A-type-systemArea: Type systemArea: Type systemC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-langRelevant to the language teamRelevant to the language team