1
Fork 0

Reduce visibilities and remove dead code.

This commit is contained in:
Camille GILLOT 2022-10-01 09:44:21 +02:00
parent 41db9b152f
commit 6977f7dbe9

View file

@ -29,28 +29,28 @@ use crate::errors::{
}; };
#[derive(Debug)] #[derive(Debug)]
pub struct LintLevelSets { struct LintLevelSets {
pub list: IndexVec<LintStackIndex, LintSet>, list: IndexVec<LintStackIndex, LintSet>,
} }
rustc_index::newtype_index! { rustc_index::newtype_index! {
pub struct LintStackIndex { struct LintStackIndex {
ENCODABLE = custom, // we don't need encoding ENCODABLE = custom, // we don't need encoding
const COMMAND_LINE = 0, const COMMAND_LINE = 0,
} }
} }
#[derive(Debug)] #[derive(Debug)]
pub struct LintSet { struct LintSet {
// -A,-W,-D flags, a `Symbol` for the flag itself and `Level` for which // -A,-W,-D flags, a `Symbol` for the flag itself and `Level` for which
// flag. // flag.
pub specs: FxHashMap<LintId, LevelAndSource>, specs: FxHashMap<LintId, LevelAndSource>,
pub parent: LintStackIndex, parent: LintStackIndex,
} }
impl LintLevelSets { impl LintLevelSets {
pub fn new() -> Self { fn new() -> Self {
LintLevelSets { list: IndexVec::new() } LintLevelSets { list: IndexVec::new() }
} }
@ -62,15 +62,14 @@ impl LintLevelSets {
sess: &Session, sess: &Session,
) -> LevelAndSource { ) -> LevelAndSource {
let lint = LintId::of(lint); let lint = LintId::of(lint);
let (level, mut src) = self.get_lint_id_level(lint, idx, aux); let (level, mut src) = self.raw_lint_id_level(lint, idx, aux);
let level = reveal_actual_level(level, &mut src, sess, lint, |id| { let level = reveal_actual_level(level, &mut src, sess, lint, |id| {
self.get_lint_id_level(id, idx, aux) self.raw_lint_id_level(id, idx, aux)
}); });
(level, src) (level, src)
} }
pub fn get_lint_id_level( fn raw_lint_id_level(
&self, &self,
id: LintId, id: LintId,
mut idx: LintStackIndex, mut idx: LintStackIndex,
@ -292,13 +291,12 @@ pub struct LintLevelsBuilder<'s, P> {
registered_tools: &'s RegisteredTools, registered_tools: &'s RegisteredTools,
} }
pub struct BuilderPush { pub(crate) struct BuilderPush {
prev: LintStackIndex, prev: LintStackIndex,
pub changed: bool,
} }
impl<'s> LintLevelsBuilder<'s, TopDown> { impl<'s> LintLevelsBuilder<'s, TopDown> {
pub fn new( pub(crate) fn new(
sess: &'s Session, sess: &'s Session,
warn_about_weird_lints: bool, warn_about_weird_lints: bool,
store: &'s LintStore, store: &'s LintStore,
@ -356,11 +354,11 @@ impl<'s> LintLevelsBuilder<'s, TopDown> {
self.provider.cur = prev; self.provider.cur = prev;
} }
BuilderPush { prev, changed: prev != self.provider.cur } BuilderPush { prev }
} }
/// Called after `push` when the scope of a set of attributes are exited. /// Called after `push` when the scope of a set of attributes are exited.
pub fn pop(&mut self, push: BuilderPush) { pub(crate) fn pop(&mut self, push: BuilderPush) {
self.provider.cur = push.prev; self.provider.cur = push.prev;
} }
} }
@ -929,7 +927,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
/// Used to emit a lint-related diagnostic based on the current state of /// Used to emit a lint-related diagnostic based on the current state of
/// this lint context. /// this lint context.
pub fn struct_lint( pub(crate) fn struct_lint(
&self, &self,
lint: &'static Lint, lint: &'static Lint,
span: Option<MultiSpan>, span: Option<MultiSpan>,