Skip to content
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

Rollup of 7 pull requests #110993

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
4f7b895
Tweak borrow suggestion
compiler-errors Apr 18, 2023
ab99cdf
Rename some suggestion/note functions
compiler-errors Apr 18, 2023
cf24419
Make suggest_deref_or_ref return a multipart suggestion
compiler-errors Apr 18, 2023
2bf5f77
treat the dev channel as nightly in compiletest
pietroalbini Apr 17, 2023
4edba55
add support for `// unset-exec-env` in compiletest
pietroalbini Apr 17, 2023
eb00459
update tests for the test harness's json formatting
pietroalbini Apr 17, 2023
21ae5bd
Add support for LibreSSL 3.7.x
mixi Apr 28, 2023
dc94522
bless line changes in tests-listing-format-json.run.stdout
cuviper Apr 28, 2023
10c77b1
rustdoc: move deref tests into a directory
notriddle Apr 28, 2023
2299ba1
rustdoc: fix weird margins between Deref impl items
notriddle Apr 28, 2023
47fb8e6
Deny the `unsafe_op_in_unsafe_fn` lint in
JohnBobbo96 Apr 28, 2023
500c19c
windows: kill rust-analyzer-proc-macro-srv before deleting stage0 dir…
jyn514 Apr 29, 2023
4f15a77
Add `rustdoc::unescaped_backtick` lint
Dec 17, 2022
4cfaead
Rollup merge of #105848 - lukas-code:backticks, r=GuillaumeGomez,jyn5…
matthiaskrgr Apr 29, 2023
07bf250
Rollup merge of #110504 - compiler-errors:tweak-borrow-sugg, r=cjgillot
matthiaskrgr Apr 29, 2023
af07ca6
Rollup merge of #110644 - pietroalbini:pa-json-formatting-tests, r=Ma…
matthiaskrgr Apr 29, 2023
c1d876f
Rollup merge of #110950 - JohnBobbo96:rustc_arena_unsafe_fn, r=Nilstrieb
matthiaskrgr Apr 29, 2023
da3e8e4
Rollup merge of #110951 - mixi:libressl-3.7.x, r=Mark-Simulacrum
matthiaskrgr Apr 29, 2023
78eb6c2
Rollup merge of #110964 - notriddle:notriddle/deref-impl, r=Guillaume…
matthiaskrgr Apr 29, 2023
ad1d3da
Rollup merge of #110979 - jyn514:windows-locking, r=ChrisDenton
matthiaskrgr Apr 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2370,9 +2370,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"

[[package]]
name = "openssl-sys"
version = "0.9.84"
version = "0.9.87"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a20eace9dc2d82904039cb76dcf50fb1a0bba071cfd1629720b5d6f1ddba0fa"
checksum = "8e17f59264b2809d77ae94f0e1ebabc434773f370d6ca667bd223ea10e06cc7e"
dependencies = [
"cc",
"libc",
Expand Down
42 changes: 31 additions & 11 deletions compiler/rustc_arena/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#![feature(rustc_attrs)]
#![cfg_attr(test, feature(test))]
#![feature(strict_provenance)]
#![deny(unsafe_op_in_unsafe_fn)]
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]
#![allow(clippy::mut_from_ref)] // Arena allocators are one of the places where this pattern is fine.
Expand Down Expand Up @@ -74,19 +75,27 @@ impl<T> ArenaChunk<T> {
#[inline]
unsafe fn new(capacity: usize) -> ArenaChunk<T> {
ArenaChunk {
storage: NonNull::new_unchecked(Box::into_raw(Box::new_uninit_slice(capacity))),
storage: NonNull::from(Box::leak(Box::new_uninit_slice(capacity))),
entries: 0,
}
}

/// Destroys this arena chunk.
///
/// # Safety
///
/// The caller must ensure that `len` elements of this chunk have been initialized.
#[inline]
unsafe fn destroy(&mut self, len: usize) {
// The branch on needs_drop() is an -O1 performance optimization.
// Without the branch, dropping TypedArena<u8> takes linear time.
// Without the branch, dropping TypedArena<T> takes linear time.
if mem::needs_drop::<T>() {
let slice = self.storage.as_mut();
ptr::drop_in_place(MaybeUninit::slice_assume_init_mut(&mut slice[..len]));
// SAFETY: The caller must ensure that `len` elements of this chunk have
// been initialized.
unsafe {
let slice = self.storage.as_mut();
ptr::drop_in_place(MaybeUninit::slice_assume_init_mut(&mut slice[..len]));
}
}
}

Expand Down Expand Up @@ -255,7 +264,9 @@ impl<T> TypedArena<T> {
self.ensure_capacity(len);

let start_ptr = self.ptr.get();
self.ptr.set(start_ptr.add(len));
// SAFETY: `self.ensure_capacity` makes sure that there is enough space
// for `len` elements.
unsafe { self.ptr.set(start_ptr.add(len)) };
start_ptr
}

Expand Down Expand Up @@ -483,6 +494,10 @@ impl DroplessArena {
}
}

/// # Safety
///
/// The caller must ensure that `mem` is valid for writes up to
/// `size_of::<T>() * len`.
#[inline]
unsafe fn write_from_iter<T, I: Iterator<Item = T>>(
&self,
Expand All @@ -494,13 +509,18 @@ impl DroplessArena {
// Use a manual loop since LLVM manages to optimize it better for
// slice iterators
loop {
let value = iter.next();
if i >= len || value.is_none() {
// We only return as many items as the iterator gave us, even
// though it was supposed to give us `len`
return slice::from_raw_parts_mut(mem, i);
// SAFETY: The caller must ensure that `mem` is valid for writes up to
// `size_of::<T>() * len`.
unsafe {
match iter.next() {
Some(value) if i < len => mem.add(i).write(value),
Some(_) | None => {
// We only return as many items as the iterator gave us, even
// though it was supposed to give us `len`
return slice::from_raw_parts_mut(mem, i);
}
}
}
ptr::write(mem.add(i), value.unwrap());
i += 1;
}
}
Expand Down
Loading