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: Defn conflict #40136

Closed
GuillaumeGomez opened this issue Feb 27, 2017 · 5 comments
Closed

ICE: Defn conflict #40136

GuillaumeGomez opened this issue Feb 27, 2017 · 5 comments
Assignees
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@GuillaumeGomez
Copy link
Member

Rust version:

> ./build/x86_64-apple-darwin/stage1/bin/rustc --version
rustc 1.17.0-dev (5ac7a035a 2017-02-26)

The code:

macro_rules! make {
    ($n:expr) => {
        pub trait T<X> {
            fn ignore(_: &X) {}
            const C: X;
            const D: i32 = ($n * $n);
        }

        impl U<Vec<i32>> for S {
            const C: Vec<i32> = vec![0; $n];
        }
    }
}

make!(4);

Which gives:

error: internal compiler error: unexpected panic

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: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'adding a def'n for node-id NodeId(3) and data Initializer but a previous def'n exists: DefKey { parent: Some(DefIndex(0)), disambiguated_data: DisambiguatedDefPathData { data: TypeNs("std"), disambiguator: 0 } }', src/librustc/hir/map/definitions.rs:335
stack backtrace:
   1:        0x111baabdc - std::sys::imp::backtrace::tracing::imp::write::h2e3ef1dc0e51ba99
   2:        0x111bb763e - std::panicking::default_hook::{{closure}}::haa60669a0a8b43e3
   3:        0x111bb71e3 - std::panicking::default_hook::h0a42e1acc48a315c
   4:        0x111bb7af7 - std::panicking::rust_panic_with_hook::h78a15ea95e294ff1
   5:        0x111bb79a4 - std::panicking::begin_panic::hba8a9f7990fef69b
   6:        0x111bb78c2 - std::panicking::begin_panic_fmt::hc74ec0af4c54fbab
   7:        0x10ebf43bc - rustc::hir::map::definitions::Definitions::create_def_with_parent::hbb102500d73fd9c1
   8:        0x10ebf11f2 - <rustc::hir::map::def_collector::DefCollector<'a> as syntax::visit::Visitor<'a>>::visit_impl_item::h81eb5dc485f72f1c
   9:        0x10eb6bb11 - syntax::visit::walk_item::h1a65815c3ec0cd25
  10:        0x10ebf0c53 - <rustc::hir::map::def_collector::DefCollector<'a> as syntax::visit::Visitor<'a>>::visit_item::{{closure}}::ha54e917d31c5446f
  11:        0x10ebf059c - <rustc::hir::map::def_collector::DefCollector<'a> as syntax::visit::Visitor<'a>>::visit_item::hdd7947b3b5779933
  12:        0x10ea711de - rustc_resolve::macros::<impl syntax::ext::base::Resolver for rustc_resolve::Resolver<'a>>::visit_expansion::h2d197847c9c689f6
  13:        0x111690d6f - syntax::ext::expand::MacroExpander::collect_invocations::hccfea5820a6cd13e
  14:        0x11168dd2b - syntax::ext::expand::MacroExpander::expand::h03bd73f7ebe53885
  15:        0x11168c61f - syntax::ext::expand::MacroExpander::expand_crate::hc1e13e0d2bbc2981
  16:        0x10d7e2881 - rustc_driver::driver::phase_2_configure_and_expand::{{closure}}::h5f58f7c0b9aa3518
  17:        0x10d7d13d0 - rustc_driver::driver::phase_2_configure_and_expand::h403f66a4c4ce608a
  18:        0x10d8a0a34 - rustdoc::core::run_core::h20b285afcad21f3a
  19:        0x10d7f0d02 - std::panicking::try::do_call::hf08ba2b971ea2e3a
  20:        0x111bba70a - __rust_maybe_catch_panic
  21:        0x10d81815a - <F as alloc::boxed::FnBox<A>>::call_box::h4d43130e36f88422
  22:        0x111bb6764 - std::sys::imp::thread::Thread::new::thread_start::h3187989cf33213df
  23:     0x7fffb9824aba - _pthread_body
  24:     0x7fffb9824a06 - _pthread_start
@TimNN
Copy link
Contributor

TimNN commented Feb 28, 2017

A bit minified:

macro_rules! make {
    ($n:expr) => {
        impl Foo for Bar {
            const C: Vec<i32> = vec![0; $n];
        }
    }
}

make!(4);

Also, technically this is a regression from stable to stable (error -> ice).

@TimNN TimNN added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Feb 28, 2017
@frewsxcv frewsxcv added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label Feb 28, 2017
@TimNN TimNN added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Feb 28, 2017
@nikomatsakis
Copy link
Contributor

cc @eddyb -- looks related to in-demand maybe?

@eddyb
Copy link
Member

eddyb commented Mar 2, 2017

I'd think @jseyfried might know something in the macro refactors that can cause this.

@jseyfried
Copy link
Contributor

Further minified:

#![feature(associated_consts)]

macro_rules! m { () => { 0 } }

struct S;
impl S {
    const C: i32 = m!(); // Replacing `m!()` with `0` compiles
}

I suspect this was caused by my macro modularization groundwork (probably one of the "miscellaneous groundwork" PRs from #35896 (comment)) -- I'll investigate ASAP.

@jseyfried
Copy link
Contributor

This was introduced in #36601, fixed in #40272.

bors added a commit that referenced this issue Mar 6, 2017
…chenkov

macros: fix const expression invocations

Fixes #40136.
r? @nrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-stable Performance or correctness regression from one stable version to another. 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

6 participants