Skip to content

Commit ea6fdd2

Browse files
committed
Auto merge of rust-lang#136774 - Urgau:rollup-cm061qo, r=Urgau
Rollup of 5 pull requests Successful merges: - rust-lang#134999 (Add cygwin target.) - rust-lang#135488 (Stabilize `vec_pop_if`) - rust-lang#136068 (crashes: more tests) - rust-lang#136694 (Update minifier version to `0.3.4`) - rust-lang#136760 (Fix unwrap error in overflowing int literal) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 124cc92 + 2d5a1bd commit ea6fdd2

File tree

30 files changed

+362
-17
lines changed

30 files changed

+362
-17
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -2322,9 +2322,9 @@ dependencies = [
23222322

23232323
[[package]]
23242324
name = "minifier"
2325-
version = "0.3.2"
2325+
version = "0.3.4"
23262326
source = "registry+https://github.com/rust-lang/crates.io-index"
2327-
checksum = "bd559bbf5d350ac7f2c1cf92ed71a869b847a92bce0c1318b47932a5b5f65cdd"
2327+
checksum = "1cf47565b1430f5fe6c81d3afcb4b835271348d7eb35294a4d592e38dd09ea22"
23282328

23292329
[[package]]
23302330
name = "minimal-lexical"

compiler/rustc_lint/src/types.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,11 @@ impl<'tcx> LateLintPass<'tcx> for TypeLimits {
543543
lit: &'tcx hir::Lit,
544544
negated: bool,
545545
) {
546-
lint_literal(cx, self, hir_id, lit.span, lit, negated)
546+
if negated {
547+
self.negated_expr_id = Some(hir_id);
548+
self.negated_expr_span = Some(lit.span);
549+
}
550+
lint_literal(cx, self, hir_id, lit.span, lit, negated);
547551
}
548552

549553
fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx hir::Expr<'tcx>) {

compiler/rustc_lint/src/types/literal.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,11 @@ fn lint_int_literal<'tcx>(
250250
lit: &hir::Lit,
251251
t: ty::IntTy,
252252
v: u128,
253-
negated: bool,
254253
) {
255254
let int_type = t.normalize(cx.sess().target.pointer_width);
256255
let (min, max) = int_ty_range(int_type);
257256
let max = max as u128;
258-
let negative = negated ^ (type_limits.negated_expr_id == Some(hir_id));
257+
let negative = type_limits.negated_expr_id == Some(hir_id);
259258

260259
// Detect literal value out of range [min, max] inclusive
261260
// avoiding use of -min to prevent overflow/panic
@@ -374,7 +373,7 @@ pub(crate) fn lint_literal<'tcx>(
374373
ty::Int(t) => {
375374
match lit.node {
376375
ast::LitKind::Int(v, ast::LitIntType::Signed(_) | ast::LitIntType::Unsuffixed) => {
377-
lint_int_literal(cx, type_limits, hir_id, span, lit, t, v.get(), negated)
376+
lint_int_literal(cx, type_limits, hir_id, span, lit, t, v.get())
378377
}
379378
_ => bug!(),
380379
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
use std::borrow::Cow;
2+
3+
use crate::spec::{Cc, DebuginfoKind, LinkerFlavor, Lld, SplitDebuginfo, TargetOptions, cvs};
4+
5+
pub(crate) fn opts() -> TargetOptions {
6+
let mut pre_link_args = TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), &[
7+
"--disable-dynamicbase",
8+
"--enable-auto-image-base",
9+
]);
10+
crate::spec::add_link_args(&mut pre_link_args, LinkerFlavor::Gnu(Cc::Yes, Lld::No), &[
11+
"-Wl,--disable-dynamicbase",
12+
"-Wl,--enable-auto-image-base",
13+
]);
14+
let cygwin_libs = &["-lcygwin", "-lgcc", "-lcygwin", "-luser32", "-lkernel32", "-lgcc_s"];
15+
let mut late_link_args =
16+
TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), cygwin_libs);
17+
crate::spec::add_link_args(
18+
&mut late_link_args,
19+
LinkerFlavor::Gnu(Cc::Yes, Lld::No),
20+
cygwin_libs,
21+
);
22+
TargetOptions {
23+
os: "cygwin".into(),
24+
vendor: "pc".into(),
25+
// FIXME(#13846) this should be enabled for cygwin
26+
function_sections: false,
27+
linker: Some("gcc".into()),
28+
dynamic_linking: true,
29+
dll_prefix: "".into(),
30+
dll_suffix: ".dll".into(),
31+
exe_suffix: ".exe".into(),
32+
families: cvs!["unix"],
33+
is_like_windows: true,
34+
allows_weak_linkage: false,
35+
pre_link_args,
36+
late_link_args,
37+
abi_return_struct_as_int: true,
38+
emit_debug_gdb_scripts: false,
39+
requires_uwtable: true,
40+
eh_frame_header: false,
41+
debuginfo_kind: DebuginfoKind::Dwarf,
42+
supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Off]),
43+
..Default::default()
44+
}
45+
}

