diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-09-24 23:45:24 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-09-24 23:45:24 +0200 |
| commit | 0d0f753955afe5c79d260b03f7fbe68ee53d4950 (patch) | |
| tree | 4369c406a21e29ac2ecda87881d7c0a6bb5d60c0 /src/libsyntax_ext | |
| parent | 6a4be432123209051f7769a6f9101a4470c3798d (diff) | |
| parent | f70665a84692a80a820fccdaed19df5dde94c533 (diff) | |
| download | rust-0d0f753955afe5c79d260b03f7fbe68ee53d4950.tar.gz rust-0d0f753955afe5c79d260b03f7fbe68ee53d4950.zip | |
Rollup merge of #64698 - Centril:infer-const-with-stash, r=estebank
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
Diffstat (limited to 'src/libsyntax_ext')
| -rw-r--r-- | src/libsyntax_ext/format.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index 26455df17b8..2765346b333 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -295,7 +295,7 @@ impl<'a, 'b> Context<'a, 'b> { .filter(|fmt| fmt.precision_span.is_some()) .count(); if self.names.is_empty() && !numbered_position_args && count != self.args.len() { - e = self.ecx.mut_span_err( + e = self.ecx.struct_span_err( sp, &format!( "{} positional argument{} in format string, but {}", @@ -336,7 +336,7 @@ impl<'a, 'b> Context<'a, 'b> { sp = MultiSpan::from_span(self.fmtsp); } - e = self.ecx.mut_span_err(sp, + e = self.ecx.struct_span_err(sp, &format!("invalid reference to positional {} ({})", arg_list, self.describe_num_args())); |
