Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8417f83

Browse files
committedJan 5, 2025
Auto merge of #135113 - workingjubilee:rollup-yy6nxel, r=workingjubilee
Rollup of 4 pull requests Successful merges: - #134925 (deny usage of special FileCheck prefixes as revision names) - #134996 (Add UWP (msvc) target support page) - #135104 (do not in-place-iterate over flatmap/flatten) - #135110 (library: fix adler{ -> 2}.debug) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 3dc3c52 + bfd7ac1 commit 8417f83

File tree

9 files changed

+149
-59
lines changed

9 files changed

+149
-59
lines changed
 

‎library/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ codegen-units = 10000
3232
[profile.release.package]
3333
addr2line.debug = 0
3434
addr2line.opt-level = "s"
35-
adler.debug = 0
35+
adler2.debug = 0
3636
gimli.debug = 0
3737
gimli.opt-level = "s"
3838
miniz_oxide.debug = 0

‎library/alloc/tests/vec.rs

+20-19
Original file line numberDiff line numberDiff line change
@@ -1204,22 +1204,16 @@ fn test_from_iter_specialization_with_iterator_adapters() {
12041204
#[test]
12051205
fn test_in_place_specialization_step_up_down() {
12061206
fn assert_in_place_trait<T: InPlaceIterable>(_: &T) {}
1207-
let src = vec![[0u8; 4]; 256];
1208-
let srcptr = src.as_ptr();
1209-
let src_cap = src.capacity();
1210-
let iter = src.into_iter().flatten();
1211-
assert_in_place_trait(&iter);
1212-
let sink = iter.collect::<Vec<_>>();
1213-
let sinkptr = sink.as_ptr();
1214-
assert_eq!(srcptr as *const u8, sinkptr);
1215-
assert_eq!(src_cap * 4, sink.capacity());
12161207

1217-
let iter = sink.into_iter().array_chunks::<4>();
1208+
let src = vec![0u8; 1024];
1209+
let srcptr = src.as_ptr();
1210+
let src_bytes = src.capacity();
1211+
let iter = src.into_iter().array_chunks::<4>();
12181212
assert_in_place_trait(&iter);
12191213
let sink = iter.collect::<Vec<_>>();
12201214
let sinkptr = sink.as_ptr();
1221-
assert_eq!(srcptr, sinkptr);
1222-
assert_eq!(src_cap, sink.capacity());
1215+
assert_eq!(srcptr.addr(), sinkptr.addr());
1216+
assert_eq!(src_bytes, sink.capacity() * 4);
12231217

12241218
let mut src: Vec<u8> = Vec::with_capacity(17);
12251219
let src_bytes = src.capacity();
@@ -1236,13 +1230,6 @@ fn test_in_place_specialization_step_up_down() {
12361230
let sink: Vec<[u8; 2]> = iter.collect();
12371231
assert_eq!(sink.len(), 8);
12381232
assert!(sink.capacity() <= 25);
1239-
1240-
let src = vec![[0u8; 4]; 256];
1241-
let srcptr = src.as_ptr();
1242-
let iter = src.into_iter().flat_map(|a| a.into_iter().map(|b| b.wrapping_add(1)));
1243-
assert_in_place_trait(&iter);
1244-
let sink = iter.collect::<Vec<_>>();
1245-
assert_eq!(srcptr as *const u8, sink.as_ptr());
12461233
}
12471234

12481235
#[test]
@@ -1350,6 +1337,20 @@ fn test_collect_after_iterator_clone() {
13501337
assert_eq!(v, [1, 1, 1, 1, 1]);
13511338
assert!(v.len() <= v.capacity());
13521339
}
1340+
1341+
// regression test for #135103, similar to the one above Flatten/FlatMap had an unsound InPlaceIterable
1342+
// implementation.
1343+
#[test]
1344+
fn test_flatten_clone() {
1345+
const S: String = String::new();
1346+
1347+
let v = vec![[S, "Hello World!".into()], [S, S]];
1348+
let mut i = v.into_iter().flatten();
1349+
let _ = i.next();
1350+
let result: Vec<String> = i.clone().collect();
1351+
assert_eq!(result, ["Hello World!", "", ""]);
1352+
}
1353+
13531354
#[test]
13541355
fn test_cow_from() {
13551356
let borrowed: &[_] = &["borrowed", "(slice)"];

‎library/core/src/iter/adapters/flatten.rs

+2-32
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::iter::adapters::SourceIter;
22
use crate::iter::{
3-
Cloned, Copied, Empty, Filter, FilterMap, Fuse, FusedIterator, InPlaceIterable, Map, Once,
4-
OnceWith, TrustedFused, TrustedLen,
3+
Cloned, Copied, Empty, Filter, FilterMap, Fuse, FusedIterator, Map, Once, OnceWith,
4+
TrustedFused, TrustedLen,
55
};
66
use crate::num::NonZero;
77
use crate::ops::{ControlFlow, Try};
@@ -157,21 +157,6 @@ where
157157
{
158158
}
159159

160-
#[unstable(issue = "none", feature = "inplace_iteration")]
161-
unsafe impl<I, U, F> InPlaceIterable for FlatMap<I, U, F>
162-
where
163-
I: InPlaceIterable,
164-
U: BoundedSize + IntoIterator,
165-
{
166-
const EXPAND_BY: Option<NonZero<usize>> = const {
167-
match (I::EXPAND_BY, U::UPPER_BOUND) {
168-
(Some(m), Some(n)) => m.checked_mul(n),
169-
_ => None,
170-
}
171-
};
172-
const MERGE_BY: Option<NonZero<usize>> = I::MERGE_BY;
173-
}
174-
175160
#[unstable(issue = "none", feature = "inplace_iteration")]
176161
unsafe impl<I, U, F> SourceIter for FlatMap<I, U, F>
177162
where
@@ -386,21 +371,6 @@ where
386371
{
387372
}
388373

389-
#[unstable(issue = "none", feature = "inplace_iteration")]
390-
unsafe impl<I> InPlaceIterable for Flatten<I>
391-
where
392-
I: InPlaceIterable + Iterator,
393-
<I as Iterator>::Item: IntoIterator + BoundedSize,
394-
{
395-
const EXPAND_BY: Option<NonZero<usize>> = const {
396-
match (I::EXPAND_BY, I::Item::UPPER_BOUND) {
397-
(Some(m), Some(n)) => m.checked_mul(n),
398-
_ => None,
399-
}
400-
};
401-
const MERGE_BY: Option<NonZero<usize>> = I::MERGE_BY;
402-
}
403-
404374
#[unstable(issue = "none", feature = "inplace_iteration")]
405375
unsafe impl<I> SourceIter for Flatten<I>
406376
where

‎library/std/src/sys/pal/windows/os.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
#[cfg(test)]
66
mod tests;
77

8-
use super::api::{self, WinError};
9-
use super::to_u16s;
8+
#[cfg(not(target_vendor = "uwp"))]
9+
use super::api::WinError;
10+
use super::{api, to_u16s};
1011
use crate::error::Error as StdError;
1112
use crate::ffi::{OsStr, OsString};
1213
use crate::os::windows::ffi::EncodeWide;

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

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
- [*-unknown-openbsd](platform-support/openbsd.md)
8888
- [*-unknown-redox](platform-support/redox.md)
8989
- [\*-unknown-uefi](platform-support/unknown-uefi.md)
90+
- [\*-uwp-windows-msvc](platform-support/uwp-windows-msvc.md)
9091
- [\*-wrs-vxworks](platform-support/vxworks.md)
9192
- [wasm32-wasip1](platform-support/wasm32-wasip1.md)
9293
- [wasm32-wasip1-threads](platform-support/wasm32-wasip1-threads.md)

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ target | std | host | notes
264264
[`aarch64-unknown-redox`](platform-support/redox.md) | ✓ | | ARM64 Redox OS
265265
[`aarch64-unknown-teeos`](platform-support/aarch64-unknown-teeos.md) | ? | | ARM64 TEEOS |
266266
[`aarch64-unknown-trusty`](platform-support/trusty.md) | ? | |
267-
`aarch64-uwp-windows-msvc` | ✓ | |
267+
[`aarch64-uwp-windows-msvc`](platform-support/uwp-windows-msvc.md) | ✓ | |
268268
[`aarch64-wrs-vxworks`](platform-support/vxworks.md) | ✓ | | ARM64 VxWorks OS
269269
`aarch64_be-unknown-linux-gnu` | ✓ | ✓ | ARM64 Linux (big-endian)
270270
`aarch64_be-unknown-linux-gnu_ilp32` | ✓ | ✓ | ARM64 Linux (big-endian, ILP32 ABI)
@@ -312,7 +312,7 @@ target | std | host | notes
312312
[`i686-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | 32-bit OpenBSD [^x86_32-floats-return-ABI]
313313
[`i686-unknown-redox`](platform-support/redox.md) | ✓ | | i686 Redox OS
314314
`i686-uwp-windows-gnu` | ✓ | | [^x86_32-floats-return-ABI]
315-
`i686-uwp-windows-msvc` | ✓ | | [^x86_32-floats-return-ABI]
315+
[`i686-uwp-windows-msvc`](platform-support/uwp-windows-msvc.md) | ✓ | | [^x86_32-floats-return-ABI]
316316
[`i686-win7-windows-msvc`](platform-support/win7-windows-msvc.md) | ✓ | | 32-bit Windows 7 support [^x86_32-floats-return-ABI]
317317
[`i686-wrs-vxworks`](platform-support/vxworks.md) | ✓ | | [^x86_32-floats-return-ABI]
318318
[`loongarch64-unknown-linux-ohos`](platform-support/openharmony.md) | ✓ | | LoongArch64 OpenHarmony
@@ -383,8 +383,8 @@ target | std | host | notes
383383
[`thumbv4t-none-eabi`](platform-support/armv4t-none-eabi.md) | * | | Thumb-mode Bare Armv4T
384384
[`thumbv5te-none-eabi`](platform-support/armv5te-none-eabi.md) | * | | Thumb-mode Bare Armv5TE
385385
[`thumbv6m-nuttx-eabi`](platform-support/nuttx.md) | * | | ARMv6M with NuttX
386-
`thumbv7a-pc-windows-msvc` | | |
387-
`thumbv7a-uwp-windows-msvc` | | |
386+
`thumbv7a-pc-windows-msvc` | | |
387+
[`thumbv7a-uwp-windows-msvc`](platform-support/uwp-windows-msvc.md) | | |
388388
[`thumbv7em-nuttx-eabi`](platform-support/nuttx.md) | * | | ARMv7EM with NuttX
389389
[`thumbv7em-nuttx-eabihf`](platform-support/nuttx.md) | * | | ARMv7EM with NuttX, hardfloat
390390
[`thumbv7m-nuttx-eabi`](platform-support/nuttx.md) | * | | ARMv7M with NuttX
@@ -406,7 +406,7 @@ target | std | host | notes
406406
[`x86_64-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | 64-bit OpenBSD
407407
[`x86_64-unknown-trusty`](platform-support/trusty.md) | ? | |
408408
`x86_64-uwp-windows-gnu` | ✓ | |
409-
`x86_64-uwp-windows-msvc` | ✓ | |
409+
[`x86_64-uwp-windows-msvc`](platform-support/uwp-windows-msvc.md) | ✓ | |
410410
[`x86_64-win7-windows-msvc`](platform-support/win7-windows-msvc.md) | ✓ | | 64-bit Windows 7 support
411411
[`x86_64-wrs-vxworks`](platform-support/vxworks.md) | ✓ | |
412412
[`x86_64h-apple-darwin`](platform-support/x86_64h-apple-darwin.md) | ✓ | ✓ | macOS with late-gen Intel (at least Haswell)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# `x86_64-uwp-windows-msvc`, `i686-uwp-windows-msvc`, `thumbv7a-uwp-windows-msvc` and `aarch64-uwp-windows-msvc`
2+
3+
**Tier: 3**
4+
5+
Windows targets for Universal Windows Platform (UWP) applications, using MSVC toolchain.
6+
7+
## Target maintainers
8+
9+
- [@bdbai](https://github.com/bdbai)
10+
11+
## Requirements
12+
13+
These targets are cross-compiled with std support. The host requirement and
14+
binary format are the same as the corresponding non-UWP targets (i.e.
15+
`x86_64-pc-windows-msvc`, `i686-pc-windows-msvc`, `thumbv7a-pc-windows-msvc`
16+
and `aarch64-pc-windows-msvc`).
17+
18+
## Building the targets
19+
20+
The targets can be built by enabling them for a `rustc` build, for example:
21+
22+
```toml
23+
[build]
24+
build-stage = 1
25+
target = ["x86_64-uwp-windows-msvc", "aarch64-uwp-windows-msvc"]
26+
```
27+
28+
## Building Rust programs
29+
30+
Rust does not yet ship pre-compiled artifacts for these targets. To compile for
31+
these targets, you will either need to build Rust with the targets enabled (see
32+
"Building the targets" above), or build your own copy of `std` by using
33+
`build-std` or similar.
34+
35+
Example of building a Rust project for x64 UWP using `build-std`:
36+
37+
```pwsh
38+
cargo build -Z build-std=std,panic_abort --target x86_64-uwp-windows-msvc
39+
```
40+
41+
## Testing
42+
43+
Currently there is no support to run the rustc test suite for this target.
44+
45+
## Cross-compilation toolchains and C code
46+
47+
In general, the toolchain target should match the corresponding non-UWP
48+
targets. Beware that not all Win32 APIs behave the same way in UWP, and some
49+
are restricted in [AppContainer](https://learn.microsoft.com/en-us/windows/win32/secauthz/appcontainer-for-legacy-applications-)
50+
or even not available at all. If the C code being compiled happens to use any
51+
of restricted or unavailable APIs, consider using allowed alternatives or
52+
disable certain feature sets to avoid using them.

‎src/tools/compiletest/src/header.rs

+12
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,9 @@ fn iter_header(
934934

935935
impl Config {
936936
fn parse_and_update_revisions(&self, testfile: &Path, line: &str, existing: &mut Vec<String>) {
937+
const FORBIDDEN_REVISION_NAMES: [&str; 9] =
938+
["CHECK", "COM", "NEXT", "SAME", "EMPTY", "NOT", "COUNT", "DAG", "LABEL"];
939+
937940
if let Some(raw) = self.parse_name_value_directive(line, "revisions") {
938941
if self.mode == Mode::RunMake {
939942
panic!("`run-make` tests do not support revisions: {}", testfile.display());
@@ -948,6 +951,15 @@ impl Config {
948951
raw,
949952
testfile.display()
950953
);
954+
} else if matches!(self.mode, Mode::Assembly | Mode::Codegen | Mode::MirOpt)
955+
&& FORBIDDEN_REVISION_NAMES.contains(&revision.as_str())
956+
{
957+
panic!(
958+
"revision name `{revision}` is not permitted in a test suite that uses `FileCheck` annotations\n\
959+
as it is confusing when used as custom `FileCheck` prefix: `{revision}` in line `{}`: {}",
960+
raw,
961+
testfile.display()
962+
);
951963
}
952964
existing.push(revision);
953965
}

‎src/tools/compiletest/src/header/tests.rs

+53
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,59 @@ fn test_duplicate_revisions() {
553553
parse_rs(&config, "//@ revisions: rpass1 rpass1");
554554
}
555555

556+
#[test]
557+
#[should_panic(
558+
expected = "revision name `CHECK` is not permitted in a test suite that uses `FileCheck` annotations"
559+
)]
560+
fn test_assembly_mode_forbidden_revisions() {
561+
let config = cfg().mode("assembly").build();
562+
parse_rs(&config, "//@ revisions: CHECK");
563+
}
564+
565+
#[test]
566+
#[should_panic(
567+
expected = "revision name `CHECK` is not permitted in a test suite that uses `FileCheck` annotations"
568+
)]
569+
fn test_codegen_mode_forbidden_revisions() {
570+
let config = cfg().mode("codegen").build();
571+
parse_rs(&config, "//@ revisions: CHECK");
572+
}
573+
574+
#[test]
575+
#[should_panic(
576+
expected = "revision name `CHECK` is not permitted in a test suite that uses `FileCheck` annotations"
577+
)]
578+
fn test_miropt_mode_forbidden_revisions() {
579+
let config = cfg().mode("mir-opt").build();
580+
parse_rs(&config, "//@ revisions: CHECK");
581+
}
582+
583+
#[test]
584+
fn test_forbidden_revisions_allowed_in_non_filecheck_dir() {
585+
let revisions = ["CHECK", "COM", "NEXT", "SAME", "EMPTY", "NOT", "COUNT", "DAG", "LABEL"];
586+
let modes = [
587+
"pretty",
588+
"debuginfo",
589+
"rustdoc",
590+
"rustdoc-json",
591+
"codegen-units",
592+
"incremental",
593+
"ui",
594+
"js-doc-test",
595+
"coverage-map",
596+
"coverage-run",
597+
"crashes",
598+
];
599+
600+
for rev in revisions {
601+
let content = format!("//@ revisions: {rev}");
602+
for mode in modes {
603+
let config = cfg().mode(mode).build();
604+
parse_rs(&config, &content);
605+
}
606+
}
607+
}
608+
556609
#[test]
557610
fn ignore_arch() {
558611
let archs = [

0 commit comments

Comments
 (0)
Failed to load comments.