Skip to content
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

"escaping bound vars in predicate" with associated_type_bounds, HRTB #70292

Closed
comex opened this issue Mar 23, 2020 · 5 comments · Fixed by #77741
Closed

"escaping bound vars in predicate" with associated_type_bounds, HRTB #70292

comex opened this issue Mar 23, 2020 · 5 comments · Fixed by #77741
Labels
A-associated-items Area: Associated items such as associated types and consts. C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. F-associated_type_bounds `#![feature(associated_type_bounds)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@comex
Copy link
Contributor

comex commented Mar 23, 2020

Playground link

#![feature(unboxed_closures, associated_type_bounds)]

fn foo<F>(f: F) where
    F: for<'a> FnOnce<(&'a i32,), Output: 'a> {}

fn main() {
    foo(|x: &i32| -> &i32 { x });
}

produces:

error: internal compiler error: src/librustc_typeck/check/mod.rs:692: escaping bound vars in predicate Obligation(predicate=Binder(OutlivesPredicate(_, ReLateBound(DebruijnIndex(1), BrNamed(DefId(0:5 ~ playground[eb44]::foo[0]::'a[0]), 'a)))), depth=0)
 --> src/main.rs:7:5
  |
7 |     foo(|x: &i32| -> &i32 { x }); // OK
  |     ^^^

This does not happen if written out in this form, even though I think it should be equivalent:

    F: for<'a> FnOnce<(&'a i32,)>,
    for<'a> <F as FnOnce<(&'a i32,)>>::Output: 'a,

May or may not be related to #70263.

@comex comex changed the title "escaping bound vars in predicate" with unboxed_closures and associated_type_bounds "escaping bound vars in predicate" with unboxed_closures, associated_type_bounds, HRTB Mar 23, 2020
@jonas-schievink jonas-schievink added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. F-associated_type_bounds `#![feature(associated_type_bounds)]` F-unboxed_closures `#![feature(unboxed_closures)]` A-associated-items Area: Associated items such as associated types and consts. A-closures Area: closures (`|args| { .. }`) labels Mar 23, 2020
@Centril
Copy link
Contributor

Centril commented Mar 23, 2020

cc @alexreg

@Centril Centril added the P-medium Medium priority label Mar 23, 2020
@alexreg
Copy link
Contributor

alexreg commented Mar 23, 2020

@Centril Interesting. Is this (should this be) even supported right now? My point is, you can't do this just by concatenating where bounds, so...

@Centril
Copy link
Contributor

Centril commented Mar 23, 2020

Minimized

#![feature(associated_type_bounds)]

fn foo<F>(_: F)
where
    F: for<'a> Trait<Output: 'a>,
{
}

trait Trait {
    type Output;
}

impl<T> Trait for T {
    type Output = ();
}

fn main() {
    foo(());
}

The "desugared" version compiles fine.

@Centril Centril removed A-closures Area: closures (`|args| { .. }`) F-unboxed_closures `#![feature(unboxed_closures)]` labels Mar 23, 2020
@Centril Centril changed the title "escaping bound vars in predicate" with unboxed_closures, associated_type_bounds, HRTB "escaping bound vars in predicate" with associated_type_bounds, HRTB Mar 23, 2020
@Centril
Copy link
Contributor

Centril commented Mar 23, 2020

@JohnTitor
Copy link
Member

Triage: This is no longer ICE with the latest nightly, marking as E-needs-test.

@JohnTitor JohnTitor added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Oct 7, 2020
@bors bors closed this as completed in 5565241 Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items such as associated types and consts. C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. F-associated_type_bounds `#![feature(associated_type_bounds)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants