Skip to content

Commit 92f82c3

Browse files
Lokathorscottmcm
andauthored
Update text/0000-cargo-check-lang-policy.md
Co-authored-by: scottmcm <scottmcm@users.noreply.github.com>
1 parent 309c26f commit 92f82c3

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

text/0000-cargo-check-lang-policy.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,26 @@ Given this performance cost and the fact that errors during monomorphization are
3434

3535
Examples where the optimization level can affect if a program passes `cargo check` and/or `cargo build` are considered bugs unless there is a documented policy exception, approved by T-lang. One example of such an exception is [RFC #3016](https://rust-lang.github.io/rfcs/3016-const-ub.html), which indicated that undefined behavior in const functions cannot always be detected statically (and in particular, optimizations may cause the UB to be undetectable).
3636

37+
# Frequently Asked Questions
38+
39+
## Why doesn't `check` catch everything?
40+
41+
The simplest example here is linker errors. There's no practical way to confirm that linking will work without actually going through all the work of generating the artifacts and actually calling the linker, but that that point one might as well run `build` instead.
42+
43+
An important part of what can make `check` faster than `build` is just *not* doing that kind of thing. And linker errors are rare in pure Rust code, so this is often a good trade-off.
44+
45+
## Why not let more things through in optimized builds?
46+
47+
Rust takes [stability without stagnation] very seriously. We want to make sure stuff keeps compiling if it did before, but we also want to be able to work on improving rust without being so constrained as to make that functionally impossible.
48+
49+
If an optimization might allow something more to compile, that means that every small tweak to that optimization requires careful oversight for exactly what it's committing to support *forever*, which results in extreme overhead for rustc's developers. The best way to avoid that is to have optimizations be about making things faster, not about what compiles *at all*.
50+
51+
For things where people want a certain behaviour, that should be something guaranteed as an intentional language semantic, which we can restrict appropriately to make it feasible with or without optimization.
52+
53+
As an example, there are various *lints* that can detect more cases when optimizations are run, but that's part of why they're lints -- which are fundamentally not *guaranteed* -- rather than part-of-the-language *errors*.
54+
55+
[stability without stagnation]: https://blog.rust-lang.org/2014/10/30/Stability.html#the-plan
56+
3757
# Unresolved questions
3858
[unresolved-questions]: #unresolved-questions
3959

0 commit comments

Comments
 (0)