Skip to content

Commit 199fe1d

Browse files
committedSep 24, 2022
Auto merge of rust-lang#102223 - matthiaskrgr:rollup-wb1qdhk, r=matthiaskrgr
Rollup of 11 pull requests Successful merges: - rust-lang#101780 (Add a platform support document for Android) - rust-lang#102044 (Remove `RtlGenRandom` (take two)) - rust-lang#102081 (Adding ignore fuchsia tests for execvp (pre_exec)) - rust-lang#102082 (Adding ignore fuchsia non-applicable commands) - rust-lang#102146 (rustdoc: CSS prevent sidebar width change jank) - rust-lang#102152 (Calculate `ProjectionTy::trait_def_id` for return-position `impl Trait` in trait correctly) - rust-lang#102175 (Also require other subtrees to always build successfully) - rust-lang#102176 (Add `llvm-dis` to the set of tools in `ci-llvm`) - rust-lang#102188 (Update doc after renaming `fn is_zero`) - rust-lang#102199 (Improve rustdoc GUI tests) - rust-lang#102218 (Document some missing command-line arguments) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 0696895 + 4fc33e9 commit 199fe1d

25 files changed

+226
-106
lines changed
 

‎compiler/rustc_middle/src/ty/sty.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -1133,9 +1133,13 @@ pub struct ProjectionTy<'tcx> {
11331133

