diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-02-09 16:16:22 +1100 | 
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-03-01 13:27:47 +1100 | 
| commit | bf62d5913a702754d46a0e9210fcf608deba63af (patch) | |
| tree | 316a7aacc8a17ef6d7fa4431ab0ca2a88b8e8d61 /compiler/rustc_interface/src/callbacks.rs | |
| parent | 1a1876c9790f168fb51afa335a7ba3e6fc267d75 (diff) | |
| download | rust-bf62d5913a702754d46a0e9210fcf608deba63af.tar.gz rust-bf62d5913a702754d46a0e9210fcf608deba63af.zip | |
Give `TRACK_DIAGNOSTIC` a return value.
This means `DiagCtxtInner::emit_diagnostic` can return its result directly, rather than having to modify a local variable.
Diffstat (limited to 'compiler/rustc_interface/src/callbacks.rs')
| -rw-r--r-- | compiler/rustc_interface/src/callbacks.rs | 10 | 
1 files changed, 5 insertions, 5 deletions
| diff --git a/compiler/rustc_interface/src/callbacks.rs b/compiler/rustc_interface/src/callbacks.rs index f44ae705a3c..a27f73789cd 100644 --- a/compiler/rustc_interface/src/callbacks.rs +++ b/compiler/rustc_interface/src/callbacks.rs @@ -29,7 +29,7 @@ fn track_span_parent(def_id: rustc_span::def_id::LocalDefId) { /// This is a callback from `rustc_errors` as it cannot access the implicit state /// in `rustc_middle` otherwise. It is used when diagnostic messages are /// emitted and stores them in the current query, if there is one. -fn track_diagnostic(diagnostic: DiagInner, f: &mut dyn FnMut(DiagInner)) { +fn track_diagnostic<R>(diagnostic: DiagInner, f: &mut dyn FnMut(DiagInner) -> R) -> R { tls::with_context_opt(|icx| { if let Some(icx) = icx { if let Some(diagnostics) = icx.diagnostics { @@ -38,11 +38,11 @@ fn track_diagnostic(diagnostic: DiagInner, f: &mut dyn FnMut(DiagInner)) { // Diagnostics are tracked, we can ignore the dependency. let icx = tls::ImplicitCtxt { task_deps: TaskDepsRef::Ignore, ..icx.clone() }; - return tls::enter_context(&icx, move || (*f)(diagnostic)); + tls::enter_context(&icx, move || (*f)(diagnostic)) + } else { + // In any other case, invoke diagnostics anyway. + (*f)(diagnostic) } - - // In any other case, invoke diagnostics anyway. - (*f)(diagnostic); }) } | 
