Skip to content

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

Closed

Description

@dwrensha

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

Activity

  1. dwrensha commented on Mar 31, 2020

    @dwrensha
    ContributorAuthor

    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

  2. added
    A-lifetimesArea: Lifetimes / regions
    C-bugCategory: This is a bug.
    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.
    on Mar 31, 2020
  3. Centril commented on Mar 31, 2020

    @Centril
    Contributor

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

  4. spastorino commented on Apr 1, 2020

    @spastorino
    Member

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

    Not removing nomination until we can assign this issue.

  5. Centril commented on Apr 2, 2020

    @Centril
    Contributor
       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.
  6. pnkfelix commented on Apr 2, 2020

    @pnkfelix
    Contributor

    @rustbot assign @matthewjasper

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

  7. eddyb commented on Apr 2, 2020

    @eddyb
    Contributor

    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.

  8. Centril commented on Apr 2, 2020

    @Centril
    Contributor

    Doesn't reproduce with (added : _):

    const e: _ = & & 39;
    pub fn main(){}
  9. nikomatsakis commented on Apr 2, 2020

    @nikomatsakis
    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?

  10. eddyb commented on Apr 2, 2020

    @eddyb
    Contributor

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

  11. added a commit that references this issue on Apr 2, 2020
    98cf9d9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-lifetimesArea: Lifetimes / regionsC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions