Skip to content

Commit

Permalink
Add warn(unreachable_pub) to rustc_lint.
Browse files Browse the repository at this point in the history
  • Loading branch information
nnethercote committed Aug 27, 2024
1 parent 6c84c55 commit f102841
Show file tree
Hide file tree
Showing 11 changed files with 269 additions and 268 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/early.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<'_>,
Expand Down
18 changes: 9 additions & 9 deletions compiler/rustc_lint/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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,
Expand Down Expand Up @@ -52,15 +52,15 @@ 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]
pub sub: MalformedAttributeSub,
}

#[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)]
Expand All @@ -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,
Expand All @@ -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")]
Expand All @@ -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>,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/levels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_lint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#![feature(rustc_attrs)]
#![feature(rustdoc_internals)]
#![feature(trait_upcasting)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end

mod async_closures;
Expand Down
Loading

0 comments on commit f102841

Please sign in to comment.