google / google/comprehensive-rust
Code snippets without `main` pass tests but fail to compile in the slide
- Dominant language
- Rust
- Stars
- 33.4k
- Forks
- 2.1k
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 10
Description
The "PartialEq and Eq" slide in the idiomatic course [has a code snippet](https://github.com/google/comprehensive-rust/blob/b9e63dd1229dbdc847820ac21f12c65d43f0e1f9/src/idiomatic/foundations-api-design/predictable-api/common-traits/partialeq-eq.md?plain=1#L18-L41) that doesn't compile or run, but is not marked `ignore` or `compile_fail`, and `mdbook test` does not fail.
The issue is that the code snippet is missing a `main` function, and so fails to compile/run when trying to run it in the slide. But when running tests, it looks like a `main` function wrapper is implicitly added if the snippet doesn't have its own `main`. This means that the tests pass, even though the code doesn't work when trying to teach the class.
I think the implicit main behavior is useful and can allow us to write more concise code examples, but we either need to add that behavior when running the code snippets in the slide, or we need to remove this behavior from the tests so that tests can catch when code snippets don't work.
Contributor guide
Assessment
This issue has not been assessed yet.