Skip to content

Commit

Permalink
Rollup merge of rust-lang#126717 - nnethercote:rustfmt-use-pre-cleanu…
Browse files Browse the repository at this point in the history
…ps, 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``
  • Loading branch information
matthiaskrgr authored Jun 20, 2024
2 parents f1c9c80 + e3e84a7 commit 0829ab8
Show file tree
Hide file tree
Showing 25 changed files with 41 additions and 18 deletions.
7 changes: 4 additions & 3 deletions alloc/src/boxed/thin.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Based on
// https://github.com/matthieu-m/rfc2580/blob/b58d1d3cba0d4b5e859d3617ea2d0943aaa31329/examples/thin.rs
// by matthieu-m
//! Based on
//! <https://github.com/matthieu-m/rfc2580/blob/b58d1d3cba0d4b5e859d3617ea2d0943aaa31329/examples/thin.rs>
//! by matthieu-m
use crate::alloc::{self, Layout, LayoutError};
use core::error::Error;
use core::fmt::{self, Debug, Display, Formatter};
Expand Down
1 change: 1 addition & 0 deletions alloc/src/vec/in_place_collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
//! }
//! vec.truncate(write_idx);
//! ```
use crate::alloc::{handle_alloc_error, Global};
use core::alloc::Allocator;
use core::alloc::Layout;
Expand Down
1 change: 1 addition & 0 deletions core/src/str/count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
//! Note: Because the term "leading byte" can sometimes be ambiguous (for
//! example, it could also refer to the first byte of a slice), we'll often use
//! the term "non-continuation byte" to refer to these bytes in the code.
use core::intrinsics::unlikely;

const USIZE_SIZE: usize = core::mem::size_of::<usize>();
Expand Down
1 change: 1 addition & 0 deletions core/tests/iter/adapters/map_windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::sync::atomic::{AtomicUsize, Ordering::SeqCst};
#[cfg(not(panic = "abort"))]
mod drop_checks {
//! These tests mainly make sure the elements are correctly dropped.
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering::SeqCst};

#[derive(Debug)]
Expand Down
1 change: 1 addition & 0 deletions core/tests/net/parser.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// FIXME: These tests are all excellent candidates for AFL fuzz testing

use core::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
use core::str::FromStr;

Expand Down
1 change: 1 addition & 0 deletions core/tests/num/ieee754.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
//! standard. That is why they accept wildly diverse inputs or may seem to duplicate other tests.
//! Please consider this carefully when adding, removing, or reorganizing these tests. They are
//! here so that it is clear what tests are required by the standard and what can be changed.
use ::core::str::FromStr;

// IEEE 754 for many tests is applied to specific bit patterns.
Expand Down
1 change: 1 addition & 0 deletions core/tests/pin_macro.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// edition:2021

use core::{
marker::PhantomPinned,
mem::{drop as stuff, transmute},
Expand Down
1 change: 1 addition & 0 deletions panic_unwind/src/miri.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Unwinding panics for Miri.
use alloc::boxed::Box;
use core::any::Any;

Expand Down
5 changes: 2 additions & 3 deletions portable-simd/crates/core_simd/examples/dot_product.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Code taken from the `packed_simd` crate
// Run this code with `cargo test --example dot_product`
//use std::iter::zip;
//! Code taken from the `packed_simd` crate.
//! Run this code with `cargo test --example dot_product`.
#![feature(array_chunks)]
#![feature(slice_as_chunks)]
Expand Down
1 change: 1 addition & 0 deletions portable-simd/crates/core_simd/src/ops/assign.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Assignment operators
use super::*;
use core::ops::{AddAssign, MulAssign}; // commutative binary op-assignment
use core::ops::{BitAndAssign, BitOrAssign, BitXorAssign}; // commutative bit binary op-assignment
Expand Down
1 change: 1 addition & 0 deletions portable-simd/crates/core_simd/src/ops/deref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//! Ideally, Rust would take care of this itself,
//! and method calls usually handle the LHS implicitly.
//! But this is not the case with arithmetic ops.
use super::*;

macro_rules! deref_lhs {
Expand Down
1 change: 1 addition & 0 deletions std/src/hash/random.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//! outside this crate.
//!
//! [`collections`]: crate::collections
#[allow(deprecated)]
use super::{BuildHasher, Hasher, SipHasher13};
use crate::cell::Cell;
Expand Down
21 changes: 11 additions & 10 deletions std/src/io/buffered/bufreader/buffer.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
///! An encapsulation of `BufReader`'s buffer management logic.
///
/// This module factors out the basic functionality of `BufReader` in order to protect two core
/// invariants:
/// * `filled` bytes of `buf` are always initialized
/// * `pos` is always <= `filled`
/// Since this module encapsulates the buffer management logic, we can ensure that the range
/// `pos..filled` is always a valid index into the initialized region of the buffer. This means
/// that user code which wants to do reads from a `BufReader` via `buffer` + `consume` can do so
/// without encountering any runtime bounds checks.
//! An encapsulation of `BufReader`'s buffer management logic.
//!
//! This module factors out the basic functionality of `BufReader` in order to protect two core
//! invariants:
//! * `filled` bytes of `buf` are always initialized
//! * `pos` is always <= `filled`
//! Since this module encapsulates the buffer management logic, we can ensure that the range
//! `pos..filled` is always a valid index into the initialized region of the buffer. This means
//! that user code which wants to do reads from a `BufReader` via `buffer` + `consume` can do so
//! without encountering any runtime bounds checks.
use crate::cmp;
use crate::io::{self, BorrowedBuf, Read};
use crate::mem::MaybeUninit;
Expand Down
5 changes: 3 additions & 2 deletions std/src/sys/os_str/wtf8.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// The underlying OsString/OsStr implementation on Windows is a
/// wrapper around the "WTF-8" encoding; see the `wtf8` module for more.
//! The underlying OsString/OsStr implementation on Windows is a
//! wrapper around the "WTF-8" encoding; see the `wtf8` module for more.
use crate::borrow::Cow;
use crate::collections::TryReserveError;
use crate::fmt;
Expand Down
1 change: 1 addition & 0 deletions std/src/sys/pal/itron/thread.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Thread implementation backed by μITRON tasks. Assumes `acre_tsk` and
//! `exd_tsk` are available.
use super::{
abi,
error::{expect_success, expect_success_aborting, ItronError},
Expand Down
1 change: 1 addition & 0 deletions std/src/sys/pal/solid/abi/fs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! `solid_fs.h`
use crate::os::raw::{c_char, c_int, c_uchar};
pub use libc::{
ino_t, off_t, stat, time_t, O_APPEND, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Emulated wait status for non-Unix #[cfg(unix) platforms
//!
//! Separate module to facilitate testing against a real Unix implementation.
use crate::ffi::c_int;
use crate::fmt;
use crate::num::NonZero;
Expand Down
1 change: 1 addition & 0 deletions std/src/sys/pal/unix/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ mod cgroups {
//! * cgroup v2 in non-standard mountpoints
//! * paths containing control characters or spaces, since those would be escaped in procfs
//! output and we don't unescape
use crate::borrow::Cow;
use crate::ffi::OsString;
use crate::fs::{try_exists, File};
Expand Down
1 change: 1 addition & 0 deletions std/src/sys/sync/condvar/itron.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! POSIX conditional variable implementation based on user-space wait queues.
use crate::sys::pal::itron::{
abi, error::expect_success_aborting, spin::SpinMutex, task, time::with_tmos_strong,
};
Expand Down
1 change: 1 addition & 0 deletions std/src/sys/sync/mutex/itron.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Mutex implementation backed by μITRON mutexes. Assumes `acre_mtx` and
//! `TA_INHERIT` are available.
use crate::sys::pal::itron::{
abi,
error::{expect_success, expect_success_aborting, fail, ItronError},
Expand Down
1 change: 1 addition & 0 deletions std/src/sys/sync/rwlock/solid.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! A readers-writer lock implementation backed by the SOLID kernel extension.
use crate::sys::pal::{
abi,
itron::{
Expand Down
1 change: 1 addition & 0 deletions std/tests/create_dir_all_bare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

//! Note that this test changes the current directory so
//! should not be in the same process as other tests.
use std::env;
use std::fs;
use std::path::{Path, PathBuf};
Expand Down
1 change: 1 addition & 0 deletions test/src/bench.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Benchmarking module.
use super::{
event::CompletedTest,
options::BenchMode,
Expand Down
1 change: 1 addition & 0 deletions test/src/helpers/concurrency.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Helper module which helps to determine amount of threads to be used
//! during tests execution.
use std::{env, num::NonZero, thread};

pub fn get_concurrency() -> usize {
Expand Down
1 change: 1 addition & 0 deletions test/src/helpers/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Benchmark metrics.
use std::collections::BTreeMap;

#[derive(Clone, PartialEq, Debug, Copy)]
Expand Down

0 comments on commit 0829ab8

Please sign in to comment.