Skip to content

Rollup of 4 pull requests #126900

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 24, 2024
27 changes: 26 additions & 1 deletion compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
@@ -902,7 +902,7 @@ impl HumanEmitter {
// <EMPTY LINE>
//
let mut annotations_position = vec![];
let mut line_len = 0;
let mut line_len: usize = 0;
let mut p = 0;
for (i, annotation) in annotations.iter().enumerate() {
for (j, next) in annotations.iter().enumerate() {
@@ -973,6 +973,31 @@ impl HumanEmitter {
return vec![];
}

if annotations_position
.iter()
.all(|(_, ann)| matches!(ann.annotation_type, AnnotationType::MultilineStart(_)))
&& let Some(max_pos) = annotations_position.iter().map(|(pos, _)| *pos).max()
{
// Special case the following, so that we minimize overlapping multiline spans.
//
// 3 │ X0 Y0 Z0
// │ ┏━━━━━┛ │ │ < We are writing these lines
// │ ┃┌───────┘ │ < by reverting the "depth" of
// │ ┃│┌─────────┘ < their multilne spans.
// 4 │ ┃││ X1 Y1 Z1
// 5 │ ┃││ X2 Y2 Z2
// │ ┃│└────╿──│──┘ `Z` label
// │ ┃└─────│──┤
// │ ┗━━━━━━┥ `Y` is a good letter too
// ╰╴ `X` is a good letter
for (pos, _) in &mut annotations_position {
*pos = max_pos - *pos;
}
// We know then that we don't need an additional line for the span label, saving us
// one line of vertical space.
line_len = line_len.saturating_sub(1);
}

// Write the column separator.
//
// After this we will have:
17 changes: 7 additions & 10 deletions compiler/rustc_parse/src/parser/tests.rs
Original file line number Diff line number Diff line change
@@ -322,9 +322,8 @@ error: foo
--> test.rs:3:3
|
3 | X0 Y0
| ___^__-
| |___|
| ||
| ____^ -
| | ______|
4 | || X1 Y1
5 | || X2 Y2
| ||____^__- `Y` is a good letter too
@@ -361,9 +360,8 @@ error: foo
--> test.rs:3:3
|
3 | X0 Y0
| ___^__-
| |___|
| ||
| ____^ -
| | ______|
4 | || Y1 X1
| ||____-__^ `X` is a good letter
| |____|
@@ -445,10 +443,9 @@ error: foo
--> test.rs:3:3
|
3 | X0 Y0 Z0
| ___^__-__-
| |___|__|
| ||___|
| |||
| _____^ - -
| | _______| |
| || _________|
4 | ||| X1 Y1 Z1
5 | ||| X2 Y2 Z2
| |||____^__-__- `Z` label
7 changes: 4 additions & 3 deletions compiler/rustc_resolve/src/macros.rs
Original file line number Diff line number Diff line change
@@ -140,9 +140,10 @@ pub(crate) fn registered_tools(tcx: TyCtxt<'_>, (): ()) -> RegisteredTools {
}
}
}
// We implicitly add `rustfmt`, `clippy`, `diagnostic` to known tools,
// but it's not an error to register them explicitly.
let predefined_tools = [sym::clippy, sym::rustfmt, sym::diagnostic, sym::miri];
// We implicitly add `rustfmt`, `clippy`, `diagnostic`, `miri` and `rust_analyzer` to known
// tools, but it's not an error to register them explicitly.
let predefined_tools =
[sym::clippy, sym::rustfmt, sym::diagnostic, sym::miri, sym::rust_analyzer];
registered_tools.extend(predefined_tools.iter().cloned().map(Ident::with_dummy_span));
registered_tools
}
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
@@ -1559,6 +1559,7 @@ symbols! {
rust_2018_preview,
rust_2021,
rust_2024,
rust_analyzer,
rust_begin_unwind,
rust_cold_cc,
rust_eh_catch_typeinfo,
50 changes: 33 additions & 17 deletions library/core/src/sync/atomic.rs
Original file line number Diff line number Diff line change
@@ -443,8 +443,8 @@ impl AtomicBool {
///
/// # Safety
///
/// * `ptr` must be aligned to `align_of::<AtomicBool>()` (note that on some platforms this can
/// be bigger than `align_of::<bool>()`).
/// * `ptr` must be aligned to `align_of::<AtomicBool>()` (note that this is always true, since
/// `align_of::<AtomicBool>() == 1`).
/// * `ptr` must be [valid] for both reads and writes for the whole lifetime `'a`.
/// * You must adhere to the [Memory model for atomic accesses]. In particular, it is not
/// 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> {
}

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

#[cfg(target_has_atomic_load_store)]
@@ -2116,18 +2116,24 @@ macro_rules! atomic_int {
$int_type:ident $atomic_type:ident) => {
/// An integer type which can be safely shared between threads.
///
/// This type has the same size and bit validity as the underlying
/// integer type, [`
/// This type has the same
#[doc = if_8_bit!(
$int_type,
yes = ["size, alignment, and bit validity"],
no = ["size and bit validity"],
)]
/// as the underlying integer type, [`
#[doc = $s_int_type]
/// `].
#[doc = if_not_8_bit! {
#[doc = if_8_bit! {
$int_type,
concat!(
no = [
"However, the alignment of this type is always equal to its ",
"size, even on targets where [`", $s_int_type, "`] has a ",
"lesser alignment."
)
],
}]
///
/// For more about the differences between atomic types and
/// non-atomic types as well as information about the portability of
/// this type, please see the [module-level documentation].
@@ -2220,9 +2226,19 @@ macro_rules! atomic_int {
///
/// # Safety
///
#[doc = concat!(" * `ptr` must be aligned to \
`align_of::<", stringify!($atomic_type), ">()` (note that on some platforms this \
can be bigger than `align_of::<", stringify!($int_type), ">()`).")]
/// * `ptr` must be aligned to
#[doc = concat!(" `align_of::<", stringify!($atomic_type), ">()`")]
#[doc = if_8_bit!{
$int_type,
yes = [
" (note that this is always true, since `align_of::<",
stringify!($atomic_type), ">() == 1`)."
],
no = [
" (note that on some platforms this can be bigger than `align_of::<",
stringify!($int_type), ">()`)."
],
}]
/// * `ptr` must be [valid] for both reads and writes for the whole lifetime `'a`.
/// * You must adhere to the [Memory model for atomic accesses]. In particular, it is not
/// allowed to mix atomic and non-atomic accesses, or atomic accesses of different sizes,
@@ -2261,12 +2277,12 @@ macro_rules! atomic_int {

#[doc = concat!("Get atomic access to a `&mut ", stringify!($int_type), "`.")]
///
#[doc = if_not_8_bit! {
#[doc = if_8_bit! {
$int_type,
concat!(
no = [
"**Note:** This function is only available on targets where `",
stringify!($int_type), "` has an alignment of ", $align, " bytes."
)
],
}]
///
/// # Examples
2 changes: 1 addition & 1 deletion src/doc/rustc/src/platform-support.md
Original file line number Diff line number Diff line change
@@ -119,7 +119,7 @@ The `std` column in the table below has the following meanings:

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

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

5 changes: 2 additions & 3 deletions tests/ui/async-await/async-is-unwindsafe.stderr
Original file line number Diff line number Diff line change
@@ -2,9 +2,8 @@ error[E0277]: the type `&mut Context<'_>` may not be safely transferred across a
--> $DIR/async-is-unwindsafe.rs:12:5
|
LL | is_unwindsafe(async {
| _____^_____________-
| |_____|
| ||
| ______^ -
| | ___________________|
LL | ||
LL | || use std::ptr::null;
LL | || use std::task::{Context, RawWaker, RawWakerVTable, Waker};
5 changes: 2 additions & 3 deletions tests/ui/lint/suggestions.stderr
Original file line number Diff line number Diff line change
@@ -41,9 +41,8 @@ warning: variable does not need to be mutable
--> $DIR/suggestions.rs:54:13
|
LL | let mut
| ______________^
| | _____________|
| ||
| _____________^
| |_____________|
LL | || b = 1;
| ||____________-^
| |_____________|