Skip to content

ICE: RangeInclusive broken in nightly-2018-05-02? #50415

Closed

Description

@kamyuentse

I tried this code:

fn main() {
    let full_length = 1024;
    let range = {
        // do some stuff, omit here
        None
    };
    
    let range = range.map(|(s, t)| s..=t).unwrap_or(0..=(full_length-1));
    
    println!("{:?}", range);
}

Which expected prints 0..=1023(work fine under beta channel), while, I got ICE:

error: internal compiler error: librustc/hir/map/mod.rs:329: local_def_id: no entry for `25`, which has a map of `Some(EntryTy(NodeId(71), 3, type(::std::ops::RangeInclusive)))`

playground

Activity

  1. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    C-bugCategory: This is a bug.
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on May 3, 2018
  2. added this to the 1.27 milestone on May 3, 2018
  3. emilyalbini commented on May 3, 2018

    @emilyalbini
    Member

    Thanks for reporting this, indeed it works on beta and fails on nightly. Bisected the cause: #49724 cc @kennytm @Kimundi

  4. self-assigned this
    on May 3, 2018
  5. kennytm commented on May 3, 2018

    @kennytm
    Member

    Fully simplified:

    fn main() {
        let _ = || 0..=1;
    }
    -Z unpretty=hir,identified
    #[prelude_import]
    use std::prelude::v1::*; /* node_id: 2 hir local_id: 0 */
    #[macro_use]
    extern crate std; /* node_id: 3 hir local_id: 0 */
    fn main() ({
                   let _ /* pat node_id: 8 hir local_id: 2 */ =
                       (||
                           ((<::std::ops::RangeInclusive>::new /*
                                node_id: 14 hir local_id: 6
                                */)((0 /* node_id: 9 hir local_id: 4 */),
                                    (1 /* node_id: 10 hir local_id: 5 */)) /*
                               node_id: 11 hir local_id: 3
                               */) /* node_id: 12 hir local_id: 7 */);
               } /* block node_id: 6 hir local_id: 9 */ /*
                  node_id: 15 hir local_id: 10 */) /* node_id: 4 hir local_id: 0
    */
    Stack trace
    error: internal compiler error: librustc/hir/map/mod.rs:329: local_def_id: no entry for `11`, which has a map of `Some(EntryTy(NodeId(14), 3, type(::std::ops::RangeInclusive)))`
    
    thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:554:9
    stack backtrace:
       0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
       1: std::sys_common::backtrace::print
       2: std::panicking::default_hook::{{closure}}
       3: std::panicking::default_hook
       4: rustc::util::common::panic_hook
       5: std::panicking::rust_panic_with_hook
       6: std::panicking::begin_panic
       7: rustc_errors::Handler::bug
       8: rustc::session::opt_span_bug_fmt::{{closure}}
       9: rustc::ty::context::tls::with_opt::{{closure}}
      10: rustc::ty::context::tls::with_context_opt
      11: rustc::ty::context::tls::with_opt
      12: rustc::session::opt_span_bug_fmt
      13: rustc::session::bug_fmt
      14: rustc::hir::map::Map::local_def_id::{{closure}}
      15: rustc::hir::map::Map::body_owner_kind
      16: <rustc::middle::region::RegionResolutionVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_body
      17: rustc::middle::region::resolve_expr
      18: rustc::hir::intravisit::walk_stmt
      19: <rustc::middle::region::RegionResolutionVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_stmt
      20: <rustc::middle::region::RegionResolutionVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_block
      21: rustc::middle::region::resolve_expr
      22: <rustc::middle::region::RegionResolutionVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_body
      23: rustc::middle::region::region_scope_tree
      24: rustc::dep_graph::graph::DepGraph::with_task_impl
      25: rustc::ty::context::tls::with_related_context
      26: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
      27: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
      28: rustc_typeck::check::regionck::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::regionck_item
      29: rustc::ty::context::tls::with_related_context
      30: rustc::infer::InferCtxtBuilder::enter
      31: rustc_typeck::check::wfcheck::check_item_well_formed
      32: rustc::dep_graph::graph::DepGraph::with_task_impl
      33: rustc::ty::context::tls::with_related_context
      34: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
      35: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
      36: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::ensure_query
      37: rustc::hir::Crate::visit_all_item_likes
      38: rustc::util::common::time
      39: rustc_typeck::check_crate
      40: rustc::ty::context::tls::enter_context
      41: <std::thread::local::LocalKey<T>>::with
      42: rustc::ty::context::TyCtxt::create_and_enter
      43: rustc_driver::driver::compile_input
      44: rustc_driver::run_compiler_impl
      45: <scoped_tls::ScopedKey<T>>::set
      46: syntax::with_globals
      47: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
      48: __rust_maybe_catch_panic
      49: rustc_driver::run
      50: rustc_driver::main
      51: std::rt::lang_start::{{closure}}
      52: std::panicking::try::do_call
      53: __rust_maybe_catch_panic
      54: std::rt::lang_start_internal
      55: main
    query stack during panic:
    #0 [region_scope_tree] processing `main`
    #1 [check_item_well_formed] processing `main`
    end of query stack
    
  6. assigned and unassigned on May 3, 2018
  7. kennytm commented on May 3, 2018

    @kennytm
    Member

    It seems this fixed it? Is this a correct change?

    diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs
    index 196f787998..64333a8957 100644
    --- a/src/librustc/hir/lowering.rs
    +++ b/src/librustc/hir/lowering.rs
    @@ -3123,7 +3123,7 @@ impl<'a> LoweringContext<'a> {
                 ExprKind::Range(Some(ref e1), Some(ref e2), RangeLimits::Closed) => {
                     // FIXME: Use head_sp directly after RangeInclusive::new() is stabilized in stage0.
                     let span = self.allow_internal_unstable(CompilerDesugaringKind::DotFill, e.span);
    -                let id = self.lower_node_id(e.id);
    +                let id = self.next_id();
                     let e1 = self.lower_expr(e1);
                     let e2 = self.lower_expr(e2);
                     let ty_path = P(self.std_path(span, &["ops", "RangeInclusive"], false));
  8. added a commit that references this issue on May 3, 2018
  9. nikomatsakis commented on May 3, 2018

    @nikomatsakis
    Contributor

    triage: P-high

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

C-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

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions