0c653d9f91
* instead simply set the primary message inside the lint decorator functions * it used to be this way before [#]101986 which introduced `msg` to prevent good path delayed bugs (which no longer exist) from firing under certain circumstances when lints were suppressed / silenced * this is no longer necessary for various reasons I presume * it shaves off complexity and makes further changes easier to implement
22 lines
677 B
Rust
22 lines
677 B
Rust
#![feature(rustc_private)]
|
|
|
|
extern crate rustc_errors;
|
|
extern crate rustc_hir;
|
|
extern crate rustc_lint;
|
|
extern crate rustc_middle;
|
|
|
|
use rustc_errors::{DiagMessage, MultiSpan};
|
|
use rustc_hir::hir_id::HirId;
|
|
use rustc_lint::{Lint, LintContext};
|
|
use rustc_middle::ty::TyCtxt;
|
|
|
|
pub fn a(cx: impl LintContext, lint: &'static Lint, span: impl Into<MultiSpan>, msg: impl Into<DiagMessage>) {
|
|
cx.span_lint(lint, span, |lint| { lint.primary_message(msg); });
|
|
}
|
|
|
|
pub fn b(tcx: TyCtxt<'_>, lint: &'static Lint, hir_id: HirId, span: impl Into<MultiSpan>, msg: impl Into<DiagMessage>) {
|
|
tcx.node_span_lint(lint, hir_id, span, |lint| { lint.primary_message(msg); });
|
|
}
|
|
|
|
fn main() {}
|