compiler/rustc_target/src/spec/base/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ pub(crate) mod android;
33
pub(crate) mod apple;
44
pub(crate) mod avr_gnu;
55
pub(crate) mod bpf;
6+
pub(crate) mod cygwin;
67
pub(crate) mod dragonfly;
78
pub(crate) mod freebsd;
89
pub(crate) mod fuchsia;

compiler/rustc_target/src/spec/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -2018,6 +2018,7 @@ supported_targets! {
20182018
("riscv64imac-unknown-nuttx-elf", riscv64imac_unknown_nuttx_elf),
20192019
("riscv64gc-unknown-nuttx-elf", riscv64gc_unknown_nuttx_elf),
20202020

2021+
("x86_64-pc-cygwin", x86_64_pc_cygwin),
20212022
}
20222023

20232024
/// Cow-Vec-Str: Cow<'static, [Cow<'static, str>]>
@@ -2999,8 +3000,8 @@ impl Target {
29993000
);
30003001
check_eq!(
30013002
self.is_like_windows,
3002-
self.os == "windows" || self.os == "uefi",
3003-
"`is_like_windows` must be set if and only if `os` is `windows` or `uefi`"
3003+
self.os == "windows" || self.os == "uefi" || self.os == "cygwin",
3004+
"`is_like_windows` must be set if and only if `os` is `windows`, `uefi` or `cygwin`"
30043005
);
30053006
check_eq!(
30063007
self.is_like_wasm,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
use crate::spec::{Cc, LinkerFlavor, Lld, Target, base};
2+
3+
pub(crate) fn target() -> Target {
4+
let mut base = base::cygwin::opts();
5+
base.cpu = "x86-64".into();
6+
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), &["-m", "i386pep"]);
7+
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
8+
base.max_atomic_width = Some(64);
9+
base.linker = Some("x86_64-pc-cygwin-gcc".into());
10+
Target {
11+
llvm_target: "x86_64-pc-cygwin".into(),
12+
pointer_width: 64,
13+
data_layout:
14+
"e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
15+
arch: "x86_64".into(),
16+
options: base,
17+
metadata: crate::spec::TargetMetadata {
18+
description: Some("64-bit x86 Cygwin".into()),
19+
tier: Some(3),
20+
host_tools: Some(false),
21+
std: None,
22+
},
23+
}
24+
}

library/alloc/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@
156156
#![feature(unicode_internals)]
157157
#![feature(unsize)]
158158
#![feature(unwrap_infallible)]
159-
#![feature(vec_pop_if)]
160159
// tidy-alphabetical-end
161160
//
162161
// Language features:

library/alloc/src/vec/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -2519,16 +2519,14 @@ impl<T, A: Allocator> Vec<T, A> {
25192519
/// # Examples
25202520
///
25212521
/// ```
2522-
/// #![feature(vec_pop_if)]
2523-
///
25242522
/// let mut vec = vec![1, 2, 3, 4];
25252523
/// let pred = |x: &mut i32| *x % 2 == 0;
25262524
///
25272525
/// assert_eq!(vec.pop_if(pred), Some(4));
25282526
/// assert_eq!(vec, [1, 2, 3]);
25292527
/// assert_eq!(vec.pop_if(pred), None);
25302528
/// ```
2531-
#[unstable(feature = "vec_pop_if", issue = "122741")]
2529+
#[stable(feature = "vec_pop_if", since = "CURRENT_RUSTC_VERSION")]
25322530
pub fn pop_if(&mut self, predicate: impl FnOnce(&mut T) -> bool) -> Option<T> {
25332531
let last = self.last_mut()?;
25342532
if predicate(last) { self.pop() } else { None }

library/alloc/tests/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
#![feature(local_waker)]
3838
#![feature(str_as_str)]
3939
#![feature(strict_provenance_lints)]
40-
#![feature(vec_pop_if)]
4140
#![feature(vec_deque_pop_if)]
4241
#![feature(unique_rc_arc)]
4342
#![feature(macro_metavar_expr_concat)]

src/bootstrap/src/core/builder/cargo.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,11 @@ impl Cargo {
245245
// flesh out rpath support more fully in the future.
246246
self.rustflags.arg("-Zosx-rpath-install-name");
247247
Some(format!("-Wl,-rpath,@loader_path/../{libdir}"))
248-
} else if !target.is_windows() && !target.contains("aix") && !target.contains("xous") {
248+
} else if !target.is_windows()
249+
&& !target.contains("cygwin")
250+
&& !target.contains("aix")
251+
&& !target.contains("xous")
252+
{
249253
self.rustflags.arg("-Clink-args=-Wl,-z,origin");
250254
Some(format!("-Wl,-rpath,$ORIGIN/../{libdir}"))
251255
} else {

src/doc/rustc/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
- [\*-win7-windows-gnu](platform-support/win7-windows-gnu.md)
102102
- [\*-win7-windows-msvc](platform-support/win7-windows-msvc.md)
103103
- [x86_64-fortanix-unknown-sgx](platform-support/x86_64-fortanix-unknown-sgx.md)
104+
- [x86_64-pc-cygwin](platform-support/x86_64-pc-cygwin.md)
104105
- [x86_64-pc-solaris](platform-support/solaris.md)
105106
- [x86_64-unknown-linux-none.md](platform-support/x86_64-unknown-linux-none.md)
106107
- [x86_64-unknown-none](platform-support/x86_64-unknown-none.md)

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

+1
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ target | std | host | notes
406406
[`wasm64-unknown-unknown`](platform-support/wasm64-unknown-unknown.md) | ? | | WebAssembly
407407
[`x86_64-apple-tvos`](platform-support/apple-tvos.md) | ✓ | | x86 64-bit tvOS
408408
[`x86_64-apple-watchos-sim`](platform-support/apple-watchos.md) | ✓ | | x86 64-bit Apple WatchOS simulator
409+
[`x86_64-pc-cygwin`](platform-support/x86_64-pc-cygwin.md) | ? | | 64-bit x86 Cygwin |
409410
[`x86_64-pc-nto-qnx710`](platform-support/nto-qnx.md) | ✓ | | x86 64-bit QNX Neutrino 7.1 RTOS with default network stack (io-pkt) |
410411
[`x86_64-pc-nto-qnx710_iosock`](platform-support/nto-qnx.md) | ✓ | | x86 64-bit QNX Neutrino 7.1 RTOS with new network stack (io-sock) |
411412
[`x86_64-pc-nto-qnx800`](platform-support/nto-qnx.md) | ✓ | | x86 64-bit QNX Neutrino 8.0 RTOS |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# `x86_64-pc-cygwin`
2+
3+
**Tier: 3**
4+
5+
Windows targets supporting Cygwin.
6+
The `*-cygwin` targets are **not** intended as native target for applications,
7+
a developer writing Windows applications should use the `*-pc-windows-*` targets instead, which are *native* Windows.
8+
9+
Cygwin is only intended as an emulation layer for Unix-only programs which do not support the native Windows targets.
10+
11+
## Target maintainers
12+
13+
- [Berrysoft](https://github.com/Berrysoft)
14+
15+
## Requirements
16+
17+
This target is cross compiled. It needs `x86_64-pc-cygwin-gcc` as linker.
18+
19+
The `target_os` of the target is `cygwin`, and it is `unix`.
20+
21+
## Building the target
22+
23+
For cross-compilation you want LLVM with [llvm/llvm-project#121439 (merged)](https://github.com/llvm/llvm-project/pull/121439) applied to fix the LLVM codegen on importing external global variables from DLLs.
24+
No native builds on Cygwin now. It should be possible theoretically though, but might need a lot of patches.
25+
26+
## Building Rust programs
27+
28+
Rust does not yet ship pre-compiled artifacts for this target. To compile for
29+
this target, you will either need to build Rust with the target enabled (see
30+
"Building the target" above), or build your own copy of `core` by using
31+
`build-std` or similar.
32+
33+
## Testing
34+
35+
Created binaries work fine on Windows with Cygwin.
36+
37+
## Cross-compilation toolchains and C code
38+
39+
Compatible C code can be built with GCC shipped with Cygwin. Clang is untested.

src/librustdoc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ rinja = { version = "0.3", default-features = false, features = ["config"] }
1313
base64 = "0.21.7"
1414
itertools = "0.12"
1515
indexmap = "2"
16-
minifier = { version = "0.3.2", default-features = false }
16+
minifier = { version = "0.3.4", default-features = false }
1717
pulldown-cmark-old = { version = "0.9.6", package = "pulldown-cmark", default-features = false }
1818
regex = "1"
1919
rustdoc-json-types = { path = "../rustdoc-json-types" }

tests/assembly/targets/targets-pe.rs

+3
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@
8484
//@ revisions: x86_64_win7_windows_msvc
8585
//@ [x86_64_win7_windows_msvc] compile-flags: --target x86_64-win7-windows-msvc
8686
//@ [x86_64_win7_windows_msvc] needs-llvm-components: x86
87+
//@ revisions: x86_64_pc_cygwin
88+
//@ [x86_64_pc_cygwin] compile-flags: --target x86_64-pc-cygwin
89+
//@ [x86_64_pc_cygwin] needs-llvm-components: x86
8790

8891
// Sanity-check that each target can produce assembly code.
8992

tests/crashes/135470.rs

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//@ known-bug: #135470
2+
//@ compile-flags: --edition=2021 -Copt-level=0
3+
4+
use std::future::Future;
5+
trait Access {
6+
type Lister;
7+
8+
fn list() -> impl Future<Output = Self::Lister> {
9+
async { todo!() }
10+
}
11+
}
12+
13+
trait Foo {}
14+
impl Access for dyn Foo {
15+
type Lister = ();
16+
}
17+
18+
fn main() {
19+
let svc = async {
20+
async { <dyn Foo>::list() }.await;
21+
};
22+
&svc as &dyn Service;
23+
}
24+
25+
trait UnaryService {
26+
fn call2() {}
27+
}
28+
trait Unimplemented {}
29+
impl<T: Unimplemented> UnaryService for T {}
30+
struct Wrap<T>(T);
31+
impl<T: Send> UnaryService for Wrap<T> {}
32+
33+
trait Service {
34+
fn call(&self);
35+
}
36+
impl<T: Send> Service for T {
37+
fn call(&self) {
38+
Wrap::<T>::call2();
39+
}
40+
}

tests/crashes/135528.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//@ known-bug: #135528
2+
//@ compile-flags: -Zvalidate-mir -Zinline-mir=yes
3+
#![feature(type_alias_impl_trait)]
4+
type Tait = impl Copy;
5+
6+
fn set(x: &isize) -> isize {
7+
*x
8+
}
9+
10+
fn d(x: Tait) {
11+
set(x);
12+
}
13+
14+
fn other_define() -> Tait {
15+
()
16+
}
17+
18+
fn main() {}

tests/crashes/135570.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@ known-bug: #135570
2+
//@compile-flags: -Zvalidate-mir -Zmir-enable-passes=+Inline -Copt-level=0 -Zmir-enable-passes=+GVN
3+
//@ only-x86_64
4+
5+
fn function_with_bytes<const BYTES: &'static [u8; 0xc7b889180b67b07d_bc1a3c88783d35b5_u128]>(
6+
) -> &'static [u8] {
7+
BYTES
8+
}
9+
10+
fn main() {
11+
function_with_bytes::<b"aa">() == &[];
12+
}

tests/crashes/135617.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//@ known-bug: #135617
2+
trait Project {
3+
const ASSOC: usize;
4+
}
5+
6+
fn foo()
7+
where
8+
for<'a> (): Project,
9+
{
10+
[(); <() as Project>::ASSOC];
11+
}
12+
13+
pub fn main() {}

tests/crashes/135646.rs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//@ known-bug: #135646
2+
//@ compile-flags: --edition=2024 -Zpolonius=next
3+
fn main() {
4+
&{ [1, 2, 3][4] };
5+
}

tests/crashes/135668.rs

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//@ known-bug: #135668
2+
//@ compile-flags: --edition=2021
3+
use std::future::Future;
4+
5+
pub async fn foo() {
6+
let _ = create_task().await;
7+
}
8+
9+
async fn create_task() -> impl Sized {
10+
bind(documentation)
11+
}
12+
13+
async fn documentation() {
14+
include_str!("nonexistent");
15+
}
16+
17+
fn bind<F>(_filter: F) -> impl Sized
18+
where
19+
F: FilterBase,
20+
{
21+
|| -> <F as FilterBase>::Assoc { panic!() }
22+
}
23+
24+
trait FilterBase {
25+
type Assoc;
26+
}
27+
28+
impl<F, R> FilterBase for F
29+
where
30+
F: Fn() -> R,
31+
// Removing the below line makes it correctly error on both stable and beta
32+
R: Future,
33+
// Removing the below line makes it ICE on both stable and beta
34+
R: Send,
35+
// Removing the above two bounds makes it ICE on stable but correctly error on beta
36+
{
37+
type Assoc = F;
38+
}

0 commit comments

Comments
 (0)