Skip to content

Commit 83ca922

Browse files
committed
Auto merge of rust-lang#3033 - rust-lang:rustup-2023-08-21, r=RalfJung
Automatic sync from rustc
2 parents 92217bb + 5356aa4 commit 83ca922

File tree

413 files changed

+10494
-6723
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

413 files changed

+10494
-6723
lines changed

.github/workflows/ci.yml

-11
Original file line numberDiff line numberDiff line change
@@ -323,17 +323,6 @@ jobs:
323323
NO_DEBUG_ASSERTIONS: 1
324324
NO_OVERFLOW_CHECKS: 1
325325
os: macos-13
326-
- name: dist-x86_64-apple-alt
327-
env:
328-
SCRIPT: "./x.py dist bootstrap --include-default-paths"
329-
RUST_CONFIGURE_ARGS: "--enable-extended --enable-profiler --set rust.jemalloc --set llvm.ninja=false"
330-
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
331-
MACOSX_DEPLOYMENT_TARGET: 10.7
332-
SELECT_XCODE: /Applications/Xcode_13.4.1.app
333-
NO_LLVM_ASSERTIONS: 1
334-
NO_DEBUG_ASSERTIONS: 1
335-
NO_OVERFLOW_CHECKS: 1
336-
os: macos-13
337326
- name: x86_64-apple-1
338327
env:
339328
SCRIPT: "./x.py --stage 2 test --skip tests/ui --skip tests/rustdoc --skip tests/run-make-fulldeps"

Cargo.lock

