-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
regression: change in async capture rules? #117059
Comments
that's probably coming from -Zdrop-tracking-mir |
for reference: 13e6f24 Assigning priority (Zulip discussion), possibly to be adjusted after discussion. @rustbot label -I-prioritize +P-high |
this is basically a duplicate of #116242 |
Heavily reduced, and can still be minimized (as e.g. depends on use std::sync::Arc;
use futures::lock::Mutex;
use futures::Stream;
pub trait VertexStream: Stream<Item = ()> + Send {}
impl<T> VertexStream for T where T: Stream<Item = ()> + Send {}
struct Inner {
stream: Box<dyn VertexStream>,
state: State,
}
enum State {
Incomplete,
Complete,
}
impl Inner {
async fn load_more(&mut self) {}
}
pub(crate) struct Iter {
inner: Arc<Mutex<Inner>>,
}
impl Iter {
async fn next(&mut self) {
let mut inner = self.inner.lock().await;
match inner.state {
State::Complete if true => {}
State::Incomplete => {
let _ = inner.load_more().await;
}
_ => {}
}
}
fn into_stream(self) -> Box<dyn VertexStream> {
Box::new(futures::stream::unfold(self, |mut state| async move {
let _ = state.next().await;
Some(()).map(|r| (r, state))
}))
}
} |
further minimized, does not depend on external crates now: https://rust.godbolt.org/z/s5MbWqvWs struct SendNotSync(*const ());
unsafe impl Send for SendNotSync {}
// impl !Sync for Foo {}
struct Inner {
stream: SendNotSync,
state: bool,
}
struct SendSync;
impl std::ops::Deref for SendSync {
type Target = Inner;
fn deref(&self) -> &Self::Target {
todo!();
}
}
async fn next() {
let inner = SendSync;
match inner.state {
true if true => {}
false => std::future::ready(()).await,
_ => {}
}
}
fn is_send<T: Send>(_: T) {}
fn main() {
is_send(async move {
let _ = next().await;
})
} |
This comment was marked as outdated.
This comment was marked as outdated.
struct SendNotSync(*const ());
unsafe impl Send for SendNotSync {}
// impl !Sync for SendNotSync {} // automatically disabled
struct Inner {
stream: SendNotSync,
state: bool,
}
struct SendSync;
impl std::ops::Deref for SendSync {
type Target = Inner;
fn deref(&self) -> &Self::Target {
todo!();
}
}
async fn next() {
let inner = SendSync;
match inner.state {
true if true => {}
false => async {}.await,
_ => {}
}
}
fn is_send<T: Send>(_: T) {}
fn main() {
is_send(next())
} This test fails regardless of whether Two questions remain:
|
We require a local to be stored at a yield point if it either is used afterwards directly or there exists a reference to that local. If the local has been dropped via a The local for If there is a match guard, we emit a fake borrow of the scrutinee before the first match x[10] {
_ if { x = &[0]; false } => (),
// would now be out of bounds
y => (),
} So, because of that fake borrow of This means we should be able to ignore |
generator layout: ignore fake borrows fixes rust-lang#117059 We emit fake shallow borrows in case the scrutinee place uses a `Deref` and there is a match guard. This is necessary to prevent the match guard from mutating the scrutinee: https://github.com/rust-lang/rust/blob/fab1054e1742790c22ccc92a625736d658363677/compiler/rustc_mir_build/src/build/matches/mod.rs#L1250-L1265 These fake borrows end up impacting the generator witness computation in `mir_generator_witnesses`, which causes the issue in rust-lang#117059. This PR now completely ignores fake borrows during this computation. This is sound as thse are always removed after analysis and the actual computation of the generator layout happens afterwards. Only the second commit impacts behavior, and could be backported by itself. r? types
reopening until beta-backport is completed |
Backported in #117764 |
https://crater-reports.s3.amazonaws.com/beta-1.74-4/beta-2023-10-21/reg/esl01-dag-0.3.0/log.txt
The text was updated successfully, but these errors were encountered: