Skip to content
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

Truncated errors could be confusing to students new to Rust #1181

Open
yawboakye opened this issue Dec 16, 2022 · 0 comments
Open

Truncated errors could be confusing to students new to Rust #1181

yawboakye opened this issue Dec 16, 2022 · 0 comments

Comments

@yawboakye
Copy link

Hello @phil-opp,

I hope you're doing well. First, I want to show my appreciation for the incredible work you're doing here. I loved the material so much that I've recommend it as a curriculum to follow for anyone who (1) wants to learn Rust, or (2) learn how the computer works, or (3) familiarize themselves with some of the greatest ideas of computer science. So, thank you very much.

I have recently started mentoring young African developers and no surprise that I've recommended that we work through your curriculum 😄. I noticed though, very early into A Freestanding Rust Binary that truncating some of the errors could cause the student to derive the wrong comprehension. Here's what happened, after reading The no_std Attribute section, they compiled and run their code, and saw the same error as predicted:

error: cannot find macro `println!` in this scope
 --> src/main.rs:4:5
  |
4 |     println!("Hello, world!");
  |     ^^^^^^^ 

Unfortunately, given that in the text they had only seen a section of the errors (specifically what's above), they ignored the remaining two. When they removed println!("Hello, world!") and still couldn't compile, they saw the two error related to the panic handler and eh_personality as net new, as in, these errors weren't there when we had println!. They thought that the new errors were caused by removing the println! statement. This isn't true, and it was relatively easy to prove to them: restore println! and review the full compilation error message.

I wanted to check with you if you'd be open to expanding the section a little bit to (1) include all the errors from cargo build since there isn't much anyways, and (2) re-organize the text a little bit so that the errors related to the panic handler and eh_personality language item are tied to no_std? The material remains great without these modifications so don't spend more time than necessary in reviewing this proposal 😄.

Take care!

PS full error message is given below:

error: cannot find macro `println` in this scope
 --> src/main.rs:4:5
  |
4 |     println!("Hello, world!");
  |     ^^^^^^^

error: `#[panic_handler]` function required, but not found

error: language item required, but not found: `eh_personality`
  |
  = note: this can occur when a binary crate with `#![no_std]` is compiled for a target where `eh_personality` is defined in the standard library
  = help: you may be able to compile for a target that doesn't need `eh_personality`, specify a target with `--target` or in `.cargo/config`

error: could not compile `blog_os` due to 3 previous errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant