Curriculum Foundations Compiler feedback
Compiler feedback
Rust is learned with the compiler, not around it. Before ownership starts, learners need the habit of reading error[E...], spans, notes, and help: suggestions. Planned exercises: 1. identify the primary error line. 2. recognise a help: suggestion. 3. choose the fix for a type mismatch. 4. fill a corrected variable name. 5. fill a corrected type. 6. apply a compiler hint to one line. 7. explain why a warning is not an error. 8. fix a short program from a rustc diagnostic. 9. use the diagnostic to repair a function.
Exercises
9 ready
01
pick one
Rust's compiler emits diagnostics that look like the one below.
02
pick one
Inside the rustc diagnostic below, which line is the
03
pick one
The compiler says: expected i64, found i32. The buggy line is
04
fill blanks
rustc says: cannot find value cont in this scope, with
05
fill blanks
rustc says: expected f64, found integer. The bug is the
06
type one line
rustc complains: `cannot assign twice to immutable variable
07
pick one
rustc emits warning: unused variable: extra but the program
08
write a program
The following Rust program FAILS to compile with:
09
write a program
The following function fails with: