Skip to content

ICE inside quote_item! when building a syntax extension (adding a block of {...} breaks things) #15268

@killerswan

Description

@killerswan

From here, again: https://github.com/killerswan/ovid/blob/ad2efdabb2eb834ca7a50cbda5806ccd033d6283/CSVProvider.rs

This change...

ovid $ git diff
diff --git a/CSVProvider.rs b/CSVProvider.rs
index 4fa650f..deed5f5 100644
--- a/CSVProvider.rs
+++ b/CSVProvider.rs
@@ -158,9 +158,11 @@ fn provide_csv_given_labels(cx: &mut ExtCtxt, sp: Span, tts: &[Token

    fn define_my_csv(cx0: &mut ExtCtxt) -> Option<Gc<syntax::ast::Item>> {
       let item1: Option<Gc<syntax::ast::Item>>  = quote_item!(cx0,
+       {
          pub struct MyCSV {
             pub data: Vec<(String)>,
          }
+       }
       );
       return item1;
    }

...causes this error:

ovid $ cat build.sh 
#!/bin/sh

rustc CSVProvider.rs \
&& RUST_BACKTRACE=1 rustc --test -L . CSVSample.rs \
&& ./CSVSample \
#&& rustc --test -L . --pretty expanded CSVSample.rs
ovid $ 
ovid $ 
ovid $ ./build.sh 
provide_csv_given_labels: name:   MyCSV
provide_csv_given_labels: path:   ./sample1.txt
provide_csv_given_labels: labels: Verse
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' failed at 'Should be able to construct MyCSV.', /Users/kevin/code/rust/src/libcore/option.rs:246

stack backtrace:
   1:        0x10ec9df15 - rt::backtrace::imp::write::haf310d3bcd19b564mPp::v0.11.0.pre
   2:        0x10eca44b7 - failure::on_fail::hc45df1f86e771253B5p::v0.11.0.pre
   3:        0x10ef578c9 - unwind::begin_unwind_inner::h3b3465087007e9d3VSd::v0.11.0.pre
   4:        0x10ef5737d - unwind::begin_unwind_fmt::h4f93c5d06986f385oQd::v0.11.0.pre
   5:        0x10ef571d1 - rust_begin_unwind
   6:        0x10efa392e - failure::begin_unwind::h719e8df35cbc239aX2v::v0.11.0.pre
   7:        0x1103c1c43 - option::Option<T>::expect::h2580405981230248213::v0.1.pre
   8:        0x1103765b9 - provide_csv_given_labels::ha0300b7498e0c1ec8ea::v0.1.pre
   9:        0x10e554a93 - ext::base::BasicMacroExpander.MacroExpander::expand::h154f68f6a6e6f5a3WuR::v0.11.0.pre
  10:        0x10e583437 - ext::expand::expand_item_mac::hb101d2d66713086aMoS::v0.11.0.pre
  11:        0x10e58047d - ext::expand::expand_item::h4d9519cde48986adRhS::v0.11.0.pre
  12:        0x10e57d9b3 - ext::expand::MacroExpander<'a, 'b>.Folder::fold_item::h1074a02b3c56a71baZS::v0.11.0.pre
  13:        0x10e5894cc - fold::noop_fold_mod::closure.36443
  14:        0x10e58904b - iter::Iterator::collect::h2886547492356325285::v0.11.0.pre
  15:        0x10e58747b - fold::Folder::fold_mod::h13372765266361103463::v0.11.0.pre
  16:        0x10e585204 - fold::noop_fold_item::h4835347241229306232::v0.11.0.pre
  17:        0x10e58039e - ext::expand::expand_item::h4d9519cde48986adRhS::v0.11.0.pre
  18:        0x10e57d9b3 - ext::expand::MacroExpander<'a, 'b>.Folder::fold_item::h1074a02b3c56a71baZS::v0.11.0.pre
  19:        0x10e5a97bc - fold::noop_fold_stmt::h312506400242028249::v0.11.0.pre
  20:        0x10e592090 - ext::expand::expand_non_macro_stmt::he6be1fb8eacd6231dGS::v0.11.0.pre
  21:        0x10e59006a - ext::expand::expand_stmt::h873ade29a19e6467LyS::v0.11.0.pre
  22:        0x10e5b2403 - ext::expand::expand_block_elts::closure.36942
  23:        0x10e57f33c - ext::expand::expand_block_elts::h127b1d2eb496eb44kOS::v0.11.0.pre
  24:        0x10e579e1c - ext::expand::MacroExpander<'a, 'b>.Folder::fold_block::h55de8bcdc64621e3PZS::v0.11.0.pre
  25:        0x10e58514e - fold::noop_fold_item::h4835347241229306232::v0.11.0.pre
  26:        0x10e580621 - ext::expand::expand_item::h4d9519cde48986adRhS::v0.11.0.pre
  27:        0x10e57d9b3 - ext::expand::MacroExpander<'a, 'b>.Folder::fold_item::h1074a02b3c56a71baZS::v0.11.0.pre
  28:        0x10e5894cc - fold::noop_fold_mod::closure.36443
  29:        0x10e58904b - iter::Iterator::collect::h2886547492356325285::v0.11.0.pre
  30:        0x10e58747b - fold::Folder::fold_mod::h13372765266361103463::v0.11.0.pre
  31:        0x10e5b7a1b - ext::expand::expand_crate::h25aa9100b57efc54W0S::v0.11.0.pre
  32:        0x10c5d5ea4 - driver::driver::phase_2_configure_and_expand::closure.114250
  33:        0x10c07ed36 - driver::driver::phase_2_configure_and_expand::h7689d645fa58c25di0p::v0.11.0.pre
  34:        0x10c57c58d - driver::driver::compile_input::hc0c03ab596166c0f0Tp::v0.11.0.pre
  35:        0x10c643bdb - driver::run_compiler::h76f7d2d37cdffc51ZDs::v0.11.0.pre
  36:        0x10c6413f6 - driver::main_args::closure.117268
  37:        0x10c655a7b - task::TaskBuilder<S>::try_future::closure.118406
  38:        0x10c655914 - task::TaskBuilder<S>::spawn_internal::closure.118383
  39:        0x10bc4fd2c - task::spawn_opts::closure.7597
  40:        0x10efbce4c - rust_try
  41:        0x10ef53d6a - unwind::try::hc87b0c05dd7c713akHd::v0.11.0.pre
  42:        0x10ef53a6c - task::Task::run::hcd249873983c9e78cTc::v0.11.0.pre
  43:        0x10bc4fbbb - task::spawn_opts::closure.7542
  44:        0x10ef565d9 - thread::thread_start::h131e955cf3141f2fKfd::v0.11.0.pre
  45:     0x7fff98ec3899 - _pthread_body
  46:     0x7fff98ec372a - _pthread_struct_init

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions