Skip to content

Commit b9015fe

Browse files
authored
Rollup merge of rust-lang#126717 - nnethercote:rustfmt-use-pre-cleanups, r=jieyouxu
Clean up some comments near `use` declarations rust-lang#125443 will reformat all `use` declarations in the repository. There are a few edge cases involving comments on `use` declarations that require care. This PR cleans up some clumsy comment cases, taking us a step closer to rust-lang#125443 being able to merge. r? `@lqd`
2 parents 84ed3cf + b5a5647 commit b9015fe

File tree

75 files changed

+98
-33
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+98
-33
lines changed

compiler/rustc_builtin_macros/src/test.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
//! The expansion from a test function to the appropriate test struct for libtest
2+
//! Ideally, this code would be in libtest but for efficiency and error messages it lives here.
3+
14
use crate::errors;
2-
/// The expansion from a test function to the appropriate test struct for libtest
3-
/// Ideally, this code would be in libtest but for efficiency and error messages it lives here.
45
use crate::util::{check_builtin_macro_attribute, warn_on_duplicate_attribute};
56
use rustc_ast::ptr::P;
67
use rustc_ast::{self as ast, attr, GenericParamKind};

compiler/rustc_codegen_gcc/tests/lang_tests_common.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! The common code for `tests/lang_tests_*.rs`
2+
23
use std::{
34
env::{self, current_dir},
45
path::{Path, PathBuf},

compiler/rustc_codegen_ssa/src/mir/locals.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Locals are in a private module as updating `LocalRef::Operand` has to
22
//! be careful wrt to subtyping. To deal with this we only allow updates by using
33
//! `FunctionCx::overwrite_local` which handles it automatically.
4+
45
use crate::mir::{FunctionCx, LocalRef};
56
use crate::traits::BuilderMethods;
67
use rustc_index::IndexVec;

compiler/rustc_data_structures/src/base_n.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
/// Converts unsigned integers into a string representation with some base.
2-
/// Bases up to and including 36 can be used for case-insensitive things.
1+
//! Converts unsigned integers into a string representation with some base.
2+
//! Bases up to and including 36 can be used for case-insensitive things.
3+
34
use std::ascii;
45
use std::fmt;
56

compiler/rustc_errors/src/markdown/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! A simple markdown parser that can write formatted text to the terminal
22
//!
33
//! Entrypoint is `MdStream::parse_str(...)`
4+
45
use std::io;
56

67
use termcolor::{Buffer, BufferWriter, ColorChoice};

compiler/rustc_expand/src/mbe/macro_check.rs

+1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
//! Kleene operators under which a meta-variable is repeating is the concatenation of the stacks
105105
//! stored when entering a macro definition starting from the state in which the meta-variable is
106106
//! bound.
107+
107108
use crate::errors;
108109
use crate::mbe::{KleeneToken, TokenTree};
109110

compiler/rustc_fs_util/src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
// tidy-alphabetical-start
21
use std::ffi::CString;
32
use std::fs;
43
use std::io;
54
use std::path::{absolute, Path, PathBuf};
6-
// tidy-alphabetical-end
75

86
// Unfortunately, on windows, it looks like msvcrt.dll is silently translating
97
// verbatim paths under the hood to non-verbatim paths! This manifests itself as

compiler/rustc_hir_analysis/src/check/dropck.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// FIXME(@lcnr): Move this module out of `rustc_hir_analysis`.
22
//
33
// We don't do any drop checking during hir typeck.
4+
45
use rustc_data_structures::fx::FxHashSet;
56
use rustc_errors::{codes::*, struct_span_code_err, ErrorGuaranteed};
67
use rustc_infer::infer::outlives::env::OutlivesEnvironment;

compiler/rustc_hir_typeck/src/autoderef.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
//! Some helper functions for `AutoDeref`
1+
//! Some helper functions for `AutoDeref`.
2+
23
use super::method::MethodCallee;
34
use super::{FnCtxt, PlaceOp};
45

compiler/rustc_hir_typeck/src/errors.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! Errors emitted by `rustc_hir_typeck`.
2+
23
use std::borrow::Cow;
34

45
use crate::fluent_generated as fluent;

compiler/rustc_hir_typeck/src/fn_ctxt/inspect_obligations.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! A utility module to inspect currently ambiguous obligations in the current context.
2+
23
use crate::FnCtxt;
34
use rustc_infer::traits::{self, ObligationCause};
45
use rustc_middle::traits::solve::Goal;

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/named_anon_conflict.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! Error Reporting for Anonymous Region Lifetime Errors
22
//! where one region is named and the other is anonymous.
3+
34
use crate::infer::error_reporting::nice_region_error::NiceRegionError;
45
use crate::{
56
errors::ExplicitLifetimeRequired,

compiler/rustc_infer/src/infer/freshen.rs

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
//! solving a set of constraints. In contrast, the type inferencer assigns a value to each type
3131
//! variable only once, and it does so as soon as it can, so it is reasonable to ask what the type
3232
//! inferencer knows "so far".
33+
3334
use super::InferCtxt;
3435
use rustc_data_structures::fx::FxHashMap;
3536
use rustc_middle::bug;

compiler/rustc_infer/src/infer/outlives/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! Various code related to computing outlives relations.
2+
23
use self::env::OutlivesEnvironment;
34
use super::region_constraints::RegionConstraintData;
45
use super::{InferCtxt, RegionResolutionError, SubregionOrigin};

compiler/rustc_lint_defs/src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// tidy-alphabetical-start
21
pub use self::Level::*;
32
use rustc_ast::node_id::NodeId;
43
use rustc_ast::{AttrId, Attribute};
@@ -15,7 +14,6 @@ use rustc_span::edition::Edition;
1514
use rustc_span::symbol::MacroRulesNormalizedIdent;
1615
use rustc_span::{sym, symbol::Ident, Span, Symbol};
1716
use rustc_target::spec::abi::Abi;
18-
// tidy-alphabetical-end
1917

2018
use serde::{Deserialize, Serialize};
2119

compiler/rustc_middle/src/middle/privacy.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! A pass that checks to make sure private fields and methods aren't used
22
//! outside their scopes. This pass will also generate a set of exported items
33
//! which are available for use externally when compiled as a library.
4+
45
use crate::ty::{TyCtxt, Visibility};
56
use rustc_data_structures::fx::{FxIndexMap, IndexEntry};
67
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};

compiler/rustc_middle/src/mir/statement.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/// Functionality for statements, operands, places, and things that appear in them.
1+
//! Functionality for statements, operands, places, and things that appear in them.
2+
23
use super::{interpret::GlobalAlloc, *};
34

45
///////////////////////////////////////////////////////////////////////////

compiler/rustc_middle/src/mir/terminator.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/// Functionality for terminators and helper types that appear in terminators.
1+
//! Functionality for terminators and helper types that appear in terminators.
2+
23
use rustc_hir::LangItem;
34
use smallvec::{smallvec, SmallVec};
45

compiler/rustc_middle/src/ty/abstract_const.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! A subset of a mir body used for const evaluability checking.
2+
23
use crate::ty::{
34
self, Const, EarlyBinder, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable,
45
TypeVisitableExt,

compiler/rustc_mir_transform/src/ctfe_limit.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! A pass that inserts the `ConstEvalCounter` instruction into any blocks that have a back edge
22
//! (thus indicating there is a loop in the CFG), or whose terminator is a function call.
3+
34
use crate::MirPass;
45

56
use rustc_data_structures::graph::dominators::Dominators;

compiler/rustc_mir_transform/src/inline.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
//! Inlining pass for MIR functions
1+
//! Inlining pass for MIR functions.
2+
23
use crate::deref_separator::deref_finder;
34
use rustc_attr::InlineAttr;
45
use rustc_hir::def::DefKind;

compiler/rustc_mir_transform/src/lint.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! This pass statically detects code which has undefined behaviour or is likely to be erroneous.
22
//! It can be used to locate problems in MIR building or optimizations. It assumes that all code
33
//! can be executed, so it has false positives.
4+
45
use rustc_data_structures::fx::FxHashSet;
56
use rustc_index::bit_set::BitSet;
67
use rustc_middle::mir::visit::{PlaceContext, Visitor};

compiler/rustc_parse/src/parser/expr.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// ignore-tidy-filelength
2+
23
use super::diagnostics::SnapshotParser;
34
use super::pat::{CommaRecoveryMode, Expected, RecoverColon, RecoverComma};
45
use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign};

compiler/rustc_pattern_analysis/src/pat.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! As explained in [`crate::usefulness`], values and patterns are made from constructors applied to
22
//! fields. This file defines types that represent patterns in this way.
3+
34
use std::fmt;
45

56
use smallvec::{smallvec, SmallVec};

compiler/rustc_pattern_analysis/tests/complexity.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! Test the pattern complexity limit.
2+
23
use common::*;
34
use rustc_pattern_analysis::{pat::DeconstructedPat, usefulness::PlaceValidity, MatchArm};
45

compiler/rustc_pattern_analysis/tests/exhaustiveness.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! Test exhaustiveness checking.
2+
23
use common::*;
34
use rustc_pattern_analysis::{
45
pat::{DeconstructedPat, WitnessPat},

compiler/rustc_pattern_analysis/tests/intersection.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! Test the computation of arm intersections.
2+
23
use common::*;
34
use rustc_pattern_analysis::{pat::DeconstructedPat, usefulness::PlaceValidity, MatchArm};
45

compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/encode.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//!
55
//! For more information about LLVM CFI and cross-language LLVM CFI support for the Rust compiler,
66
//! see design document in the tracking issue #89653.
7+
78
use rustc_data_structures::base_n::ToBaseN;
89
use rustc_data_structures::base_n::ALPHANUMERIC_ONLY;
910
use rustc_data_structures::base_n::CASE_INSENSITIVE;

compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//!
44
//! For more information about LLVM CFI and cross-language LLVM CFI support for the Rust compiler,
55
//! see design document in the tracking issue #89653.
6+
67
use rustc_data_structures::fx::FxHashMap;
78
use rustc_middle::bug;
89
use rustc_middle::ty::{self, Instance, Ty, TyCtxt, TypeFoldable};

compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//!
44
//! For more information about LLVM CFI and cross-language LLVM CFI support for the Rust compiler,
55
//! see design document in the tracking issue #89653.
6+
67
use rustc_hir as hir;
78
use rustc_hir::LangItem;
89
use rustc_middle::bug;

compiler/rustc_sanitizers/src/cfi/typeid/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//!
44
//! For more information about LLVM CFI and cross-language LLVM CFI support for the Rust compiler,
55
//! see design document in the tracking issue #89653.
6+
67
use bitflags::bitflags;
78
use rustc_middle::ty::{Instance, Ty, TyCtxt};
89
use rustc_target::abi::call::FnAbi;

compiler/rustc_sanitizers/src/kcfi/typeid/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//!
44
//! For more information about LLVM KCFI and cross-language LLVM KCFI support for the Rust compiler,
55
//! see the tracking issue #123479.
6+
67
use rustc_middle::ty::{Instance, InstanceKind, ReifyReason, Ty, TyCtxt};
78
use rustc_target::abi::call::FnAbi;
89
use std::hash::Hasher;

compiler/rustc_session/src/output.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! Related to out filenames of compilation (e.g. binaries).
2+
23
use crate::config::{self, CrateType, Input, OutFileName, OutputFilenames, OutputType};
34
use crate::errors::{
45
self, CrateNameDoesNotMatch, CrateNameEmpty, CrateNameInvalid, FileIsNotWriteable,

compiler/rustc_smir/src/rustc_smir/builder.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//! We first retrieve and monomorphize the rustc body representation, i.e., we generate a
44
//! monomorphic body using internal representation.
55
//! After that, we convert the internal representation into a stable one.
6+
67
use crate::rustc_smir::{Stable, Tables};
78
use rustc_hir::def::DefKind;
89
use rustc_middle::mir;

compiler/rustc_smir/src/rustc_smir/convert/error.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Handle the conversion of different internal errors into a stable version.
22
//!
33
//! Currently we encode everything as [stable_mir::Error], which is represented as a string.
4+
45
use crate::rustc_smir::{Stable, Tables};
56
use rustc_middle::mir::interpret::AllocError;
67
use rustc_middle::ty::layout::LayoutError;

compiler/rustc_target/src/spec/targets/mips64_openwrt_linux_musl.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/// A target tuple for OpenWrt MIPS64 targets
2-
///
1+
//! A target tuple for OpenWrt MIPS64 targets.
2+
33
use crate::abi::Endian;
44
use crate::spec::{base, Target, TargetOptions};
55

compiler/rustc_trait_selection/src/traits/normalize.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! Deeply normalize types using the old trait solver.
2+
23
use super::error_reporting::OverflowCause;
34
use super::error_reporting::TypeErrCtxtExt;
45
use super::SelectionContext;

compiler/rustc_trait_selection/src/traits/select/confirmation.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//!
77
//! [rustc dev guide]:
88
//! https://rustc-dev-guide.rust-lang.org/traits/resolution.html#confirmation
9+
910
use rustc_ast::Mutability;
1011
use rustc_data_structures::stack::ensure_sufficient_stack;
1112
use rustc_hir::lang_items::LangItem;

compiler/stable_mir/src/mir/alloc.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! This module provides methods to retrieve allocation information, such as static variables.
2+
23
use crate::mir::mono::{Instance, StaticDef};
34
use crate::target::{Endian, MachineInfo};
45
use crate::ty::{Allocation, Binder, ExistentialTraitRef, IndexedVal, Ty};

library/alloc/src/boxed/thin.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
// Based on
2-
// https://github.com/matthieu-m/rfc2580/blob/b58d1d3cba0d4b5e859d3617ea2d0943aaa31329/examples/thin.rs
3-
// by matthieu-m
1+
//! Based on
2+
//! <https://github.com/matthieu-m/rfc2580/blob/b58d1d3cba0d4b5e859d3617ea2d0943aaa31329/examples/thin.rs>
3+
//! by matthieu-m
4+
45
use crate::alloc::{self, Layout, LayoutError};
56
use core::error::Error;
67
use core::fmt::{self, Debug, Display, Formatter};

library/alloc/src/vec/in_place_collect.rs

+1
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@
154154
//! }
155155
//! vec.truncate(write_idx);
156156
//! ```
157+
157158
use crate::alloc::{handle_alloc_error, Global};
158159
use core::alloc::Allocator;
159160
use core::alloc::Layout;

library/core/src/str/count.rs

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
//! Note: Because the term "leading byte" can sometimes be ambiguous (for
1818
//! example, it could also refer to the first byte of a slice), we'll often use
1919
//! the term "non-continuation byte" to refer to these bytes in the code.
20+
2021
use core::intrinsics::unlikely;
2122

2223
const USIZE_SIZE: usize = core::mem::size_of::<usize>();

library/core/tests/iter/adapters/map_windows.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::sync::atomic::{AtomicUsize, Ordering::SeqCst};
33
#[cfg(not(panic = "abort"))]
44
mod drop_checks {
55
//! These tests mainly make sure the elements are correctly dropped.
6+
67
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering::SeqCst};
78

89
#[derive(Debug)]

library/core/tests/net/parser.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// FIXME: These tests are all excellent candidates for AFL fuzz testing
2+
23
use core::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
34
use core::str::FromStr;
45

library/core/tests/num/ieee754.rs

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
//! standard. That is why they accept wildly diverse inputs or may seem to duplicate other tests.
2828
//! Please consider this carefully when adding, removing, or reorganizing these tests. They are
2929
//! here so that it is clear what tests are required by the standard and what can be changed.
30+
3031
use ::core::str::FromStr;
3132

3233
// IEEE 754 for many tests is applied to specific bit patterns.

library/core/tests/pin_macro.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// edition:2021
2+
23
use core::{
34
marker::PhantomPinned,
45
mem::{drop as stuff, transmute},

library/panic_unwind/src/miri.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! Unwinding panics for Miri.
2+
23
use alloc::boxed::Box;
34
use core::any::Any;
45

library/portable-simd/crates/core_simd/examples/dot_product.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
// Code taken from the `packed_simd` crate
2-
// Run this code with `cargo test --example dot_product`
3-
//use std::iter::zip;
1+
//! Code taken from the `packed_simd` crate.
2+
//! Run this code with `cargo test --example dot_product`.
43
54
#![feature(array_chunks)]
65
#![feature(slice_as_chunks)]

library/portable-simd/crates/core_simd/src/ops/assign.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! Assignment operators
2+
23
use super::*;
34
use core::ops::{AddAssign, MulAssign}; // commutative binary op-assignment
45
use core::ops::{BitAndAssign, BitOrAssign, BitXorAssign}; // commutative bit binary op-assignment

library/portable-simd/crates/core_simd/src/ops/deref.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//! Ideally, Rust would take care of this itself,
33
//! and method calls usually handle the LHS implicitly.
44
//! But this is not the case with arithmetic ops.
5+
56
use super::*;
67

78
macro_rules! deref_lhs {

library/std/src/hash/random.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//! outside this crate.
77
//!
88
//! [`collections`]: crate::collections
9+
910
#[allow(deprecated)]
1011
use super::{BuildHasher, Hasher, SipHasher13};
1112
use crate::cell::Cell;

0 commit comments

Comments
 (0)