-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cargo init
's boilerplate doesn't work with ?
#14007
Comments
I have mixed feelings above this. Personally I use plain But: I think we should improve the current diagnostics to output something like that:
|
I also rarely use |
My experience as a beginning Rust dev was that I often needed to cut-and-paste examples from documents, and I was often frustrated by them not working until I remembered to add a
I think it's really useful for new users if |
I didn't hit this as a beginner Rust programmer. I would manually handle my errors and then call So maybe many other people did hit this when they were beginners, but I myself don't have the perspective of hitting this as a beginner. |
Also, |
This should be moved to rust-lang/cargo, no? Anyway, Cargo has this semi-related issue about |
Triage: Yep, this should be moved to cargo. Can someone with sufficient privileges do that please? |
@estebank Independent of what we do for Thoughts? |
@epage yes, I agree we should do that. I am unsure if there's a ticket for it already. We should create one in the compiler's repo for improving this output. We already detect |
I went through about 3 pages of diagnostic issues with the error code in them and didn't see something related, so I created rust-lang/rust#125997 |
cargo init
currently produces boilerplate that looks like this:However, if someone starts from this boilerplate and pastes in examples from documentation that use
?
, they'll get an error. main doesn't return Result, so?
can't be used. The API guidelines recommend that examples use?
rather than unwrap.As an example, if someone tries to paste in this small File example:
They get some rather confusing errors (what's FromResidual?):
This is a problem I remember running into when I was first learning the language. I suspect it may be an issue for other language learners too.
I propose changing the boilerplate to:
This compiles cleanly and passes clippy.
The text was updated successfully, but these errors were encountered: