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

cannot relate region: LUB(ReErased, ReFree(...)) #80779

Closed
ptal opened this issue Jan 7, 2021 · 5 comments · Fixed by #84646
Closed

cannot relate region: LUB(ReErased, ReFree(...)) #80779

ptal opened this issue Jan 7, 2021 · 5 comments · Fixed by #84646
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. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ptal
Copy link

ptal commented Jan 7, 2021

Code

pub struct T<'a>
{
  raw_data: &'a str
}

pub fn f<'a>(a: T<'a>) -> _
{
  g(a)
}

pub fn g<'a>(_: T<'a>) -> _ {}

Meta

rustc --version --verbose:

rustc 1.51.0-nightly (0b644e419 2020-12-26)
binary: rustc
commit-hash: 0b644e419681835bd0f5871c3bfbd648aa04f157
commit-date: 2020-12-26
host: x86_64-unknown-linux-gnu
release: 1.51.0-nightly

Note: Same error on stable and beta.

Error output

error[E0601]: `main` function not found in crate `main`
  --> main.rs:1:1
   |
1  | / pub struct T<'a>
2  | | {
3  | |   raw_data: &'a str
4  | | }
...  |
10 | |
11 | | pub fn g<'a>(_: T<'a>) -> _ {}
   | |______________________________^ consider adding a `main` function to `main.rs`

error[E0121]: the type placeholder `_` is not allowed within types on item signatures
  --> main.rs:11:27
   |
11 | pub fn g<'a>(_: T<'a>) -> _ {}
   |                           ^
   |                           |
   |                           not allowed in type signatures
   |                           help: replace with the correct return type: `()`

error: internal compiler error: compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs:501:17: cannot relate region: LUB(ReErased, ReFree(DefId(0:6 ~ main[317d]::f), BrNamed(DefId(0:7 ~ main[317d]::f::'a), 'a)))

thread 'rustc' panicked at 'Box<Any>', compiler/rustc_errors/src/lib.rs:958:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.51.0-nightly (0b644e419 2020-12-26) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `f`
#1 [fn_sig] computing function signature of `f`
end of query stack
error: aborting due to 3 previous errors

Some errors have detailed explanations: E0121, E0601.
For more information about an error, try `rustc --explain E0121`.
Backtrace

error[E0601]: `main` function not found in crate `main`
  --> main.rs:1:1
   |
1  | / pub struct T<'a>
2  | | {
3  | |   raw_data: &'a str
4  | | }
...  |
10 | |
11 | | pub fn g<'a>(_: T<'a>) -> _ {}
   | |______________________________^ consider adding a `main` function to `main.rs`

error[E0121]: the type placeholder `_` is not allowed within types on item signatures
  --> main.rs:11:27
   |
11 | pub fn g<'a>(_: T<'a>) -> _ {}
   |                           ^
   |                           |
   |                           not allowed in type signatures
   |                           help: replace with the correct return type: `()`

error: internal compiler error: compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs:501:17: cannot relate region: LUB(ReErased, ReFree(DefId(0:6 ~ main[317d]::f), BrNamed(DefId(0:7 ~ main[317d]::f::'a), 'a)))

thread 'rustc' panicked at 'Box<Any>', compiler/rustc_errors/src/lib.rs:958:9
stack backtrace:
   0: std::panicking::begin_panic
   1: rustc_errors::HandlerInner::bug
   2: rustc_errors::Handler::bug
   3: rustc_middle::ty::context::tls::with_opt
   4: rustc_middle::util::bug::opt_span_bug_fmt
   5: rustc_middle::util::bug::bug_fmt
   6: rustc_infer::infer::lexical_region_resolve::LexicalResolver::lub_concrete_regions
   7: rustc_infer::infer::lexical_region_resolve::LexicalResolver::infer_variable_values
   8: rustc_infer::infer::lexical_region_resolve::resolve
   9: rustc_infer::infer::InferCtxt::resolve_regions_and_report_errors
  10: rustc_typeck::check::regionck::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::regionck_fn
  11: rustc_infer::infer::InferCtxtBuilder::enter
  12: rustc_typeck::check::typeck
  13: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck>::compute
  14: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  15: rustc_data_structures::stack::ensure_sufficient_stack
  16: rustc_query_system::query::plumbing::get_query_impl
  17: rustc_typeck::collect::fn_sig
  18: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::fn_sig>::compute
  19: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  20: rustc_data_structures::stack::ensure_sufficient_stack
  21: rustc_query_system::query::plumbing::get_query_impl
  22: rustc_query_system::query::plumbing::ensure_query_impl
  23: <rustc_typeck::collect::CollectItemTypesVisitor as rustc_hir::intravisit::Visitor>::visit_item
  24: rustc_middle::hir::map::Map::visit_item_likes_in_module
  25: rustc_typeck::collect::collect_mod_item_types
  26: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::collect_mod_item_types>::compute
  27: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  28: rustc_data_structures::stack::ensure_sufficient_stack
  29: rustc_query_system::query::plumbing::get_query_impl
  30: rustc_query_system::query::plumbing::ensure_query_impl
  31: rustc_session::session::Session::track_errors
  32: rustc_typeck::check_crate
  33: rustc_interface::passes::analysis
  34: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  35: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  36: rustc_data_structures::stack::ensure_sufficient_stack
  37: rustc_query_system::query::plumbing::get_query_impl
  38: rustc_interface::passes::QueryContext::enter
  39: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  40: rustc_span::with_source_map
  41: rustc_interface::interface::create_compiler_and_run
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.51.0-nightly (0b644e419 2020-12-26) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `f`
#1 [fn_sig] computing function signature of `f`
#2 [collect_mod_item_types] collecting item types in top-level module
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors

Some errors have detailed explanations: E0121, E0601.
For more information about an error, try `rustc --explain E0121`.

@ptal ptal added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 7, 2021
@jyn514
Copy link
Member

jyn514 commented Jan 7, 2021

@ptal this works for me on latest nightly. If you update your version of the compiler, does it work for you? https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=8ac488d8147229b6a0435e5a73c15333

@jyn514
Copy link
Member

jyn514 commented Jan 7, 2021

@jyn514
Copy link
Member

jyn514 commented Jan 7, 2021

Slightly smaller:

pub struct T<'a>(&'a str);

pub fn f<'a>(val: T<'a>) -> _ {
  g(val)
}

pub fn g(_: T<'static>) -> _ {}

If you change T<'a> to T<'static>, it works, so I think this is while trying to infer 'a.

@jyn514 jyn514 added the A-lifetimes Area: Lifetimes / regions label Jan 7, 2021
@JohnTitor
Copy link
Member

rustbot added a commit to rustbot/glacier that referenced this issue Jan 11, 2021
JohnTitor added a commit to rust-lang/glacier that referenced this issue Jan 11, 2021
Co-authored-by: Yuki Okushi <huyuumi.dev@gmail.com>
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Jan 11, 2021
@JohnTitor
Copy link
Member

This issue has been fixed by #82494, 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 Feb 28, 2021
JohnTitor added a commit to JohnTitor/rust that referenced this issue Apr 28, 2021
m-ou-se added a commit to m-ou-se/rust that referenced this issue Apr 28, 2021
…tests, r=Dylan-DPC

Add some regression tests related to rust-lang#82494

Closes rust-lang#75883, closes rust-lang#80779
r? `@estebank`
jackh726 added a commit to jackh726/rust that referenced this issue Apr 28, 2021
…tests, r=Dylan-DPC

Add some regression tests related to rust-lang#82494

Closes rust-lang#75883, closes rust-lang#80779
r? ``@estebank``
jackh726 added a commit to jackh726/rust that referenced this issue Apr 29, 2021
…tests, r=Dylan-DPC

Add some regression tests related to rust-lang#82494

Closes rust-lang#75883, closes rust-lang#80779
r? ```@estebank```
@bors bors closed this as completed in 96c2316 Apr 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in 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. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ 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.

4 participants