Skip to content

Commit

Permalink
Stop emitting lints during lowering.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Dec 26, 2021
1 parent 5eef76d commit bfca57c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 23 deletions.
3 changes: 0 additions & 3 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ use rustc_hir::intravisit;
use rustc_hir::{ConstArg, GenericArg, ParamName};
use rustc_index::vec::{Idx, IndexVec};
use rustc_query_system::ich::StableHashingContext;
use rustc_session::lint::LintBuffer;
use rustc_session::utils::{FlattenNonterminals, NtToTokenstream};
use rustc_session::Session;
use rustc_span::hygiene::ExpnId;
Expand Down Expand Up @@ -185,8 +184,6 @@ pub trait ResolverAstLowering {

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

fn lint_buffer(&mut self) -> &mut LintBuffer;

fn next_node_id(&mut self) -> NodeId;

fn take_trait_map(&mut self, node: NodeId) -> Option<Vec<hir::TraitCandidate>>;
Expand Down
30 changes: 14 additions & 16 deletions compiler/rustc_interface/src/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,12 +482,23 @@ pub fn configure_and_expand(
}
});

sess.time("early_lint_checks", || {
rustc_lint::check_ast_crate(
sess,
lint_store,
&krate,
&krate.attrs,
false,
Some(std::mem::take(resolver.lint_buffer())),
rustc_lint::BuiltinCombinedEarlyLintPass::new(),
)
});

Ok(krate)
}

pub fn lower_to_hir<'res, 'tcx>(
sess: &'tcx Session,
lint_store: &LintStore,
resolver: &'res mut Resolver<'_>,
krate: Rc<ast::Crate>,
arena: &'tcx rustc_ast_lowering::Arena<'tcx>,
Expand All @@ -501,18 +512,6 @@ pub fn lower_to_hir<'res, 'tcx>(
arena,
);

sess.time("early_lint_checks", || {
rustc_lint::check_ast_crate(
sess,
lint_store,
&krate,
&krate.attrs,
false,
Some(std::mem::take(resolver.lint_buffer())),
rustc_lint::BuiltinCombinedEarlyLintPass::new(),
)
});

// Drop AST to free memory
sess.time("drop_ast", || std::mem::drop(krate));

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

let sess = &compiler.session();
let krate = resolver
.borrow_mut()
.access(|resolver| lower_to_hir(sess, &lint_store, resolver, krate, hir_arena));
let krate =
resolver.borrow_mut().access(|resolver| lower_to_hir(sess, resolver, krate, hir_arena));
let (definitions, cstore, resolver_outputs) = BoxedResolver::to_resolver_outputs(resolver);

let query_result_on_disk_cache = rustc_incremental::load_query_result_cache(sess);
Expand Down
4 changes: 0 additions & 4 deletions compiler/rustc_resolve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1185,10 +1185,6 @@ impl ResolverAstLowering for Resolver<'_> {
self.definitions.init_def_id_to_hir_id_mapping(mapping)
}

fn lint_buffer(&mut self) -> &mut LintBuffer {
&mut self.lint_buffer
}

fn next_node_id(&mut self) -> NodeId {
self.next_node_id()
}
Expand Down

0 comments on commit bfca57c

Please sign in to comment.