Skip to content

Commit 922bc28

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 a7f6809 commit 922bc28

File tree

17 files changed

+43
-35
lines changed

17 files changed

+43
-35
lines changed

compiler/rustc_const_eval/src/interpret/validity.rs

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ use super::{
3434
Pointer, Projectable, Scalar, ValueVisitor,
3535
};
3636

37-
// for the validation errors
3837
use super::InterpError::UndefinedBehavior as Ub;
3938
use super::InterpError::Unsupported as Unsup;
4039
use super::UndefinedBehaviorInfo::*;

compiler/rustc_lint/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ use types::*;
116116
use unit_bindings::*;
117117
use unused::*;
118118

119-
/// Useful for other parts of the compiler / Clippy.
120119
pub use builtin::{MissingDoc, SoftLints};
121120
pub use context::{CheckLintNameResult, FindLintError, LintStore};
122121
pub use context::{EarlyContext, LateContext, LintContext};

compiler/rustc_pattern_analysis/src/lib.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
2121

2222
use std::fmt;
2323

24-
// Re-exports to avoid rustc_index version issues.
25-
pub use rustc_index::Idx;
26-
pub use rustc_index::IndexVec;
24+
pub use rustc_index::{Idx, IndexVec}; // re-exported to avoid rustc_index version issues
2725

2826
#[cfg(feature = "rustc")]
2927
use rustc_middle::ty::Ty;

compiler/rustc_smir/src/rustc_internal/internal.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//! due to incomplete stable coverage.
55
66
// Prefer importing stable_mir over internal rustc constructs to make this file more readable.
7+
78
use crate::rustc_smir::Tables;
89
use rustc_middle::ty::{self as rustc_ty, Const as InternalConst, Ty as InternalTy, TyCtxt};
910
use rustc_span::Symbol;

library/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;

library/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)]

library/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;

library/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
///

library/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;

library/std/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,6 @@ pub mod rt;
473473
// The Rust prelude
474474
pub mod prelude;
475475

476-
// Public module declarations and re-exports
477476
#[stable(feature = "rust1", since = "1.0.0")]
478477
pub use alloc_crate::borrow;
479478
#[stable(feature = "rust1", since = "1.0.0")]

library/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,

library/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)]

library/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;

library/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

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

+6-3
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,15 @@ pub mod time;
4343
#[deny(unsafe_op_in_unsafe_fn)]
4444
#[allow(unused)]
4545
mod common;
46+
4647
pub use common::*;
4748

4849
mod helpers;
49-
// These exports are listed individually to work around Rust's glob import
50-
// conflict rules. If we glob export `helpers` and `common` together, then
51-
// the compiler complains about conflicts.
50+
51+
// The following exports are listed individually to work around Rust's glob
52+
// import conflict rules. If we glob export `helpers` and `common` together,
53+
// then the compiler complains about conflicts.
54+
5255
pub use helpers::abort_internal;
5356
pub use helpers::decode_error_kind;
5457
use helpers::err2io;

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

+6-3
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,16 @@ pub mod time;
4545
#[deny(unsafe_op_in_unsafe_fn)]
4646
#[allow(unused)]
4747
mod common;
48+
4849
pub use common::*;
4950

5051
#[path = "../wasi/helpers.rs"]
5152
mod helpers;
52-
// These exports are listed individually to work around Rust's glob import
53-
// conflict rules. If we glob export `helpers` and `common` together, then
54-
// the compiler complains about conflicts.
53+
54+
// The following exports are listed individually to work around Rust's glob
55+
// import conflict rules. If we glob export `helpers` and `common` together,
56+
// then the compiler complains about conflicts.
57+
5558
pub use helpers::abort_internal;
5659
pub use helpers::decode_error_kind;
5760
use helpers::err2io;

library/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)