1
Fork 0

Merge builtins into EarlyLintPassObjects.

This avoids calling `early_lint_node` twice.

Note: one `early_lint_node` call had `!pre_expansion` for the second
argument and the other had `false`. The new single call just has
`!pre_expansion`. This results in a reduction of duplicate error
messages in some `ui-fulldeps` tests. The order of some `ui-fulldeps`
output also changes, but that doesn't matter.
This commit is contained in:
Nicholas Nethercote 2022-12-01 13:22:08 +11:00
parent 44cb4f70a8
commit a9b02af62b
12 changed files with 93 additions and 147 deletions

View file

@ -393,36 +393,25 @@ pub fn check_ast_node<'a>(
lint_store: &LintStore,
registered_tools: &RegisteredTools,
lint_buffer: Option<LintBuffer>,
builtin_lints: impl EarlyLintPass,
builtin_lints: impl EarlyLintPass + 'static,
check_node: impl EarlyCheckNode<'a>,
) {
let passes =
if pre_expansion { &lint_store.pre_expansion_passes } else { &lint_store.early_passes };
let mut passes: Vec<_> = passes.iter().map(|p| (p)()).collect();
let mut buffered = lint_buffer.unwrap_or_default();
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,
builtin_lints,
EarlyLintPassObjects { lints: &mut passes[..] },
check_node,
);
if !passes.is_empty() {
buffered = early_lint_node(
sess,
false,
lint_store,
registered_tools,
buffered,
EarlyLintPassObjects { lints: &mut passes[..] },
check_node,
);
}
// 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.