11341134
impl<'tcx> ProjectionTy<'tcx> {
11351135
pub fn trait_def_id(&self, tcx: TyCtxt<'tcx>) -> DefId {
1136-
let parent = tcx.parent(self.item_def_id);
1137-
assert_eq!(tcx.def_kind(parent), DefKind::Trait);
1138-
parent
1136+
match tcx.def_kind(self.item_def_id) {
1137+
DefKind::AssocTy | DefKind::AssocConst => tcx.parent(self.item_def_id),
1138+
DefKind::ImplTraitPlaceholder => {
1139+
tcx.parent(tcx.impl_trait_in_trait_parent(self.item_def_id))
1140+
}
1141+
kind => bug!("unexpected DefKind in ProjectionTy: {kind:?}"),
1142+
}
11391143
}
11401144

11411145
/// Extracts the underlying trait reference and own substs from this projection.

‎library/std/src/panicking.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ pub mod panic_count {
300300
thread_local! { static LOCAL_PANIC_COUNT: Cell<usize> = const { Cell::new(0) } }
301301

302302
// Sum of panic counts from all threads. The purpose of this is to have
303-
// a fast path in `is_zero` (which is used by `panicking`). In any particular
303+
// a fast path in `count_is_zero` (which is used by `panicking`). In any particular
304304
// thread, if that thread currently views `GLOBAL_PANIC_COUNT` as being zero,
305305
// then `LOCAL_PANIC_COUNT` in that thread is zero. This invariant holds before
306306
// and after increase and decrease, but not necessarily during their execution.
@@ -369,7 +369,7 @@ pub mod panic_count {
369369
}
370370

371371
// Slow path is in a separate function to reduce the amount of code
372-
// inlined from `is_zero`.
372+
// inlined from `count_is_zero`.
373373
#[inline(never)]
374374
#[cold]
375375
fn is_zero_slow_path() -> bool {

‎library/std/src/sys/windows/c.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@ pub const STATUS_INVALID_PARAMETER: NTSTATUS = 0xc000000d_u32 as _;
279279
pub const STATUS_PENDING: NTSTATUS = 0x103 as _;
280280
pub const STATUS_END_OF_FILE: NTSTATUS = 0xC0000011_u32 as _;
281281
pub const STATUS_NOT_IMPLEMENTED: NTSTATUS = 0xC0000002_u32 as _;
282-
pub const STATUS_NOT_SUPPORTED: NTSTATUS = 0xC00000BB_u32 as _;
283282

284283
// Equivalent to the `NT_SUCCESS` C preprocessor macro.
285284
// See: https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/using-ntstatus-values
@@ -289,6 +288,7 @@ pub fn nt_success(status: NTSTATUS) -> bool {
289288

290289
// "RNG\0"
291290
pub const BCRYPT_RNG_ALGORITHM: &[u16] = &[b'R' as u16, b'N' as u16, b'G' as u16, 0];
291+
pub const BCRYPT_USE_SYSTEM_PREFERRED_RNG: DWORD = 0x00000002;
292292

293293
#[repr(C)]
294294
pub struct UNICODE_STRING {
@@ -817,10 +817,6 @@ if #[cfg(not(target_vendor = "uwp"))] {
817817

818818
#[link(name = "advapi32")]
819819
extern "system" {
820-
// Forbidden when targeting UWP
821-
#[link_name = "SystemFunction036"]
822-
pub fn RtlGenRandom(RandomBuffer: *mut u8, RandomBufferLength: ULONG) -> BOOLEAN;
823-
824820
// Allowed but unused by UWP
825821
pub fn OpenProcessToken(
826822
ProcessHandle: HANDLE,

‎library/std/src/sys/windows/rand.rs

+28-48
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,12 @@
1313
//! but significant number of users to experience panics caused by a failure of
1414
//! this function. See [#94098].
1515
//!
16-
//! The current version changes this to use the `BCRYPT_RNG_ALG_HANDLE`
17-
//! [Pseudo-handle], which gets the default RNG algorithm without querying the
18-
//! system preference thus hopefully avoiding the previous issue.
19-
//! This is only supported on Windows 10+ so a fallback is used for older versions.
16+
//! The current version falls back to using `BCryptOpenAlgorithmProvider` if
17+
//! `BCRYPT_USE_SYSTEM_PREFERRED_RNG` fails for any reason.
2018
//!
2119
//! [#94098]: https://github.com/rust-lang/rust/issues/94098
2220
//! [`RtlGenRandom`]: https://docs.microsoft.com/en-us/windows/win32/api/ntsecapi/nf-ntsecapi-rtlgenrandom
2321
//! [`BCryptGenRandom`]: https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom
24-
//! [Pseudo-handle]: https://docs.microsoft.com/en-us/windows/win32/seccng/cng-algorithm-pseudo-handles
2522
use crate::mem;
2623
use crate::ptr;
2724
use crate::sys::c;
@@ -33,37 +30,35 @@ use crate::sys::c;
3330
/// [`HashMap`]: crate::collections::HashMap
3431
/// [`RandomState`]: crate::collections::hash_map::RandomState
3532
pub fn hashmap_random_keys() -> (u64, u64) {
36-
Rng::open().and_then(|rng| rng.gen_random_keys()).unwrap_or_else(fallback_rng)
33+
Rng::SYSTEM.gen_random_keys().unwrap_or_else(fallback_rng)
3734
}
3835

39-
struct Rng(c::BCRYPT_ALG_HANDLE);
36+
struct Rng {
37+
algorithm: c::BCRYPT_ALG_HANDLE,
38+
flags: u32,
39+
}
4040
impl Rng {
41-
#[cfg(miri)]
42-
fn open() -> Result<Self, c::NTSTATUS> {
43-
const BCRYPT_RNG_ALG_HANDLE: c::BCRYPT_ALG_HANDLE = ptr::invalid_mut(0x81);
44-
let _ = (
45-
c::BCryptOpenAlgorithmProvider,
46-
c::BCryptCloseAlgorithmProvider,
47-
c::BCRYPT_RNG_ALGORITHM,
48-
c::STATUS_NOT_SUPPORTED,
49-
);
50-
Ok(Self(BCRYPT_RNG_ALG_HANDLE))
41+
const SYSTEM: Self = unsafe { Self::new(ptr::null_mut(), c::BCRYPT_USE_SYSTEM_PREFERRED_RNG) };
42+
43+
/// Create the RNG from an existing algorithm handle.
44+
///
45+
/// # Safety
46+
///
47+
/// The handle must either be null or a valid algorithm handle.
48+
const unsafe fn new(algorithm: c::BCRYPT_ALG_HANDLE, flags: u32) -> Self {
49+
Self { algorithm, flags }
5150
}
52-
#[cfg(not(miri))]
53-
// Open a handle to the RNG algorithm.
51+
52+
/// Open a handle to the RNG algorithm.
5453
fn open() -> Result<Self, c::NTSTATUS> {
5554
use crate::sync::atomic::AtomicPtr;
5655
use crate::sync::atomic::Ordering::{Acquire, Release};
57-
const ERROR_VALUE: c::LPVOID = ptr::invalid_mut(usize::MAX);
5856

5957
// An atomic is used so we don't need to reopen the handle every time.
6058
static HANDLE: AtomicPtr<crate::ffi::c_void> = AtomicPtr::new(ptr::null_mut());
6159

6260
let mut handle = HANDLE.load(Acquire);
63-
// We use a sentinel value to designate an error occurred last time.
64-
if handle == ERROR_VALUE {
65-
Err(c::STATUS_NOT_SUPPORTED)
66-
} else if handle.is_null() {
61+
if handle.is_null() {
6762
let status = unsafe {
6863
c::BCryptOpenAlgorithmProvider(
6964
&mut handle,
@@ -80,47 +75,32 @@ impl Rng {
8075
unsafe { c::BCryptCloseAlgorithmProvider(handle, 0) };
8176
handle = previous_handle;
8277
}
83-
Ok(Self(handle))
78+
Ok(unsafe { Self::new(handle, 0) })
8479
} else {
85-
HANDLE.store(ERROR_VALUE, Release);
8680
Err(status)
8781
}
8882
} else {
89-
Ok(Self(handle))
83+
Ok(unsafe { Self::new(handle, 0) })
9084
}
9185
}
9286

9387
fn gen_random_keys(self) -> Result<(u64, u64), c::NTSTATUS> {
9488
let mut v = (0, 0);
9589
let status = unsafe {
9690
let size = mem::size_of_val(&v).try_into().unwrap();
97-
c::BCryptGenRandom(self.0, ptr::addr_of_mut!(v).cast(), size, 0)
91+
c::BCryptGenRandom(self.algorithm, ptr::addr_of_mut!(v).cast(), size, self.flags)
9892
};
9993
if c::nt_success(status) { Ok(v) } else { Err(status) }
10094
}
10195
}
10296

103-
/// Generate random numbers using the fallback RNG function (RtlGenRandom)
104-
#[cfg(not(target_vendor = "uwp"))]
97+
/// Generate random numbers using the fallback RNG function
10598
#[inline(never)]
10699
fn fallback_rng(rng_status: c::NTSTATUS) -> (u64, u64) {
107-
let mut v = (0, 0);
108-
let ret =
109-
unsafe { c::RtlGenRandom(&mut v as *mut _ as *mut u8, mem::size_of_val(&v) as c::ULONG) };
110-
111-
if ret != 0 {
112-
v
113-
} else {
114-
panic!(
115-
"RNG broken: {rng_status:#x}, fallback RNG broken: {}",
116-
crate::io::Error::last_os_error()
117-
)
100+
match Rng::open().and_then(|rng| rng.gen_random_keys()) {
101+
Ok(keys) => keys,
102+
Err(status) => {
103+
panic!("RNG broken: {rng_status:#x}, fallback RNG broken: {status:#x}")
104+
}
118105
}
119106
}
120-
121-
/// We can't use RtlGenRandom with UWP, so there is no fallback
122-
#[cfg(target_vendor = "uwp")]
123-
#[inline(never)]
124-
fn fallback_rng(rng_status: c::NTSTATUS) -> (u64, u64) {
125-
panic!("RNG broken: {rng_status:#x} fallback RNG broken: RtlGenRandom() not supported on UWP");
126-
}

‎src/bootstrap/dist.rs

+23-22
Original file line numberDiff line numberDiff line change
@@ -1424,7 +1424,7 @@ impl Step for Extended {
14241424

14251425
let xform = |p: &Path| {
14261426
let mut contents = t!(fs::read_to_string(p));
1427-
for tool in &["rust-demangler", "rust-analyzer", "rustfmt"] {
1427+
for tool in &["rust-demangler"] {
14281428
if !built_tools.contains(tool) {
14291429
contents = filter(&contents, tool);
14301430
}
@@ -1465,7 +1465,8 @@ impl Step for Extended {
14651465
prepare("rust-analysis");
14661466
prepare("clippy");
14671467
prepare("miri");
1468-
for tool in &["rust-docs", "rust-demangler", "rust-analyzer"] {
1468+
prepare("rust-analyzer");
1469+
for tool in &["rust-docs", "rust-demangler"] {
14691470
if built_tools.contains(tool) {
14701471
prepare(tool);
14711472
}
@@ -1525,7 +1526,8 @@ impl Step for Extended {
15251526
prepare("rust-std");
15261527
prepare("clippy");
15271528
prepare("miri");
1528-
for tool in &["rust-demangler", "rust-analyzer"] {
1529+
prepare("rust-analyzer");
1530+
for tool in &["rust-demangler"] {
15291531
if built_tools.contains(tool) {
15301532
prepare(tool);
15311533
}
@@ -1609,25 +1611,23 @@ impl Step for Extended {
16091611
.arg("-out")
16101612
.arg(exe.join("StdGroup.wxs")),
16111613
);
1612-
if built_tools.contains("rust-analyzer") {
1613-
builder.run(
1614-
Command::new(&heat)
1615-
.current_dir(&exe)
1616-
.arg("dir")
1617-
.arg("rust-analyzer")
1618-
.args(&heat_flags)
1619-
.arg("-cg")
1620-
.arg("RustAnalyzerGroup")
1621-
.arg("-dr")
1622-
.arg("RustAnalyzer")
1623-
.arg("-var")
1624-
.arg("var.RustAnalyzerDir")
1625-
.arg("-out")
1626-
.arg(exe.join("RustAnalyzerGroup.wxs"))
1627-
.arg("-t")
1628-
.arg(etc.join("msi/remove-duplicates.xsl")),
1629-
);
1630-
}
1614+
builder.run(
1615+
Command::new(&heat)
1616+
.current_dir(&exe)
1617+
.arg("dir")
1618+
.arg("rust-analyzer")
1619+
.args(&heat_flags)
1620+
.arg("-cg")
1621+
.arg("RustAnalyzerGroup")
1622+
.arg("-dr")
1623+
.arg("RustAnalyzer")
1624+
.arg("-var")
1625+
.arg("var.RustAnalyzerDir")
1626+
.arg("-out")
1627+
.arg(exe.join("RustAnalyzerGroup.wxs"))
1628+
.arg("-t")
1629+
.arg(etc.join("msi/remove-duplicates.xsl")),
1630+
);
16311631
builder.run(
16321632
Command::new(&heat)
16331633
.current_dir(&exe)
@@ -2026,6 +2026,7 @@ impl Step for RustDev {
20262026
"llvm-dwp",
20272027
"llvm-nm",
20282028
"llvm-dwarfdump",
2029+
"llvm-dis",
20292030
] {
20302031
tarball.add_file(src_bindir.join(exe(bin, target)), "bin", 0o755);
20312032
}

‎src/bootstrap/download-ci-llvm-stamp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Change this file to make users of the `download-ci-llvm` configuration download
22
a new version of LLVM from CI, even if the LLVM submodule hasn’t changed.
33

4-
Last change is for: https://github.com/rust-lang/rust/pull/96867
4+
Last change is for: https://github.com/rust-lang/rust/pull/97550
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.10.0
1+
0.11.0

‎src/doc/rustc/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
- [armv6k-nintendo-3ds](platform-support/armv6k-nintendo-3ds.md)
2525
- [armv7-unknown-linux-uclibceabi](platform-support/armv7-unknown-linux-uclibceabi.md)
2626
- [armv7-unknown-linux-uclibceabihf](platform-support/armv7-unknown-linux-uclibceabihf.md)
27+
- [\*-android and \*-androideabi](platform-support/android.md)
2728
- [\*-fuchsia](platform-support/fuchsia.md)
2829
- [\*-kmc-solid_\*](platform-support/kmc-solid.md)
2930
- [m68k-unknown-linux-gnu](platform-support/m68k-unknown-linux-gnu.md)

‎src/doc/rustc/src/command-line-arguments.md

+11
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,11 @@ This flag will set which lints should be set to the [warn level](lints/levels.md
270270

271271
_Note:_ The order of these lint level arguments is taken into account, see [lint level via compiler flag](lints/levels.md#via-compiler-flag) for more information.
272272

273+
<a id="option-force-warn"></a>
274+
## `--force-warn`: force a lint to warn
275+
276+
This flag sets the given lint to the [forced warn level](lints/levels.md#force-warn) and the level cannot be overridden, even ignoring the [lint caps](lints/levels.md#capping-lints).
277+
273278
<a id="option-a-allow"></a>
274279
## `-A`: set lint allowed
275280

@@ -381,6 +386,12 @@ are:
381386
- `always` — Always use colors.
382387
- `never` — Never colorize output.
383388

389+
<a id="option-diagnostic-width"></a>
390+
## `--diagnostic-width`: specify the terminal width for diagnostics
391+
392+
This flag takes a number that specifies the width of the terminal in characters.
393+
Formatting of diagnostics will take the width into consideration to make them better fit on the screen.
394+
384395
<a id="option-remap-path-prefix"></a>
385396
## `--remap-path-prefix`: remap source names in output
386397

‎src/doc/rustc/src/platform-support.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,17 @@ target | std | notes
125125
`aarch64-apple-ios` | ✓ | ARM64 iOS
126126
[`aarch64-apple-ios-sim`](platform-support/aarch64-apple-ios-sim.md) | ✓ | Apple iOS Simulator on ARM64
127127
`aarch64-fuchsia` | ✓ | ARM64 Fuchsia
128-
`aarch64-linux-android` | ✓ | ARM64 Android
128+
[`aarch64-linux-android`](platform-support/android.md) | ✓ | ARM64 Android
129129
`aarch64-unknown-none-softfloat` | * | Bare ARM64, softfloat
130130
`aarch64-unknown-none` | * | Bare ARM64, hardfloat
131-
`arm-linux-androideabi` | ✓ | ARMv7 Android
131+
[`arm-linux-androideabi`](platform-support/android.md) | ✓ | ARMv7 Android
132132
`arm-unknown-linux-musleabi` | ✓ | ARMv6 Linux with MUSL
133133
`arm-unknown-linux-musleabihf` | ✓ | ARMv6 Linux with MUSL, hardfloat
134134
`armebv7r-none-eabi` | * | Bare ARMv7-R, Big Endian
135135
`armebv7r-none-eabihf` | * | Bare ARMv7-R, Big Endian, hardfloat
136136
`armv5te-unknown-linux-gnueabi` | ✓ | ARMv5TE Linux (kernel 4.4, glibc 2.23)
137137
`armv5te-unknown-linux-musleabi` | ✓ | ARMv5TE Linux with MUSL
138-
`armv7-linux-androideabi` | ✓ | ARMv7a Android
138+
[`armv7-linux-androideabi`](platform-support/android.md) | ✓ | ARMv7a Android
139139
`armv7-unknown-linux-gnueabi` | ✓ |ARMv7 Linux (kernel 4.15, glibc 2.27)
140140
`armv7-unknown-linux-musleabi` | ✓ |ARMv7 Linux with MUSL
141141
`armv7-unknown-linux-musleabihf` | ✓ | ARMv7 Linux with MUSL, hardfloat
@@ -146,7 +146,7 @@ target | std | notes
146146
`i586-pc-windows-msvc` | * | 32-bit Windows w/o SSE
147147
`i586-unknown-linux-gnu` | ✓ | 32-bit Linux w/o SSE (kernel 4.4, glibc 2.23)
148148
`i586-unknown-linux-musl` | ✓ | 32-bit Linux w/o SSE, MUSL
149-
`i686-linux-android` | ✓ | 32-bit x86 Android
149+
[`i686-linux-android`](platform-support/android.md) | ✓ | 32-bit x86 Android
150150
`i686-unknown-freebsd` | ✓ | 32-bit FreeBSD
151151
`i686-unknown-linux-musl` | ✓ | 32-bit Linux with MUSL
152152
`mips-unknown-linux-musl` | ✓ | MIPS Linux with MUSL
@@ -165,7 +165,7 @@ target | std | notes
165165
`thumbv7em-none-eabi` | * | Bare Cortex-M4, M7
166166
`thumbv7em-none-eabihf` | * | Bare Cortex-M4F, M7F, FPU, hardfloat
167167
`thumbv7m-none-eabi` | * | Bare Cortex-M3
168-
`thumbv7neon-linux-androideabi` | ✓ | Thumb2-mode ARMv7a Android with NEON
168+
[`thumbv7neon-linux-androideabi`](platform-support/android.md) | ✓ | Thumb2-mode ARMv7a Android with NEON
169169
`thumbv7neon-unknown-linux-gnueabihf` | ✓ | Thumb2-mode ARMv7a Linux with NEON (kernel 4.4, glibc 2.23)
170170
`thumbv8m.base-none-eabi` | * | ARMv8-M Baseline
171171
`thumbv8m.main-none-eabi` | * | ARMv8-M Mainline
@@ -176,7 +176,7 @@ target | std | notes
176176
`x86_64-apple-ios` | ✓ | 64-bit x86 iOS
177177
[`x86_64-fortanix-unknown-sgx`](platform-support/x86_64-fortanix-unknown-sgx.md) | ✓ | [Fortanix ABI] for 64-bit Intel SGX
178178
`x86_64-fuchsia` | ✓ | 64-bit Fuchsia
179-
`x86_64-linux-android` | ✓ | 64-bit x86 Android
179+
[`x86_64-linux-android`](platform-support/android.md) | ✓ | 64-bit x86 Android
180180
`x86_64-pc-solaris` | ✓ | 64-bit Solaris 10/11, illumos
181181
`x86_64-unknown-linux-gnux32` | ✓ | 64-bit Linux (x32 ABI) (kernel 4.15, glibc 2.27)
182182
[`x86_64-unknown-none`](platform-support/x86_64-unknown-none.md) | * | Freestanding/bare-metal x86_64, softfloat

0 commit comments

Comments
 (0)
Please sign in to comment.