-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Compiler panic on type inference for impl Generator yielding a reference #52304
Comments
We don't generate an error message for the
Should |
Why are we capturing |
There isn't any |
@Zoxc Oh, all of that code is for exporting |
I think the problem is that the |
This doesn't occur with closures because regionck forces the return type of the closure to outlive the closure's call scope, which prevents |
I think that the correct way to fix it would be to |
The requirement we want is that that "implicit" That requires that the projections in that impl are alive as long as |
I think that in closures, |
This can, in fact, be used as a soundness hole (assuming you can call #![feature(generators, generator_trait)]
use std::fmt::Debug;
use std::ops::Generator;
fn gen_taker<G: Generator>(mut g: G)
where G::Yield: Debug, G::Return: Debug
{
let a = unsafe { g.resume() };
drop(g);
println!("{:?}", a);
}
fn main() {
gen_taker(|| {
let x = 1;
yield &x
});
} |
Note: the version above is fixed by NLL. need to check whether fix is tight. |
@arielb1 any ideas on how to check whether the "fix is tight"? Otherwise perhaps this issue can be closed? |
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
…rrors Add regression test for rust-lang#52304 Closes rust-lang#52304 r? `@compiler-errors` Signed-off-by: Yuki Okushi <jtitor@2k36.org>
…rrors Add regression test for rust-lang#52304 Closes rust-lang#52304 r? ``@compiler-errors`` Signed-off-by: Yuki Okushi <jtitor@2k36.org>
…rrors Add regression test for rust-lang#52304 Closes rust-lang#52304 r? ````@compiler-errors```` Signed-off-by: Yuki Okushi <jtitor@2k36.org>
…askrgr Rollup of 11 pull requests Successful merges: - rust-lang#98707 (std: use futex-based locks on Fuchsia) - rust-lang#99413 (Add `PhantomData` marker for dropck to `BTreeMap`) - rust-lang#99454 (Add map_continue and continue_value combinators to ControlFlow) - rust-lang#99523 (Fix the stable version of `AsFd for Arc<T>` and `Box<T>`) - rust-lang#99526 (Normalize the arg spans to be within the call span) - rust-lang#99528 (couple of clippy::perf fixes) - rust-lang#99549 (Add regression test for rust-lang#52304) - rust-lang#99552 (Rewrite `orphan_check_trait_ref` to use a `TypeVisitor`) - rust-lang#99557 (Edit `rustc_index::vec::IndexVec::pick3_mut` docs) - rust-lang#99558 (Fix `remap_constness`) - rust-lang#99559 (Remove unused field in ItemKind::KeywordItem) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
I'm getting
when trying to compile
on rustc 1.29.0-nightly (e5f6498 2018-07-10) - Playground demo.
This seems to happen when I
yield
a reference type and don't specify the exact type inimpl Generator<Yield=&Whatever>
.The text was updated successfully, but these errors were encountered: