Add warn(unreachable_pub) to rustc_lint.

This commit is contained in:
Nicholas Nethercote 2024-08-27 15:24:11 +10:00
parent 6c84c55c9f
commit f10284162f
11 changed files with 269 additions and 268 deletions

View File

@ -413,7 +413,7 @@ pub fn check_ast_node<'a>(
}
}
pub fn check_ast_node_inner<'a, T: EarlyLintPass>(
fn check_ast_node_inner<'a, T: EarlyLintPass>(
sess: &Session,
check_node: impl EarlyCheckNode<'a>,
context: EarlyContext<'_>,

View File

@ -8,7 +8,7 @@ use crate::fluent_generated as fluent;
#[derive(Diagnostic)]
#[diag(lint_overruled_attribute, code = E0453)]
pub struct OverruledAttribute<'a> {
pub(crate) struct OverruledAttribute<'a> {
#[primary_span]
pub span: Span,
#[label]
@ -19,7 +19,7 @@ pub struct OverruledAttribute<'a> {
pub sub: OverruledAttributeSub,
}
pub enum OverruledAttributeSub {
pub(crate) enum OverruledAttributeSub {
DefaultSource { id: String },
NodeSource { span: Span, reason: Option<Symbol> },
CommandLineSource,
@ -52,7 +52,7 @@ impl Subdiagnostic for OverruledAttributeSub {
#[derive(Diagnostic)]
#[diag(lint_malformed_attribute, code = E0452)]
pub struct MalformedAttribute {
pub(crate) struct MalformedAttribute {
#[primary_span]
pub span: Span,
#[subdiagnostic]
@ -60,7 +60,7 @@ pub struct MalformedAttribute {
}
#[derive(Subdiagnostic)]
pub enum MalformedAttributeSub {
pub(crate) enum MalformedAttributeSub {
#[label(lint_bad_attribute_argument)]
BadAttributeArgument(#[primary_span] Span),
#[label(lint_reason_must_be_string_literal)]
@ -71,7 +71,7 @@ pub enum MalformedAttributeSub {
#[derive(Diagnostic)]
#[diag(lint_unknown_tool_in_scoped_lint, code = E0710)]
pub struct UnknownToolInScopedLint {
pub(crate) struct UnknownToolInScopedLint {
#[primary_span]
pub span: Option<Span>,
pub tool_name: Symbol,
@ -82,7 +82,7 @@ pub struct UnknownToolInScopedLint {
#[derive(Diagnostic)]
#[diag(lint_builtin_ellipsis_inclusive_range_patterns, code = E0783)]
pub struct BuiltinEllipsisInclusiveRangePatterns {
pub(crate) struct BuiltinEllipsisInclusiveRangePatterns {
#[primary_span]
pub span: Span,
#[suggestion(style = "short", code = "{replace}", applicability = "machine-applicable")]
@ -92,20 +92,20 @@ pub struct BuiltinEllipsisInclusiveRangePatterns {
#[derive(Subdiagnostic)]
#[note(lint_requested_level)]
pub struct RequestedLevel<'a> {
pub(crate) struct RequestedLevel<'a> {
pub level: Level,
pub lint_name: &'a str,
}
#[derive(Diagnostic)]
#[diag(lint_unsupported_group, code = E0602)]
pub struct UnsupportedGroup {
pub(crate) struct UnsupportedGroup {
pub lint_group: String,
}
#[derive(Diagnostic)]
#[diag(lint_check_name_unknown_tool, code = E0602)]
pub struct CheckNameUnknownTool<'a> {
pub(crate) struct CheckNameUnknownTool<'a> {
pub tool_name: Symbol,
#[subdiagnostic]
pub sub: RequestedLevel<'a>,

View File

@ -47,7 +47,7 @@ macro_rules! lint_callback { ($cx:expr, $f:ident, $($args:expr),*) => ({
/// Implements the AST traversal for late lint passes. `T` provides the
/// `check_*` methods.
pub struct LateContextAndPass<'tcx, T: LateLintPass<'tcx>> {
struct LateContextAndPass<'tcx, T: LateLintPass<'tcx>> {
context: LateContext<'tcx>,
pass: T,
}

View File

@ -1103,7 +1103,7 @@ pub(crate) fn provide(providers: &mut Providers) {
*providers = Providers { shallow_lint_levels_on, lint_expectations, ..*providers };
}
pub fn parse_lint_and_tool_name(lint_name: &str) -> (Option<Symbol>, &str) {
pub(crate) fn parse_lint_and_tool_name(lint_name: &str) -> (Option<Symbol>, &str) {
match lint_name.split_once("::") {
Some((tool_name, lint_name)) => {
let tool_name = Symbol::intern(tool_name);

View File

@ -39,6 +39,7 @@
#![feature(rustc_attrs)]
#![feature(rustdoc_internals)]
#![feature(trait_upcasting)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
mod async_closures;

File diff suppressed because it is too large Load Diff

View File

@ -55,7 +55,7 @@ declare_lint! {
}
#[derive(Default)]
pub struct NonLocalDefinitions {
pub(crate) struct NonLocalDefinitions {
body_depth: u32,
}

View File

@ -17,13 +17,13 @@ use crate::lints::{
use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext};
#[derive(PartialEq)]
pub enum MethodLateContext {
pub(crate) enum MethodLateContext {
TraitAutoImpl,
TraitImpl,
PlainImpl,
}
pub fn method_context(cx: &LateContext<'_>, id: LocalDefId) -> MethodLateContext {
pub(crate) fn method_context(cx: &LateContext<'_>, id: LocalDefId) -> MethodLateContext {
let item = cx.tcx.associated_item(id);
match item.container {
ty::TraitContainer => MethodLateContext::TraitAutoImpl,

View File

@ -65,7 +65,7 @@ declare_lint! {
}
#[derive(Copy, Clone)]
pub struct ShadowedIntoIter;
pub(crate) struct ShadowedIntoIter;
impl_lint_pass!(ShadowedIntoIter => [ARRAY_INTO_ITER, BOXED_SLICE_INTO_ITER]);

View File

@ -165,7 +165,7 @@ declare_lint! {
}
#[derive(Copy, Clone)]
pub struct TypeLimits {
pub(crate) struct TypeLimits {
/// Id of the last visited negated expression
negated_expr_id: Option<hir::HirId>,
/// Span of the last visited negated expression
@ -180,7 +180,7 @@ impl_lint_pass!(TypeLimits => [
]);
impl TypeLimits {
pub fn new() -> TypeLimits {
pub(crate) fn new() -> TypeLimits {
TypeLimits { negated_expr_id: None, negated_expr_span: None }
}
}
@ -1008,7 +1008,7 @@ pub(crate) fn nonnull_optimization_guaranteed<'tcx>(
/// `repr(transparent)` structs can have a single non-1-ZST field, this function returns that
/// field.
pub fn transparent_newtype_field<'a, 'tcx>(
pub(crate) fn transparent_newtype_field<'a, 'tcx>(
tcx: TyCtxt<'tcx>,
variant: &'a ty::VariantDef,
) -> Option<&'a ty::FieldDef> {

View File

@ -1019,7 +1019,7 @@ declare_lint! {
"`if`, `match`, `while` and `return` do not need parentheses"
}
pub struct UnusedParens {
pub(crate) struct UnusedParens {
with_self_ty_parens: bool,
/// `1 as (i32) < 2` parses to ExprKind::Lt
/// `1 as i32 < 2` parses to i32::<2[missing angle bracket]
@ -1027,7 +1027,7 @@ pub struct UnusedParens {
}
impl UnusedParens {
pub fn new() -> Self {
pub(crate) fn new() -> Self {
Self { with_self_ty_parens: false, parens_in_cast_in_lt: Vec::new() }
}
}