Use () for lint_levels.

This commit is contained in:
Camille GILLOT 2021-05-11 12:22:11 +02:00
parent b7bf467fa3
commit 9d15abe0cc
3 changed files with 5 additions and 7 deletions

View File

@ -6,8 +6,7 @@
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder};
use rustc_hir as hir;
use rustc_hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
use rustc_hir::{intravisit, HirId};
use rustc_hir::{intravisit, HirId, CRATE_HIR_ID};
use rustc_middle::hir::map::Map;
use rustc_middle::lint::LevelAndSource;
use rustc_middle::lint::LintDiagnosticBuilder;
@ -28,10 +27,9 @@
use std::cmp;
fn lint_levels(tcx: TyCtxt<'_>, cnum: CrateNum) -> LintLevelMap {
assert_eq!(cnum, LOCAL_CRATE);
fn lint_levels(tcx: TyCtxt<'_>, (): ()) -> LintLevelMap {
let store = unerased_lint_store(tcx);
let crate_attrs = tcx.get_attrs(DefId { krate: cnum, index: CRATE_DEF_INDEX });
let crate_attrs = tcx.hir().attrs(CRATE_HIR_ID);
let levels = LintLevelsBuilder::new(tcx.sess, false, &store, crate_attrs);
let mut builder = LintLevelMapBuilder { levels, tcx, store };
let krate = tcx.hir().krate();

View File

@ -199,7 +199,7 @@
desc { "looking up the native libraries of a linked crate" }
}
query lint_levels(_: CrateNum) -> LintLevelMap {
query lint_levels(_: ()) -> LintLevelMap {
storage(ArenaCacheSelector<'tcx>)
eval_always
desc { "computing the lint levels for items in this crate" }

View File

@ -2623,7 +2623,7 @@ pub fn lint_level_at_node(
lint: &'static Lint,
mut id: hir::HirId,
) -> (Level, LintLevelSource) {
let sets = self.lint_levels(LOCAL_CRATE);
let sets = self.lint_levels(());
loop {
if let Some(pair) = sets.level_and_source(lint, id, self.sess) {
return pair;