Skip to content

ICE: compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs:498:17: cannot relate region: LUB(ReErased, ReEmpty(U0)) #87490

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

Closed
chengniansun opened this issue Jul 26, 2021 · 4 comments · Fixed by #91239
Labels
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) ❄️ P-low Low priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@chengniansun
Copy link

Code

trait StreamOnce {
    type Position;
}
impl StreamOnce for &str {
    type Position = usize;
}
fn follow(_: &str) -> <&str as StreamOnce>::Position {
    String::new
}

Meta

rustc --version --verbose:

rustc 1.56.0-nightly (9c25eb7aa 2021-07-25)
binary: rustc
commit-hash: 9c25eb7aa3a71fb951564b0ddf131be59c2c951d
commit-date: 2021-07-25
host: x86_64-unknown-linux-gnu
release: 1.56.0-nightly
LLVM version: 12.0.1

Error output

error[E0601]: `main` function not found in crate `mutant`
 --> mutant.rs:1:1
  |
1 | / trait StreamOnce {
2 | |     type Position;
3 | | }
4 | | impl StreamOnce for &str {
... |
8 | |     String::new
9 | | }
  | |_^ consider adding a `main` function to `mutant.rs`

error[E0308]: mismatched types
 --> mutant.rs:8:5
  |
7 | fn follow(_: &str) -> <&str as StreamOnce>::Position {
  |                       ------------------------------ expected `usize` because of return type
8 |     String::new
  |     ^^^^^^^^^^^ expected `usize`, found fn item
  |
  = note: expected type `usize`
          found fn item `fn() -> String {String::new}`

error: internal compiler error: compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs:498:17: cannot relate region: LUB(ReErased, ReEmpty(U0))

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1034: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.56.0-nightly (9c25eb7aa 2021-07-25) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `follow`
#1 [typeck_item_bodies] type-checking all item bodies
end of query stack
error: aborting due to 3 previous errors

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

error[E0601]: `main` function not found in crate `mutant`
 --> mutant.rs:1:1
  |
1 | / trait StreamOnce {
2 | |     type Position;
3 | | }
4 | | impl StreamOnce for &str {
... |
8 | |     String::new
9 | | }
  | |_^ consider adding a `main` function to `mutant.rs`

error[E0308]: mismatched types
 --> mutant.rs:8:5
  |
7 | fn follow(_: &str) -> <&str as StreamOnce>::Position {
  |                       ------------------------------ expected `usize` because of return type
8 |     String::new
  |     ^^^^^^^^^^^ expected `usize`, found fn item
  |
  = note: expected type `usize`
          found fn item `fn() -> String {String::new}`

error: internal compiler error: compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs:498:17: cannot relate region: LUB(ReErased, ReEmpty(U0))

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1034:9
stack backtrace:
   0: std::panicking::begin_panic
   1: std::panic::panic_any
   2: rustc_errors::HandlerInner::bug
   3: rustc_errors::Handler::bug
   4: rustc_middle::ty::context::tls::with_opt
   5: rustc_middle::util::bug::opt_span_bug_fmt
   6: rustc_middle::util::bug::bug_fmt
   7: rustc_infer::infer::lexical_region_resolve::LexicalResolver::lub_concrete_regions
   8: rustc_infer::infer::lexical_region_resolve::LexicalResolver::expand_node
   9: rustc_infer::infer::lexical_region_resolve::LexicalResolver::infer_variable_values
  10: rustc_infer::infer::lexical_region_resolve::resolve
  11: rustc_infer::infer::InferCtxt::resolve_regions_and_report_errors
  12: rustc_typeck::check::regionck::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::regionck_fn
  13: rustc_infer::infer::InferCtxtBuilder::enter
  14: rustc_typeck::check::typeck
  15: rustc_query_system::query::plumbing::get_query_impl
  16: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck
  17: rustc_middle::ty::<impl rustc_middle::ty::context::TyCtxt>::par_body_owners
  18: rustc_typeck::check::typeck_item_bodies
  19: rustc_query_system::query::plumbing::get_query_impl
  20: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck_item_bodies
  21: rustc_session::utils::<impl rustc_session::session::Session>::time
  22: rustc_typeck::check_crate
  23: rustc_interface::passes::analysis
  24: rustc_query_system::query::plumbing::get_query_impl
  25: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  26: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  27: rustc_span::with_source_map
  28: rustc_interface::interface::create_compiler_and_run
  29: scoped_tls::ScopedKey<T>::set
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.56.0-nightly (9c25eb7aa 2021-07-25) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `follow`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors

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

@chengniansun chengniansun 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 Jul 26, 2021
@hellow554
Copy link
Contributor

hellow554 commented Jul 27, 2021

String::new can be replaced by any function item, e.g. main or || ().
Lifetime of <&str as ...> must be bounded to a parameter, therefore 'static does not work

Regression in 3cb1c11 not sure which PR exactly though but I think #86666

@rustbot modify labels: regression-from-stable-to-nightly

@rustbot rustbot added regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jul 27, 2021
@apiraino
Copy link
Contributor

Assigning priority as discussed in the Zulip thread of the Prioritization Working Group.

@rustbot label -I-prioritize +P-low

@rustbot rustbot added P-low Low priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jul 29, 2021
@Diomendius
Copy link

String::new can actually also be replaced with () or seemingly any type other than the return type in the function signature, but strangely leaving the function body empty does not trigger the ICE.

@Alexendoo
Copy link
Member

No longer ICEs since #88846

@Alexendoo Alexendoo added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Sep 23, 2021
@bors bors closed this as completed in c0e3dde Dec 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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) ❄️ P-low Low priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. 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.

7 participants