-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Ran exercises/option/option2.rs with errors #424
Comments
Hi @alexxroche, thanks for bringing this up. It is indeed a bug (more like an omission) at Basically, when the program is running interactively (i.e. using Adding Please feel free to submit a pull request. Feel free to reach out if you have any questions. Thanks, Abdou |
That is an improvement. (I tried a few variations of your patch.) Adding your suggestion (inserting an additional So I agree that you have found an improvement, (for my case; I don't know enough about this program to know if printing to both stdout and stderr would harm any of the other exercises or would create a problematic edge case somewhere else.) I still have the issue that if I compile options2.rs by hand I get a warning and running the resulting binary throws a, (useful and informative) panic: cmdline compile by hand$ rustc exercises/option/option2.rs
warning: irrefutable if-let pattern
--> exercises/option/option2.rs:9:5
|
9 | / if let value = optional_value.unwrap() {
10 | | println!("the value of optional value is: {}", value);
11 | | } else {
12 | | println!("The optional value doesn't contain anything!");
13 | | }
| |_____^
|
= note: `#[warn(irrefutable_let_patterns)]` on by default ... and run example showing panic$ ./option2 1>/dev/null
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', exercises/option/option2.rs:36:29
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace I can understand suppressing the irrefutable_let_patterns but the panic message seems relevant and helpful, and worth showing to the user. |
Suggestion from AbdouSeck rust-lang#424 (comment) for when the student's code has errors.
Hi @alexxroche the missing warnings are also another omission because the assumption by If you want the warnings to show, you would have to add a few lines below that (inside the if statement) to display the standard error if it's not empty. So that if statement can be rewritten as something like the following:
Please give that a try and let me know what you think. Thank you, Abdou |
Application of rust-lang#424 (comment)
My attempt to apply your patch to src/exercise.rs (near line 128) compiled but didn't change the output of I tried |
Hi @alexxroche I added your fork as remote and used it. I was able to see the changes I mentioned earlier upon compiling and calling
I am really not sure what could be the issue. But the following is my setup:
Not quite sure what else to suggest other than that you make sure that you have compiled before running? Thank you, Abdou |
Thank you @AbdouSeck for looking at this issue. I think this could be considered a minor edge case that may interest someone that wants to specialise in UX. I'm going to move on with more of the exercises. |
Suggestion from AbdouSeck #424 (comment) for when the student's code has errors.
Suggestion from AbdouSeck #424 (comment) for when the student's code has errors.
Suggestion from AbdouSeck rust-lang#424 (comment) for when the student's code has errors.
Suggestion from AbdouSeck rust-lang#424 (comment) for when the student's code has errors.
Suggestion from AbdouSeck rust-lang#424 (comment) for when the student's code has errors.
Suggestion from AbdouSeck rust-lang/rustlings#424 (comment) for when the student's code has errors.
Suggestion from AbdouSeck rust-lang/rustlings#424 (comment) for when the student's code has errors.
Suggestion from AbdouSeck rust-lang#424 (comment) for when the student's code has errors.
Suggestion from AbdouSeck rust-lang#424 (comment) for when the student's code has errors.
Suggestion from AbdouSeck rust-lang/rustlings#424 (comment) for when the student's code has errors.
I had
rustlings watch
running in one screen and was editing options2.rs in the other. After saving my attempt my operating system ground to a sticky halt, (it felt like a forkbomb.)When I managed to restart
rustlings watch
the output was simply:! Ran exercises/option/option2.rs with errors current value: 9 current value: 8 current value: 7 current value: 6 current value: 5 current value: 4 current value: 3 current value: 2 current value: 1
So rustlings was telling me that there were errors, but rustc wasn't being its usual helpful self, and was silent about what those errors might be.
[I finished the exercise but went back through my branch to dig this out and report it.]
This was during the second half of the options2.rs exercise, so I trimmed out everything else and it was still happening, (example broken code folded away in the [SPOILER]).
[SPOILER] example BAD code
As this is meant to be teaching, I would have liked a little more guidance at that point to indicate what my mistake was. (Though
hint
was still functioning and was all that I needed to finish the exercise, I still don't know what was causing the "! Ran ... with errors".)My rust/rustlings/OS version info
$ rustc --version rustc 1.43.1 (8d69840ab 2020-05-04) $ rustlings --version rustlings 3.0.0 $ uname -a Linux laptop 4.12.0-1-amd64 #1 SMP Debian 4.12.6-1 (2017-08-12) x86_64 GNU/Linux
The text was updated successfully, but these errors were encountered: