Skip to content

Commit bfca57c

Browse files
committed
Stop emitting lints during lowering.
1 parent 5eef76d commit bfca57c

File tree

3 files changed

+14
-23
lines changed

3 files changed

+14
-23
lines changed

compiler/rustc_ast_lowering/src/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ use rustc_hir::intravisit;
5555
use rustc_hir::{ConstArg, GenericArg, ParamName};
5656
use rustc_index::vec::{Idx, IndexVec};
5757
use rustc_query_system::ich::StableHashingContext;
58-
use rustc_session::lint::LintBuffer;
5958
use rustc_session::utils::{FlattenNonterminals, NtToTokenstream};
6059
use rustc_session::Session;
6160
use rustc_span::hygiene::ExpnId;
@@ -185,8 +184,6 @@ pub trait ResolverAstLowering {
185184

186185
fn init_def_id_to_hir_id_mapping(&mut self, mapping: IndexVec<LocalDefId, Option<hir::HirId>>);
187186

188-
fn lint_buffer(&mut self) -> &mut LintBuffer;
189-
190187
fn next_node_id(&mut self) -> NodeId;
191188

192189
fn take_trait_map(&mut self, node: NodeId) -> Option<Vec<hir::TraitCandidate>>;

compiler/rustc_interface/src/passes.rs

+14-16
Original file line numberDiff line numberDiff line change
@@ -482,12 +482,23 @@ pub fn configure_and_expand(
482482
}
483483
});
484484

485+
sess.time("early_lint_checks", || {
486+
rustc_lint::check_ast_crate(
487+
sess,
488+
lint_store,
489+
&krate,
490+
&krate.attrs,
491+
false,
492+
Some(std::mem::take(resolver.lint_buffer())),
493+
rustc_lint::BuiltinCombinedEarlyLintPass::new(),
494+
)
495+
});
496+
485497
Ok(krate)
486498
}
487499

488500
pub fn lower_to_hir<'res, 'tcx>(
489501
sess: &'tcx Session,
490-
lint_store: &LintStore,
491502
resolver: &'res mut Resolver<'_>,
492503
krate: Rc<ast::Crate>,
493504
arena: &'tcx rustc_ast_lowering::Arena<'tcx>,
@@ -501,18 +512,6 @@ pub fn lower_to_hir<'res, 'tcx>(
501512
arena,
502513
);
503514

504-
sess.time("early_lint_checks", || {
505-
rustc_lint::check_ast_crate(
506-
sess,
507-
lint_store,
508-
&krate,
509-
&krate.attrs,
510-
false,
511-
Some(std::mem::take(resolver.lint_buffer())),
512-
rustc_lint::BuiltinCombinedEarlyLintPass::new(),
513-
)
514-
});
515-
516515
// Drop AST to free memory
517516
sess.time("drop_ast", || std::mem::drop(krate));
518517

@@ -844,9 +843,8 @@ pub fn create_global_ctxt<'tcx>(
844843
dep_graph.assert_ignored();
845844

846845
let sess = &compiler.session();
847-
let krate = resolver
848-
.borrow_mut()
849-
.access(|resolver| lower_to_hir(sess, &lint_store, resolver, krate, hir_arena));
846+
let krate =
847+
resolver.borrow_mut().access(|resolver| lower_to_hir(sess, resolver, krate, hir_arena));
850848
let (definitions, cstore, resolver_outputs) = BoxedResolver::to_resolver_outputs(resolver);
851849

852850
let query_result_on_disk_cache = rustc_incremental::load_query_result_cache(sess);

compiler/rustc_resolve/src/lib.rs

-4
Original file line numberDiff line numberDiff line change
@@ -1185,10 +1185,6 @@ impl ResolverAstLowering for Resolver<'_> {
11851185
self.definitions.init_def_id_to_hir_id_mapping(mapping)
11861186
}
11871187

1188-
fn lint_buffer(&mut self) -> &mut LintBuffer {
1189-
&mut self.lint_buffer
1190-
}
1191-
11921188
fn next_node_id(&mut self) -> NodeId {
11931189
self.next_node_id()
11941190
}

0 commit comments

Comments
 (0)