Skip to content

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

Closed
@ptal

Description

@ptal

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`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lifetimesArea: Lifetimes / regionsC-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions