Skip to content

Commit d371d17

Browse files
committed
Auto merge of #126900 - matthiaskrgr:rollup-24ah97b, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - #125241 (Add `rust_analyzer` as a predefined tool) - #126213 (Update docs for AtomicBool/U8/I8 with regard to alignment) - #126414 (Tier 2 std support must always be known) - #126882 (Special case when a code line only has multiline span starts) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 06c072f + a80ee91 commit d371d17

File tree

8 files changed

+76
-38
lines changed

8 files changed

+76
-38
lines changed

compiler/rustc_errors/src/emitter.rs

+26-1
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ impl HumanEmitter {
902902
// <EMPTY LINE>
903903
//
904904
let mut annotations_position = vec![];
905-
let mut line_len = 0;
905+
let mut line_len: usize = 0;
906906
let mut p = 0;
907907
for (i, annotation) in annotations.iter().enumerate() {
908908
for (j, next) in annotations.iter().enumerate() {
@@ -973,6 +973,31 @@ impl HumanEmitter {
973973
return vec![];
974974
}
975975

976+
if annotations_position
977+
.iter()
978+
.all(|(_, ann)| matches!(ann.annotation_type, AnnotationType::MultilineStart(_)))
979+
&& let Some(max_pos) = annotations_position.iter().map(|(pos, _)| *pos).max()
980+
{
981+
// Special case the following, so that we minimize overlapping multiline spans.
982+
//
983+
// 3 │ X0 Y0 Z0
984+
// │ ┏━━━━━┛ │ │ < We are writing these lines
985+
// │ ┃┌───────┘ │ < by reverting the "depth" of
986+
// │ ┃│┌─────────┘ < their multilne spans.
987+
// 4 │ ┃││ X1 Y1 Z1
988+
// 5 │ ┃││ X2 Y2 Z2
989+
// │ ┃│└────╿──│──┘ `Z` label
990+
// │ ┃└─────│──┤
991+
// │ ┗━━━━━━┥ `Y` is a good letter too
992+
// ╰╴ `X` is a good letter
993+
for (pos, _) in &mut annotations_position {
994+
*pos = max_pos - *pos;
995+
}
996+
// We know then that we don't need an additional line for the span label, saving us
997+
// one line of vertical space.
998+
line_len = line_len.saturating_sub(1);
999+
}
1000+
9761001
// Write the column separator.
9771002
//
9781003
// After this we will have:

compiler/rustc_parse/src/parser/tests.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,8 @@ error: foo
322322
--> test.rs:3:3
323323
|
324324
3 | X0 Y0
325-
| ___^__-
326-
| |___|
327-
| ||
325+
| ____^ -
326+
| | ______|
328327
4 | || X1 Y1
329328
5 | || X2 Y2
330329
| ||____^__- `Y` is a good letter too
@@ -361,9 +360,8 @@ error: foo
361360
--> test.rs:3:3
362361
|
363362
3 | X0 Y0
364-
| ___^__-
365-
| |___|
366-
| ||
363+
| ____^ -
364+
| | ______|
367365
4 | || Y1 X1
368366
| ||____-__^ `X` is a good letter
369367
| |____|
@@ -445,10 +443,9 @@ error: foo
445443
--> test.rs:3:3
446444
|
447445
3 | X0 Y0 Z0
448-
| ___^__-__-
449-
| |___|__|
450-
| ||___|
451-
| |||
446+
| _____^ - -
447+
| | _______| |
448+
| || _________|
452449
4 | ||| X1 Y1 Z1
453450
5 | ||| X2 Y2 Z2
454451
| |||____^__-__- `Z` label

compiler/rustc_resolve/src/macros.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,10 @@ pub(crate) fn registered_tools(tcx: TyCtxt<'_>, (): ()) -> RegisteredTools {
140140
}
141141
}
142142
}
143-
// We implicitly add `rustfmt`, `clippy`, `diagnostic` to known tools,
144-
// but it's not an error to register them explicitly.
145-
let predefined_tools = [sym::clippy, sym::rustfmt, sym::diagnostic, sym::miri];
143+
// We implicitly add `rustfmt`, `clippy`, `diagnostic`, `miri` and `rust_analyzer` to known
144+
// tools, but it's not an error to register them explicitly.
145+
let predefined_tools =
146+
[sym::clippy, sym::rustfmt, sym::diagnostic, sym::miri, sym::rust_analyzer];
146147
registered_tools.extend(predefined_tools.iter().cloned().map(Ident::with_dummy_span));
147148
registered_tools
148149
}

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1559,6 +1559,7 @@ symbols! {
15591559
rust_2018_preview,
15601560
rust_2021,
15611561
rust_2024,
1562+
rust_analyzer,
15621563
rust_begin_unwind,
15631564
rust_cold_cc,
15641565
rust_eh_catch_typeinfo,

library/core/src/sync/atomic.rs

+33-17
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,8 @@ impl AtomicBool {
443443
///
444444
/// # Safety
445445
///
446-
/// * `ptr` must be aligned to `align_of::<AtomicBool>()` (note that on some platforms this can
447-
/// be bigger than `align_of::<bool>()`).
446+
/// * `ptr` must be aligned to `align_of::<AtomicBool>()` (note that this is always true, since
447+
/// `align_of::<AtomicBool>() == 1`).
448448
/// * `ptr` must be [valid] for both reads and writes for the whole lifetime `'a`.
449449
/// * You must adhere to the [Memory model for atomic accesses]. In particular, it is not
450450
/// allowed to mix atomic and non-atomic accesses, or atomic accesses of different sizes,
@@ -2091,10 +2091,10 @@ impl<T> From<*mut T> for AtomicPtr<T> {
20912091
}
20922092

20932093
#[allow(unused_macros)] // This macro ends up being unused on some architectures.
2094-
macro_rules! if_not_8_bit {
2095-
(u8, $($tt:tt)*) => { "" };
2096-
(i8, $($tt:tt)*) => { "" };
2097-
($_:ident, $($tt:tt)*) => { $($tt)* };
2094+
macro_rules! if_8_bit {
2095+
(u8, $( yes = [$($yes:tt)*], )? $( no = [$($no:tt)*], )? ) => { concat!("", $($($yes)*)?) };
2096+
(i8, $( yes = [$($yes:tt)*], )? $( no = [$($no:tt)*], )? ) => { concat!("", $($($yes)*)?) };
2097+
($_:ident, $( yes = [$($yes:tt)*], )? $( no = [$($no:tt)*], )? ) => { concat!("", $($($no)*)?) };
20982098
}
20992099

21002100
#[cfg(target_has_atomic_load_store)]
@@ -2116,18 +2116,24 @@ macro_rules! atomic_int {
21162116
$int_type:ident $atomic_type:ident) => {
21172117
/// An integer type which can be safely shared between threads.
21182118
///
2119-
/// This type has the same size and bit validity as the underlying
2120-
/// integer type, [`
2119+
/// This type has the same
2120+
#[doc = if_8_bit!(
2121+
$int_type,
2122+
yes = ["size, alignment, and bit validity"],
2123+
no = ["size and bit validity"],
2124+
)]
2125+
/// as the underlying integer type, [`
21212126
#[doc = $s_int_type]
21222127
/// `].
2123-
#[doc = if_not_8_bit! {
2128+
#[doc = if_8_bit! {
21242129
$int_type,
2125-
concat!(
2130+
no = [
21262131
"However, the alignment of this type is always equal to its ",
21272132
"size, even on targets where [`", $s_int_type, "`] has a ",
21282133
"lesser alignment."
2129-
)
2134+
],
21302135
}]
2136+
///
21312137
/// For more about the differences between atomic types and
21322138
/// non-atomic types as well as information about the portability of
21332139
/// this type, please see the [module-level documentation].
@@ -2220,9 +2226,19 @@ macro_rules! atomic_int {
22202226
///
22212227
/// # Safety
22222228
///
2223-
#[doc = concat!(" * `ptr` must be aligned to \
2224-
`align_of::<", stringify!($atomic_type), ">()` (note that on some platforms this \
2225-
can be bigger than `align_of::<", stringify!($int_type), ">()`).")]
2229+
/// * `ptr` must be aligned to
2230+
#[doc = concat!(" `align_of::<", stringify!($atomic_type), ">()`")]
2231+
#[doc = if_8_bit!{
2232+
$int_type,
2233+
yes = [
2234+
" (note that this is always true, since `align_of::<",
2235+
stringify!($atomic_type), ">() == 1`)."
2236+
],
2237+
no = [
2238+
" (note that on some platforms this can be bigger than `align_of::<",
2239+
stringify!($int_type), ">()`)."
2240+
],
2241+
}]
22262242
/// * `ptr` must be [valid] for both reads and writes for the whole lifetime `'a`.
22272243
/// * You must adhere to the [Memory model for atomic accesses]. In particular, it is not
22282244
/// allowed to mix atomic and non-atomic accesses, or atomic accesses of different sizes,
@@ -2261,12 +2277,12 @@ macro_rules! atomic_int {
22612277

22622278
#[doc = concat!("Get atomic access to a `&mut ", stringify!($int_type), "`.")]
22632279
///
2264-
#[doc = if_not_8_bit! {
2280+
#[doc = if_8_bit! {
22652281
$int_type,
2266-
concat!(
2282+
no = [
22672283
"**Note:** This function is only available on targets where `",
22682284
stringify!($int_type), "` has an alignment of ", $align, " bytes."
2269-
)
2285+
],
22702286
}]
22712287
///
22722288
/// # Examples