+6-6
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,9 @@ dependencies = [
167167

168168
[[package]]
169169
name = "anyhow"
170-
version = "1.0.71"
170+
version = "1.0.75"
171171
source = "registry+https://github.com/rust-lang/crates.io-index"
172-
checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8"
172+
checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6"
173173
dependencies = [
174174
"backtrace",
175175
]
@@ -5126,9 +5126,9 @@ checksum = "aac81b6fd6beb5884b0cf3321b8117e6e5d47ecb6fc89f414cfdcca8b2fe2dd8"
51265126

51275127
[[package]]
51285128
name = "thiserror"
5129-
version = "1.0.40"
5129+
version = "1.0.47"
51305130
source = "registry+https://github.com/rust-lang/crates.io-index"
5131-
checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac"
5131+
checksum = "97a802ec30afc17eee47b2855fc72e0c4cd62be9b4efe6591edde0ec5bd68d8f"
51325132
dependencies = [
51335133
"thiserror-impl",
51345134
]
@@ -5155,9 +5155,9 @@ dependencies = [
51555155

51565156
[[package]]
51575157
name = "thiserror-impl"
5158-
version = "1.0.40"
5158+
version = "1.0.47"
51595159
source = "registry+https://github.com/rust-lang/crates.io-index"
5160-
checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f"
5160+
checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b"
51615161
dependencies = [
51625162
"proc-macro2",
51635163
"quote",

RELEASES.md

+105
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,108 @@
1+
Version 1.72.0 (2023-08-24)
2+
==========================
3+
4+
<a id="1.72.0-Language"></a>
5+
6+
Language
7+
--------
8+
9+
- [Replace const eval limit by a lint and add an exponential backoff warning](https://github.com/rust-lang/rust/pull/103877/)
10+
- [expand: Change how `#![cfg(FALSE)]` behaves on crate root](https://github.com/rust-lang/rust/pull/110141/)
11+
- [Stabilize inline asm for LoongArch64](https://github.com/rust-lang/rust/pull/111235/)
12+
- [Uplift `clippy::undropped_manually_drops` lint](https://github.com/rust-lang/rust/pull/111530/)
13+
- [Uplift `clippy::invalid_utf8_in_unchecked` lint](https://github.com/rust-lang/rust/pull/111543/)
14+
- [Uplift `clippy::cast_ref_to_mut` lint](https://github.com/rust-lang/rust/pull/111567/)
15+
- [Uplift `clippy::cmp_nan` lint](https://github.com/rust-lang/rust/pull/111818/)
16+
- [resolve: Remove artificial import ambiguity errors](https://github.com/rust-lang/rust/pull/112086/)
17+
- [Don't require associated types with Self: Sized bounds in `dyn Trait` objects](https://github.com/rust-lang/rust/pull/112319/)
18+
19+
<a id="1.72.0-Compiler"></a>
20+
21+
Compiler
22+
--------
23+
24+
- [Remember names of `cfg`-ed out items to mention them in diagnostics](https://github.com/rust-lang/rust/pull/109005/)
25+
- [Support for native WASM exceptions](https://github.com/rust-lang/rust/pull/111322/)
26+
- [Add support for NetBSD/aarch64-be (big-endian arm64).](https://github.com/rust-lang/rust/pull/111326/)
27+
- [Write to stdout if `-` is given as output file](https://github.com/rust-lang/rust/pull/111626/)
28+
- [Force all native libraries to be statically linked when linking a static binary](https://github.com/rust-lang/rust/pull/111698/)
29+
- [Add Tier 3 support for `loongarch64-unknown-none*`](https://github.com/rust-lang/rust/pull/112310/)
30+
- [Prevent `.eh_frame` from being emitted for `-C panic=abort`](https://github.com/rust-lang/rust/pull/112403/)
31+
- [Support 128-bit enum variant in debuginfo codegen](https://github.com/rust-lang/rust/pull/112474/)
32+
- [compiler: update solaris/illumos to enable tsan support.](https://github.com/rust-lang/rust/pull/112039/)
33+
34+
Refer to Rust's [platform support page][platform-support-doc]
35+
for more information on Rust's tiered platform support.
36+
37+
<a id="1.72.0-Libraries"></a>
38+
39+
Libraries
40+
---------
41+
42+
- [Document memory orderings of `thread::{park, unpark}`](https://github.com/rust-lang/rust/pull/99587/)
43+
- [io: soften ‘at most one write attempt’ requirement in io::Write::write](https://github.com/rust-lang/rust/pull/107200/)
44+
- [Specify behavior of HashSet::insert](https://github.com/rust-lang/rust/pull/107619/)
45+
- [Relax implicit `T: Sized` bounds on `BufReader<T>`, `BufWriter<T>` and `LineWriter<T>`](https://github.com/rust-lang/rust/pull/111074/)
46+
- [Update runtime guarantee for `select_nth_unstable`](https://github.com/rust-lang/rust/pull/111974/)
47+
- [Return `Ok` on kill if process has already exited](https://github.com/rust-lang/rust/pull/112594/)
48+
- [Implement PartialOrd for `Vec`s over different allocators](https://github.com/rust-lang/rust/pull/112632/)
49+
- [Use 128 bits for TypeId hash](https://github.com/rust-lang/rust/pull/109953/)
50+
- [Don't drain-on-drop in DrainFilter impls of various collections.](https://github.com/rust-lang/rust/pull/104455/)
51+
- [Make `{Arc,Rc,Weak}::ptr_eq` ignore pointer metadata](https://github.com/rust-lang/rust/pull/106450/)
52+
53+
<a id="1.72.0-Rustdoc"></a>
54+
55+
Rustdoc
56+
-------
57+
58+
- [Allow whitespace as path separator like double colon](https://github.com/rust-lang/rust/pull/108537/)
59+
- [Add search result item types after their name](https://github.com/rust-lang/rust/pull/110688/)
60+
- [Search for slices and arrays by type with `[]`](https://github.com/rust-lang/rust/pull/111958/)
61+
- [Clean up type unification and "unboxing"](https://github.com/rust-lang/rust/pull/112233/)
62+
63+
<a id="1.72.0-Stabilized-APIs"></a>
64+
65+
Stabilized APIs
66+
---------------
67+
68+
- [`impl<T: Send> Sync for mpsc::Sender<T>`](https://doc.rust-lang.org/nightly/std/sync/mpsc/struct.Sender.html#impl-Sync-for-Sender%3CT%3E)
69+
- [`impl TryFrom<&OsStr> for &str`](https://doc.rust-lang.org/nightly/std/primitive.str.html#impl-TryFrom%3C%26'a+OsStr%3E-for-%26'a+str)
70+
- [`String::leak`](https://doc.rust-lang.org/nightly/alloc/string/struct.String.html#method.leak)
71+
72+
These APIs are now stable in const contexts:
73+
74+
- [`CStr::from_bytes_with_nul`](https://doc.rust-lang.org/nightly/std/ffi/struct.CStr.html#method.from_bytes_with_nul)
75+
- [`CStr::to_bytes`](https://doc.rust-lang.org/nightly/std/ffi/struct.CStr.html#method.from_bytes_with_nul)
76+
- [`CStr::to_bytes_with_nul`](https://doc.rust-lang.org/nightly/std/ffi/struct.CStr.html#method.from_bytes_with_nul)
77+
- [`CStr::to_str`](https://doc.rust-lang.org/nightly/std/ffi/struct.CStr.html#method.from_bytes_with_nul)
78+
79+
<a id="1.72.0-Cargo"></a>
80+
81+
Cargo
82+
-----
83+
84+
- Enable `-Zdoctest-in-workspace` by default. When running each documentation
85+
test, the working directory is set to the root directory of the package the
86+
test belongs to.
87+
[docs](https://doc.rust-lang.org/nightly/cargo/commands/cargo-test.html#working-directory-of-tests)
88+
[#12221](https://github.com/rust-lang/cargo/pull/12221)
89+
[#12288](https://github.com/rust-lang/cargo/pull/12288)
90+
- Add support of the "default" keyword to reset previously set `build.jobs`
91+
parallelism back to the default.
92+
[#12222](https://github.com/rust-lang/cargo/pull/12222)
93+
94+
<a id="1.72.0-Compatibility-Notes"></a>
95+
96+
Compatibility Notes
97+
-------------------
98+
99+
- [Alter `Display` for `Ipv6Addr` for IPv4-compatible addresses](https://github.com/rust-lang/rust/pull/112606/)
100+
- Cargo changed feature name validation check to a hard error. The warning was
101+
added in Rust 1.49. These extended characters aren't allowed on crates.io, so
102+
this should only impact users of other registries, or people who don't publish
103+
to a registry.
104+
[#12291](https://github.com/rust-lang/cargo/pull/12291)
105+
1106
Version 1.71.0 (2023-07-13)
2107
==========================
3108

compiler/rustc_arena/src/lib.rs

+70-17
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
1212
test(no_crate_inject, attr(deny(warnings)))
1313
)]
14+
#![feature(core_intrinsics)]
1415
#![feature(dropck_eyepatch)]
1516
#![feature(new_uninit)]
1617
#![feature(maybe_uninit_slice)]
@@ -30,11 +31,11 @@ use smallvec::SmallVec;
3031

3132
use std::alloc::Layout;
3233
use std::cell::{Cell, RefCell};
33-
use std::cmp;
3434
use std::marker::PhantomData;
3535
use std::mem::{self, MaybeUninit};
3636
use std::ptr::{self, NonNull};
3737
use std::slice;
38+
use std::{cmp, intrinsics};
3839

3940
#[inline(never)]
4041
#[cold]
@@ -363,6 +364,22 @@ unsafe impl<#[may_dangle] T> Drop for TypedArena<T> {
363364

364365
unsafe impl<T: Send> Send for TypedArena<T> {}
365366

367+
#[inline(always)]
368+
fn align_down(val: usize, align: usize) -> usize {
369+
debug_assert!(align.is_power_of_two());
370+
val & !(align - 1)
371+
}
372+
373+
#[inline(always)]
374+
fn align_up(val: usize, align: usize) -> usize {
375+
debug_assert!(align.is_power_of_two());
376+
(val + align - 1) & !(align - 1)
377+
}
378+
379+
// Pointer alignment is common in compiler types, so keep `DroplessArena` aligned to them
380+
// to optimize away alignment code.
381+
const DROPLESS_ALIGNMENT: usize = mem::align_of::<usize>();
382+
366383
/// An arena that can hold objects of multiple different types that impl `Copy`
367384
/// and/or satisfy `!mem::needs_drop`.
368385
pub struct DroplessArena {
@@ -375,6 +392,8 @@ pub struct DroplessArena {
375392
/// start. (This is slightly simpler and faster than allocating upwards,
376393
/// see <https://fitzgeraldnick.com/2019/11/01/always-bump-downwards.html>.)
377394
/// When this pointer crosses the start pointer, a new chunk is allocated.
395+
///
396+
/// This is kept aligned to DROPLESS_ALIGNMENT.
378397
end: Cell<*mut u8>,
379398

380399
/// A vector of arena chunks.
@@ -395,9 +414,11 @@ impl Default for DroplessArena {
395414
}
396415

397416
impl DroplessArena {
398-
#[inline(never)]
399-
#[cold]
400-
fn grow(&self, additional: usize) {
417+
fn grow(&self, layout: Layout) {
418+
// Add some padding so we can align `self.end` while
419+
// stilling fitting in a `layout` allocation.
420+
let additional = layout.size() + cmp::max(DROPLESS_ALIGNMENT, layout.align()) - 1;
421+
401422
unsafe {
402423
let mut chunks = self.chunks.borrow_mut();
403424
let mut new_cap;
@@ -416,13 +437,35 @@ impl DroplessArena {
416437
// Also ensure that this chunk can fit `additional`.
417438
new_cap = cmp::max(additional, new_cap);
418439

419-
let mut chunk = ArenaChunk::new(new_cap);
440+
let mut chunk = ArenaChunk::new(align_up(new_cap, PAGE));
420441
self.start.set(chunk.start());
421-
self.end.set(chunk.end());
442+
443+
// Align the end to DROPLESS_ALIGNMENT
444+
let end = align_down(chunk.end().addr(), DROPLESS_ALIGNMENT);
445+
446+
// Make sure we don't go past `start`. This should not happen since the allocation
447+
// should be at least DROPLESS_ALIGNMENT - 1 bytes.
448+
debug_assert!(chunk.start().addr() <= end);
449+
450+
self.end.set(chunk.end().with_addr(end));
451+
422452
chunks.push(chunk);
423453
}
424454
}
425455

456+
#[inline(never)]
457+
#[cold]
458+
fn grow_and_alloc_raw(&self, layout: Layout) -> *mut u8 {
459+
self.grow(layout);
460+
self.alloc_raw_without_grow(layout).unwrap()
461+
}
462+
463+
#[inline(never)]
464+
#[cold]
465+
fn grow_and_alloc<T>(&self) -> *mut u8 {
466+
self.grow_and_alloc_raw(Layout::new::<T>())
467+
}
468+
426469
/// Allocates a byte slice with specified layout from the current memory
427470
/// chunk. Returns `None` if there is no free space left to satisfy the
428471
/// request.
@@ -432,12 +475,17 @@ impl DroplessArena {
432475
let old_end = self.end.get();
433476
let end = old_end.addr();
434477

435-
let align = layout.align();
436-
let bytes = layout.size();
478+
// Align allocated bytes so that `self.end` stays aligned to DROPLESS_ALIGNMENT
479+
let bytes = align_up(layout.size(), DROPLESS_ALIGNMENT);
480+
481+
// Tell LLVM that `end` is aligned to DROPLESS_ALIGNMENT
482+
unsafe { intrinsics::assume(end == align_down(end, DROPLESS_ALIGNMENT)) };
437483

438-
let new_end = end.checked_sub(bytes)? & !(align - 1);
484+
let new_end = align_down(end.checked_sub(bytes)?, layout.align());
439485
if start <= new_end {
440486
let new_end = old_end.with_addr(new_end);
487+
// `new_end` is aligned to DROPLESS_ALIGNMENT as `align_down` preserves alignment
488+
// as both `end` and `bytes` are already aligned to DROPLESS_ALIGNMENT.
441489
self.end.set(new_end);
442490
Some(new_end)
443491
} else {
@@ -448,21 +496,26 @@ impl DroplessArena {
448496
#[inline]
449497
pub fn alloc_raw(&self, layout: Layout) -> *mut u8 {
450498
assert!(layout.size() != 0);
451-
loop {
452-
if let Some(a) = self.alloc_raw_without_grow(layout) {
453-
break a;
454-
}
455-
// No free space left. Allocate a new chunk to satisfy the request.
456-
// On failure the grow will panic or abort.
457-
self.grow(layout.size());
499+
if let Some(a) = self.alloc_raw_without_grow(layout) {
500+
return a;
458501
}
502+
// No free space left. Allocate a new chunk to satisfy the request.
503+
// On failure the grow will panic or abort.
504+
self.grow_and_alloc_raw(layout)
459505
}
460506

461507
#[inline]
462508
pub fn alloc<T>(&self, object: T) -> &mut T {
463509
assert!(!mem::needs_drop::<T>());
510+
assert!(mem::size_of::<T>() != 0);
464511

465-
let mem = self.alloc_raw(Layout::for_value::<T>(&object)) as *mut T;
512+
let mem = if let Some(a) = self.alloc_raw_without_grow(Layout::for_value::<T>(&object)) {
513+
a
514+
} else {
515+
// No free space left. Allocate a new chunk to satisfy the request.
516+
// On failure the grow will panic or abort.
517+
self.grow_and_alloc::<T>()
518+
} as *mut T;
466519

467520
unsafe {
468521
// Write into uninitialized memory.

compiler/rustc_ast/src/mut_visit.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use crate::tokenstream::*;
1313
use crate::{ast::*, StaticItem};
1414

1515
use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
16+
use rustc_data_structures::stack::ensure_sufficient_stack;
1617
use rustc_data_structures::sync::Lrc;
1718
use rustc_span::source_map::Spanned;
1819
use rustc_span::symbol::Ident;
@@ -1369,7 +1370,7 @@ pub fn noop_visit_expr<T: MutVisitor>(
13691370
ExprKind::If(cond, tr, fl) => {
13701371
vis.visit_expr(cond);
13711372
vis.visit_block(tr);
1372-
visit_opt(fl, |fl| vis.visit_expr(fl));
1373+
visit_opt(fl, |fl| ensure_sufficient_stack(|| vis.visit_expr(fl)));
13731374
}
13741375
ExprKind::While(cond, body, label) => {
13751376
vis.visit_expr(cond);

compiler/rustc_ast_pretty/src/pprust/state.rs

+11
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ pub fn print_crate<'a>(
150150
/// and also addresses some specific regressions described in #63896 and #73345.
151151
fn tt_prepend_space(tt: &TokenTree, prev: &TokenTree) -> bool {
152152
if let TokenTree::Token(token, _) = prev {
153+
// No space after these tokens, e.g. `x.y`, `$e`
154+
// (The carets point to `prev`.) ^ ^
153155
if matches!(token.kind, token::Dot | token::Dollar) {
154156
return false;
155157
}
@@ -158,10 +160,19 @@ fn tt_prepend_space(tt: &TokenTree, prev: &TokenTree) -> bool {
158160
}
159161
}
160162
match tt {
163+
// No space before these tokens, e.g. `foo,`, `println!`, `x.y`
164+
// (The carets point to `token`.) ^ ^ ^
165+
//
166+
// FIXME: having `Not` here works well for macro invocations like
167+
// `println!()`, but is bad when `!` means "logical not" or "the never
168+
// type", where the lack of space causes ugliness like this:
169+
// `Fn() ->!`, `x =! y`, `if! x { f(); }`.
161170
TokenTree::Token(token, _) => !matches!(token.kind, token::Comma | token::Not | token::Dot),
171+
// No space before parentheses if preceded by these tokens, e.g. `foo(...)`
162172
TokenTree::Delimited(_, Delimiter::Parenthesis, _) => {
163173
!matches!(prev, TokenTree::Token(Token { kind: token::Ident(..), .. }, _))
164174
}
175+
// No space before brackets if preceded by these tokens, e.g. `#[...]`
165176
TokenTree::Delimited(_, Delimiter::Bracket, _) => {
166177
!matches!(prev, TokenTree::Token(Token { kind: token::Pound, .. }, _))
167178
}

compiler/rustc_borrowck/src/consumers.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub use super::{
3030
/// will be retrieved.
3131
#[derive(Debug, Copy, Clone)]
3232
pub enum ConsumerOptions {
33-
/// Retrieve the [`Body`] along with the [`BorrowSet`](super::borrow_set::BorrowSet)
33+
/// Retrieve the [`Body`] along with the [`BorrowSet`]
3434
/// and [`RegionInferenceContext`]. If you would like the body only, use
3535
/// [`TyCtxt::mir_promoted`].
3636
///

0 commit comments

Comments
 (0)