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

Weird error message when returning an &'r T #12187

Closed
TethysSvensson opened this issue Feb 11, 2014 · 1 comment · Fixed by #15486
Closed

Weird error message when returning an &'r T #12187

TethysSvensson opened this issue Feb 11, 2014 · 1 comment · Fixed by #15486

Comments

@TethysSvensson
Copy link
Contributor

This program causes an internal compiler error:

fn new<T>() -> &'static T {
  fail!("placeholder")
}

fn main() {
  let &v = new();
}

I get this error, when compiling it:

error: internal compiler error: ty_region() invoked on in appropriate ty: &ty_err
  • The problem disappears, if I force the type of v.
  • A more reasonable error message appears if I write let v = new(); instead.
  • It remains, if I replace the signature with fn new<'r, T>() -> &'r T.
  • It also remain if I replace the type signature with fn new<T>() -> Option<&'static T> and alter main accordingly.
@eddyb
Copy link
Member

eddyb commented Feb 15, 2014

My guess would be that the ICE happens while trying to format the actual error. IMO, &ty_err should have a valid lifetime, since it's just &T with T = ty_err.

bors added a commit to rust-lang-ci/rust that referenced this issue Jul 25, 2022
internal: More completion context refactoring
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants