diff options
| author | Laurențiu Nicola <lnicola@users.noreply.github.com> | 2024-12-23 10:12:23 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-23 10:12:23 +0000 |
| commit | 8dbdcc03ebfd5d3c21671d8a021669dc79d93038 (patch) | |
| tree | e61d058d30fdd35c4a306fde5be669b08092a4fd /compiler/rustc_errors/src/lib.rs | |
| parent | 63a3c394617b114a8fa6e54401700b3adee65a7d (diff) | |
| parent | 0180d2d16f5f5d60384a594568a98a6e6f8eea59 (diff) | |
| download | rust-8dbdcc03ebfd5d3c21671d8a021669dc79d93038.tar.gz rust-8dbdcc03ebfd5d3c21671d8a021669dc79d93038.zip | |
Merge pull request #18746 from lnicola/sync-from-rust
minor: Sync from downstream
Diffstat (limited to 'compiler/rustc_errors/src/lib.rs')
| -rw-r--r-- | compiler/rustc_errors/src/lib.rs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 6232c875ee8..58fe3ec4b85 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -94,8 +94,7 @@ mod styled_buffer; mod tests; pub mod translation; -pub type PErr<'a> = Diag<'a>; -pub type PResult<'a, T> = Result<T, PErr<'a>>; +pub type PResult<'a, T> = Result<T, Diag<'a>>; rustc_fluent_macro::fluent_messages! { "../messages.ftl" } @@ -576,6 +575,10 @@ pub enum StashKey { UndeterminedMacroResolution, /// Used by `Parser::maybe_recover_trailing_expr` ExprInPat, + /// If in the parser we detect a field expr with turbofish generic params it's possible that + /// it's a method call without parens. If later on in `hir_typeck` we find out that this is + /// the case we suppress this message and we give a better suggestion. + GenericInFieldExpr, } fn default_track_diagnostic<R>(diag: DiagInner, f: &mut dyn FnMut(DiagInner) -> R) -> R { @@ -1291,7 +1294,7 @@ impl<'a> DiagCtxtHandle<'a> { Diag::<ErrorGuaranteed>::new(self, DelayedBug, msg.into()).emit() } - /// Ensures that an error is printed. See `Level::DelayedBug`. + /// Ensures that an error is printed. See [`Level::DelayedBug`]. /// /// Note: this function used to be called `delay_span_bug`. It was renamed /// to match similar functions like `span_err`, `span_warn`, etc. @@ -1566,18 +1569,18 @@ impl DiagCtxtInner { debug!(?diagnostic); debug!(?self.emitted_diagnostics); - let already_emitted_sub = |sub: &mut Subdiag| { + let not_yet_emitted = |sub: &mut Subdiag| { debug!(?sub); if sub.level != OnceNote && sub.level != OnceHelp { - return false; + return true; } let mut hasher = StableHasher::new(); sub.hash(&mut hasher); let diagnostic_hash = hasher.finish(); debug!(?diagnostic_hash); - !self.emitted_diagnostics.insert(diagnostic_hash) + self.emitted_diagnostics.insert(diagnostic_hash) }; - diagnostic.children.extract_if(already_emitted_sub).for_each(|_| {}); + diagnostic.children.retain_mut(not_yet_emitted); if already_emitted { let msg = "duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`"; diagnostic.sub(Note, msg, MultiSpan::new()); |
