Skip to content

Commit 4320ba0

Browse files
committed
Avoid comments that describe multiple use items.
There are some comments describing multiple subsequent `use` items. When the big `use` reformatting happens some of these `use` items will be reordered, possibly moving them away from the comment. With this additional level of formatting it's not really feasible to have comments of this type. This commit removes them in various ways: - merging separate `use` items when appropriate; - inserting blank lines between the comment and the first `use` item; - outright deletion (for comments that are relatively low-value); - adding a separate "top-level" comment. We also entirely skip formatting for four library files that contain nothing but `pub use` re-exports, where reordering would be painful.
1 parent 1aeddb0 commit 4320ba0

File tree

13 files changed

+41
-30
lines changed

13 files changed

+41
-30
lines changed

core/src/char/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,17 @@ mod convert;
2424
mod decode;
2525
mod methods;
2626

27-
// stable re-exports
2827
#[stable(feature = "try_from", since = "1.34.0")]
2928
pub use self::convert::CharTryFromError;
3029
#[stable(feature = "char_from_str", since = "1.20.0")]
3130
pub use self::convert::ParseCharError;
3231
#[stable(feature = "decode_utf16", since = "1.9.0")]
3332
pub use self::decode::{DecodeUtf16, DecodeUtf16Error};
3433

35-
// perma-unstable re-exports
3634
#[unstable(feature = "char_internals", reason = "exposed only for libstd", issue = "none")]
37-
pub use self::methods::encode_utf16_raw;
35+
pub use self::methods::encode_utf16_raw; // perma-unstable
3836
#[unstable(feature = "char_internals", reason = "exposed only for libstd", issue = "none")]
39-
pub use self::methods::encode_utf8_raw;
37+
pub use self::methods::encode_utf8_raw; // perma-unstable
4038

4139
use crate::ascii;
4240
use crate::error::Error;

core/src/prelude/common.rs

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
//!
33
//! See the [module-level documentation](super) for more.
44
5+
// No formatting: this file is nothing but re-exports, and their order is worth preserving.
6+
#![cfg_attr(rustfmt, rustfmt::skip)]
7+
58
// Re-exported core operators
69
#[stable(feature = "core_prelude", since = "1.4.0")]
710
#[doc(no_inline)]

core/src/prelude/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
//! This module is imported by default when `#![no_std]` is used in the same
55
//! manner as the standard library's prelude.
66
7+
// No formatting: this file is nothing but re-exports, and their order is worth preserving.
8+
#![cfg_attr(rustfmt, rustfmt::skip)]
9+
710
#![stable(feature = "core_prelude", since = "1.4.0")]
811

912
mod common;

core/src/ptr/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1809,10 +1809,9 @@ pub(crate) const unsafe fn align_offset<T: Sized>(p: *const T, a: usize) -> usiz
18091809
// FIXME(#75598): Direct use of these intrinsics improves codegen significantly at opt-level <=
18101810
// 1, where the method versions of these operations are not inlined.
18111811
use intrinsics::{
1812-
assume, cttz_nonzero, exact_div, mul_with_overflow, unchecked_rem, unchecked_sub,
1813-
wrapping_add, wrapping_mul, wrapping_sub,
1812+
assume, cttz_nonzero, exact_div, mul_with_overflow, unchecked_rem, unchecked_shl,
1813+
unchecked_shr, unchecked_sub, wrapping_add, wrapping_mul, wrapping_sub,
18141814
};
1815-
use intrinsics::{unchecked_shl, unchecked_shr};
18161815

18171816
/// Calculate multiplicative modular inverse of `x` modulo `m`.
18181817
///

core/src/unicode/mod.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
#![unstable(feature = "unicode_internals", issue = "none")]
22
#![allow(missing_docs)]
33

4+
// The `pub use` ones are for use in alloc, and are not re-exported in std.
5+
6+
pub(crate) use unicode_data::alphabetic::lookup as Alphabetic;
7+
pub use unicode_data::case_ignorable::lookup as Case_Ignorable;
8+
pub use unicode_data::cased::lookup as Cased;
9+
pub(crate) use unicode_data::cc::lookup as Cc;
10+
pub use unicode_data::conversions;
11+
pub(crate) use unicode_data::grapheme_extend::lookup as Grapheme_Extend;
12+
pub(crate) use unicode_data::lowercase::lookup as Lowercase;
13+
pub(crate) use unicode_data::n::lookup as N;
14+
pub(crate) use unicode_data::uppercase::lookup as Uppercase;
15+
pub(crate) use unicode_data::white_space::lookup as White_Space;
16+
417
pub(crate) mod printable;
518
mod unicode_data;
619

@@ -16,16 +29,3 @@ mod unicode_data;
1629
/// [Unicode 11.0 or later, Section 3.1 Versions of the Unicode Standard](https://www.unicode.org/versions/Unicode11.0.0/ch03.pdf#page=4).
1730
#[stable(feature = "unicode_version", since = "1.45.0")]
1831
pub const UNICODE_VERSION: (u8, u8, u8) = unicode_data::UNICODE_VERSION;
19-
20-
// For use in alloc, not re-exported in std.
21-
pub use unicode_data::{
22-
case_ignorable::lookup as Case_Ignorable, cased::lookup as Cased, conversions,
23-
};
24-
25-
pub(crate) use unicode_data::alphabetic::lookup as Alphabetic;
26-
pub(crate) use unicode_data::cc::lookup as Cc;
27-
pub(crate) use unicode_data::grapheme_extend::lookup as Grapheme_Extend;
28-
pub(crate) use unicode_data::lowercase::lookup as Lowercase;
29-
pub(crate) use unicode_data::n::lookup as N;
30-
pub(crate) use unicode_data::uppercase::lookup as Uppercase;
31-
pub(crate) use unicode_data::white_space::lookup as White_Space;

std/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,6 @@ pub mod rt;
469469
// The Rust prelude
470470
pub mod prelude;
471471

472-
// Public module declarations and re-exports
473472
#[stable(feature = "rust1", since = "1.0.0")]
474473
pub use alloc_crate::borrow;
475474
#[stable(feature = "rust1", since = "1.0.0")]

std/src/os/fortanix_sgx/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ pub mod usercalls {
2828
pub use crate::sys::abi::usercalls::raw::{do_usercall, Usercalls as UsercallNrs};
2929
pub use crate::sys::abi::usercalls::raw::{Register, RegisterArgument, ReturnValue};
3030

31-
// fortanix-sgx-abi re-exports
3231
pub use crate::sys::abi::usercalls::raw::Error;
3332
pub use crate::sys::abi::usercalls::raw::{
3433
ByteBuffer, Cancel, FifoDescriptor, Return, Usercall,

std/src/prelude/common.rs

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
//!
33
//! See the [module-level documentation](super) for more.
44
5+
// No formatting: this file is nothing but re-exports, and their order is worth preserving.
6+
#![cfg_attr(rustfmt, rustfmt::skip)]
7+
58
// Re-exported core operators
69
#[stable(feature = "rust1", since = "1.0.0")]
710
#[doc(no_inline)]

std/src/prelude/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@
9595
//! [book-enums]: ../../book/ch06-01-defining-an-enum.html
9696
//! [book-iter]: ../../book/ch13-02-iterators.html
9797
98+
// No formatting: this file is nothing but re-exports, and their order is worth preserving.
99+
#![cfg_attr(rustfmt, rustfmt::skip)]
100+
98101
#![stable(feature = "rust1", since = "1.0.0")]
99102

100103
mod common;

std/src/rt.rs

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#![deny(unsafe_op_in_unsafe_fn)]
1717
#![allow(unused_macros)]
1818

19-
// Re-export some of our utilities which are expected by other crates.
2019
pub use crate::panicking::{begin_panic, panic_count};
2120
pub use core::panicking::{panic_display, panic_fmt};
2221

std/src/sys/pal/wasi/mod.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,15 @@ pub mod time;
3939
#[deny(unsafe_op_in_unsafe_fn)]
4040
#[allow(unused)]
4141
mod common;
42+
4243
pub use common::*;
4344

4445
mod helpers;
45-
// These exports are listed individually to work around Rust's glob import
46-
// conflict rules. If we glob export `helpers` and `common` together, then
47-
// the compiler complains about conflicts.
46+
47+
// The following exports are listed individually to work around Rust's glob
48+
// import conflict rules. If we glob export `helpers` and `common` together,
49+
// then the compiler complains about conflicts.
50+
4851
pub use helpers::abort_internal;
4952
pub use helpers::decode_error_kind;
5053
use helpers::err2io;

std/src/sys/pal/wasip2/mod.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,16 @@ pub mod time;
4141
#[deny(unsafe_op_in_unsafe_fn)]
4242
#[allow(unused)]
4343
mod common;
44+
4445
pub use common::*;
4546

4647
#[path = "../wasi/helpers.rs"]
4748
mod helpers;
48-
// These exports are listed individually to work around Rust's glob import
49-
// conflict rules. If we glob export `helpers` and `common` together, then
50-
// the compiler complains about conflicts.
49+
50+
// The following exports are listed individually to work around Rust's glob
51+
// import conflict rules. If we glob export `helpers` and `common` together,
52+
// then the compiler complains about conflicts.
53+
5154
pub use helpers::abort_internal;
5255
pub use helpers::decode_error_kind;
5356
use helpers::err2io;

test/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#![feature(test)]
2626
#![allow(internal_features)]
2727

28-
// Public reexports
2928
pub use self::bench::{black_box, Bencher};
3029
pub use self::console::run_tests_console;
3130
pub use self::options::{ColorConfig, Options, OutputFormat, RunIgnored, ShouldPanic};

0 commit comments

Comments
 (0)