src/doc/rustc/src/platform-support.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ The `std` column in the table below has the following meanings:
119119

120120
* ✓ indicates the full standard library is available.
121121
* \* indicates the target only supports [`no_std`] development.
122-
* ? indicates the standard library support is unknown or a work-in-progress.
122+
* ? indicates the standard library support is a work-in-progress.
123123

124124
[`no_std`]: https://rust-embedded.github.io/book/intro/no-std.html
125125

tests/ui/async-await/async-is-unwindsafe.stderr

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ error[E0277]: the type `&mut Context<'_>` may not be safely transferred across a
22
--> $DIR/async-is-unwindsafe.rs:12:5
33
|
44
LL | is_unwindsafe(async {
5-
| _____^_____________-
6-
| |_____|
7-
| ||
5+
| ______^ -
6+
| | ___________________|
87
LL | ||
98
LL | || use std::ptr::null;
109
LL | || use std::task::{Context, RawWaker, RawWakerVTable, Waker};

tests/ui/lint/suggestions.stderr

+2-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ warning: variable does not need to be mutable
4141
--> $DIR/suggestions.rs:54:13
4242
|
4343
LL | let mut
44-
| ______________^
45-
| | _____________|
46-
| ||
44+
| _____________^
45+
| |_____________|
4746
LL | || b = 1;
4847
| ||____________-^
4948
| |_____________|

0 commit comments

Comments
 (0)