Skip to content

Commit 366ef95

Browse files
committed
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
1 parent b54dd08 commit 366ef95

2 files changed

Lines changed: 10 additions & 17 deletions

File tree

  • compiler

‎compiler/rustc_lint_defs/src/lib.rs‎

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -764,19 +764,7 @@ pub struct LintBuffer {
764764

765765
implLintBuffer{
766766
pubfnadd_early_lint(&mutself,early_lint:BufferedEarlyLint){
767-
let arr = self.map.entry(early_lint.node_id).or_default();
768-
arr.push(early_lint);
769-
}
770-
771-
pubfnadd_lint(
772-
&mutself,
773-
lint:&'staticLint,
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
pubfntake(&mutself,id:NodeId) -> Vec<BufferedEarlyLint>{
@@ -787,11 +775,16 @@ impl LintBuffer {
787775
pubfnbuffer_lint(
788776
&mutself,
789777
lint:&'staticLint,
790-
id:NodeId,
791-
sp:implInto<MultiSpan>,
778+
node_id:NodeId,
779+
span:implInto<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

‎compiler/rustc_macros/src/diagnostics/mod.rs‎

Lines changed: 1 addition & 1 deletion
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,

0 commit comments

Comments
 (0)