Slightly clean up some lint infra code · rust-lang/rust@366ef95

File tree

2 files changed

lines changed

    • rustc_macros/src/diagnostics

2 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -764,19 +764,7 @@ pub struct LintBuffer {

764764
765765

impl LintBuffer {

766766

pub fn add_early_lint(&mut self, early_lint: BufferedEarlyLint) {

767-

let arr = self.map.entry(early_lint.node_id).or_default();

768-

arr.push(early_lint);

769-

}

770-
771-

pub fn add_lint(

772-

&mut self,

773-

lint: &'static Lint,

774-

node_id: NodeId,

775-

span: MultiSpan,

776-

diagnostic: BuiltinLintDiag,

777-

) {

778-

let lint_id = LintId::of(lint);

779-

self.add_early_lint(BufferedEarlyLint { lint_id, node_id, span, diagnostic });

767+

self.map.entry(early_lint.node_id).or_default().push(early_lint);

780768

}

781769
782770

pub fn take(&mut self, id: NodeId) -> Vec<BufferedEarlyLint> {

@@ -787,11 +775,16 @@ impl LintBuffer {

787775

pub fn buffer_lint(

788776

&mut self,

789777

lint: &'static Lint,

790-

id: NodeId,

791-

sp: impl Into<MultiSpan>,

778+

node_id: NodeId,

779+

span: impl Into<MultiSpan>,

792780

diagnostic: BuiltinLintDiag,

793781

) {

794-

self.add_lint(lint, id, sp.into(), diagnostic)

782+

self.add_early_lint(BufferedEarlyLint {

783+

lint_id: LintId::of(lint),

784+

node_id,

785+

span: span.into(),

786+

diagnostic,

787+

});

795788

}

796789

}

797790
Original file line numberDiff line numberDiff line change

@@ -91,7 +91,7 @@ pub fn diagnostic_derive(mut s: Structure<'_>) -> TokenStream {

9191

/// Then, later, to emit the error:

9292

///

9393

/// ```ignore (rust)

94-

/// cx.span_lint(INVALID_ATOMIC_ORDERING, fail_order_arg_span, AtomicOrderingInvalidLint {

94+

/// cx.emit_span_lint(INVALID_ATOMIC_ORDERING, fail_order_arg_span, AtomicOrderingInvalidLint {

9595

/// method,

9696

/// success_ordering,

9797

/// fail_ordering,