Recover on `const X = 42;` and infer type + Error Stash API
Here we:
1. Introduce a notion of the "error stash".
This is a map in the `Handler` to which you can `err.stash(...)` away your diagnostics and then steal them in a later "phase" of the compiler (e.g. stash in parser, steal in typeck) to enrich them with more information that isn't available in the previous "phase".
I believe I've covered all the bases to make sure these diagnostics are actually emitted eventually even under `#[cfg(FALSE)]` but please check my logic.
2. Recover when parsing `[const | static mut?] $ident = $expr;` which has a missing type.
Use the "error stash" to stash away the error and later steal the error in typeck where we emit the error as `MachineApplicable` with the actual inferred type. This builds on https://github.com/rust-lang/rust/pull/62804.
cc https://github.com/rust-lang/rfcs/pull/2545
r? @estebank
|
||
|---|---|---|
| .. | ||
| ast | ||
| attr | ||
| diagnostics | ||
| ext | ||
| feature_gate | ||
| mut_visit | ||
| parse | ||
| source_map | ||
| tokenstream | ||
| util | ||
| ast.rs | ||
| build.rs | ||
| Cargo.toml | ||
| config.rs | ||
| early_buffered_lints.rs | ||
| entry.rs | ||
| error_codes.rs | ||
| json.rs | ||
| lib.rs | ||
| mut_visit.rs | ||
| ptr.rs | ||
| README.md | ||
| show_span.rs | ||
| source_map.rs | ||
| tests.rs | ||
| tokenstream.rs | ||
| visit.rs | ||
The syntax crate contains those things concerned purely with syntax
– that is, the AST ("abstract syntax tree"), parser, pretty-printer,
lexer, macro expander, and utilities for traversing ASTs.
For more information about how these things work in rustc, see the rustc guide: