Skip to content

ICE with higher ranked lifetimes #49919

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
mcarton opened this issue Apr 12, 2018 · 2 comments · Fixed by #62578
Closed

ICE with higher ranked lifetimes #49919

mcarton opened this issue Apr 12, 2018 · 2 comments · Fixed by #62578
Labels
A-lifetimes Area: Lifetimes / regions 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. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-lang Relevant to the language team

Comments

@mcarton
Copy link
Member

mcarton commented Apr 12, 2018

While trying to find the right syntax for this SO question, I came upon this:

fn foo<'a, T: 'a>(t: T) -> Box<Fn() -> &'a T + 'a> {
    let foo: Box<for <'c> Fn() -> &'c T> = Box::new(move || &t);
    unimplemented!()
}

fn main() {}

which ICEs on Stable, Beta and Nightly:

   Compiling playground v0.0.1 (file:///playground)
error[E0582]: binding for associated type `Output` references lifetime `'c`, which does not appear in the trait input types
 --> src/main.rs:2:35
  |
2 |     let foo: Box<for <'c> Fn() -> &'c T> = Box::new(move || &t);
  |                                   ^^^^^

error: internal compiler error: librustc/infer/higher_ranked/mod.rs:160: no representative region for `ReSkolemized(1, BrAnon(1))` in `{ReSkolemized(1, BrAnon(1))}`

thread 'rustc' panicked at 'Box<Any>', librustc_errors/lib.rs:543:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0582`.

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.26.0-beta.3 (8a75d2b50 2018-04-08) running on x86_64-unknown-linux-gnu

note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type bin

https://play.rust-lang.org/?gist=99fafbbcbd0fc919138de28d5e1a6326&version=nightly

@estebank
Copy link
Contributor

// For each skolemized region, pick a representative -- which can
// be any region from the sets above, except for other members of
// `skol_map`. There should always be a representative if things
// are properly well-formed.
let skol_representatives: FxHashMap<_, _> =
skol_resolution_map
.iter()
.map(|(&skol, &(_, ref regions))| {
let representative =
regions.iter()
.filter(|&&r| !skol_resolution_map.contains_key(r))
.cloned()
.next()
.unwrap_or_else(|| {
bug!("no representative region for `{:?}` in `{:?}`",
skol, regions)
});
(skol, representative)
})
.collect();

@estebank estebank added A-lifetimes Area: Lifetimes / regions I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Apr 13, 2018
@XAMPPRocky XAMPPRocky added T-lang Relevant to the language team C-bug Category: This is a bug. labels Jul 7, 2018
@JohnTitor
Copy link
Member

This seems no longer reproduced in the latest stable (also beta and nightly).

@rustbot modify labels: +E-needstest

@rustbot rustbot added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jul 11, 2019
JohnTitor added a commit to JohnTitor/rust that referenced this issue Jul 11, 2019
Centril added a commit to Centril/rust that referenced this issue Jul 12, 2019
bors added a commit that referenced this issue Jul 12, 2019
Rollup of 12 pull requests

Successful merges:

 - #61535 (Coherence test when a generic type param has a default value from an associated type)
 - #62274 (rustc_mir: follow FalseUnwind's real_target edge in qualify_consts.)
 - #62431 (Add messages to `Option`'s and `Result`'s `must_use` annotation for `is_*`)
 - #62453 (in which we suggest anonymizing single-use lifetimes in paths )
 - #62568 (Replace unsafe_destructor_blind_to_params with may_dangle)
 - #62578 (Add test for #49919)
 - #62595 (Document that the crate keyword refers to the project root)
 - #62599 (move mem::uninitialized deprecation back by 1 release, to 1.39)
 - #62605 (Emit dropped unemitted errors to aid in ICE debugging)
 - #62607 (Correctly break out of recovery loop)
 - #62608 (`async unsafe fn` tests)
 - #62623 (downgrade indirect_structural_match lint to allow)

Failed merges:

r? @ghost
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-lifetimes Area: Lifetimes / regions 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. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-lang Relevant to the language team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants