Skip to content

Remove or fix some more FIXME(async_closure) #132488

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

Merged
merged 1 commit into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion compiler/rustc_infer/src/infer/opaque_types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,6 @@ where
upvar.visit_with(self);
}

// FIXME(async_closures): Is this the right signature to visit here?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it gets the job done.

args.as_coroutine_closure().signature_parts_ty().visit_with(self);
}

Expand Down
3 changes: 0 additions & 3 deletions tests/ui/async-await/async-closures/mangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
//@[v0] compile-flags: -Csymbol-mangling-version=v0
//@[legacy] compile-flags: -Csymbol-mangling-version=legacy -Zunstable-options

// FIXME(async_closures): When `fn_sig_for_fn_abi` is fixed, remove this.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was fixed.

//@ ignore-pass (test emits codegen-time warnings)

#![feature(async_closure, noop_waker)]

extern crate block_on;
Expand Down
5 changes: 4 additions & 1 deletion tests/ui/async-await/async-closures/no-borrow-from-env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ fn through_field_and_ref<'a>(x: &S<'a>) {

let c = async move || { println!("{}", *x.0); };
outlives::<'a>(c());
// outlives::<'a>(call_once(c)); // FIXME(async_closures): Figure out why this fails

// outlives::<'a>(call_once(c));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explanation for why this fails, since I understand it now, and it's totally expected.

// The above fails b/c the by-move coroutine of `c` captures `x` in its entirety.
// Since we have not asserted that the borrow for `&S<'a>` outlives `'a`, it'll fail.
}

fn main() {}
2 changes: 1 addition & 1 deletion tests/ui/async-await/async-closures/not-fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fn main() {

let mut x = 1;
needs_fn(async || {
//~^ ERROR async closure does not implement `FnMut` because it captures state from its environment
//~^ ERROR async closure does not implement `FnMut` because it captures state from its environment
x += 1;
});
}
4 changes: 2 additions & 2 deletions tests/ui/async-await/async-closures/precise-captures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ async fn async_main() {
{
let mut s = S { a: 1, b: Drop("drop first"), c: Drop("untouched") };
let c = guidance!(async move || {
// s.a = 2; // FIXME(async_closures): Figure out why this fails
s.a = 2;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was fixed!

drop(s.b);
});
s.c.0 = "uncaptured";
Expand All @@ -141,7 +141,7 @@ async fn async_main() {
{
let mut s = S { a: 1, b: Drop("drop first"), c: Drop("untouched") };
let c = guidance!(async move || {
// s.a = 2; // FIXME(async_closures): Figure out why this fails
s.a = 2;
drop(s.b);
});
s.c.0 = "uncaptured";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ fn through_field_and_ref<'a>(x: &S<'a>) {
let c = async || { println!("{}", *x.0); }; //~ ERROR `x` does not live long enough
outlives::<'a>(c());
outlives::<'a>(call_once(c)); //~ ERROR explicit lifetime required in the type of `x`
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split into two functions since one error actually just suppresses the other (due to NLL error deduplication, I believe).


fn through_field_and_ref_move<'a>(x: &S<'a>) {
let c = async move || { println!("{}", *x.0); };
outlives::<'a>(c()); //~ ERROR `c` does not live long enough
// outlives::<'a>(call_once(c)); // FIXME(async_closures): Figure out why this fails
outlives::<'a>(call_once(c)); //~ ERROR explicit lifetime required in the type of `x`
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is expected to fail for the same reason as I elaborated above in tests/ui/async-await/async-closures/no-borrow-from-env.rs.

}

fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ LL | let c = async || { println!("{}", *x.0); };
LL | outlives::<'a>(c());
LL | outlives::<'a>(call_once(c));
| ------------ argument requires that `x` is borrowed for `'a`
...
LL | }
| - `x` dropped here while still borrowed

Expand All @@ -114,23 +113,31 @@ LL | outlives::<'a>(call_once(c));
| ^^^^^^^^^^^^ lifetime `'a` required

error[E0597]: `c` does not live long enough
--> $DIR/without-precise-captures-we-are-powerless.rs:43:20
--> $DIR/without-precise-captures-we-are-powerless.rs:45:20
|
LL | fn through_field_and_ref<'a>(x: &S<'a>) {
| -- lifetime `'a` defined here
...
LL | fn through_field_and_ref_move<'a>(x: &S<'a>) {
| -- lifetime `'a` defined here
LL | let c = async move || { println!("{}", *x.0); };
| - binding `c` declared here
LL | outlives::<'a>(c());
| ^--
| |
| borrowed value does not live long enough
| argument requires that `c` is borrowed for `'a`
LL | // outlives::<'a>(call_once(c)); // FIXME(async_closures): Figure out why this fails
LL | outlives::<'a>(call_once(c));
LL | }
| - `c` dropped here while still borrowed

error: aborting due to 9 previous errors
error[E0621]: explicit lifetime required in the type of `x`
--> $DIR/without-precise-captures-we-are-powerless.rs:46:20
|
LL | fn through_field_and_ref_move<'a>(x: &S<'a>) {
| ------ help: add explicit lifetime `'a` to the type of `x`: `&'a S<'a>`
...
LL | outlives::<'a>(call_once(c));
| ^^^^^^^^^^^^ lifetime `'a` required

error: aborting due to 10 previous errors

Some errors have detailed explanations: E0505, E0597, E0621.
For more information about an error, try `rustc --explain E0505`.
Loading