-   Notifications  
You must be signed in to change notification settings  - Fork 13.9k
 
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Description
struct MyError; impl From<i32> for Result<(), MyError> { fn from(x: i32) -> Self { if x == 0 { Ok(()) } else { Err(MyError) } } } fn main() {}Errors:
 Compiling playground v0.0.1 (/playground) error[E0117]: only traits defined in the current crate can be implemented for arbitrary types --> src/main.rs:3:1 | 3 | impl From<i32> for Result<(), MyError> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | = note: the impl does not reference any types defined in this crate = note: define and implement a trait or new type instead error: aborting due to previous error For more information about this error, try `rustc --explain E0117`. error: Could not compile `playground`. To learn more, run the command again with --verbose. This is incorrect because the error message states:
the impl does not reference any types defined in this crate
but the impl does reference one type defined in this crate: MyError.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.