Skip to content

Commit 1fc8c3b

Browse files
committed
Auto merge of #153507 - JonathanBrouwer:rollup-ki59UTE, r=JonathanBrouwer
Rollup of 14 pull requests Successful merges: - rust-lang/rust#153466 (`rust-analyzer` subtree update) - rust-lang/rust#151280 (Fix incorrect trailing comma suggested in no_accessible_fields) - rust-lang/rust#152593 (Box in `ValTreeKind::Branch(Box<[I::Const]>)` changed to `List`) - rust-lang/rust#153174 (std: add wasm64 to sync::Once and thread_parking atomics cfg guards) - rust-lang/rust#153485 (libcore float tests: replace macro shadowing by const-compatible macro) - rust-lang/rust#153495 (Fix ICE in `offset_of!` error recovery) - rust-lang/rust#152040 (Do not emit ConstEvaluatable goals if type-const) - rust-lang/rust#152741 (Suppress invalid suggestions in destructuring assignment) - rust-lang/rust#153189 (refactor: move `check_align` to `parse_alignment`) - rust-lang/rust#153230 (Roll rustfmt reviewers for in-tree rustfmt) - rust-lang/rust#153445 (Consider try blocks as block-like for overflowed expr) - rust-lang/rust#153452 (Cleanup unused diagnostic emission methods) - rust-lang/rust#153476 (bootstrap.py: fix typo "parallle") - rust-lang/rust#153483 (Preserve parentheses around `Fn` trait bounds in pretty printer)
2 parents b4d2445 + ae25efb commit 1fc8c3b

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

clippy_utils/src/diagnostics.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
//! Thank you!
99
//! ~The `INTERNAL_METADATA_COLLECTOR` lint
1010
11-
use rustc_errors::{Applicability, Diag, DiagMessage, MultiSpan};
11+
use rustc_errors::{Applicability, Diag, Diagnostic, DiagCtxtHandle, DiagMessage, Level, MultiSpan};
1212
#[cfg(debug_assertions)]
1313
use rustc_errors::{EmissionGuarantee, SubstitutionPart, Suggestions};
1414
use rustc_hir::HirId;
@@ -240,15 +240,27 @@ where
240240
M: Into<DiagMessage>,
241241
F: FnOnce(&mut Diag<'_, ()>),
242242
{
243+
struct ClippyDiag<F: FnOnce(&mut Diag<'_, ()>)>(F);
244+
245+
impl<'a, F: FnOnce(&mut Diag<'_, ()>)> Diagnostic<'a, ()> for ClippyDiag<F> {
246+
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
247+
let mut lint = Diag::new(dcx, level, "");
248+
(self.0)(&mut lint);
249+
lint
250+
}
251+
}
252+
253+
let sp = sp.into();
243254
#[expect(clippy::disallowed_methods)]
244-
cx.span_lint(lint, sp, |diag| {
255+
cx.emit_span_lint(lint, sp.clone(), ClippyDiag(|diag: &mut Diag<'_, ()>| {
245256
diag.primary_message(msg);
257+
diag.span(sp);
246258
f(diag);
247259
docs_link(diag, lint);
248260

249261
#[cfg(debug_assertions)]
250262
validate_diag(diag);
251-
});
263+
}));
252264
}
253265

254266
/// Like [`span_lint`], but emits the lint at the node identified by the given `HirId`.

0 commit comments

Comments
 (0)