mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Slightly clean up some lint infra code
* inline `LintBuffer::add_lint`, it only had a single use * update a lint infra example code snippet * it used the wrong API (the snippet isn't tested) * presumably the arguments were updated from builder to diag struct style at some point without updating the method
This commit is contained in:
parent
b54dd08a84
commit
366ef95407
@ -764,19 +764,7 @@ pub struct LintBuffer {
|
|||||||
|
|
||||||
impl LintBuffer {
|
impl LintBuffer {
|
||||||
pub fn add_early_lint(&mut self, early_lint: BufferedEarlyLint) {
|
pub fn add_early_lint(&mut self, early_lint: BufferedEarlyLint) {
|
||||||
let arr = self.map.entry(early_lint.node_id).or_default();
|
self.map.entry(early_lint.node_id).or_default().push(early_lint);
|
||||||
arr.push(early_lint);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn add_lint(
|
|
||||||
&mut self,
|
|
||||||
lint: &'static Lint,
|
|
||||||
node_id: NodeId,
|
|
||||||
span: MultiSpan,
|
|
||||||
diagnostic: BuiltinLintDiag,
|
|
||||||
) {
|
|
||||||
let lint_id = LintId::of(lint);
|
|
||||||
self.add_early_lint(BufferedEarlyLint { lint_id, node_id, span, diagnostic });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn take(&mut self, id: NodeId) -> Vec<BufferedEarlyLint> {
|
pub fn take(&mut self, id: NodeId) -> Vec<BufferedEarlyLint> {
|
||||||
@ -787,11 +775,16 @@ impl LintBuffer {
|
|||||||
pub fn buffer_lint(
|
pub fn buffer_lint(
|
||||||
&mut self,
|
&mut self,
|
||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
id: NodeId,
|
node_id: NodeId,
|
||||||
sp: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
diagnostic: BuiltinLintDiag,
|
diagnostic: BuiltinLintDiag,
|
||||||
) {
|
) {
|
||||||
self.add_lint(lint, id, sp.into(), diagnostic)
|
self.add_early_lint(BufferedEarlyLint {
|
||||||
|
lint_id: LintId::of(lint),
|
||||||
|
node_id,
|
||||||
|
span: span.into(),
|
||||||
|
diagnostic,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ pub fn diagnostic_derive(mut s: Structure<'_>) -> TokenStream {
|
|||||||
/// Then, later, to emit the error:
|
/// Then, later, to emit the error:
|
||||||
///
|
///
|
||||||
/// ```ignore (rust)
|
/// ```ignore (rust)
|
||||||
/// cx.span_lint(INVALID_ATOMIC_ORDERING, fail_order_arg_span, AtomicOrderingInvalidLint {
|
/// cx.emit_span_lint(INVALID_ATOMIC_ORDERING, fail_order_arg_span, AtomicOrderingInvalidLint {
|
||||||
/// method,
|
/// method,
|
||||||
/// success_ordering,
|
/// success_ordering,
|
||||||
/// fail_ordering,
|
/// fail_ordering,
|
||||||
|
Loading…
Reference in New Issue
Block a user