Skip to content

Commit 6188c58

Browse files
committed
Auto merge of #54711 - kennytm:rollup, r=kennytm
Rollup of 13 pull requests Successful merges: - #53784 (Document that slices cannot be larger than `isize::MAX` bytes) - #54308 (Better user experience when attempting to call associated functions with dot notation) - #54488 (in which we include attributes in unused `extern crate` suggestion spans) - #54544 (Indicate how to move value out of Box in docs.) - #54623 (Added help message for `impl_trait_in_bindings` feature gate) - #54641 (A few cleanups and minor improvements to rustc/infer) - #54656 (Correct doc for WorkQueue<T>::pop().) - #54674 (update miri) - #54676 (Remove `-Z disable_ast_check_for_mutation_in_guard`) - #54679 (Improve bug! message for impossible case in Relate) - #54681 (Rename sanitizer runtime libraries on OSX) - #54708 (Make ./x.py help <cmd> invoke ./x.py <cmd> -h on its own) - #54713 (Add nightly check for tool_lints warning)
2 parents f55129d + 5b08200 commit 6188c58

40 files changed

+491
-298
lines changed

Diff for: src/bootstrap/bootstrap.py

+5
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,11 @@ def bootstrap(help_triggered):
844844
def main():
845845
"""Entry point for the bootstrap process"""
846846
start_time = time()
847+
848+
# x.py help <cmd> ...
849+
if len(sys.argv) > 1 and sys.argv[1] == 'help':
850+
sys.argv = sys.argv[:1] + [sys.argv[2], '-h'] + sys.argv[3:]
851+
847852
help_triggered = (
848853
'-h' in sys.argv) or ('--help' in sys.argv) or (len(sys.argv) == 1)
849854
try:

Diff for: src/bootstrap/compile.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ impl Step for StdLink {
249249

250250
fn copy_apple_sanitizer_dylibs(builder: &Builder, native_dir: &Path, platform: &str, into: &Path) {
251251
for &sanitizer in &["asan", "tsan"] {
252-
let filename = format!("libclang_rt.{}_{}_dynamic.dylib", sanitizer, platform);
252+
let filename = format!("lib__rustc__clang_rt.{}_{}_dynamic.dylib", sanitizer, platform);
253253
let mut src_path = native_dir.join(sanitizer);
254254
src_path.push("build");
255255
src_path.push("lib");

Diff for: src/build_helper/lib.rs

+34-3
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,37 @@ pub struct NativeLibBoilerplate {
178178
pub out_dir: PathBuf,
179179
}
180180

181+
impl NativeLibBoilerplate {
182+
/// On OSX we don't want to ship the exact filename that compiler-rt builds.
183+
/// This conflicts with the system and ours is likely a wildly different
184+
/// version, so they can't be substituted.
185+
///
186+
/// As a result, we rename it here but we need to also use
187+
/// `install_name_tool` on OSX to rename the commands listed inside of it to
188+
/// ensure it's linked against correctly.
189+
pub fn fixup_sanitizer_lib_name(&self, sanitizer_name: &str) {
190+
if env::var("TARGET").unwrap() != "x86_64-apple-darwin" {
191+
return
192+
}
193+
194+
let dir = self.out_dir.join("build/lib/darwin");
195+
let name = format!("clang_rt.{}_osx_dynamic", sanitizer_name);
196+
let src = dir.join(&format!("lib{}.dylib", name));
197+
let new_name = format!("lib__rustc__{}.dylib", name);
198+
let dst = dir.join(&new_name);
199+
200+
println!("{} => {}", src.display(), dst.display());
201+
fs::rename(&src, &dst).unwrap();
202+
let status = Command::new("install_name_tool")
203+
.arg("-id")
204+
.arg(format!("@rpath/{}", new_name))
205+
.arg(&dst)
206+
.status()
207+
.expect("failed to execute `install_name_tool`");
208+
assert!(status.success());
209+
}
210+
}
211+
181212
impl Drop for NativeLibBoilerplate {
182213
fn drop(&mut self) {
183214
if !thread::panicking() {
@@ -229,7 +260,7 @@ pub fn native_lib_boilerplate(
229260
pub fn sanitizer_lib_boilerplate(sanitizer_name: &str)
230261
-> Result<(NativeLibBoilerplate, String), ()>
231262
{
232-
let (link_name, search_path, dynamic) = match &*env::var("TARGET").unwrap() {
263+
let (link_name, search_path, apple) = match &*env::var("TARGET").unwrap() {
233264
"x86_64-unknown-linux-gnu" => (
234265
format!("clang_rt.{}-x86_64", sanitizer_name),
235266
"build/lib/linux",
@@ -242,8 +273,8 @@ pub fn sanitizer_lib_boilerplate(sanitizer_name: &str)
242273
),
243274
_ => return Err(()),
244275
};
245-
let to_link = if dynamic {
246-
format!("dylib={}", link_name)
276+
let to_link = if apple {
277+
format!("dylib=__rustc__{}", link_name)
247278
} else {
248279
format!("static={}", link_name)
249280
};

Diff for: src/liballoc/boxed.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,18 @@
1616
//!
1717
//! # Examples
1818
//!
19-
//! Creating a box:
19+
//! Move a value from the stack to the heap by creating a [`Box`]:
2020
//!
2121
//! ```
22-
//! let x = Box::new(5);
22+
//! let val: u8 = 5;
23+
//! let boxed: Box<u8> = Box::new(val);
24+
//! ```
25+
//!
26+
//! Move a value from a [`Box`] back to the stack by [dereferencing]:
27+
//!
28+
//! ```
29+
//! let boxed: Box<u8> = Box::new(5);
30+
//! let val: u8 = *boxed;
2331
//! ```
2432
//!
2533
//! Creating a recursive data structure:
@@ -52,6 +60,9 @@
5260
//! elements are in the list, and so we don't know how much memory to allocate
5361
//! for a `Cons`. By introducing a `Box`, which has a defined size, we know how
5462
//! big `Cons` needs to be.
63+
//!
64+
//! [dereferencing]: ../../std/ops/trait.Deref.html
65+
//! [`Box`]: struct.Box.html
5566
5667
#![stable(feature = "rust1", since = "1.0.0")]
5768

Diff for: src/libcore/slice/mod.rs

+14-3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ use cmp::Ordering::{self, Less, Equal, Greater};
3434
use cmp;
3535
use fmt;
3636
use intrinsics::assume;
37+
use isize;
3738
use iter::*;
3839
use ops::{FnMut, Try, self};
3940
use option::Option;
@@ -4080,6 +4081,9 @@ unsafe impl<'a, T> TrustedRandomAccess for ChunksExactMut<'a, T> {
40804081
/// them from other data. You can obtain a pointer that is usable as `data`
40814082
/// for zero-length slices using [`NonNull::dangling()`].
40824083
///
4084+
/// The total size of the slice must be no larger than `isize::MAX` **bytes**
4085+
/// in memory. See the safety documentation of [`pointer::offset`].
4086+
///
40834087
/// # Caveat
40844088
///
40854089
/// The lifetime for the returned slice is inferred from its usage. To
@@ -4101,10 +4105,13 @@ unsafe impl<'a, T> TrustedRandomAccess for ChunksExactMut<'a, T> {
41014105
/// ```
41024106
///
41034107
/// [`NonNull::dangling()`]: ../../std/ptr/struct.NonNull.html#method.dangling
4108+
/// [`pointer::offset`]: ../../std/primitive.pointer.html#method.offset
41044109
#[inline]
41054110
#[stable(feature = "rust1", since = "1.0.0")]
41064111
pub unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] {
41074112
debug_assert!(data as usize % mem::align_of::<T>() == 0, "attempt to create unaligned slice");
4113+
debug_assert!(mem::size_of::<T>().saturating_mul(len) <= isize::MAX as usize,
4114+
"attempt to create slice covering half the address space");
41084115
Repr { raw: FatPtr { data, len } }.rust
41094116
}
41104117

@@ -4114,15 +4121,19 @@ pub unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] {
41144121
/// This function is unsafe for the same reasons as [`from_raw_parts`], as well
41154122
/// as not being able to provide a non-aliasing guarantee of the returned
41164123
/// mutable slice. `data` must be non-null and aligned even for zero-length
4117-
/// slices as with [`from_raw_parts`]. See the documentation of
4118-
/// [`from_raw_parts`] for more details.
4124+
/// slices as with [`from_raw_parts`]. The total size of the slice must be no
4125+
/// larger than `isize::MAX` **bytes** in memory.
4126+
///
4127+
/// See the documentation of [`from_raw_parts`] for more details.
41194128
///
41204129
/// [`from_raw_parts`]: ../../std/slice/fn.from_raw_parts.html
41214130
#[inline]
41224131
#[stable(feature = "rust1", since = "1.0.0")]
41234132
pub unsafe fn from_raw_parts_mut<'a, T>(data: *mut T, len: usize) -> &'a mut [T] {
41244133
debug_assert!(data as usize % mem::align_of::<T>() == 0, "attempt to create unaligned slice");
4125-
Repr { raw: FatPtr { data, len} }.rust_mut
4134+
debug_assert!(mem::size_of::<T>().saturating_mul(len) <= isize::MAX as usize,
4135+
"attempt to create slice covering half the address space");
4136+
Repr { raw: FatPtr { data, len } }.rust_mut
41264137
}
41274138

41284139
/// Converts a reference to T into a slice of length 1 (without copying).

0 commit comments

Comments
 (0)