-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Trouble passing closures with borrowed pointers inside options #10846
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
Comments
visiting for triage. It can be simplified to:
It's erroring with:
|
cc me. This may be blocking some work on Servo. |
cc me |
Slightly simpler test case: #![crate_type="lib"]
fn erickt_fn() {
fn test2(_x: Option<|f: |g: &int||>) {}
test2(Some(|_f: |g: &int|| {}));
} Also, I found the problem goes away if you manually lift the closure types into #[cfg(show_erickt_bug)]
fn erickt_fn() {
fn test2(_x: Option<|y: Option<|z: &int|>|>) {}
test2(Some(|_y: Option<|z: &int|>| {}));
}
#[cfg(not(show_erickt_bug))]
fn erickt_fn() {
type F1<'a> = |z: &'a int|:'a;
type F2<'b> = |y: Option<F1<'b>>|:'b;
fn test2<'c>(_x: Option<F2>) {}
test2(Some(|_y| {}))
} This probably reflects some change where the lifetimes go from being late-bound to being early bound. The version with |
The type item versions are not equivalent because they don't have any bound lifetimes. Niko -------- Original message -------- Slightly simpler test case: #![crate_type="lib"] fn erickt_fn() {
This probably reflects some change where the lifetimes go from being late-bound to being early bound. The version with type items might not be handle cases that the version with inlined closure types can handle, I'm not 100% sure yet. — |
In other words, Late-bound regions that occur non-free should be skipped. Fix rust-lang#10846.
In other words, Late-bound regions that occur non-free should be skipped. Fix #10846 (specifically the ICE, not the weakness in the current type inference).
This commit fixes rust-lang#10846 by checking if the path segment contains the word "prelude". Signed-off-by: Charalampos Mitrodimas <[email protected]>
… r=llogiq [`wildcard_imports`] Modules that contain `prelude` are also allowed This commit fixes rust-lang#10846 by checking if the path segment contains the word "prelude", allowing us `use module_prelude::*`. changelog: [`wildcard_imports`]: Modules that contain `prelude` are also allowed
rustc 0.9-pre (aa4455e 2013-12-06 01:11:18 -0800)
Consider this code and errors:
As you can see, in case of
test1
, it has trouble inferring the type of the closure parameter, but if you specify it manually it works. In the case oftest2
specifying it manually crashes the compiler outright. Note that both cases work just fine if you remove all theOption
s.The text was updated successfully, but these errors were encountered: