Skip to content

Commit 9d09331

Browse files
committed
Auto merge of rust-lang#74245 - Manishearth:rollup-r0xq9dn, r=Manishearth
Rollup of 10 pull requests Successful merges: - rust-lang#72920 (Stabilize `transmute` in constants and statics but not const fn) - rust-lang#73715 (debuginfo: Mangle tuples to be natvis friendly, typedef basic types) - rust-lang#74066 (Optimize is_ascii for str and [u8].) - rust-lang#74116 (Fix cross compilation of LLVM to aarch64 Windows targets) - rust-lang#74167 (linker: illumos ld does not support --eh-frame-hdr) - rust-lang#74168 (Add a help to use `in_band_lifetimes` in nightly) - rust-lang#74197 (Reword incorrect `self` token suggestion) - rust-lang#74213 (Minor refactor for rustc_resolve diagnostics match) - rust-lang#74240 (Fix rust-lang#74081 and add the test case from rust-lang#74236) - rust-lang#74241 (update miri) Failed merges: r? @ghost
2 parents 346aec9 + c8c4fd7 commit 9d09331

File tree

71 files changed

+955
-133
lines changed

Some content is hidden

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

71 files changed

+955
-133
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -404,9 +404,9 @@ version = "0.1.0"
404404

405405
[[package]]
406406
name = "cc"
407-
version = "1.0.54"
407+
version = "1.0.57"
408408
source = "registry+https://github.com/rust-lang/crates.io-index"
409-
checksum = "7bbb73db36c1246e9034e307d0fba23f9a2e251faa47ade70c1bd252220c8311"
409+
checksum = "0fde55d2a2bfaa4c9668bbc63f531fbdeee3ffe188f4662511ce2c22b3eedebe"
410410
dependencies = [
411411
"jobserver",
412412
]

src/bootstrap/native.rs

+23-8
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
//! ensure that they're always in place if needed.
1010
1111
use std::env;
12+
use std::env::consts::EXE_EXTENSION;
1213
use std::ffi::OsString;
1314
use std::fs::{self, File};
1415
use std::io;
@@ -252,8 +253,14 @@ impl Step for Llvm {
252253
// FIXME: if the llvm root for the build triple is overridden then we
253254
// should use llvm-tblgen from there, also should verify that it
254255
// actually exists most of the time in normal installs of LLVM.
255-
let host = builder.llvm_out(builder.config.build).join("bin/llvm-tblgen");
256-
cfg.define("CMAKE_CROSSCOMPILING", "True").define("LLVM_TABLEGEN", &host);
256+
let host_bin = builder.llvm_out(builder.config.build).join("bin");
257+
cfg.define("CMAKE_CROSSCOMPILING", "True");
258+
cfg.define("LLVM_TABLEGEN", host_bin.join("llvm-tblgen").with_extension(EXE_EXTENSION));
259+
cfg.define("LLVM_NM", host_bin.join("llvm-nm").with_extension(EXE_EXTENSION));
260+
cfg.define(
261+
"LLVM_CONFIG_PATH",
262+
host_bin.join("llvm-config").with_extension(EXE_EXTENSION),
263+
);
257264

258265
if target.contains("netbsd") {
259266
cfg.define("CMAKE_SYSTEM_NAME", "NetBSD");
@@ -262,8 +269,6 @@ impl Step for Llvm {
262269
} else if target.contains("windows") {
263270
cfg.define("CMAKE_SYSTEM_NAME", "Windows");
264271
}
265-
266-
cfg.define("LLVM_NATIVE_BUILD", builder.llvm_out(builder.config.build).join("build"));
267272
}
268273

269274
if let Some(ref suffix) = builder.config.llvm_version_suffix {
@@ -431,6 +436,9 @@ fn configure_cmake(
431436
cflags.push_str(" -miphoneos-version-min=10.0");
432437
}
433438
}
439+
if builder.config.llvm_clang_cl.is_some() {
440+
cflags.push_str(&format!(" --target={}", target))
441+
}
434442
cfg.define("CMAKE_C_FLAGS", cflags);
435443
let mut cxxflags = builder.cflags(target, GitRepo::Llvm).join(" ");
436444
if builder.config.llvm_static_stdcpp && !target.contains("msvc") && !target.contains("netbsd") {
@@ -439,6 +447,9 @@ fn configure_cmake(
439447
if let Some(ref s) = builder.config.llvm_cxxflags {
440448
cxxflags.push_str(&format!(" {}", s));
441449
}
450+
if builder.config.llvm_clang_cl.is_some() {
451+
cxxflags.push_str(&format!(" --target={}", target))
452+
}
442453
cfg.define("CMAKE_CXX_FLAGS", cxxflags);
443454
if let Some(ar) = builder.ar(target) {
444455
if ar.is_absolute() {
@@ -484,7 +495,7 @@ impl Step for Lld {
484495
run.builder.ensure(Lld { target: run.target });
485496
}
486497

487-
/// Compile LLVM for `target`.
498+
/// Compile LLD for `target`.
488499
fn run(self, builder: &Builder<'_>) -> PathBuf {
489500
if builder.config.dry_run {
490501
return PathBuf::from("lld-out-dir-test-gen");
@@ -521,6 +532,7 @@ impl Step for Lld {
521532
// can't build on a system where your paths require `\` on Windows, but
522533
// there's probably a lot of reasons you can't do that other than this.
523534
let llvm_config_shim = env::current_exe().unwrap().with_file_name("llvm-config-wrapper");
535+
524536
cfg.out_dir(&out_dir)
525537
.profile("Release")
526538
.env("LLVM_CONFIG_REAL", &llvm_config)
@@ -543,7 +555,10 @@ impl Step for Lld {
543555
if target != builder.config.build {
544556
cfg.env("LLVM_CONFIG_SHIM_REPLACE", &builder.config.build)
545557
.env("LLVM_CONFIG_SHIM_REPLACE_WITH", &target)
546-
.define("LLVM_TABLEGEN_EXE", llvm_config.with_file_name("llvm-tblgen"));
558+
.define(
559+
"LLVM_TABLEGEN_EXE",
560+
llvm_config.with_file_name("llvm-tblgen").with_extension(EXE_EXTENSION),
561+
);
547562
}
548563

549564
// Explicitly set C++ standard, because upstream doesn't do so
@@ -595,8 +610,8 @@ impl Step for TestHelpers {
595610
}
596611

597612
// We may have found various cross-compilers a little differently due to our
598-
// extra configuration, so inform gcc of these compilers. Note, though, that
599-
// on MSVC we still need gcc's detection of env vars (ugh).
613+
// extra configuration, so inform cc of these compilers. Note, though, that
614+
// on MSVC we still need cc's detection of env vars (ugh).
600615
if !target.contains("msvc") {
601616
if let Some(ar) = builder.ar(target) {
602617
cfg.archiver(ar);

src/etc/natvis/intrinsic.natvis

+124
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,128 @@
2121
</ArrayItems>
2222
</Expand>
2323
</Type>
24+
<Type Name="tuple&lt;&gt;">
25+
<DisplayString>()</DisplayString>
26+
</Type>
27+
<Type Name="tuple&lt;*&gt;">
28+
<DisplayString>({__0})</DisplayString>
29+
<Expand>
30+
<Item Name="[0]">__0</Item>
31+
</Expand>
32+
</Type>
33+
<Type Name="tuple&lt;*,*&gt;">
34+
<DisplayString>({__0}, {__1})</DisplayString>
35+
<Expand>
36+
<Item Name="[0]">__0</Item>
37+
<Item Name="[1]">__1</Item>
38+
</Expand>
39+
</Type>
40+
<Type Name="tuple&lt;*,*,*&gt;">
41+
<DisplayString>({__0}, {__1}, {__2})</DisplayString>
42+
<Expand>
43+
<Item Name="[0]">__0</Item>
44+
<Item Name="[1]">__1</Item>
45+
<Item Name="[2]">__2</Item>
46+
</Expand>
47+
</Type>
48+
<Type Name="tuple&lt;*,*,*,*&gt;">
49+
<DisplayString>({__0}, {__1}, {__2}, {__3})</DisplayString>
50+
<Expand>
51+
<Item Name="[0]">__0</Item>
52+
<Item Name="[1]">__1</Item>
53+
<Item Name="[2]">__2</Item>
54+
<Item Name="[3]">__3</Item>
55+
</Expand>
56+
</Type>
57+
<Type Name="tuple&lt;*,*,*,*,*&gt;">
58+
<DisplayString>({__0}, {__1}, {__2}, {__3}, {__4})</DisplayString>
59+
<Expand>
60+
<Item Name="[0]">__0</Item>
61+
<Item Name="[1]">__1</Item>
62+
<Item Name="[2]">__2</Item>
63+
<Item Name="[3]">__3</Item>
64+
<Item Name="[4]">__4</Item>
65+
</Expand>
66+
</Type>
67+
<Type Name="tuple&lt;*,*,*,*,*,*&gt;">
68+
<DisplayString>({__0}, {__1}, {__2}, {__3}, {__4}, {__5})</DisplayString>
69+
<Expand>
70+
<Item Name="[0]">__0</Item>
71+
<Item Name="[1]">__1</Item>
72+
<Item Name="[2]">__2</Item>
73+
<Item Name="[3]">__3</Item>
74+
<Item Name="[4]">__4</Item>
75+
<Item Name="[5]">__5</Item>
76+
</Expand>
77+
</Type>
78+
<Type Name="tuple&lt;*,*,*,*,*,*,*&gt;">
79+
<DisplayString>({__0}, {__1}, {__2}, {__3}, {__4}, {__5}, {__6})</DisplayString>
80+
<Expand>
81+
<Item Name="[0]">__0</Item>
82+
<Item Name="[1]">__1</Item>
83+
<Item Name="[2]">__2</Item>
84+
<Item Name="[3]">__3</Item>
85+
<Item Name="[4]">__4</Item>
86+
<Item Name="[5]">__5</Item>
87+
<Item Name="[6]">__6</Item>
88+
</Expand>
89+
</Type>
90+
<Type Name="tuple&lt;*,*,*,*,*,*,*,*&gt;">
91+
<DisplayString>({__0}, {__1}, {__2}, {__3}, {__4}, {__5}, {__6}, {__7})</DisplayString>
92+
<Expand>
93+
<Item Name="[0]">__0</Item>
94+
<Item Name="[1]">__1</Item>
95+
<Item Name="[2]">__2</Item>
96+
<Item Name="[3]">__3</Item>
97+
<Item Name="[4]">__4</Item>
98+
<Item Name="[5]">__5</Item>
99+
<Item Name="[6]">__6</Item>
100+
<Item Name="[7]">__7</Item>
101+
</Expand>
102+
</Type>
103+
<Type Name="tuple&lt;*,*,*,*,*,*,*,*,*&gt;">
104+
<DisplayString>({__0}, {__1}, {__2}, {__3}, {__4}, {__5}, {__6}, {__7}, {__8})</DisplayString>
105+
<Expand>
106+
<Item Name="[0]">__0</Item>
107+
<Item Name="[1]">__1</Item>
108+
<Item Name="[2]">__2</Item>
109+
<Item Name="[3]">__3</Item>
110+
<Item Name="[4]">__4</Item>
111+
<Item Name="[5]">__5</Item>
112+
<Item Name="[6]">__6</Item>
113+
<Item Name="[7]">__7</Item>
114+
<Item Name="[8]">__8</Item>
115+
</Expand>
116+
</Type>
117+
<Type Name="tuple&lt;*,*,*,*,*,*,*,*,*,*&gt;">
118+
<DisplayString>({__0}, {__1}, {__2}, {__3}, {__4}, {__5}, {__6}, {__7}, {__8}, {__9})</DisplayString>
119+
<Expand>
120+
<Item Name="[0]">__0</Item>
121+
<Item Name="[1]">__1</Item>
122+
<Item Name="[2]">__2</Item>
123+
<Item Name="[3]">__3</Item>
124+
<Item Name="[4]">__4</Item>
125+
<Item Name="[5]">__5</Item>
126+
<Item Name="[6]">__6</Item>
127+
<Item Name="[7]">__7</Item>
128+
<Item Name="[8]">__8</Item>
129+
<Item Name="[9]">__9</Item>
130+
</Expand>
131+
</Type>
132+
<Type Name="tuple&lt;*,*,*,*,*,*,*,*,*,*,*&gt;">
133+
<DisplayString>({__0}, {__1}, {__2}, {__3}, {__4}, {__5}, {__6}, {__7}, {__8}, {__9}, ...)</DisplayString>
134+
<Expand>
135+
<Item Name="[0]">__0</Item>
136+
<Item Name="[1]">__1</Item>
137+
<Item Name="[2]">__2</Item>
138+
<Item Name="[3]">__3</Item>
139+
<Item Name="[4]">__4</Item>
140+
<Item Name="[5]">__5</Item>
141+
<Item Name="[6]">__6</Item>
142+
<Item Name="[7]">__7</Item>
143+
<Item Name="[8]">__8</Item>
144+
<Item Name="[9]">__9</Item>
145+
<Synthetic Name="[...]"><DisplayString>...</DisplayString></Synthetic>
146+
</Expand>
147+
</Type>
24148
</AutoVisualizer>

src/libcore/benches/ascii.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
mod is_ascii;
2+
13
// Lower-case ASCII 'a' is the first byte that has its highest bit set
24
// after wrap-adding 0x1F:
35
//

src/libcore/benches/ascii/is_ascii.rs

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
use super::{LONG, MEDIUM, SHORT};
2+
use test::black_box;
3+
use test::Bencher;
4+
5+
macro_rules! benches {
6+
($( fn $name: ident($arg: ident: &[u8]) $body: block )+) => {
7+
benches!(mod short SHORT[..] $($name $arg $body)+);
8+
benches!(mod medium MEDIUM[..] $($name $arg $body)+);
9+
benches!(mod long LONG[..] $($name $arg $body)+);
10+
// Ensure we benchmark cases where the functions are called with strings
11+
// that are not perfectly aligned or have a length which is not a
12+
// multiple of size_of::<usize>() (or both)
13+
benches!(mod unaligned_head MEDIUM[1..] $($name $arg $body)+);
14+
benches!(mod unaligned_tail MEDIUM[..(MEDIUM.len() - 1)] $($name $arg $body)+);
15+
benches!(mod unaligned_both MEDIUM[1..(MEDIUM.len() - 1)] $($name $arg $body)+);
16+
};
17+
18+
(mod $mod_name: ident $input: ident [$range: expr] $($name: ident $arg: ident $body: block)+) => {
19+
mod $mod_name {
20+
use super::*;
21+
$(
22+
#[bench]
23+
fn $name(bencher: &mut Bencher) {
24+
bencher.bytes = $input[$range].len() as u64;
25+
let mut vec = $input.as_bytes().to_vec();
26+
bencher.iter(|| {
27+
let $arg: &[u8] = &black_box(&mut vec)[$range];
28+
black_box($body)
29+
})
30+
}
31+
)+
32+
}
33+
};
34+
}
35+
36+
benches! {
37+
fn case00_libcore(bytes: &[u8]) {
38+
bytes.is_ascii()
39+
}
40+
41+
fn case01_iter_all(bytes: &[u8]) {
42+
bytes.iter().all(|b| b.is_ascii())
43+
}
44+
45+
fn case02_align_to(bytes: &[u8]) {
46+
is_ascii_align_to(bytes)
47+
}
48+
49+
fn case03_align_to_unrolled(bytes: &[u8]) {
50+
is_ascii_align_to_unrolled(bytes)
51+
}
52+
}
53+
54+
// These are separate since it's easier to debug errors if they don't go through
55+
// macro expansion first.
56+
fn is_ascii_align_to(bytes: &[u8]) -> bool {
57+
if bytes.len() < core::mem::size_of::<usize>() {
58+
return bytes.iter().all(|b| b.is_ascii());
59+
}
60+
// SAFETY: transmuting a sequence of `u8` to `usize` is always fine
61+
let (head, body, tail) = unsafe { bytes.align_to::<usize>() };
62+
head.iter().all(|b| b.is_ascii())
63+
&& body.iter().all(|w| !contains_nonascii(*w))
64+
&& tail.iter().all(|b| b.is_ascii())
65+
}
66+
67+
fn is_ascii_align_to_unrolled(bytes: &[u8]) -> bool {
68+
if bytes.len() < core::mem::size_of::<usize>() {
69+
return bytes.iter().all(|b| b.is_ascii());
70+
}
71+
// SAFETY: transmuting a sequence of `u8` to `[usize; 2]` is always fine
72+
let (head, body, tail) = unsafe { bytes.align_to::<[usize; 2]>() };
73+
head.iter().all(|b| b.is_ascii())
74+
&& body.iter().all(|w| !contains_nonascii(w[0] | w[1]))
75+
&& tail.iter().all(|b| b.is_ascii())
76+
}
77+
78+
#[inline]
79+
fn contains_nonascii(v: usize) -> bool {
80+
const NONASCII_MASK: usize = 0x80808080_80808080u64 as usize;
81+
(NONASCII_MASK & v) != 0
82+
}

src/libcore/intrinsics.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,9 @@ extern "rust-intrinsic" {
12851285
/// }
12861286
/// ```
12871287
#[stable(feature = "rust1", since = "1.0.0")]
1288-
#[rustc_const_unstable(feature = "const_transmute", issue = "53605")]
1288+
// NOTE: While this makes the intrinsic const stable, we have some custom code in const fn
1289+
// checks that prevent its use within `const fn`.
1290+
#[rustc_const_stable(feature = "const_transmute", since = "1.46.0")]
12891291
pub fn transmute<T, U>(e: T) -> U;
12901292

12911293
/// Returns `true` if the actual type given as `T` requires drop

src/libcore/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
#![feature(rtm_target_feature)]
141141
#![feature(f16c_target_feature)]
142142
#![feature(hexagon_target_feature)]
143-
#![feature(const_transmute)]
143+
#![cfg_attr(not(bootstrap), feature(const_fn_transmute))]
144144
#![feature(abi_unadjusted)]
145145
#![feature(adx_target_feature)]
146146
#![feature(maybe_uninit_slice)]

0 commit comments

Comments
 (0)