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

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

Closed
kamyuentse opened this issue May 3, 2018 · 4 comments
Closed

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

kamyuentse opened this issue May 3, 2018 · 4 comments
Assignees
Labels
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.
Milestone

Comments

@kamyuentse
Copy link

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

@pietroalbini pietroalbini added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 3, 2018
@pietroalbini pietroalbini added this to the 1.27 milestone May 3, 2018
@pietroalbini
Copy link
Member

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

@kennytm kennytm self-assigned this May 3, 2018
@kennytm
Copy link
Member

kennytm commented May 3, 2018

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

@kennytm kennytm assigned kennytm and unassigned kennytm May 3, 2018
@kennytm
Copy link
Member

kennytm commented May 3, 2018

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));

kennytm added a commit to kennytm/rust that referenced this issue May 3, 2018
@nikomatsakis
Copy link
Contributor

triage: P-high

@nikomatsakis nikomatsakis added P-high High priority and removed I-nominated labels May 3, 2018
kennytm added a commit to kennytm/rust that referenced this issue May 3, 2018
…g-range-inclusive-from-closure, r=michaelwoerister

Fix ICE when using a..=b in a closure.

Fix rust-lang#50415.
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. 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

No branches or pull requests

4 participants