Skip to content

Apply unused_doc_comments lint to inner items #78367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/rustc_ast/src/util/comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct Comment {
/// Makes a doc string more presentable to users.
/// Used by rustdoc and perhaps other tools, but not by rustc.
pub fn beautify_doc_string(data: Symbol) -> String {
/// remove whitespace-only lines from the start/end of lines
// remove whitespace-only lines from the start/end of lines
fn vertical_trim(lines: Vec<String>) -> Vec<String> {
let mut i = 0;
let mut j = lines.len();
Expand All @@ -50,7 +50,7 @@ pub fn beautify_doc_string(data: Symbol) -> String {
lines[i..j].to_vec()
}

/// remove a "[ \t]*\*" block from each line, if possible
// remove a "[ \t]*\*" block from each line, if possible
fn horizontal_trim(lines: Vec<String>) -> Vec<String> {
let mut i = usize::MAX;
let mut can_trim = true;
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,11 @@ impl Visitor<'_> for ImplTraitTypeIdVisitor<'_> {

impl<'a, 'hir> LoweringContext<'a, 'hir> {
fn lower_crate(mut self, c: &Crate) -> hir::Crate<'hir> {
/// Full-crate AST visitor that inserts into a fresh
/// `LoweringContext` any information that may be
/// needed from arbitrary locations in the crate,
/// e.g., the number of lifetime generic parameters
/// declared for every type and trait definition.
// Full-crate AST visitor that inserts into a fresh
// `LoweringContext` any information that may be
// needed from arbitrary locations in the crate,
// e.g., the number of lifetime generic parameters
// declared for every type and trait definition.
struct MiscCollector<'tcx, 'lowering, 'hir> {
lctx: &'tcx mut LoweringContext<'lowering, 'hir>,
hir_id_owner: Option<NodeId>,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ impl EmitterWriter {
// `max_line_num_len`
let padding = " ".repeat(padding + label.len() + 5);

/// Returns `override` if it is present and `style` is `NoStyle` or `style` otherwise
// Returns `override` if it is present and `style` is `NoStyle` or `style` otherwise
fn style_or_override(style: Style, override_: Option<Style>) -> Style {
match (style, override_) {
(Style::NoStyle, Some(override_)) => override_,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_index/src/bit_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ impl<R: Idx, C: Idx> BitMatrix<R, C> {

impl<R: Idx, C: Idx> fmt::Debug for BitMatrix<R, C> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
/// Forces its contents to print in regular mode instead of alternate mode.
// Forces its contents to print in regular mode instead of alternate mode.
struct OneLinePrinter<T>(T);
impl<T: fmt::Debug> fmt::Debug for OneLinePrinter<T> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand Down
23 changes: 11 additions & 12 deletions compiler/rustc_lint/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -994,8 +994,7 @@ impl EarlyLintPass for UnusedDocComment {
fn check_stmt(&mut self, cx: &EarlyContext<'_>, stmt: &ast::Stmt) {
let kind = match stmt.kind {
ast::StmtKind::Local(..) => "statements",
// Disabled pending discussion in #78306
ast::StmtKind::Item(..) => return,
ast::StmtKind::Item(..) => "inner items",
// expressions will be reported by `check_expr`.
ast::StmtKind::Empty
| ast::StmtKind::Semi(_)
Expand Down Expand Up @@ -1659,8 +1658,8 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns {

use self::ast::{PatKind, RangeSyntax::DotDotDot};

/// If `pat` is a `...` pattern, return the start and end of the range, as well as the span
/// corresponding to the ellipsis.
// If `pat` is a `...` pattern, return the start and end of the range, as well as the span
// corresponding to the ellipsis.
fn matches_ellipsis_pat(pat: &ast::Pat) -> Option<(Option<&Expr>, &Expr, Span)> {
match &pat.kind {
PatKind::Range(
Expand Down Expand Up @@ -2349,11 +2348,11 @@ impl<'tcx> LateLintPass<'tcx> for InvalidValue {
Uninit,
};

/// Information about why a type cannot be initialized this way.
/// Contains an error message and optionally a span to point at.
// Information about why a type cannot be initialized this way.
// Contains an error message and optionally a span to point at.
type InitError = (String, Option<Span>);

/// Test if this constant is all-0.
// Test if this constant is all-0.
fn is_zero(expr: &hir::Expr<'_>) -> bool {
use hir::ExprKind::*;
use rustc_ast::LitKind::*;
Expand All @@ -2370,7 +2369,7 @@ impl<'tcx> LateLintPass<'tcx> for InvalidValue {
}
}

/// Determine if this expression is a "dangerous initialization".
// Determine if this expression is a "dangerous initialization".
fn is_dangerous_init(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> Option<InitKind> {
if let hir::ExprKind::Call(ref path_expr, ref args) = expr.kind {
// Find calls to `mem::{uninitialized,zeroed}` methods.
Expand Down Expand Up @@ -2410,16 +2409,16 @@ impl<'tcx> LateLintPass<'tcx> for InvalidValue {
None
}

/// Test if this enum has several actually "existing" variants.
/// Zero-sized uninhabited variants do not always have a tag assigned and thus do not "exist".
// Test if this enum has several actually "existing" variants.
// Zero-sized uninhabited variants do not always have a tag assigned and thus do not "exist".
fn is_multi_variant(adt: &ty::AdtDef) -> bool {
// As an approximation, we only count dataless variants. Those are definitely inhabited.
let existing_variants = adt.variants.iter().filter(|v| v.fields.is_empty()).count();
existing_variants > 1
}

/// Return `Some` only if we are sure this type does *not*
/// allow zero initialization.
// Return `Some` only if we are sure this type does *not*
// allow zero initialization.
fn ty_find_init_error<'tcx>(
tcx: TyCtxt<'tcx>,
ty: Ty<'tcx>,
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_middle/src/mir/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ pub struct GeneratorLayout<'tcx> {

impl Debug for GeneratorLayout<'_> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
/// Prints an iterator of (key, value) tuples as a map.
// Prints an iterator of (key, value) tuples as a map.
struct MapPrinter<'a, K, V>(Cell<Option<Box<dyn Iterator<Item = (K, V)> + 'a>>>);
impl<'a, K, V> MapPrinter<'a, K, V> {
fn new(iter: impl Iterator<Item = (K, V)> + 'a) -> Self {
Expand All @@ -180,7 +180,7 @@ impl Debug for GeneratorLayout<'_> {
}
}

/// Prints the generator variant name.
// Prints the generator variant name.
struct GenVariantPrinter(VariantIdx);
impl From<VariantIdx> for GenVariantPrinter {
fn from(idx: VariantIdx) -> Self {
Expand All @@ -198,7 +198,7 @@ impl Debug for GeneratorLayout<'_> {
}
}

/// Forces its contents to print in regular mode instead of alternate mode.
// Forces its contents to print in regular mode instead of alternate mode.
struct OneLinePrinter<T>(T);
impl<T: Debug> Debug for OneLinePrinter<T> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir/src/interpret/operand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pub struct ImmTy<'tcx, Tag = ()> {

impl<Tag: Copy> std::fmt::Display for ImmTy<'tcx, Tag> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
/// Helper function for printing a scalar to a FmtPrinter
// Helper function for printing a scalar to a FmtPrinter
fn p<'a, 'tcx, F: std::fmt::Write, Tag>(
cx: FmtPrinter<'a, 'tcx, F>,
s: ScalarMaybeUninit<Tag>,
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_mir/src/transform/simplify_try.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ fn get_arm_identity_info<'a, 'tcx>(
matches!(stmt.kind, StatementKind::StorageLive(_) | StatementKind::StorageDead(_))
}

/// Eats consecutive Statements which match `test`, performing the specified `action` for each.
/// The iterator `stmt_iter` is not advanced if none were matched.
// Eats consecutive Statements which match `test`, performing the specified `action` for each.
// The iterator `stmt_iter` is not advanced if none were matched.
fn try_eat<'a, 'tcx>(
stmt_iter: &mut StmtIter<'a, 'tcx>,
test: impl Fn(&'a Statement<'tcx>) -> bool,
Expand All @@ -120,8 +120,8 @@ fn get_arm_identity_info<'a, 'tcx>(
}
}

/// Eats consecutive `StorageLive` and `StorageDead` Statements.
/// The iterator `stmt_iter` is not advanced if none were found.
// Eats consecutive `StorageLive` and `StorageDead` Statements.
// The iterator `stmt_iter` is not advanced if none were found.
fn try_eat_storage_stmts<'a, 'tcx>(
stmt_iter: &mut StmtIter<'a, 'tcx>,
storage_live_stmts: &mut Vec<(usize, Local)>,
Expand All @@ -145,7 +145,7 @@ fn get_arm_identity_info<'a, 'tcx>(
}
}

/// Eats consecutive `Assign` Statements.
// Eats consecutive `Assign` Statements.
// The iterator `stmt_iter` is not advanced if none were found.
fn try_eat_assign_tmp_stmts<'a, 'tcx>(
stmt_iter: &mut StmtIter<'a, 'tcx>,
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_mir_build/src/thir/pattern/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2260,9 +2260,9 @@ fn split_grouped_constructors<'p, 'tcx>(
continue;
}

/// Represents a border between 2 integers. Because the intervals spanning borders
/// must be able to cover every integer, we need to be able to represent
/// 2^128 + 1 such borders.
// Represents a border between 2 integers. Because the intervals spanning borders
// must be able to cover every integer, we need to be able to represent
// 2^128 + 1 such borders.
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)]
enum Border {
JustBefore(u128),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_parse/src/parser/nonterminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ impl<'a> Parser<'a> {
/// Returning `false` is a *stability guarantee* that such a matcher will *never* begin with that
/// token. Be conservative (return true) if not sure.
pub fn nonterminal_may_begin_with(kind: NonterminalKind, token: &Token) -> bool {
/// Checks whether the non-terminal may contain a single (non-keyword) identifier.
// Checks whether the non-terminal may contain a single (non-keyword) identifier.
fn may_be_ident(nt: &token::Nonterminal) -> bool {
match *nt {
token::NtItem(_) | token::NtBlock(_) | token::NtVis(_) | token::NtLifetime(_) => {
Expand Down
80 changes: 40 additions & 40 deletions compiler/rustc_passes/src/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,17 +509,17 @@ fn resolve_local<'tcx>(
visitor.visit_pat(pat);
}

/// Returns `true` if `pat` match the `P&` non-terminal.
///
/// ```text
/// P& = ref X
/// | StructName { ..., P&, ... }
/// | VariantName(..., P&, ...)
/// | [ ..., P&, ... ]
/// | ( ..., P&, ... )
/// | ... "|" P& "|" ...
/// | box P&
/// ```
// Returns `true` if `pat` match the `P&` non-terminal.
//
// ```text
// P& = ref X
// | StructName { ..., P&, ... }
// | VariantName(..., P&, ...)
// | [ ..., P&, ... ]
// | ( ..., P&, ... )
// | ... "|" P& "|" ...
// | box P&
// ```
fn is_binding_pat(pat: &hir::Pat<'_>) -> bool {
// Note that the code below looks for *explicit* refs only, that is, it won't
// know about *implicit* refs as introduced in #42640.
Expand Down Expand Up @@ -576,18 +576,18 @@ fn resolve_local<'tcx>(
}
}

/// If `expr` matches the `E&` grammar, then records an extended rvalue scope as appropriate:
///
/// ```text
/// E& = & ET
/// | StructName { ..., f: E&, ... }
/// | [ ..., E&, ... ]
/// | ( ..., E&, ... )
/// | {...; E&}
/// | box E&
/// | E& as ...
/// | ( E& )
/// ```
// If `expr` matches the `E&` grammar, then records an extended rvalue scope as appropriate:
//
// ```text
// E& = & ET
// | StructName { ..., f: E&, ... }
// | [ ..., E&, ... ]
// | ( ..., E&, ... )
// | {...; E&}
// | box E&
// | E& as ...
// | ( E& )
// ```
fn record_rvalue_scope_if_borrow_expr<'tcx>(
visitor: &mut RegionResolutionVisitor<'tcx>,
expr: &hir::Expr<'_>,
Expand Down Expand Up @@ -620,23 +620,23 @@ fn resolve_local<'tcx>(
}
}

/// Applied to an expression `expr` if `expr` -- or something owned or partially owned by
/// `expr` -- is going to be indirectly referenced by a variable in a let statement. In that
/// case, the "temporary lifetime" or `expr` is extended to be the block enclosing the `let`
/// statement.
///
/// More formally, if `expr` matches the grammar `ET`, record the rvalue scope of the matching
/// `<rvalue>` as `blk_id`:
///
/// ```text
/// ET = *ET
/// | ET[...]
/// | ET.f
/// | (ET)
/// | <rvalue>
/// ```
///
/// Note: ET is intended to match "rvalues or places based on rvalues".
// Applied to an expression `expr` if `expr` -- or something owned or partially owned by
// `expr` -- is going to be indirectly referenced by a variable in a let statement. In that
// case, the "temporary lifetime" or `expr` is extended to be the block enclosing the `let`
// statement.
//
// More formally, if `expr` matches the grammar `ET`, record the rvalue scope of the matching
// `<rvalue>` as `blk_id`:
//
// ```text
// ET = *ET
// | ET[...]
// | ET.f
// | (ET)
// | <rvalue>
// ```
//
// Note: ET is intended to match "rvalues or places based on rvalues".
fn record_rvalue_scope<'tcx>(
visitor: &mut RegionResolutionVisitor<'tcx>,
expr: &hir::Expr<'_>,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
errors: Vec<(String, UnresolvedImportError)>,
span: Option<MultiSpan>,
) {
/// Upper limit on the number of `span_label` messages.
// Upper limit on the number of `span_label` messages.
const MAX_LABEL_COUNT: usize = 10;

let (span, msg) = if errors.is_empty() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1242,8 +1242,8 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
}

fn fuzzy_match_tys(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> bool {
/// returns the fuzzy category of a given type, or None
/// if the type can be equated to any type.
// returns the fuzzy category of a given type, or None
// if the type can be equated to any type.
fn type_category(t: Ty<'_>) -> Option<u32> {
match t.kind() {
ty::Bool => Some(0),
Expand Down
8 changes: 4 additions & 4 deletions library/alloc/src/collections/vec_deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ impl<T: Clone> Clone for VecDeque<T> {
#[stable(feature = "rust1", since = "1.0.0")]
unsafe impl<#[may_dangle] T> Drop for VecDeque<T> {
fn drop(&mut self) {
/// Runs the destructor for all items in the slice when it gets dropped (normally or
/// during unwinding).
// Runs the destructor for all items in the slice when it gets dropped (normally or
// during unwinding).
struct Dropper<'a, T>(&'a mut [T]);

impl<'a, T> Drop for Dropper<'a, T> {
Expand Down Expand Up @@ -901,8 +901,8 @@ impl<T> VecDeque<T> {
/// ```
#[stable(feature = "deque_extras", since = "1.16.0")]
pub fn truncate(&mut self, len: usize) {
/// Runs the destructor for all items in the slice when it gets dropped (normally or
/// during unwinding).
// Runs the destructor for all items in the slice when it gets dropped (normally or
// during unwinding).
struct Dropper<'a, T>(&'a mut [T]);

impl<'a, T> Drop for Dropper<'a, T> {
Expand Down
4 changes: 2 additions & 2 deletions library/alloc/src/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3144,8 +3144,8 @@ impl<T> DoubleEndedIterator for Drain<'_, T> {
#[stable(feature = "drain", since = "1.6.0")]
impl<T> Drop for Drain<'_, T> {
fn drop(&mut self) {
/// Continues dropping the remaining elements in the `Drain`, then moves back the
/// un-`Drain`ed elements to restore the original `Vec`.
// Continues dropping the remaining elements in the `Drain`, then moves back the
// un-`Drain`ed elements to restore the original `Vec`.
struct DropGuard<'r, 'a, T>(&'r mut Drain<'a, T>);

impl<'r, 'a, T> Drop for DropGuard<'r, 'a, T> {
Expand Down
4 changes: 2 additions & 2 deletions library/alloc/tests/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1541,8 +1541,8 @@ fn test_try_reserve_exact() {

#[test]
fn test_stable_pointers() {
/// Pull an element from the iterator, then drop it.
/// Useful to cover both the `next` and `drop` paths of an iterator.
// Pull an element from the iterator, then drop it.
// Useful to cover both the `next` and `drop` paths of an iterator.
fn next_then_drop<I: Iterator>(mut i: I) {
i.next().unwrap();
drop(i);
Expand Down
3 changes: 2 additions & 1 deletion library/core/src/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1800,7 +1800,7 @@ pub(crate) fn is_nonoverlapping<T>(src: *const T, dst: *const T, count: usize) -
/// ```
/// use std::ptr;
///
/// /// Moves all the elements of `src` into `dst`, leaving `src` empty.
/// // Moves all the elements of `src` into `dst`, leaving `src` empty.
/// fn append<T>(dst: &mut Vec<T>, src: &mut Vec<T>) {
/// let src_len = src.len();
/// let dst_len = dst.len();
Expand Down Expand Up @@ -1907,6 +1907,7 @@ pub unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize) {
/// /// * `ptr` must be valid for reads of `elts` contiguous elements of type `T`.
/// /// * Those elements must not be used after calling this function unless `T: Copy`.
/// # #[allow(dead_code)]
/// # #[allow(unused_doc_comments)]
/// unsafe fn from_buf_raw<T>(ptr: *const T, elts: usize) -> Vec<T> {
/// let mut dst = Vec::with_capacity(elts);
///
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/iter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
//! ```
//! // First, the struct:
//!
//! /// An iterator which counts from one to five
//! // An iterator which counts from one to five
//! struct Counter {
//! count: usize,
//! }
Expand Down
Loading