]> git.lizzy.rs Git - rust.git/commitdiff
Inline and remove `early_lint_node`.
authorNicholas Nethercote <n.nethercote@gmail.com>
Thu, 1 Dec 2022 02:31:48 +0000 (13:31 +1100)
committerNicholas Nethercote <n.nethercote@gmail.com>
Fri, 2 Dec 2022 04:24:01 +0000 (15:24 +1100)
It has a single call site.

compiler/rustc_lint/src/early.rs

index f198aada9b298565f5bb01fab271915c2e6b1924..215df567e0e02f8e0f2b5bcc22b57c013d61c184 100644 (file)
@@ -363,30 +363,6 @@ fn check<'b>(self, cx: &mut EarlyContextAndPass<'b, impl EarlyLintPass>)
     }
 }
 
-fn early_lint_node<'a>(
-    sess: &Session,
-    warn_about_weird_lints: bool,
-    lint_store: &LintStore,
-    registered_tools: &RegisteredTools,
-    buffered: LintBuffer,
-    pass: impl EarlyLintPass,
-    check_node: impl EarlyCheckNode<'a>,
-) -> LintBuffer {
-    let mut cx = EarlyContextAndPass {
-        context: EarlyContext::new(
-            sess,
-            warn_about_weird_lints,
-            lint_store,
-            registered_tools,
-            buffered,
-        ),
-        pass,
-    };
-
-    cx.with_lint_attrs(check_node.id(), check_node.attrs(), |cx| check_node.check(cx));
-    cx.context.buffered
-}
-
 pub fn check_ast_node<'a>(
     sess: &Session,
     pre_expansion: bool,
@@ -401,21 +377,22 @@ pub fn check_ast_node<'a>(
     let mut passes: Vec<_> = passes.iter().map(|p| (p)()).collect();
     passes.push(Box::new(builtin_lints));
 
-    let mut buffered = lint_buffer.unwrap_or_default();
-    buffered = early_lint_node(
-        sess,
-        !pre_expansion,
-        lint_store,
-        registered_tools,
-        buffered,
-        EarlyLintPassObjects { lints: &mut passes[..] },
-        check_node,
-    );
+    let mut cx = EarlyContextAndPass {
+        context: EarlyContext::new(
+            sess,
+            !pre_expansion,
+            lint_store,
+            registered_tools,
+            lint_buffer.unwrap_or_default(),
+        ),
+        pass: EarlyLintPassObjects { lints: &mut passes[..] },
+    };
+    cx.with_lint_attrs(check_node.id(), check_node.attrs(), |cx| check_node.check(cx));
 
     // All of the buffered lints should have been emitted at this point.
     // If not, that means that we somehow buffered a lint for a node id
     // that was not lint-checked (perhaps it doesn't exist?). This is a bug.
-    for (id, lints) in buffered.map {
+    for (id, lints) in cx.context.buffered.map {
         for early_lint in lints {
             sess.delay_span_bug(
                 early_lint.span,