c8b76bcf58
On some architectures, vector types may have a different ABI depending on whether the relevant target features are enabled. (The ABI when the feature is disabled is often not specified, but LLVM implements some de-facto ABI.) As discussed in rust-lang/lang-team#235, this turns out to very easily lead to unsound code. This commit makes it a post-monomorphization future-incompat warning to declare or call functions using those vector types in a context in which the corresponding target features are disabled, if using an ABI for which the difference is relevant. This ensures that these functions are always called with a consistent ABI. See the [nomination comment](https://github.com/rust-lang/rust/pull/127731#issuecomment-2288558187) for more discussion. Part of #116558
59 lines
1.1 KiB
Rust
59 lines
1.1 KiB
Rust
//@ build-fail
|
|
//@ edition: 2021
|
|
|
|
#![feature(async_closure, noop_waker)]
|
|
|
|
use std::future::Future;
|
|
use std::pin::pin;
|
|
use std::task::*;
|
|
|
|
pub fn block_on<T>(fut: impl Future<Output = T>) -> T {
|
|
let mut fut = pin!(fut);
|
|
// Poll loop, just to test the future...
|
|
let ctx = &mut Context::from_waker(Waker::noop());
|
|
|
|
loop {
|
|
match fut.as_mut().poll(ctx) {
|
|
Poll::Pending => {}
|
|
Poll::Ready(t) => break t,
|
|
}
|
|
}
|
|
}
|
|
|
|
trait Blah {
|
|
async fn iter<T>(&mut self, iterator: T)
|
|
where
|
|
T: IntoIterator<Item = ()>;
|
|
}
|
|
|
|
impl Blah for () {
|
|
async fn iter<T>(&mut self, iterator: T)
|
|
//~^ ERROR recursion in an async fn requires boxing
|
|
where
|
|
T: IntoIterator<Item = ()>,
|
|
{
|
|
Blah::iter(self, iterator).await
|
|
}
|
|
}
|
|
|
|
struct Wrap<T: Blah> {
|
|
t: T,
|
|
}
|
|
|
|
impl<T: Blah> Wrap<T>
|
|
where
|
|
T: Blah,
|
|
{
|
|
async fn ice(&mut self) {
|
|
let arr: [(); 0] = [];
|
|
self.t.iter(arr.into_iter()).await;
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
block_on(async {
|
|
let mut t = Wrap { t: () };
|
|
t.ice();
|
|
})
|
|
}
|