Skip to content

Commit 6a192fb

Browse files
author
The Miri Conjob Bot
committed
Merge from rustc
2 parents 611a0e9 + 9c7dd30 commit 6a192fb

File tree

6 files changed

+122
-53
lines changed

6 files changed

+122
-53
lines changed

alloc/src/boxed.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ use core::iter::FusedIterator;
159159
use core::marker::Tuple;
160160
use core::marker::Unsize;
161161
use core::mem::{self, SizedTypeProperties};
162+
use core::ops::{AsyncFn, AsyncFnMut, AsyncFnOnce};
162163
use core::ops::{
163164
CoerceUnsized, Coroutine, CoroutineState, Deref, DerefMut, DispatchFromDyn, Receiver,
164165
};
@@ -2030,6 +2031,34 @@ impl<Args: Tuple, F: Fn<Args> + ?Sized, A: Allocator> Fn<Args> for Box<F, A> {
20302031
}
20312032
}
20322033

2034+
#[unstable(feature = "async_fn_traits", issue = "none")]
2035+
impl<Args: Tuple, F: AsyncFnOnce<Args> + ?Sized, A: Allocator> AsyncFnOnce<Args> for Box<F, A> {
2036+
type Output = F::Output;
2037+
type CallOnceFuture = F::CallOnceFuture;
2038+
2039+
extern "rust-call" fn async_call_once(self, args: Args) -> Self::CallOnceFuture {
2040+
F::async_call_once(*self, args)
2041+
}
2042+
}
2043+
2044+
#[unstable(feature = "async_fn_traits", issue = "none")]
2045+
impl<Args: Tuple, F: AsyncFnMut<Args> + ?Sized, A: Allocator> AsyncFnMut<Args> for Box<F, A> {
2046+
type CallMutFuture<'a> = F::CallMutFuture<'a> where Self: 'a;
2047+
2048+
extern "rust-call" fn async_call_mut(&mut self, args: Args) -> Self::CallMutFuture<'_> {
2049+
F::async_call_mut(self, args)
2050+
}
2051+
}
2052+
2053+
#[unstable(feature = "async_fn_traits", issue = "none")]
2054+
impl<Args: Tuple, F: AsyncFn<Args> + ?Sized, A: Allocator> AsyncFn<Args> for Box<F, A> {
2055+
type CallFuture<'a> = F::CallFuture<'a> where Self: 'a;
2056+
2057+
extern "rust-call" fn async_call(&self, args: Args) -> Self::CallFuture<'_> {
2058+
F::async_call(self, args)
2059+
}
2060+
}
2061+
20332062
#[unstable(feature = "coerce_unsized", issue = "18598")]
20342063
impl<T: ?Sized + Unsize<U>, U: ?Sized, A: Allocator> CoerceUnsized<Box<U, A>> for Box<T, A> {}
20352064

alloc/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
#![feature(array_windows)]
107107
#![feature(ascii_char)]
108108
#![feature(assert_matches)]
109+
#![feature(async_fn_traits)]
109110
#![feature(async_iterator)]
110111
#![feature(coerce_unsized)]
111112
#![feature(const_align_of_val)]

core/src/ops/async_function.rs

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,44 +65,67 @@ pub trait AsyncFnOnce<Args: Tuple> {
6565

6666
mod impls {
6767
use super::{AsyncFn, AsyncFnMut, AsyncFnOnce};
68-
use crate::future::Future;
6968
use crate::marker::Tuple;
7069

7170
#[unstable(feature = "async_fn_traits", issue = "none")]
72-
impl<F: Fn<A>, A: Tuple> AsyncFn<A> for F
71+
impl<A: Tuple, F: ?Sized> AsyncFn<A> for &F
7372
where
74-
<F as FnOnce<A>>::Output: Future,
73+
F: AsyncFn<A>,
7574
{
76-
type CallFuture<'a> = <F as FnOnce<A>>::Output where Self: 'a;
75+
type CallFuture<'a> = F::CallFuture<'a> where Self: 'a;
7776

7877
extern "rust-call" fn async_call(&self, args: A) -> Self::CallFuture<'_> {
79-
self.call(args)
78+
F::async_call(*self, args)
8079
}
8180
}
8281

8382
#[unstable(feature = "async_fn_traits", issue = "none")]
84-
impl<F: FnMut<A>, A: Tuple> AsyncFnMut<A> for F
83+
impl<A: Tuple, F: ?Sized> AsyncFnMut<A> for &F
8584
where
86-
<F as FnOnce<A>>::Output: Future,
85+
F: AsyncFn<A>,
8786
{
88-
type CallMutFuture<'a> = <F as FnOnce<A>>::Output where Self: 'a;
87+
type CallMutFuture<'a> = F::CallFuture<'a> where Self: 'a;
8988

9089
extern "rust-call" fn async_call_mut(&mut self, args: A) -> Self::CallMutFuture<'_> {
91-
self.call_mut(args)
90+
F::async_call(*self, args)
9291
}
9392
}
9493

9594
#[unstable(feature = "async_fn_traits", issue = "none")]
96-
impl<F: FnOnce<A>, A: Tuple> AsyncFnOnce<A> for F
95+
impl<'a, A: Tuple, F: ?Sized> AsyncFnOnce<A> for &'a F
9796
where
98-
<F as FnOnce<A>>::Output: Future,
97+
F: AsyncFn<A>,
9998
{
100-
type CallOnceFuture = <F as FnOnce<A>>::Output;
99+
type Output = F::Output;
100+
type CallOnceFuture = F::CallFuture<'a>;
101101

102-
type Output = <<F as FnOnce<A>>::Output as Future>::Output;
102+
extern "rust-call" fn async_call_once(self, args: A) -> Self::CallOnceFuture {
103+
F::async_call(self, args)
104+
}
105+
}
106+
107+
#[unstable(feature = "async_fn_traits", issue = "none")]
108+
impl<A: Tuple, F: ?Sized> AsyncFnMut<A> for &mut F
109+
where
110+
F: AsyncFnMut<A>,
111+
{
112+
type CallMutFuture<'a> = F::CallMutFuture<'a> where Self: 'a;
113+
114+
extern "rust-call" fn async_call_mut(&mut self, args: A) -> Self::CallMutFuture<'_> {
115+
F::async_call_mut(*self, args)
116+
}
117+
}
118+
119+
#[unstable(feature = "async_fn_traits", issue = "none")]
120+
impl<'a, A: Tuple, F: ?Sized> AsyncFnOnce<A> for &'a mut F
121+
where
122+
F: AsyncFnMut<A>,
123+
{
124+
type Output = F::Output;
125+
type CallOnceFuture = F::CallMutFuture<'a>;
103126

104127
extern "rust-call" fn async_call_once(self, args: A) -> Self::CallOnceFuture {
105-
self.call_once(args)
128+
F::async_call_mut(self, args)
106129
}
107130
}
108131
}

core/src/sync/atomic.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2119,7 +2119,16 @@ macro_rules! atomic_int {
21192119
/// This type has the same in-memory representation as the underlying
21202120
/// integer type, [`
21212121
#[doc = $s_int_type]
2122-
/// `]. For more about the differences between atomic types and
2122+
/// `].
2123+
#[doc = if_not_8_bit! {
2124+
$int_type,
2125+
concat!(
2126+
"However, the alignment of this type is always equal to its ",
2127+
"size, even on targets where [`", $s_int_type, "`] has a ",
2128+
"lesser alignment."
2129+
)
2130+
}]
2131+
/// For more about the differences between atomic types and
21232132
/// non-atomic types as well as information about the portability of
21242133
/// this type, please see the [module-level documentation].
21252134
///

profiler_builtins/build.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ fn main() {
1212
return;
1313
}
1414

15-
let target = env::var("TARGET").expect("TARGET was not set");
15+
let target_os = env::var("CARGO_CFG_TARGET_OS").expect("CARGO_CFG_TARGET_OS was not set");
16+
let target_env = env::var("CARGO_CFG_TARGET_ENV").expect("CARGO_CFG_TARGET_ENV was not set");
1617
let cfg = &mut cc::Build::new();
1718

1819
// FIXME: `rerun-if-changed` directives are not currently emitted and the build script
@@ -40,7 +41,7 @@ fn main() {
4041
"InstrProfilingBiasVar.c",
4142
];
4243

43-
if target.contains("msvc") {
44+
if target_env == "msvc" {
4445
// Don't pull in extra libraries on MSVC
4546
cfg.flag("/Zl");
4647
profile_sources.push("WindowsMMap.c");
@@ -55,7 +56,7 @@ fn main() {
5556
cfg.flag("-fno-builtin");
5657
cfg.flag("-fomit-frame-pointer");
5758
cfg.define("VISIBILITY_HIDDEN", None);
58-
if !target.contains("windows") {
59+
if target_os != "windows" {
5960
cfg.flag("-fvisibility=hidden");
6061
cfg.define("COMPILER_RT_HAS_UNAME", Some("1"));
6162
} else {

std/build.rs

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,47 @@ use std::env;
22

33
fn main() {
44
println!("cargo:rerun-if-changed=build.rs");
5-
let target = env::var("TARGET").expect("TARGET was not set");
6-
if target.contains("linux")
7-
|| target.contains("netbsd")
8-
|| target.contains("dragonfly")
9-
|| target.contains("openbsd")
10-
|| target.contains("freebsd")
11-
|| target.contains("solaris")
12-
|| target.contains("illumos")
13-
|| target.contains("apple-darwin")
14-
|| target.contains("apple-ios")
15-
|| target.contains("apple-tvos")
16-
|| target.contains("apple-watchos")
17-
|| target.contains("uwp")
18-
|| target.contains("windows")
19-
|| target.contains("fuchsia")
20-
|| (target.contains("sgx") && target.contains("fortanix"))
21-
|| target.contains("hermit")
22-
|| target.contains("l4re")
23-
|| target.contains("redox")
24-
|| target.contains("haiku")
25-
|| target.contains("vxworks")
26-
|| target.contains("wasm32")
27-
|| target.contains("wasm64")
28-
|| target.contains("espidf")
29-
|| target.contains("solid")
30-
|| target.contains("nintendo-3ds")
31-
|| target.contains("vita")
32-
|| target.contains("aix")
33-
|| target.contains("nto")
34-
|| target.contains("xous")
35-
|| target.contains("hurd")
36-
|| target.contains("uefi")
37-
|| target.contains("teeos")
38-
|| target.contains("zkvm")
39-
// See src/bootstrap/synthetic_targets.rs
5+
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").expect("CARGO_CFG_TARGET_ARCH was not set");
6+
let target_os = env::var("CARGO_CFG_TARGET_OS").expect("CARGO_CFG_TARGET_OS was not set");
7+
let target_vendor =
8+
env::var("CARGO_CFG_TARGET_VENDOR").expect("CARGO_CFG_TARGET_VENDOR was not set");
9+
let target_env = env::var("CARGO_CFG_TARGET_ENV").expect("CARGO_CFG_TARGET_ENV was not set");
10+
11+
if target_os == "linux"
12+
|| target_os == "android"
13+
|| target_os == "netbsd"
14+
|| target_os == "dragonfly"
15+
|| target_os == "openbsd"
16+
|| target_os == "freebsd"
17+
|| target_os == "solaris"
18+
|| target_os == "illumos"
19+
|| target_os == "macos"
20+
|| target_os == "ios"
21+
|| target_os == "tvos"
22+
|| target_os == "watchos"
23+
|| target_os == "windows"
24+
|| target_os == "fuchsia"
25+
|| (target_vendor == "fortanix" && target_env == "sgx")
26+
|| target_os == "hermit"
27+
|| target_os == "l4re"
28+
|| target_os == "redox"
29+
|| target_os == "haiku"
30+
|| target_os == "vxworks"
31+
|| target_arch == "wasm32"
32+
|| target_arch == "wasm64"
33+
|| target_os == "espidf"
34+
|| target_os.starts_with("solid")
35+
|| (target_vendor == "nintendo" && target_env == "newlib")
36+
|| target_os == "vita"
37+
|| target_os == "aix"
38+
|| target_os == "nto"
39+
|| target_os == "xous"
40+
|| target_os == "hurd"
41+
|| target_os == "uefi"
42+
|| target_os == "teeos"
43+
|| target_os == "zkvm"
44+
45+
// See src/bootstrap/src/core/build_steps/synthetic_targets.rs
4046
|| env::var("RUSTC_BOOTSTRAP_SYNTHETIC_TARGET").is_ok()
4147
{
4248
// These platforms don't have any special requirements.

0 commit comments

Comments
 (0)