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

internal compiler error: cannot relate region: LUB(ReErased, ReErased) #70608

Closed
dwrensha opened this issue Mar 31, 2020 · 9 comments · Fixed by #70716
Closed

internal compiler error: cannot relate region: LUB(ReErased, ReErased) #70608

dwrensha opened this issue Mar 31, 2020 · 9 comments · Fixed by #70716
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-lifetimes Area: Lifetimes / regions C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High 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

@dwrensha
Copy link
Contributor

dwrensha commented Mar 31, 2020

I'm seeing an internal compiler error on the following input (found by fuzz-rustc):

const e = & & 39;
pub fn main(){}
$ rustc main.rs
error: missing type for `const` item
 --> main.rs:1:7
  |
1 | const e = & & 39;
  |       ^ help: provide a type for the item: `e: &&i32`

error: internal compiler error: src/librustc_infer/infer/lexical_region_resolve/mod.rs:497: cannot relate region: LUB(ReErased, ReErased)

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:880: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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.44.0-nightly (211365947 2020-03-30) running on x86_64-unknown-linux-gnu

error: aborting due to 2 previous errors
@dwrensha
Copy link
Contributor Author

Report from cargo bisect-rustc:

searched nightlies: from nightly-2020-03-09 to nightly-2020-03-31
regressed nightly: nightly-2020-03-20
searched commits: from f509b26 to f4c675c
regressed commit: 57e1da5

@jonas-schievink jonas-schievink added A-lifetimes Area: Lifetimes / regions C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ I-nominated T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. labels Mar 31, 2020
@Centril
Copy link
Contributor

Centril commented Mar 31, 2020

This is presumably due to #69189 -- cc @matthewjasper

@Centril Centril added the A-diagnostics Area: Messages for errors, warnings, and lints label Mar 31, 2020
@spastorino
Copy link
Member

spastorino commented Apr 1, 2020

This was briefly discussed in our Zulip pre-triage meeting. Tagging it as P-high.

Not removing nomination until we can assign this issue.

@spastorino spastorino added the P-high High priority label Apr 1, 2020
@Centril
Copy link
Contributor

Centril commented Apr 2, 2020

   Compiling playground v0.0.1 (/playground)
error: missing type for `const` item
 --> src/main.rs:1:7
  |
1 | const e = & & 39;
  |       ^ help: provide a type for the item: `e: &&i32`

error: internal compiler error: src/librustc_infer/infer/lexical_region_resolve/mod.rs:497: cannot relate region: LUB(ReErased, ReErased)

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:880:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:78
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1069
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1439
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:198
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:218
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:515
  12: std::panicking::begin_panic
  13: rustc_errors::HandlerInner::bug
  14: rustc_errors::Handler::bug
  15: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}
  16: rustc_middle::ty::context::tls::with_opt::{{closure}}
  17: rustc_middle::ty::context::tls::with_opt
  18: rustc_middle::util::bug::opt_span_bug_fmt
  19: rustc_middle::util::bug::bug_fmt
  20: rustc_infer::infer::lexical_region_resolve::LexicalResolver::lub_concrete_regions
  21: rustc_infer::infer::lexical_region_resolve::LexicalResolver::sub_concrete_regions
  22: rustc_infer::infer::lexical_region_resolve::LexicalResolver::infer_variable_values
  23: rustc_infer::infer::lexical_region_resolve::resolve
  24: rustc_infer::infer::InferCtxt::resolve_regions_and_report_errors
  25: rustc_typeck::check::regionck::<impl rustc_typeck::check::FnCtxt>::regionck_item
  26: rustc_middle::ty::context::GlobalCtxt::enter_local
  27: rustc_typeck::check::wfcheck::check_item_type
  28: rustc_typeck::check::wfcheck::check_item_well_formed
  29: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::check_item_well_formed>::compute
  30: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  31: rustc_query_system::query::plumbing::get_query
  32: rustc_query_system::query::plumbing::ensure_query
  33: rustc_data_structures::sync::par_for_each_in
  34: rustc_hir::hir::Crate::par_visit_all_item_likes
  35: rustc_session::session::Session::track_errors
  36: rustc_typeck::check_crate
  37: rustc_interface::passes::analysis
  38: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  39: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  40: rustc_query_system::query::plumbing::get_query
  41: rustc_middle::ty::context::tls::enter_global
  42: rustc_interface::interface::run_compiler_in_existing_thread_pool
  43: scoped_tls::ScopedKey<T>::set
  44: rustc_ast::attr::with_globals
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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.44.0-nightly (76b11980a 2020-04-01) running on x86_64-unknown-linux-gnu

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

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [check_item_well_formed] processing `e`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors

error: could not compile `playground`.

To learn more, run the command again with --verbose.

@pnkfelix
Copy link
Member

pnkfelix commented Apr 2, 2020

@rustbot assign @matthewjasper

(assigning based on claim that this was injected by PR #69189)

@eddyb
Copy link
Member

eddyb commented Apr 2, 2020

This is the feature where type_of for a const with a missing type will look at the body and get the type from there.

We should replace all regions in that situation with 'static, just so the code which ICEs here will continue to ICE for legitimate bugs.

@Centril
Copy link
Contributor

Centril commented Apr 2, 2020

Doesn't reproduce with (added : _):

const e: _ = & & 39;
pub fn main(){}

@nikomatsakis
Copy link
Contributor

We should replace all regions in that situation with 'static, just so the code which ICEs here will continue to ICE for legitimate bugs.

Hmmmm, I'm not sure I agree with that assessment, unless -- well -- I guess you're saying that the "correct static type" for any such expression would be 'static anyway?

@eddyb
Copy link
Member

eddyb commented Apr 2, 2020

@nikomatsakis yes, this is recovery for a guaranteed error, after all.

A slightly more aggressive example:

const e = & & 39;
const FOO: [(); { let _ = e; 0 }] = [];
pub fn main(){}

Results in this query stack for the ICE:

#0 [typeck_tables_of] type-checking `FOO::{{constant}}#0`
#1 [const_eval_raw] const-evaluating `FOO::{{constant}}#0`
#2 [const_eval_validated] const-evaluating + checking `FOO::{{constant}}#0`
#3 [const_eval_validated] const-evaluating + checking `FOO::{{constant}}#0`
#4 [check_item_well_formed] processing `FOO`
#5 [analysis] running analysis passes on this crate

I have no idea why changing const e = to const e: _ = changes anything but they should both ICE IMO (before we switch to replacing erased regions with 'static).

I'm now worried there are other places in which typeck_tables_of is used to extract some type and "export" it outside of the context of the body, without the necessary precautions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-lifetimes Area: Lifetimes / regions C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High 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.

8 participants