Skip to content

Commit c5dadd0

Browse files
committed
Use #[rustfmt::skip] on some use groups to prevent reordering.
`use` declarations will be reformatted in #125443. Very rarely, there is a desire to force a group of `use` declarations together in a way that auto-formatting will break up. E.g. when you want a single comment to apply to a group. #126776 dealt with all of these in the codebase, ensuring that no comments intended for multiple `use` declarations would end up in the wrong place. But some people were unhappy with it. This commit uses `#[rustfmt::skip]` to create these custom `use` groups in an idiomatic way for a few of the cases changed in #126776. This works because rustfmt treats any `use` item annotated with `#[rustfmt::skip]` as a barrier and won't reorder other `use` items around it.
1 parent 5affbb1 commit c5dadd0

File tree

5 files changed

+16
-4
lines changed

5 files changed

+16
-4
lines changed

compiler/rustc_const_eval/src/interpret/validity.rs

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

37+
// for the validation errors
38+
#[rustfmt::skip]
3739
use super::InterpError::UndefinedBehavior as Ub;
3840
use super::InterpError::Unsupported as Unsup;
3941
use super::UndefinedBehaviorInfo::*;

compiler/rustc_lint/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ use types::*;
120120
use unit_bindings::*;
121121
use unused::*;
122122

123+
#[rustfmt::skip]
123124
pub use builtin::{MissingDoc, SoftLints};
124125
pub use context::{CheckLintNameResult, FindLintError, LintStore};
125126
pub use context::{EarlyContext, LateContext, LintContext};

library/core/src/char/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,23 @@ mod convert;
2424
mod decode;
2525
mod methods;
2626

27+
// stable re-exports
28+
#[rustfmt::skip]
2729
#[stable(feature = "try_from", since = "1.34.0")]
2830
pub use self::convert::CharTryFromError;
2931
#[stable(feature = "char_from_str", since = "1.20.0")]
3032
pub use self::convert::ParseCharError;
3133
#[stable(feature = "decode_utf16", since = "1.9.0")]
3234
pub use self::decode::{DecodeUtf16, DecodeUtf16Error};
3335

36+
// perma-unstable re-exports
37+
#[rustfmt::skip]
3438
#[unstable(feature = "char_internals", reason = "exposed only for libstd", issue = "none")]
3539
pub use self::methods::encode_utf16_raw; // perma-unstable
3640
#[unstable(feature = "char_internals", reason = "exposed only for libstd", issue = "none")]
3741
pub use self::methods::encode_utf8_raw; // perma-unstable
3842

43+
#[rustfmt::skip]
3944
use crate::ascii;
4045
use crate::error::Error;
4146
use crate::escape;

library/core/src/unicode/mod.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
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;
4+
// for use in alloc, not re-exported in std.
5+
#[rustfmt::skip]
76
pub use unicode_data::case_ignorable::lookup as Case_Ignorable;
87
pub use unicode_data::cased::lookup as Cased;
9-
pub(crate) use unicode_data::cc::lookup as Cc;
108
pub use unicode_data::conversions;
9+
10+
#[rustfmt::skip]
11+
pub(crate) use unicode_data::alphabetic::lookup as Alphabetic;
12+
pub(crate) use unicode_data::cc::lookup as Cc;
1113
pub(crate) use unicode_data::grapheme_extend::lookup as Grapheme_Extend;
1214
pub(crate) use unicode_data::lowercase::lookup as Lowercase;
1315
pub(crate) use unicode_data::n::lookup as N;

library/std/src/rt.rs

+2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616
#![deny(unsafe_op_in_unsafe_fn)]
1717
#![allow(unused_macros)]
1818

19+
#[rustfmt::skip]
1920
pub use crate::panicking::{begin_panic, panic_count};
2021
pub use core::panicking::{panic_display, panic_fmt};
2122

23+
#[rustfmt::skip]
2224
use crate::sync::Once;
2325
use crate::sys;
2426
use crate::thread::{self, Thread};

0 commit comments

Comments
 (0)