Make LevelAndSource a struct
This commit is contained in:
parent
f3eaf1624c
commit
c51816ee59
23 changed files with 105 additions and 86 deletions
|
@ -959,9 +959,9 @@ fn link_natively(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let (level, src) = codegen_results.crate_info.lint_levels.linker_messages;
|
let level = codegen_results.crate_info.lint_levels.linker_messages;
|
||||||
let lint = |msg| {
|
let lint = |msg| {
|
||||||
lint_level(sess, LINKER_MESSAGES, level, src, None, |diag| {
|
lint_level(sess, LINKER_MESSAGES, level, None, |diag| {
|
||||||
LinkerOutput { inner: msg }.decorate_lint(diag)
|
LinkerOutput { inner: msg }.decorate_lint(diag)
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
|
@ -34,7 +34,7 @@ use rustc_hir::CRATE_HIR_ID;
|
||||||
use rustc_hir::def_id::CrateNum;
|
use rustc_hir::def_id::CrateNum;
|
||||||
use rustc_macros::{Decodable, Encodable, HashStable};
|
use rustc_macros::{Decodable, Encodable, HashStable};
|
||||||
use rustc_middle::dep_graph::WorkProduct;
|
use rustc_middle::dep_graph::WorkProduct;
|
||||||
use rustc_middle::lint::LintLevelSource;
|
use rustc_middle::lint::LevelAndSource;
|
||||||
use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile;
|
use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile;
|
||||||
use rustc_middle::middle::dependency_format::Dependencies;
|
use rustc_middle::middle::dependency_format::Dependencies;
|
||||||
use rustc_middle::middle::exported_symbols::SymbolExportKind;
|
use rustc_middle::middle::exported_symbols::SymbolExportKind;
|
||||||
|
@ -45,7 +45,6 @@ use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
|
||||||
use rustc_session::Session;
|
use rustc_session::Session;
|
||||||
use rustc_session::config::{CrateType, OutputFilenames, OutputType, RUST_CGU_EXT};
|
use rustc_session::config::{CrateType, OutputFilenames, OutputType, RUST_CGU_EXT};
|
||||||
use rustc_session::cstore::{self, CrateSource};
|
use rustc_session::cstore::{self, CrateSource};
|
||||||
use rustc_session::lint::Level;
|
|
||||||
use rustc_session::lint::builtin::LINKER_MESSAGES;
|
use rustc_session::lint::builtin::LINKER_MESSAGES;
|
||||||
use rustc_session::utils::NativeLibKind;
|
use rustc_session::utils::NativeLibKind;
|
||||||
use rustc_span::Symbol;
|
use rustc_span::Symbol;
|
||||||
|
@ -341,7 +340,7 @@ impl CodegenResults {
|
||||||
/// Instead, encode exactly the information we need.
|
/// Instead, encode exactly the information we need.
|
||||||
#[derive(Copy, Clone, Debug, Encodable, Decodable)]
|
#[derive(Copy, Clone, Debug, Encodable, Decodable)]
|
||||||
pub struct CodegenLintLevels {
|
pub struct CodegenLintLevels {
|
||||||
linker_messages: (Level, LintLevelSource),
|
linker_messages: LevelAndSource,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CodegenLintLevels {
|
impl CodegenLintLevels {
|
||||||
|
|
|
@ -546,7 +546,7 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
|
||||||
rustc_session::lint::builtin::LONG_RUNNING_CONST_EVAL,
|
rustc_session::lint::builtin::LONG_RUNNING_CONST_EVAL,
|
||||||
hir_id,
|
hir_id,
|
||||||
)
|
)
|
||||||
.0
|
.level
|
||||||
.is_error();
|
.is_error();
|
||||||
let span = ecx.cur_span();
|
let span = ecx.cur_span();
|
||||||
ecx.tcx.emit_node_span_lint(
|
ecx.tcx.emit_node_span_lint(
|
||||||
|
|
|
@ -2323,8 +2323,9 @@ fn should_do_rust_2021_incompatible_closure_captures_analysis(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let (level, _) =
|
let level = tcx
|
||||||
tcx.lint_level_at_node(lint::builtin::RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES, closure_id);
|
.lint_level_at_node(lint::builtin::RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES, closure_id)
|
||||||
|
.level;
|
||||||
|
|
||||||
!matches!(level, lint::Level::Allow)
|
!matches!(level, lint::Level::Allow)
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ use rustc_hir::def_id::{CRATE_DEF_ID, DefId, LocalDefId};
|
||||||
use rustc_hir::intravisit::FnKind as HirFnKind;
|
use rustc_hir::intravisit::FnKind as HirFnKind;
|
||||||
use rustc_hir::{Body, FnDecl, GenericParamKind, PatKind, PredicateOrigin};
|
use rustc_hir::{Body, FnDecl, GenericParamKind, PatKind, PredicateOrigin};
|
||||||
use rustc_middle::bug;
|
use rustc_middle::bug;
|
||||||
|
use rustc_middle::lint::LevelAndSource;
|
||||||
use rustc_middle::ty::layout::LayoutOf;
|
use rustc_middle::ty::layout::LayoutOf;
|
||||||
use rustc_middle::ty::print::with_no_trimmed_paths;
|
use rustc_middle::ty::print::with_no_trimmed_paths;
|
||||||
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt, Upcast, VariantDef};
|
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt, Upcast, VariantDef};
|
||||||
|
@ -694,7 +695,8 @@ impl<'tcx> LateLintPass<'tcx> for MissingDebugImplementations {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Avoid listing trait impls if the trait is allowed.
|
// Avoid listing trait impls if the trait is allowed.
|
||||||
let (level, _) = cx.tcx.lint_level_at_node(MISSING_DEBUG_IMPLEMENTATIONS, item.hir_id());
|
let LevelAndSource { level, .. } =
|
||||||
|
cx.tcx.lint_level_at_node(MISSING_DEBUG_IMPLEMENTATIONS, item.hir_id());
|
||||||
if level == Level::Allow {
|
if level == Level::Allow {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -643,7 +643,7 @@ impl<'tcx> LintContext for LateContext<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_lint_level(&self, lint: &'static Lint) -> Level {
|
fn get_lint_level(&self, lint: &'static Lint) -> Level {
|
||||||
self.tcx.lint_level_at_node(lint, self.last_node_with_lint_attrs).0
|
self.tcx.lint_level_at_node(lint, self.last_node_with_lint_attrs).level
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -664,7 +664,7 @@ impl LintContext for EarlyContext<'_> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_lint_level(&self, lint: &'static Lint) -> Level {
|
fn get_lint_level(&self, lint: &'static Lint) -> Level {
|
||||||
self.builder.lint_level(lint).0
|
self.builder.lint_level(lint).level
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ impl LintLevelSets {
|
||||||
let level = reveal_actual_level(level, &mut src, sess, lint, |id| {
|
let level = reveal_actual_level(level, &mut src, sess, lint, |id| {
|
||||||
self.raw_lint_id_level(id, idx, aux)
|
self.raw_lint_id_level(id, idx, aux)
|
||||||
});
|
});
|
||||||
(level, src)
|
LevelAndSource { level, src }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn raw_lint_id_level(
|
fn raw_lint_id_level(
|
||||||
|
@ -97,14 +97,14 @@ impl LintLevelSets {
|
||||||
aux: Option<&FxIndexMap<LintId, LevelAndSource>>,
|
aux: Option<&FxIndexMap<LintId, LevelAndSource>>,
|
||||||
) -> (Option<Level>, LintLevelSource) {
|
) -> (Option<Level>, LintLevelSource) {
|
||||||
if let Some(specs) = aux
|
if let Some(specs) = aux
|
||||||
&& let Some(&(level, src)) = specs.get(&id)
|
&& let Some(&LevelAndSource { level, src }) = specs.get(&id)
|
||||||
{
|
{
|
||||||
return (Some(level), src);
|
return (Some(level), src);
|
||||||
}
|
}
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let LintSet { ref specs, parent } = self.list[idx];
|
let LintSet { ref specs, parent } = self.list[idx];
|
||||||
if let Some(&(level, src)) = specs.get(&id) {
|
if let Some(&LevelAndSource { level, src }) = specs.get(&id) {
|
||||||
return (Some(level), src);
|
return (Some(level), src);
|
||||||
}
|
}
|
||||||
if idx == COMMAND_LINE {
|
if idx == COMMAND_LINE {
|
||||||
|
@ -131,8 +131,8 @@ fn lints_that_dont_need_to_run(tcx: TyCtxt<'_>, (): ()) -> FxIndexSet<LintId> {
|
||||||
})
|
})
|
||||||
.filter_map(|lint| {
|
.filter_map(|lint| {
|
||||||
let lint_level = map.lint_level_id_at_node(tcx, LintId::of(lint), CRATE_HIR_ID);
|
let lint_level = map.lint_level_id_at_node(tcx, LintId::of(lint), CRATE_HIR_ID);
|
||||||
if matches!(lint_level, (Level::Allow, ..))
|
if matches!(lint_level.level, Level::Allow)
|
||||||
|| (matches!(lint_level, (.., LintLevelSource::Default)))
|
|| (matches!(lint_level.src, LintLevelSource::Default))
|
||||||
&& lint.default_level(tcx.sess.edition()) == Level::Allow
|
&& lint.default_level(tcx.sess.edition()) == Level::Allow
|
||||||
{
|
{
|
||||||
Some(LintId::of(lint))
|
Some(LintId::of(lint))
|
||||||
|
@ -595,7 +595,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
||||||
};
|
};
|
||||||
for id in ids {
|
for id in ids {
|
||||||
// ForceWarn and Forbid cannot be overridden
|
// ForceWarn and Forbid cannot be overridden
|
||||||
if let Some((Level::ForceWarn(_) | Level::Forbid, _)) =
|
if let Some(LevelAndSource { level: Level::ForceWarn(_) | Level::Forbid, .. }) =
|
||||||
self.current_specs().get(&id)
|
self.current_specs().get(&id)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
@ -603,7 +603,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
||||||
|
|
||||||
if self.check_gated_lint(id, DUMMY_SP, true) {
|
if self.check_gated_lint(id, DUMMY_SP, true) {
|
||||||
let src = LintLevelSource::CommandLine(lint_flag_val, orig_level);
|
let src = LintLevelSource::CommandLine(lint_flag_val, orig_level);
|
||||||
self.insert(id, (level, src));
|
self.insert(id, LevelAndSource { level, src });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -612,8 +612,9 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
||||||
/// Attempts to insert the `id` to `level_src` map entry. If unsuccessful
|
/// Attempts to insert the `id` to `level_src` map entry. If unsuccessful
|
||||||
/// (e.g. if a forbid was already inserted on the same scope), then emits a
|
/// (e.g. if a forbid was already inserted on the same scope), then emits a
|
||||||
/// diagnostic with no change to `specs`.
|
/// diagnostic with no change to `specs`.
|
||||||
fn insert_spec(&mut self, id: LintId, (level, src): LevelAndSource) {
|
fn insert_spec(&mut self, id: LintId, LevelAndSource { level, src }: LevelAndSource) {
|
||||||
let (old_level, old_src) = self.provider.get_lint_level(id.lint, self.sess);
|
let LevelAndSource { level: old_level, src: old_src } =
|
||||||
|
self.provider.get_lint_level(id.lint, self.sess);
|
||||||
|
|
||||||
// Setting to a non-forbid level is an error if the lint previously had
|
// Setting to a non-forbid level is an error if the lint previously had
|
||||||
// a forbid level. Note that this is not necessarily true even with a
|
// a forbid level. Note that this is not necessarily true even with a
|
||||||
|
@ -693,13 +694,16 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
||||||
|
|
||||||
match (old_level, level) {
|
match (old_level, level) {
|
||||||
// If the new level is an expectation store it in `ForceWarn`
|
// If the new level is an expectation store it in `ForceWarn`
|
||||||
(Level::ForceWarn(_), Level::Expect(expectation_id)) => {
|
(Level::ForceWarn(_), Level::Expect(expectation_id)) => self.insert(
|
||||||
self.insert(id, (Level::ForceWarn(Some(expectation_id)), old_src))
|
id,
|
||||||
}
|
LevelAndSource { level: Level::ForceWarn(Some(expectation_id)), src: old_src },
|
||||||
|
),
|
||||||
// Keep `ForceWarn` level but drop the expectation
|
// Keep `ForceWarn` level but drop the expectation
|
||||||
(Level::ForceWarn(_), _) => self.insert(id, (Level::ForceWarn(None), old_src)),
|
(Level::ForceWarn(_), _) => {
|
||||||
|
self.insert(id, LevelAndSource { level: Level::ForceWarn(None), src: old_src })
|
||||||
|
}
|
||||||
// Set the lint level as normal
|
// Set the lint level as normal
|
||||||
_ => self.insert(id, (level, src)),
|
_ => self.insert(id, LevelAndSource { level, src }),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -714,7 +718,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
||||||
if attr.has_name(sym::automatically_derived) {
|
if attr.has_name(sym::automatically_derived) {
|
||||||
self.insert(
|
self.insert(
|
||||||
LintId::of(SINGLE_USE_LIFETIMES),
|
LintId::of(SINGLE_USE_LIFETIMES),
|
||||||
(Level::Allow, LintLevelSource::Default),
|
LevelAndSource { level: Level::Allow, src: LintLevelSource::Default },
|
||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -725,7 +729,10 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
||||||
.meta_item_list()
|
.meta_item_list()
|
||||||
.is_some_and(|l| ast::attr::list_contains_name(&l, sym::hidden))
|
.is_some_and(|l| ast::attr::list_contains_name(&l, sym::hidden))
|
||||||
{
|
{
|
||||||
self.insert(LintId::of(MISSING_DOCS), (Level::Allow, LintLevelSource::Default));
|
self.insert(
|
||||||
|
LintId::of(MISSING_DOCS),
|
||||||
|
LevelAndSource { level: Level::Allow, src: LintLevelSource::Default },
|
||||||
|
);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -933,7 +940,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
||||||
let src = LintLevelSource::Node { name, span: sp, reason };
|
let src = LintLevelSource::Node { name, span: sp, reason };
|
||||||
for &id in ids {
|
for &id in ids {
|
||||||
if self.check_gated_lint(id, sp, false) {
|
if self.check_gated_lint(id, sp, false) {
|
||||||
self.insert_spec(id, (level, src));
|
self.insert_spec(id, LevelAndSource { level, src });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -964,7 +971,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.lint_added_lints && !is_crate_node {
|
if self.lint_added_lints && !is_crate_node {
|
||||||
for (id, &(level, ref src)) in self.current_specs().iter() {
|
for (id, &LevelAndSource { level, ref src }) in self.current_specs().iter() {
|
||||||
if !id.lint.crate_level_only {
|
if !id.lint.crate_level_only {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1002,10 +1009,10 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
||||||
|
|
||||||
if self.lint_added_lints {
|
if self.lint_added_lints {
|
||||||
let lint = builtin::UNKNOWN_LINTS;
|
let lint = builtin::UNKNOWN_LINTS;
|
||||||
let (level, src) = self.lint_level(builtin::UNKNOWN_LINTS);
|
let level = self.lint_level(builtin::UNKNOWN_LINTS);
|
||||||
// FIXME: make this translatable
|
// FIXME: make this translatable
|
||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||||
lint_level(self.sess, lint, level, src, Some(span.into()), |lint| {
|
lint_level(self.sess, lint, level, Some(span.into()), |lint| {
|
||||||
lint.primary_message(fluent::lint_unknown_gated_lint);
|
lint.primary_message(fluent::lint_unknown_gated_lint);
|
||||||
lint.arg("name", lint_id.lint.name_lower());
|
lint.arg("name", lint_id.lint.name_lower());
|
||||||
lint.note(fluent::lint_note);
|
lint.note(fluent::lint_note);
|
||||||
|
@ -1040,8 +1047,8 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
||||||
span: Option<MultiSpan>,
|
span: Option<MultiSpan>,
|
||||||
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
||||||
) {
|
) {
|
||||||
let (level, src) = self.lint_level(lint);
|
let level = self.lint_level(lint);
|
||||||
lint_level(self.sess, lint, level, src, span, decorate)
|
lint_level(self.sess, lint, level, span, decorate)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
|
@ -1051,16 +1058,16 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
||||||
span: MultiSpan,
|
span: MultiSpan,
|
||||||
decorate: impl for<'a> LintDiagnostic<'a, ()>,
|
decorate: impl for<'a> LintDiagnostic<'a, ()>,
|
||||||
) {
|
) {
|
||||||
let (level, src) = self.lint_level(lint);
|
let level = self.lint_level(lint);
|
||||||
lint_level(self.sess, lint, level, src, Some(span), |lint| {
|
lint_level(self.sess, lint, level, Some(span), |lint| {
|
||||||
decorate.decorate_lint(lint);
|
decorate.decorate_lint(lint);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn emit_lint(&self, lint: &'static Lint, decorate: impl for<'a> LintDiagnostic<'a, ()>) {
|
pub fn emit_lint(&self, lint: &'static Lint, decorate: impl for<'a> LintDiagnostic<'a, ()>) {
|
||||||
let (level, src) = self.lint_level(lint);
|
let level = self.lint_level(lint);
|
||||||
lint_level(self.sess, lint, level, src, None, |lint| {
|
lint_level(self.sess, lint, level, None, |lint| {
|
||||||
decorate.decorate_lint(lint);
|
decorate.decorate_lint(lint);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,12 +159,13 @@ impl EarlyLintPass for NonAsciiIdents {
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
use unicode_security::GeneralSecurityProfile;
|
use unicode_security::GeneralSecurityProfile;
|
||||||
|
|
||||||
let check_non_ascii_idents = cx.builder.lint_level(NON_ASCII_IDENTS).0 != Level::Allow;
|
let check_non_ascii_idents = cx.builder.lint_level(NON_ASCII_IDENTS).level != Level::Allow;
|
||||||
let check_uncommon_codepoints =
|
let check_uncommon_codepoints =
|
||||||
cx.builder.lint_level(UNCOMMON_CODEPOINTS).0 != Level::Allow;
|
cx.builder.lint_level(UNCOMMON_CODEPOINTS).level != Level::Allow;
|
||||||
let check_confusable_idents = cx.builder.lint_level(CONFUSABLE_IDENTS).0 != Level::Allow;
|
let check_confusable_idents =
|
||||||
|
cx.builder.lint_level(CONFUSABLE_IDENTS).level != Level::Allow;
|
||||||
let check_mixed_script_confusables =
|
let check_mixed_script_confusables =
|
||||||
cx.builder.lint_level(MIXED_SCRIPT_CONFUSABLES).0 != Level::Allow;
|
cx.builder.lint_level(MIXED_SCRIPT_CONFUSABLES).level != Level::Allow;
|
||||||
|
|
||||||
if !check_non_ascii_idents
|
if !check_non_ascii_idents
|
||||||
&& !check_uncommon_codepoints
|
&& !check_uncommon_codepoints
|
||||||
|
|
|
@ -340,7 +340,7 @@ impl CStore {
|
||||||
}
|
}
|
||||||
let level = tcx
|
let level = tcx
|
||||||
.lint_level_at_node(lint::builtin::UNUSED_CRATE_DEPENDENCIES, rustc_hir::CRATE_HIR_ID)
|
.lint_level_at_node(lint::builtin::UNUSED_CRATE_DEPENDENCIES, rustc_hir::CRATE_HIR_ID)
|
||||||
.0;
|
.level;
|
||||||
if level != lint::Level::Allow {
|
if level != lint::Level::Allow {
|
||||||
let unused_externs =
|
let unused_externs =
|
||||||
self.unused_externs.iter().map(|ident| ident.to_ident_string()).collect::<Vec<_>>();
|
self.unused_externs.iter().map(|ident| ident.to_ident_string()).collect::<Vec<_>>();
|
||||||
|
|
|
@ -51,8 +51,12 @@ impl LintLevelSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A tuple of a lint level and its source.
|
/// Convenience helper for moving things around together that frequently are paired
|
||||||
pub type LevelAndSource = (Level, LintLevelSource);
|
#[derive(Copy, Clone, Debug, HashStable, Encodable, Decodable)]
|
||||||
|
pub struct LevelAndSource {
|
||||||
|
pub level: Level,
|
||||||
|
pub src: LintLevelSource,
|
||||||
|
}
|
||||||
|
|
||||||
/// Return type for the `shallow_lint_levels_on` query.
|
/// Return type for the `shallow_lint_levels_on` query.
|
||||||
///
|
///
|
||||||
|
@ -123,7 +127,7 @@ impl ShallowLintLevelMap {
|
||||||
start: HirId,
|
start: HirId,
|
||||||
) -> (Option<Level>, LintLevelSource) {
|
) -> (Option<Level>, LintLevelSource) {
|
||||||
if let Some(map) = self.specs.get(&start.local_id)
|
if let Some(map) = self.specs.get(&start.local_id)
|
||||||
&& let Some(&(level, src)) = map.get(&id)
|
&& let Some(&LevelAndSource { level, src }) = map.get(&id)
|
||||||
{
|
{
|
||||||
return (Some(level), src);
|
return (Some(level), src);
|
||||||
}
|
}
|
||||||
|
@ -137,7 +141,7 @@ impl ShallowLintLevelMap {
|
||||||
specs = &tcx.shallow_lint_levels_on(owner).specs;
|
specs = &tcx.shallow_lint_levels_on(owner).specs;
|
||||||
}
|
}
|
||||||
if let Some(map) = specs.get(&parent.local_id)
|
if let Some(map) = specs.get(&parent.local_id)
|
||||||
&& let Some(&(level, src)) = map.get(&id)
|
&& let Some(&LevelAndSource { level, src }) = map.get(&id)
|
||||||
{
|
{
|
||||||
return (Some(level), src);
|
return (Some(level), src);
|
||||||
}
|
}
|
||||||
|
@ -153,18 +157,18 @@ impl ShallowLintLevelMap {
|
||||||
tcx: TyCtxt<'_>,
|
tcx: TyCtxt<'_>,
|
||||||
lint: LintId,
|
lint: LintId,
|
||||||
cur: HirId,
|
cur: HirId,
|
||||||
) -> (Level, LintLevelSource) {
|
) -> LevelAndSource {
|
||||||
let (level, mut src) = self.probe_for_lint_level(tcx, lint, cur);
|
let (level, mut src) = self.probe_for_lint_level(tcx, lint, cur);
|
||||||
let level = reveal_actual_level(level, &mut src, tcx.sess, lint, |lint| {
|
let level = reveal_actual_level(level, &mut src, tcx.sess, lint, |lint| {
|
||||||
self.probe_for_lint_level(tcx, lint, cur)
|
self.probe_for_lint_level(tcx, lint, cur)
|
||||||
});
|
});
|
||||||
(level, src)
|
LevelAndSource { level, src }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TyCtxt<'_> {
|
impl TyCtxt<'_> {
|
||||||
/// Fetch and return the user-visible lint level for the given lint at the given HirId.
|
/// Fetch and return the user-visible lint level for the given lint at the given HirId.
|
||||||
pub fn lint_level_at_node(self, lint: &'static Lint, id: HirId) -> (Level, LintLevelSource) {
|
pub fn lint_level_at_node(self, lint: &'static Lint, id: HirId) -> LevelAndSource {
|
||||||
self.shallow_lint_levels_on(id.owner).lint_level_id_at_node(self, LintId::of(lint), id)
|
self.shallow_lint_levels_on(id.owner).lint_level_id_at_node(self, LintId::of(lint), id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -267,8 +271,7 @@ fn explain_lint_level_source(
|
||||||
pub fn lint_level(
|
pub fn lint_level(
|
||||||
sess: &Session,
|
sess: &Session,
|
||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
level: Level,
|
level: LevelAndSource,
|
||||||
src: LintLevelSource,
|
|
||||||
span: Option<MultiSpan>,
|
span: Option<MultiSpan>,
|
||||||
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
||||||
) {
|
) {
|
||||||
|
@ -278,11 +281,12 @@ pub fn lint_level(
|
||||||
fn lint_level_impl(
|
fn lint_level_impl(
|
||||||
sess: &Session,
|
sess: &Session,
|
||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
level: Level,
|
level: LevelAndSource,
|
||||||
src: LintLevelSource,
|
|
||||||
span: Option<MultiSpan>,
|
span: Option<MultiSpan>,
|
||||||
decorate: Box<dyn '_ + for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>)>,
|
decorate: Box<dyn '_ + for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>)>,
|
||||||
) {
|
) {
|
||||||
|
let LevelAndSource { level, src } = level;
|
||||||
|
|
||||||
// Check for future incompatibility lints and issue a stronger warning.
|
// Check for future incompatibility lints and issue a stronger warning.
|
||||||
let future_incompatible = lint.future_incompatible;
|
let future_incompatible = lint.future_incompatible;
|
||||||
|
|
||||||
|
@ -421,5 +425,5 @@ pub fn lint_level(
|
||||||
explain_lint_level_source(lint, level, src, &mut err);
|
explain_lint_level_source(lint, level, src, &mut err);
|
||||||
err.emit()
|
err.emit()
|
||||||
}
|
}
|
||||||
lint_level_impl(sess, lint, level, src, span, Box::new(decorate))
|
lint_level_impl(sess, lint, level, span, Box::new(decorate))
|
||||||
}
|
}
|
||||||
|
|
|
@ -255,7 +255,7 @@ fn late_report_deprecation(
|
||||||
// Calculating message for lint involves calling `self.def_path_str`,
|
// Calculating message for lint involves calling `self.def_path_str`,
|
||||||
// which will by default invoke the expensive `visible_parent_map` query.
|
// which will by default invoke the expensive `visible_parent_map` query.
|
||||||
// Skip all that work if the lint is allowed anyway.
|
// Skip all that work if the lint is allowed anyway.
|
||||||
if tcx.lint_level_at_node(lint, hir_id).0 == Level::Allow {
|
if tcx.lint_level_at_node(lint, hir_id).level == Level::Allow {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3022,8 +3022,8 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
decorator: impl for<'a> LintDiagnostic<'a, ()>,
|
decorator: impl for<'a> LintDiagnostic<'a, ()>,
|
||||||
) {
|
) {
|
||||||
let (level, src) = self.lint_level_at_node(lint, hir_id);
|
let level = self.lint_level_at_node(lint, hir_id);
|
||||||
lint_level(self.sess, lint, level, src, Some(span.into()), |lint| {
|
lint_level(self.sess, lint, level, Some(span.into()), |lint| {
|
||||||
decorator.decorate_lint(lint);
|
decorator.decorate_lint(lint);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -3040,8 +3040,8 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
||||||
) {
|
) {
|
||||||
let (level, src) = self.lint_level_at_node(lint, hir_id);
|
let level = self.lint_level_at_node(lint, hir_id);
|
||||||
lint_level(self.sess, lint, level, src, Some(span.into()), decorate);
|
lint_level(self.sess, lint, level, Some(span.into()), decorate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Find the crate root and the appropriate span where `use` and outer attributes can be
|
/// Find the crate root and the appropriate span where `use` and outer attributes can be
|
||||||
|
@ -3108,8 +3108,8 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
id: HirId,
|
id: HirId,
|
||||||
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
|
||||||
) {
|
) {
|
||||||
let (level, src) = self.lint_level_at_node(lint, id);
|
let level = self.lint_level_at_node(lint, id);
|
||||||
lint_level(self.sess, lint, level, src, None, decorate);
|
lint_level(self.sess, lint, level, None, decorate);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn in_scope_traits(self, id: HirId) -> Option<&'tcx [TraitCandidate]> {
|
pub fn in_scope_traits(self, id: HirId) -> Option<&'tcx [TraitCandidate]> {
|
||||||
|
|
|
@ -195,7 +195,7 @@ impl<'tcx> UnsafetyVisitor<'_, 'tcx> {
|
||||||
|
|
||||||
/// Whether the `unsafe_op_in_unsafe_fn` lint is `allow`ed at the current HIR node.
|
/// Whether the `unsafe_op_in_unsafe_fn` lint is `allow`ed at the current HIR node.
|
||||||
fn unsafe_op_in_unsafe_fn_allowed(&self) -> bool {
|
fn unsafe_op_in_unsafe_fn_allowed(&self) -> bool {
|
||||||
self.tcx.lint_level_at_node(UNSAFE_OP_IN_UNSAFE_FN, self.hir_context).0 == Level::Allow
|
self.tcx.lint_level_at_node(UNSAFE_OP_IN_UNSAFE_FN, self.hir_context).level == Level::Allow
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handle closures/coroutines/inline-consts, which is unsafecked with their parent body.
|
/// Handle closures/coroutines/inline-consts, which is unsafecked with their parent body.
|
||||||
|
@ -292,8 +292,10 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
BlockSafety::ExplicitUnsafe(hir_id) => {
|
BlockSafety::ExplicitUnsafe(hir_id) => {
|
||||||
let used =
|
let used = matches!(
|
||||||
matches!(self.tcx.lint_level_at_node(UNUSED_UNSAFE, hir_id), (Level::Allow, _));
|
self.tcx.lint_level_at_node(UNUSED_UNSAFE, hir_id).level,
|
||||||
|
Level::Allow
|
||||||
|
);
|
||||||
self.in_safety_context(
|
self.in_safety_context(
|
||||||
SafetyContext::UnsafeBlock {
|
SafetyContext::UnsafeBlock {
|
||||||
span: block.span,
|
span: block.span,
|
||||||
|
|
|
@ -1025,7 +1025,7 @@ fn find_fallback_pattern_typo<'tcx>(
|
||||||
pat: &Pat<'tcx>,
|
pat: &Pat<'tcx>,
|
||||||
lint: &mut UnreachablePattern<'_>,
|
lint: &mut UnreachablePattern<'_>,
|
||||||
) {
|
) {
|
||||||
if let (Level::Allow, _) = cx.tcx.lint_level_at_node(UNREACHABLE_PATTERNS, hir_id) {
|
if let Level::Allow = cx.tcx.lint_level_at_node(UNREACHABLE_PATTERNS, hir_id).level {
|
||||||
// This is because we use `with_no_trimmed_paths` later, so if we never emit the lint we'd
|
// This is because we use `with_no_trimmed_paths` later, so if we never emit the lint we'd
|
||||||
// ICE. At the same time, we don't really need to do all of this if we won't emit anything.
|
// ICE. At the same time, we don't really need to do all of this if we won't emit anything.
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -696,7 +696,7 @@ fn has_allow_dead_code_or_lang_attr(
|
||||||
|
|
||||||
fn has_allow_expect_dead_code(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
|
fn has_allow_expect_dead_code(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
|
||||||
let hir_id = tcx.local_def_id_to_hir_id(def_id);
|
let hir_id = tcx.local_def_id_to_hir_id(def_id);
|
||||||
let lint_level = tcx.lint_level_at_node(lint::builtin::DEAD_CODE, hir_id).0;
|
let lint_level = tcx.lint_level_at_node(lint::builtin::DEAD_CODE, hir_id).level;
|
||||||
matches!(lint_level, lint::Allow | lint::Expect(_))
|
matches!(lint_level, lint::Allow | lint::Expect(_))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -961,7 +961,7 @@ impl<'tcx> DeadVisitor<'tcx> {
|
||||||
|
|
||||||
fn def_lint_level(&self, id: LocalDefId) -> lint::Level {
|
fn def_lint_level(&self, id: LocalDefId) -> lint::Level {
|
||||||
let hir_id = self.tcx.local_def_id_to_hir_id(id);
|
let hir_id = self.tcx.local_def_id_to_hir_id(id);
|
||||||
self.tcx.lint_level_at_node(DEAD_CODE, hir_id).0
|
self.tcx.lint_level_at_node(DEAD_CODE, hir_id).level
|
||||||
}
|
}
|
||||||
|
|
||||||
// # Panics
|
// # Panics
|
||||||
|
|
|
@ -980,7 +980,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'tcx> {
|
||||||
// Calculating message for lint involves calling `self.def_path_str`,
|
// Calculating message for lint involves calling `self.def_path_str`,
|
||||||
// which will by default invoke the expensive `visible_parent_map` query.
|
// which will by default invoke the expensive `visible_parent_map` query.
|
||||||
// Skip all that work if the lint is allowed anyway.
|
// Skip all that work if the lint is allowed anyway.
|
||||||
if self.tcx.lint_level_at_node(DEPRECATED, id).0
|
if self.tcx.lint_level_at_node(DEPRECATED, id).level
|
||||||
== lint::Level::Allow
|
== lint::Level::Allow
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use rustc_middle::lint::LevelAndSource;
|
||||||
use rustc_session::lint::builtin::NON_EXHAUSTIVE_OMITTED_PATTERNS;
|
use rustc_session::lint::builtin::NON_EXHAUSTIVE_OMITTED_PATTERNS;
|
||||||
use rustc_span::ErrorGuaranteed;
|
use rustc_span::ErrorGuaranteed;
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
@ -64,7 +65,7 @@ pub(crate) fn lint_nonexhaustive_missing_variants<'p, 'tcx>(
|
||||||
scrut_ty: RevealedTy<'tcx>,
|
scrut_ty: RevealedTy<'tcx>,
|
||||||
) -> Result<(), ErrorGuaranteed> {
|
) -> Result<(), ErrorGuaranteed> {
|
||||||
if !matches!(
|
if !matches!(
|
||||||
rcx.tcx.lint_level_at_node(NON_EXHAUSTIVE_OMITTED_PATTERNS, rcx.match_lint_level).0,
|
rcx.tcx.lint_level_at_node(NON_EXHAUSTIVE_OMITTED_PATTERNS, rcx.match_lint_level).level,
|
||||||
rustc_session::lint::Level::Allow
|
rustc_session::lint::Level::Allow
|
||||||
) {
|
) {
|
||||||
let witnesses = collect_nonexhaustive_missing_variants(rcx, pat_column)?;
|
let witnesses = collect_nonexhaustive_missing_variants(rcx, pat_column)?;
|
||||||
|
@ -88,13 +89,13 @@ pub(crate) fn lint_nonexhaustive_missing_variants<'p, 'tcx>(
|
||||||
// arm. This no longer makes sense so we warn users, to avoid silently breaking their
|
// arm. This no longer makes sense so we warn users, to avoid silently breaking their
|
||||||
// usage of the lint.
|
// usage of the lint.
|
||||||
for arm in arms {
|
for arm in arms {
|
||||||
let (lint_level, lint_level_source) =
|
let LevelAndSource { level, src } =
|
||||||
rcx.tcx.lint_level_at_node(NON_EXHAUSTIVE_OMITTED_PATTERNS, arm.arm_data);
|
rcx.tcx.lint_level_at_node(NON_EXHAUSTIVE_OMITTED_PATTERNS, arm.arm_data);
|
||||||
if !matches!(lint_level, rustc_session::lint::Level::Allow) {
|
if !matches!(level, rustc_session::lint::Level::Allow) {
|
||||||
let decorator = NonExhaustiveOmittedPatternLintOnArm {
|
let decorator = NonExhaustiveOmittedPatternLintOnArm {
|
||||||
lint_span: lint_level_source.span(),
|
lint_span: src.span(),
|
||||||
suggest_lint_on_match: rcx.whole_match_span.map(|span| span.shrink_to_lo()),
|
suggest_lint_on_match: rcx.whole_match_span.map(|span| span.shrink_to_lo()),
|
||||||
lint_level: lint_level.as_str(),
|
lint_level: level.as_str(),
|
||||||
lint_name: "non_exhaustive_omitted_patterns",
|
lint_name: "non_exhaustive_omitted_patterns",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ use std::ops;
|
||||||
|
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_lint::builtin::MISSING_DOCS;
|
use rustc_lint::builtin::MISSING_DOCS;
|
||||||
use rustc_middle::lint::LintLevelSource;
|
use rustc_middle::lint::{LevelAndSource, LintLevelSource};
|
||||||
use rustc_session::lint;
|
use rustc_session::lint;
|
||||||
use rustc_span::FileName;
|
use rustc_span::FileName;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
@ -216,7 +216,8 @@ impl DocVisitor<'_> for CoverageCalculator<'_, '_> {
|
||||||
|
|
||||||
let has_doc_example = tests.found_tests != 0;
|
let has_doc_example = tests.found_tests != 0;
|
||||||
let hir_id = DocContext::as_local_hir_id(self.ctx.tcx, i.item_id).unwrap();
|
let hir_id = DocContext::as_local_hir_id(self.ctx.tcx, i.item_id).unwrap();
|
||||||
let (level, source) = self.ctx.tcx.lint_level_at_node(MISSING_DOCS, hir_id);
|
let LevelAndSource { level, src } =
|
||||||
|
self.ctx.tcx.lint_level_at_node(MISSING_DOCS, hir_id);
|
||||||
|
|
||||||
// In case we have:
|
// In case we have:
|
||||||
//
|
//
|
||||||
|
@ -251,7 +252,7 @@ impl DocVisitor<'_> for CoverageCalculator<'_, '_> {
|
||||||
// unless the user had an explicit `allow`.
|
// unless the user had an explicit `allow`.
|
||||||
//
|
//
|
||||||
let should_have_docs = !should_be_ignored
|
let should_have_docs = !should_be_ignored
|
||||||
&& (level != lint::Level::Allow || matches!(source, LintLevelSource::Default));
|
&& (level != lint::Level::Allow || matches!(src, LintLevelSource::Default));
|
||||||
|
|
||||||
if let Some(span) = i.span(self.ctx.tcx) {
|
if let Some(span) = i.span(self.ctx.tcx) {
|
||||||
let filename = span.filename(self.ctx.sess());
|
let filename = span.filename(self.ctx.sess());
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
//! - PRIVATE_DOC_TESTS: this lint is **STABLE** and looks for private items with doctests.
|
//! - PRIVATE_DOC_TESTS: this lint is **STABLE** and looks for private items with doctests.
|
||||||
|
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_middle::lint::LintLevelSource;
|
use rustc_middle::lint::{LevelAndSource, LintLevelSource};
|
||||||
use rustc_session::lint;
|
use rustc_session::lint;
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
|
@ -107,11 +107,11 @@ pub(crate) fn should_have_doc_example(cx: &DocContext<'_>, item: &clean::Item) -
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let (level, source) = cx.tcx.lint_level_at_node(
|
let LevelAndSource { level, src } = cx.tcx.lint_level_at_node(
|
||||||
crate::lint::MISSING_DOC_CODE_EXAMPLES,
|
crate::lint::MISSING_DOC_CODE_EXAMPLES,
|
||||||
cx.tcx.local_def_id_to_hir_id(def_id),
|
cx.tcx.local_def_id_to_hir_id(def_id),
|
||||||
);
|
);
|
||||||
level != lint::Level::Allow || matches!(source, LintLevelSource::Default)
|
level != lint::Level::Allow || matches!(src, LintLevelSource::Default)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn look_for_tests(cx: &DocContext<'_>, dox: &str, item: &Item) {
|
pub(crate) fn look_for_tests(cx: &DocContext<'_>, dox: &str, item: &Item) {
|
||||||
|
|
|
@ -199,7 +199,7 @@ fn check_simplify_not(cx: &LateContext<'_>, msrv: Msrv, expr: &Expr<'_>) {
|
||||||
&& !expr.span.from_expansion()
|
&& !expr.span.from_expansion()
|
||||||
&& !inner.span.from_expansion()
|
&& !inner.span.from_expansion()
|
||||||
&& let Some(suggestion) = simplify_not(cx, msrv, inner)
|
&& let Some(suggestion) = simplify_not(cx, msrv, inner)
|
||||||
&& cx.tcx.lint_level_at_node(NONMINIMAL_BOOL, expr.hir_id).0 != Level::Allow
|
&& cx.tcx.lint_level_at_node(NONMINIMAL_BOOL, expr.hir_id).level != Level::Allow
|
||||||
{
|
{
|
||||||
use clippy_utils::sugg::{Sugg, has_enclosing_paren};
|
use clippy_utils::sugg::{Sugg, has_enclosing_paren};
|
||||||
let maybe_par = if let Some(sug) = Sugg::hir_opt(cx, inner) {
|
let maybe_par = if let Some(sug) = Sugg::hir_opt(cx, inner) {
|
||||||
|
@ -605,7 +605,7 @@ impl<'tcx> NonminimalBoolVisitor<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let nonminimal_bool_lint = |mut suggestions: Vec<_>| {
|
let nonminimal_bool_lint = |mut suggestions: Vec<_>| {
|
||||||
if self.cx.tcx.lint_level_at_node(NONMINIMAL_BOOL, e.hir_id).0 != Level::Allow {
|
if self.cx.tcx.lint_level_at_node(NONMINIMAL_BOOL, e.hir_id).level != Level::Allow {
|
||||||
suggestions.sort();
|
suggestions.sort();
|
||||||
span_lint_hir_and_then(
|
span_lint_hir_and_then(
|
||||||
self.cx,
|
self.cx,
|
||||||
|
|
|
@ -69,7 +69,7 @@ impl EarlyLintPass for DisallowedScriptIdents {
|
||||||
// Implementation is heavily inspired by the implementation of [`non_ascii_idents`] lint:
|
// Implementation is heavily inspired by the implementation of [`non_ascii_idents`] lint:
|
||||||
// https://github.com/rust-lang/rust/blob/master/compiler/rustc_lint/src/non_ascii_idents.rs
|
// https://github.com/rust-lang/rust/blob/master/compiler/rustc_lint/src/non_ascii_idents.rs
|
||||||
|
|
||||||
let check_disallowed_script_idents = cx.builder.lint_level(DISALLOWED_SCRIPT_IDENTS).0 != Level::Allow;
|
let check_disallowed_script_idents = cx.builder.lint_level(DISALLOWED_SCRIPT_IDENTS).level != Level::Allow;
|
||||||
if !check_disallowed_script_idents {
|
if !check_disallowed_script_idents {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,8 +73,8 @@ impl_lint_pass!(ModStyle => [MOD_MODULE_FILES, SELF_NAMED_MODULE_FILES]);
|
||||||
|
|
||||||
impl EarlyLintPass for ModStyle {
|
impl EarlyLintPass for ModStyle {
|
||||||
fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &ast::Crate) {
|
fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &ast::Crate) {
|
||||||
if cx.builder.lint_level(MOD_MODULE_FILES).0 == Level::Allow
|
if cx.builder.lint_level(MOD_MODULE_FILES).level == Level::Allow
|
||||||
&& cx.builder.lint_level(SELF_NAMED_MODULE_FILES).0 == Level::Allow
|
&& cx.builder.lint_level(SELF_NAMED_MODULE_FILES).level == Level::Allow
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,6 +114,7 @@ use rustc_hir::{
|
||||||
use rustc_lexer::{TokenKind, tokenize};
|
use rustc_lexer::{TokenKind, tokenize};
|
||||||
use rustc_lint::{LateContext, Level, Lint, LintContext};
|
use rustc_lint::{LateContext, Level, Lint, LintContext};
|
||||||
use rustc_middle::hir::place::PlaceBase;
|
use rustc_middle::hir::place::PlaceBase;
|
||||||
|
use rustc_middle::lint::LevelAndSource;
|
||||||
use rustc_middle::mir::{AggregateKind, Operand, RETURN_PLACE, Rvalue, StatementKind, TerminatorKind};
|
use rustc_middle::mir::{AggregateKind, Operand, RETURN_PLACE, Rvalue, StatementKind, TerminatorKind};
|
||||||
use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow};
|
use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow};
|
||||||
use rustc_middle::ty::fast_reject::SimplifiedType;
|
use rustc_middle::ty::fast_reject::SimplifiedType;
|
||||||
|
@ -1976,7 +1977,7 @@ pub fn fulfill_or_allowed(cx: &LateContext<'_>, lint: &'static Lint, ids: impl I
|
||||||
let mut suppress_lint = false;
|
let mut suppress_lint = false;
|
||||||
|
|
||||||
for id in ids {
|
for id in ids {
|
||||||
let (level, _) = cx.tcx.lint_level_at_node(lint, id);
|
let LevelAndSource { level, .. } = cx.tcx.lint_level_at_node(lint, id);
|
||||||
if let Some(expectation) = level.get_expectation_id() {
|
if let Some(expectation) = level.get_expectation_id() {
|
||||||
cx.fulfill_expectation(expectation);
|
cx.fulfill_expectation(expectation);
|
||||||
}
|
}
|
||||||
|
@ -1998,7 +1999,7 @@ pub fn fulfill_or_allowed(cx: &LateContext<'_>, lint: &'static Lint, ids: impl I
|
||||||
/// make sure to use `span_lint_hir` functions to emit the lint. This ensures that
|
/// make sure to use `span_lint_hir` functions to emit the lint. This ensures that
|
||||||
/// expectations at the checked nodes will be fulfilled.
|
/// expectations at the checked nodes will be fulfilled.
|
||||||
pub fn is_lint_allowed(cx: &LateContext<'_>, lint: &'static Lint, id: HirId) -> bool {
|
pub fn is_lint_allowed(cx: &LateContext<'_>, lint: &'static Lint, id: HirId) -> bool {
|
||||||
cx.tcx.lint_level_at_node(lint, id).0 == Level::Allow
|
cx.tcx.lint_level_at_node(lint, id).level == Level::Allow
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn strip_pat_refs<'hir>(mut pat: &'hir Pat<'hir>) -> &'hir Pat<'hir> {
|
pub fn strip_pat_refs<'hir>(mut pat: &'hir Pat<'hir>) -> &'hir Pat<'hir> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue