Closed
Description
error: non-defining existential type use in defining scope
--> src/main.rs:9:22
|
9 | fn bar() -> ServeFut {
| ______________________^
10 | | async move {
11 | | let x = 5;
12 | | await!(foo(&x))
13 | | }
14 | | }
| |_^ lifetime `'_` is part of concrete type but not used in parameter list of existential type
error: aborting due to previous error
cc @oli-obk
Activity
oli-obk commentedon May 9, 2019
Am I correct in assuming that this should not compile, but report an error about returning a reference to the local variable
x
? Or is the self-borrowing generator part what makes this work? so thex
is part of the generator struct and the&x
is the yielded thing?I'll try pretty printing to the expanded HIR, since I'm not sure what's going on there
oli-obk commentedon May 9, 2019
Expanded version:
Playground
cramertj commentedon May 9, 2019
No, this should definitely compile.
&x
isn't yielded, but yes, it's a local variable inside the generator (that references another local variable in the generator).oli-obk commentedon May 10, 2019
Hmm, so because the generator contains references, it has lifetimes, but these lifetimes actually refer to the generator again? Do we have a special kind of lifetime that we use for this? We should just ignore those generator lifetimes for existential types.
cramertj commentedon May 10, 2019
There's no special lifetime afaik (cc @Zoxc @tmandry).
matthewjasper commentedon May 12, 2019
We should ignore all bound regions. Function pointers have the same issue:
Rollup merge of rust-lang#60799 - matthewjasper:allow-bound-regions-i…