Make "only traits defined in the current crate can be implemented for arbitrary types" less vague #96227
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=b04540728eae88b27ee5d19b5bc0b685
The current output is:
Ideally the output should look like:
Not sure... my main issue with this error is the message itself: "only traits defined in the current crate can be implemented for arbitrary types." The fact that it only mentioned "arbitrary types" leads me to believe that my only solution is to change something about the type, but I don't what that change Is supposed to be (In this case, it is using the "newtype" idiom.
The word
arbitrary
is vague to me - as a beginner, I don't fully know what that means. In fact, if I had to guess, I would consider both the original type, and the new type that wraps the old type, both "arbitrary," so I think the issue is around that word. I feel as if the message should not mention "arbitrary" and should rather indicate that you can only implement this trait on a type that's defined within this crate.I do understand that the help diagnostic is nudging the user towards a newtype pattern, but my main point is that the error is pretty ambiguous to me.
The text was updated successfully, but these errors were encountered: