Rename rustc_middle::lint::LintSource
Rename rustc_middle::lint::LintSource to rustc_middle::lint::LintLevelSource.
This commit is contained in:
parent
11c94a1977
commit
aec3575aa7
5 changed files with 32 additions and 32 deletions
|
@ -12,7 +12,7 @@ use rustc_hir::{intravisit, HirId};
|
||||||
use rustc_middle::hir::map::Map;
|
use rustc_middle::hir::map::Map;
|
||||||
use rustc_middle::lint::LevelSource;
|
use rustc_middle::lint::LevelSource;
|
||||||
use rustc_middle::lint::LintDiagnosticBuilder;
|
use rustc_middle::lint::LintDiagnosticBuilder;
|
||||||
use rustc_middle::lint::{struct_lint_level, LintLevelMap, LintLevelSets, LintSet, LintSource};
|
use rustc_middle::lint::{struct_lint_level, LintLevelMap, LintLevelSets, LintSet, LintLevelSource};
|
||||||
use rustc_middle::ty::query::Providers;
|
use rustc_middle::ty::query::Providers;
|
||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
use rustc_session::lint::{builtin, Level, Lint, LintId};
|
use rustc_session::lint::{builtin, Level, Lint, LintId};
|
||||||
|
@ -91,7 +91,7 @@ impl<'s> LintLevelsBuilder<'s> {
|
||||||
};
|
};
|
||||||
for id in ids {
|
for id in ids {
|
||||||
self.check_gated_lint(id, DUMMY_SP);
|
self.check_gated_lint(id, DUMMY_SP);
|
||||||
let src = LintSource::CommandLine(lint_flag_val, orig_level);
|
let src = LintLevelSource::CommandLine(lint_flag_val, orig_level);
|
||||||
specs.insert(id, (level, src));
|
specs.insert(id, (level, src));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,19 +128,19 @@ impl<'s> LintLevelsBuilder<'s> {
|
||||||
);
|
);
|
||||||
diag_builder.span_label(src.span(), "overruled by previous forbid");
|
diag_builder.span_label(src.span(), "overruled by previous forbid");
|
||||||
match old_src {
|
match old_src {
|
||||||
LintSource::Default => {
|
LintLevelSource::Default => {
|
||||||
diag_builder.note(&format!(
|
diag_builder.note(&format!(
|
||||||
"`forbid` lint level is the default for {}",
|
"`forbid` lint level is the default for {}",
|
||||||
id.to_string()
|
id.to_string()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
LintSource::Node(_, forbid_source_span, reason) => {
|
LintLevelSource::Node(_, forbid_source_span, reason) => {
|
||||||
diag_builder.span_label(forbid_source_span, "`forbid` level set here");
|
diag_builder.span_label(forbid_source_span, "`forbid` level set here");
|
||||||
if let Some(rationale) = reason {
|
if let Some(rationale) = reason {
|
||||||
diag_builder.note(&rationale.as_str());
|
diag_builder.note(&rationale.as_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LintSource::CommandLine(_, _) => {
|
LintLevelSource::CommandLine(_, _) => {
|
||||||
diag_builder.note("`forbid` lint level was set on command line");
|
diag_builder.note("`forbid` lint level was set on command line");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -276,7 +276,7 @@ impl<'s> LintLevelsBuilder<'s> {
|
||||||
let name = meta_item.path.segments.last().expect("empty lint name").ident.name;
|
let name = meta_item.path.segments.last().expect("empty lint name").ident.name;
|
||||||
match store.check_lint_name(&name.as_str(), tool_name) {
|
match store.check_lint_name(&name.as_str(), tool_name) {
|
||||||
CheckLintNameResult::Ok(ids) => {
|
CheckLintNameResult::Ok(ids) => {
|
||||||
let src = LintSource::Node(name, li.span(), reason);
|
let src = LintLevelSource::Node(name, li.span(), reason);
|
||||||
for &id in ids {
|
for &id in ids {
|
||||||
self.check_gated_lint(id, attr.span);
|
self.check_gated_lint(id, attr.span);
|
||||||
self.insert_spec(&mut specs, id, (level, src));
|
self.insert_spec(&mut specs, id, (level, src));
|
||||||
|
@ -287,7 +287,7 @@ impl<'s> LintLevelsBuilder<'s> {
|
||||||
match result {
|
match result {
|
||||||
Ok(ids) => {
|
Ok(ids) => {
|
||||||
let complete_name = &format!("{}::{}", tool_name.unwrap(), name);
|
let complete_name = &format!("{}::{}", tool_name.unwrap(), name);
|
||||||
let src = LintSource::Node(
|
let src = LintLevelSource::Node(
|
||||||
Symbol::intern(complete_name),
|
Symbol::intern(complete_name),
|
||||||
li.span(),
|
li.span(),
|
||||||
reason,
|
reason,
|
||||||
|
@ -324,7 +324,7 @@ impl<'s> LintLevelsBuilder<'s> {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
let src = LintSource::Node(
|
let src = LintLevelSource::Node(
|
||||||
Symbol::intern(&new_lint_name),
|
Symbol::intern(&new_lint_name),
|
||||||
li.span(),
|
li.span(),
|
||||||
reason,
|
reason,
|
||||||
|
@ -403,7 +403,7 @@ impl<'s> LintLevelsBuilder<'s> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let (lint_attr_name, lint_attr_span) = match *src {
|
let (lint_attr_name, lint_attr_span) = match *src {
|
||||||
LintSource::Node(name, span, _) => (name, span),
|
LintLevelSource::Node(name, span, _) => (name, span),
|
||||||
_ => continue,
|
_ => continue,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -460,7 +460,7 @@ impl<'s> LintLevelsBuilder<'s> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Find the lint level for a lint.
|
/// Find the lint level for a lint.
|
||||||
pub fn lint_level(&self, lint: &'static Lint) -> (Level, LintSource) {
|
pub fn lint_level(&self, lint: &'static Lint) -> (Level, LintLevelSource) {
|
||||||
self.sets.get_lint_level(lint, self.cur, None, self.sess)
|
self.sets.get_lint_level(lint, self.cur, None, self.sess)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ use rustc_span::{symbol, Span, Symbol, DUMMY_SP};
|
||||||
|
|
||||||
/// How a lint level was set.
|
/// How a lint level was set.
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, HashStable)]
|
#[derive(Clone, Copy, PartialEq, Eq, HashStable)]
|
||||||
pub enum LintSource {
|
pub enum LintLevelSource {
|
||||||
/// Lint is at the default level as declared
|
/// Lint is at the default level as declared
|
||||||
/// in rustc or a plugin.
|
/// in rustc or a plugin.
|
||||||
Default,
|
Default,
|
||||||
|
@ -27,25 +27,25 @@ pub enum LintSource {
|
||||||
CommandLine(Symbol, Level),
|
CommandLine(Symbol, Level),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LintSource {
|
impl LintLevelSource {
|
||||||
pub fn name(&self) -> Symbol {
|
pub fn name(&self) -> Symbol {
|
||||||
match *self {
|
match *self {
|
||||||
LintSource::Default => symbol::kw::Default,
|
LintLevelSource::Default => symbol::kw::Default,
|
||||||
LintSource::Node(name, _, _) => name,
|
LintLevelSource::Node(name, _, _) => name,
|
||||||
LintSource::CommandLine(name, _) => name,
|
LintLevelSource::CommandLine(name, _) => name,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn span(&self) -> Span {
|
pub fn span(&self) -> Span {
|
||||||
match *self {
|
match *self {
|
||||||
LintSource::Default => DUMMY_SP,
|
LintLevelSource::Default => DUMMY_SP,
|
||||||
LintSource::Node(_, span, _) => span,
|
LintLevelSource::Node(_, span, _) => span,
|
||||||
LintSource::CommandLine(_, _) => DUMMY_SP,
|
LintLevelSource::CommandLine(_, _) => DUMMY_SP,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type LevelSource = (Level, LintSource);
|
pub type LevelSource = (Level, LintLevelSource);
|
||||||
|
|
||||||
pub struct LintLevelSets {
|
pub struct LintLevelSets {
|
||||||
pub list: Vec<LintSet>,
|
pub list: Vec<LintSet>,
|
||||||
|
@ -113,7 +113,7 @@ impl LintLevelSets {
|
||||||
id: LintId,
|
id: LintId,
|
||||||
mut idx: u32,
|
mut idx: u32,
|
||||||
aux: Option<&FxHashMap<LintId, LevelSource>>,
|
aux: Option<&FxHashMap<LintId, LevelSource>>,
|
||||||
) -> (Option<Level>, LintSource) {
|
) -> (Option<Level>, LintLevelSource) {
|
||||||
if let Some(specs) = aux {
|
if let Some(specs) = aux {
|
||||||
if let Some(&(level, src)) = specs.get(&id) {
|
if let Some(&(level, src)) = specs.get(&id) {
|
||||||
return (Some(level), src);
|
return (Some(level), src);
|
||||||
|
@ -125,7 +125,7 @@ impl LintLevelSets {
|
||||||
if let Some(&(level, src)) = specs.get(&id) {
|
if let Some(&(level, src)) = specs.get(&id) {
|
||||||
return (Some(level), src);
|
return (Some(level), src);
|
||||||
}
|
}
|
||||||
return (None, LintSource::Default);
|
return (None, LintLevelSource::Default);
|
||||||
}
|
}
|
||||||
LintSet::Node { ref specs, parent } => {
|
LintSet::Node { ref specs, parent } => {
|
||||||
if let Some(&(level, src)) = specs.get(&id) {
|
if let Some(&(level, src)) = specs.get(&id) {
|
||||||
|
@ -213,7 +213,7 @@ pub fn struct_lint_level<'s, 'd>(
|
||||||
sess: &'s Session,
|
sess: &'s Session,
|
||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
level: Level,
|
level: Level,
|
||||||
src: LintSource,
|
src: LintLevelSource,
|
||||||
span: Option<MultiSpan>,
|
span: Option<MultiSpan>,
|
||||||
decorate: impl for<'a> FnOnce(LintDiagnosticBuilder<'a>) + 'd,
|
decorate: impl for<'a> FnOnce(LintDiagnosticBuilder<'a>) + 'd,
|
||||||
) {
|
) {
|
||||||
|
@ -223,7 +223,7 @@ pub fn struct_lint_level<'s, 'd>(
|
||||||
sess: &'s Session,
|
sess: &'s Session,
|
||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
level: Level,
|
level: Level,
|
||||||
src: LintSource,
|
src: LintLevelSource,
|
||||||
span: Option<MultiSpan>,
|
span: Option<MultiSpan>,
|
||||||
decorate: Box<dyn for<'b> FnOnce(LintDiagnosticBuilder<'b>) + 'd>,
|
decorate: Box<dyn for<'b> FnOnce(LintDiagnosticBuilder<'b>) + 'd>,
|
||||||
) {
|
) {
|
||||||
|
@ -274,14 +274,14 @@ pub fn struct_lint_level<'s, 'd>(
|
||||||
|
|
||||||
let name = lint.name_lower();
|
let name = lint.name_lower();
|
||||||
match src {
|
match src {
|
||||||
LintSource::Default => {
|
LintLevelSource::Default => {
|
||||||
sess.diag_note_once(
|
sess.diag_note_once(
|
||||||
&mut err,
|
&mut err,
|
||||||
DiagnosticMessageId::from(lint),
|
DiagnosticMessageId::from(lint),
|
||||||
&format!("`#[{}({})]` on by default", level.as_str(), name),
|
&format!("`#[{}({})]` on by default", level.as_str(), name),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
LintSource::CommandLine(lint_flag_val, orig_level) => {
|
LintLevelSource::CommandLine(lint_flag_val, orig_level) => {
|
||||||
let flag = match orig_level {
|
let flag = match orig_level {
|
||||||
Level::Warn => "-W",
|
Level::Warn => "-W",
|
||||||
Level::Deny => "-D",
|
Level::Deny => "-D",
|
||||||
|
@ -310,7 +310,7 @@ pub fn struct_lint_level<'s, 'd>(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LintSource::Node(lint_attr_name, src, reason) => {
|
LintLevelSource::Node(lint_attr_name, src, reason) => {
|
||||||
if let Some(rationale) = reason {
|
if let Some(rationale) = reason {
|
||||||
err.note(&rationale.as_str());
|
err.note(&rationale.as_str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ use crate::dep_graph::{self, DepGraph, DepKind, DepNode, DepNodeExt};
|
||||||
use crate::hir::exports::ExportMap;
|
use crate::hir::exports::ExportMap;
|
||||||
use crate::ich::{NodeIdHashingMode, StableHashingContext};
|
use crate::ich::{NodeIdHashingMode, StableHashingContext};
|
||||||
use crate::infer::canonical::{Canonical, CanonicalVarInfo, CanonicalVarInfos};
|
use crate::infer::canonical::{Canonical, CanonicalVarInfo, CanonicalVarInfos};
|
||||||
use crate::lint::{struct_lint_level, LintDiagnosticBuilder, LintSource};
|
use crate::lint::{struct_lint_level, LintDiagnosticBuilder, LintLevelSource};
|
||||||
use crate::middle;
|
use crate::middle;
|
||||||
use crate::middle::cstore::{CrateStoreDyn, EncodedMetadata};
|
use crate::middle::cstore::{CrateStoreDyn, EncodedMetadata};
|
||||||
use crate::middle::resolve_lifetime::{self, ObjectLifetimeDefault};
|
use crate::middle::resolve_lifetime::{self, ObjectLifetimeDefault};
|
||||||
|
@ -2559,7 +2559,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
self,
|
self,
|
||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
mut id: hir::HirId,
|
mut id: hir::HirId,
|
||||||
) -> (Level, LintSource) {
|
) -> (Level, LintLevelSource) {
|
||||||
let sets = self.lint_levels(LOCAL_CRATE);
|
let sets = self.lint_levels(LOCAL_CRATE);
|
||||||
loop {
|
loop {
|
||||||
if let Some(pair) = sets.level_and_source(lint, id, self.sess) {
|
if let Some(pair) = sets.level_and_source(lint, id, self.sess) {
|
||||||
|
|
|
@ -5,7 +5,7 @@ use crate::html::markdown::{find_testable_code, ErrorCodes};
|
||||||
use crate::passes::doc_test_lints::{should_have_doc_example, Tests};
|
use crate::passes::doc_test_lints::{should_have_doc_example, Tests};
|
||||||
use crate::passes::Pass;
|
use crate::passes::Pass;
|
||||||
use rustc_lint::builtin::MISSING_DOCS;
|
use rustc_lint::builtin::MISSING_DOCS;
|
||||||
use rustc_middle::lint::LintSource;
|
use rustc_middle::lint::LintLevelSource;
|
||||||
use rustc_session::lint;
|
use rustc_session::lint;
|
||||||
use rustc_span::symbol::sym;
|
use rustc_span::symbol::sym;
|
||||||
use rustc_span::FileName;
|
use rustc_span::FileName;
|
||||||
|
@ -254,7 +254,7 @@ impl<'a, 'b> fold::DocFolder for CoverageCalculator<'a, 'b> {
|
||||||
// `missing_docs` is allow-by-default, so don't treat this as ignoring the item
|
// `missing_docs` is allow-by-default, so don't treat this as ignoring the item
|
||||||
// unless the user had an explicit `allow`
|
// unless the user had an explicit `allow`
|
||||||
let should_have_docs =
|
let should_have_docs =
|
||||||
level != lint::Level::Allow || matches!(source, LintSource::Default);
|
level != lint::Level::Allow || matches!(source, LintLevelSource::Default);
|
||||||
debug!("counting {:?} {:?} in {}", i.type_(), i.name, filename);
|
debug!("counting {:?} {:?} in {}", i.type_(), i.name, filename);
|
||||||
self.items.entry(filename).or_default().count_item(
|
self.items.entry(filename).or_default().count_item(
|
||||||
has_docs,
|
has_docs,
|
||||||
|
|
|
@ -9,7 +9,7 @@ use crate::clean::*;
|
||||||
use crate::core::DocContext;
|
use crate::core::DocContext;
|
||||||
use crate::fold::DocFolder;
|
use crate::fold::DocFolder;
|
||||||
use crate::html::markdown::{find_testable_code, ErrorCodes, Ignore, LangString};
|
use crate::html::markdown::{find_testable_code, ErrorCodes, Ignore, LangString};
|
||||||
use rustc_middle::lint::LintSource;
|
use rustc_middle::lint::LintLevelSource;
|
||||||
use rustc_session::lint;
|
use rustc_session::lint;
|
||||||
|
|
||||||
crate const CHECK_PRIVATE_ITEMS_DOC_TESTS: Pass = Pass {
|
crate const CHECK_PRIVATE_ITEMS_DOC_TESTS: Pass = Pass {
|
||||||
|
@ -77,7 +77,7 @@ crate fn should_have_doc_example(cx: &DocContext<'_>, item: &clean::Item) -> boo
|
||||||
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(item.def_id.expect_local());
|
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(item.def_id.expect_local());
|
||||||
let (level, source) =
|
let (level, source) =
|
||||||
cx.tcx.lint_level_at_node(lint::builtin::MISSING_DOC_CODE_EXAMPLES, hir_id);
|
cx.tcx.lint_level_at_node(lint::builtin::MISSING_DOC_CODE_EXAMPLES, hir_id);
|
||||||
level != lint::Level::Allow || matches!(source, LintSource::Default)
|
level != lint::Level::Allow || matches!(source, LintLevelSource::Default)
|
||||||
}
|
}
|
||||||
|
|
||||||
crate fn look_for_tests<'tcx>(cx: &DocContext<'tcx>, dox: &str, item: &Item) {
|
crate fn look_for_tests<'tcx>(cx: &DocContext<'tcx>, dox: &str, item: &Item) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue