Skip to content

Associated types: ICE "get_unique_type_id_of_type() - unexpected type" #20797

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

Closed
kinghajj opened this issue Jan 9, 2015 · 30 comments · Fixed by #20960
Closed

Associated types: ICE "get_unique_type_id_of_type() - unexpected type" #20797

kinghajj opened this issue Jan 9, 2015 · 30 comments · Fixed by #20960
Labels
A-associated-items Area: Associated items (types, constants & functions) A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@kinghajj
Copy link

kinghajj commented Jan 9, 2015

I thought that my example in #20368 was sufficient to cover one of my desired uses of associated types, but, while that example does now successfully compile, the module I really wanted to improve still fails with yet another ICE. Here's the module in full:

    use std::default::Default;
    use std::io::IoResult;
    use std::io::fs;
    use std::io::fs::PathExtensions;

    /// A strategy for acquiring more subpaths to walk.
    pub trait Strategy {
      type P: PathExtensions;
      /// Get additional subpaths from a given path.
      fn get_more(&self, item: &Self::P) -> IoResult<Vec<Self::P>>;
      /// Determine whether a path should be walked further.
      /// This is run against each item from `get_more()`.
      fn prune(&self, p: &Self::P) -> bool;
    }

    /// The basic fully-recursive strategy. Nothing is pruned.
    #[derive(Copy, Default)]
    pub struct Recursive;

    impl Strategy for Recursive {
      type P = Path;
      fn get_more(&self, p: &Path) -> IoResult<Vec<Path>> { fs::readdir(p) }

      fn prune(&self, _: &Path) -> bool { false }
    }

    /// A directory walker of `P` using strategy `S`.
    pub struct Subpaths<S: Strategy> {
        stack: Vec<S::P>,
        strategy: S,
    }

    impl<S: Strategy> Subpaths<S> {
      /// Create a directory walker with a root path and strategy.
      pub fn new(p: &S::P, strategy: S) -> IoResult<Subpaths<S>> {
        let stack = try!(strategy.get_more(p));
        Ok(Subpaths { stack: stack, strategy: strategy })
      }
    }

    impl<S: Default + Strategy> Subpaths<S> {
      /// Create a directory walker with a root path and a default strategy.
      pub fn walk(p: &S::P) -> IoResult<Subpaths<S>> {
          Subpaths::new(p, Default::default())
      }
    }

    impl<S: Default + Strategy> Default for Subpaths<S> {
      fn default() -> Subpaths<S> {
        Subpaths { stack: Vec::new(), strategy: Default::default() }
      }
    }

    impl<S: Strategy> Iterator for Subpaths<S> {
      type Item = S::P;
      fn next (&mut self) -> Option<S::P> {
        let mut opt_path = self.stack.pop();
        while opt_path.is_some() && self.strategy.prune(opt_path.as_ref().unwrap()) {
          opt_path = self.stack.pop();
        }
        match opt_path {
          Some(path) => {
            if PathExtensions::is_dir(&path) {
              let result = self.strategy.get_more(&path);
              match result {
                Ok(dirs) => { self.stack.extend(dirs.into_iter()); },
                Err(..) => { }
              }
            }
            Some(path)
          }
          None => None,
        }
      }
    }

    #[test]
    fn woot() {
      let mut walker: Subpaths<Recursive> = Subpaths::walk(&Path::new("/home")).unwrap();
    }

Here's the error and backtrace:

error: internal compiler error: get_unique_type_id_of_type() - unexpected type: <Recursive as Strategy>::P, ty_projection(ProjectionTy { trait_ref: Rc(TraitRef { def_id: DefId { krate: 0u32, node: 8u32 }, substs: Substs { types: VecPerParamSpace {TypeSpace: [], SelfSpace: [TyS { sty: ty_struct(DefId { krate: 0u32, node: 40u32 }, Substs { types: VecPerParamSpace {TypeSpace: [], SelfSpace: [], FnSpace: [], }, regions: ErasedRegions }), flags: 0, region_depth: 0u32 }], FnSpace: [], }, regions: NonerasedRegions(VecPerParamSpace {TypeSpace: [], SelfSpace: [], FnSpace: [], }) } }), item_name: "P"(73) })
note: the compiler unexpectedly panicked. 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
thread 'rustc' panicked at 'Box<Any>', /home/samuel/rust/src/libsyntax/diagnostic.rs:182

stack backtrace:
   1:     0x7f4a265a0570 - sys::backtrace::write::h3452feb04e320bcfCzt
   2:     0x7f4a265c2780 - failure::on_fail::hd0efae8686875716aPz
   3:     0x7f4a26530300 - rt::unwind::begin_unwind_inner::h229232f5734654792tz
   4:     0x7f4a214ada20 - rt::unwind::begin_unwind::h9438643137198476843
   5:     0x7f4a214ae2d0 - diagnostic::Handler::bug::he657a4296d705a33tWF
   6:     0x7f4a2488f180 - session::Session::bug::ha8836431c543757ciRq
   7:     0x7f4a25673ba0 - trans::debuginfo::TypeMap<'tcx>::get_unique_type_id_of_type::h606c89215412cd5brGD
   8:     0x7f4a256778d0 - trans::debuginfo::TypeMap<'tcx>::get_unique_type_id_of_type::from_def_id_and_substs::h9fa1f90635ed12d03PD
   9:     0x7f4a25673ba0 - trans::debuginfo::TypeMap<'tcx>::get_unique_type_id_of_type::h606c89215412cd5brGD
  10:     0x7f4a25679e30 - trans::debuginfo::type_metadata::h7557684678d0dd25RSF
  11:     0x7f4a25682220 - trans::debuginfo::StructMemberDescriptionFactory<'tcx>::create_member_descriptions::unboxed_closure.45598
  12:     0x7f4a25681e00 - vec::Vec<T>.FromIterator<T>::from_iter::h9648212210143919248
  13:     0x7f4a2567dda0 - trans::debuginfo::StructMemberDescriptionFactory<'tcx>::create_member_descriptions::hf79fdc4d3167c5d0j9E
  14:     0x7f4a25680980 - trans::debuginfo::RecursiveTypeDescription<'tcx>::finalize::h0ff9cf1ab1bdbcef26E
  15:     0x7f4a25679e30 - trans::debuginfo::type_metadata::h7557684678d0dd25RSF
  16:     0x7f4a25684fd0 - trans::debuginfo::VariantMemberDescriptionFactory<'tcx>::create_member_descriptions::unboxed_closure.45632
  17:     0x7f4a25684be0 - vec::Vec<T>.FromIterator<T>::from_iter::h5453357870208096995
  18:     0x7f4a25683270 - trans::debuginfo::EnumMemberDescriptionFactory<'tcx>::create_member_descriptions::unboxed_closure.45606
  19:     0x7f4a25682e50 - vec::Vec<T>.FromIterator<T>::from_iter::h13188062602912948975
  20:     0x7f4a2567de90 - trans::debuginfo::EnumMemberDescriptionFactory<'tcx>::create_member_descriptions::h1355d0387a727939hgF
  21:     0x7f4a25680980 - trans::debuginfo::RecursiveTypeDescription<'tcx>::finalize::h0ff9cf1ab1bdbcef26E
  22:     0x7f4a25679e30 - trans::debuginfo::type_metadata::h7557684678d0dd25RSF
  23:     0x7f4a25688070 - trans::debuginfo::subroutine_type_metadata::haec4c13f9a5d7a59vOF
  24:     0x7f4a25679e30 - trans::debuginfo::type_metadata::h7557684678d0dd25RSF
  25:     0x7f4a25620ae0 - trans::debuginfo::create_function_debug_context::h985b11ad61da52fdwsE
  26:     0x7f4a25580890 - trans::base::new_fn_ctxt::hbe79965b1049ecf2Zxt
  27:     0x7f4a25626410 - trans::base::trans_closure::h5c0a7253f08a6c1bEYt
  28:     0x7f4a255452b0 - trans::base::trans_fn::h84cc11dd50b05f50j9t
  29:     0x7f4a25545710 - trans::monomorphize::monomorphic_fn::h44708ba9400c75dbFpd
  30:     0x7f4a25597ff0 - trans::callee::trans_fn_ref_with_substs::h1741ea29b53c270fGxg
  31:     0x7f4a25596590 - trans::callee::trans_fn_ref::h611f01f0cbdf2e42Rlg
  32:     0x7f4a25593870 - trans::callee::trans::h2d6fbfb713fd152ayag
  33:     0x7f4a2559da90 - trans::callee::trans_call_inner::h893956557312987459
  34:     0x7f4a255a34b0 - trans::expr::trans_rvalue_dps_unadjusted::h4ab35d4af002299e1Si
  35:     0x7f4a255a2790 - trans::expr::trans_unadjusted::h15f19eba475549d3Oji
  36:     0x7f4a2555b000 - trans::expr::trans::ha962b869e642f0b8eCh
  37:     0x7f4a2556c0b0 - trans::callee::trans_args::h2dbfd3d1c7128174xch
  38:     0x7f4a2559f460 - trans::callee::trans_call_inner::h11730372111330536098
  39:     0x7f4a255a34b0 - trans::expr::trans_rvalue_dps_unadjusted::h4ab35d4af002299e1Si
  40:     0x7f4a25559d90 - trans::expr::trans_into::h70023b40e1df277dKyh
  41:     0x7f4a2565e030 - trans::_match::mk_binding_alloca::h14708251032129145358
  42:     0x7f4a25559390 - trans::base::init_local::h17113ff3a822f41bC7s
  43:     0x7f4a2555a3e0 - trans::controlflow::trans_block::hd4046f45161d1f00B3d
  44:     0x7f4a25626410 - trans::base::trans_closure::h5c0a7253f08a6c1bEYt
  45:     0x7f4a255452b0 - trans::base::trans_fn::h84cc11dd50b05f50j9t
  46:     0x7f4a25540840 - trans::base::trans_item::h560b1558a6cec5e6Ewu
  47:     0x7f4a2562dc30 - trans::base::trans_crate::heb94c899d24982b8lsv
  48:     0x7f4a26b09fa0 - driver::phase_4_translate_to_llvm::h4be77ff61772864dPFa
  49:     0x7f4a26ae3f30 - driver::compile_input::hefa96b3bea08e00bxba
  50:     0x7f4a26bb3bc0 - monitor::unboxed_closure.22498
  51:     0x7f4a26bb3a20 - thunk::F.Invoke<A, R>::invoke::h2604081160332846052
  52:     0x7f4a26bb27a0 - rt::unwind::try::try_fn::h10712615664574212328
  53:     0x7f4a26630f00 - rust_try_inner
  54:     0x7f4a26630ef0 - rust_try
  55:     0x7f4a26bb2a90 - thunk::F.Invoke<A, R>::invoke::h6088602545528080049
  56:     0x7f4a265b0630 - sys::thread::thread_start::h803dac673dcdb1abqrw
  57:     0x7f4a20cc7250 - start_thread
  58:     0x7f4a261e0219 - clone
  59:                0x0 - <unknown>

Could not compile `subpaths`.
@kmcallister kmcallister added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jan 9, 2015
@erickt
Copy link
Contributor

erickt commented Jan 11, 2015

I just ran into this as well with a smaller example:

struct Peekable<I> where I: Iterator {
    _iter: I,
    _next: Option<<I as Iterator>::Item>,
}

fn main() {
    let mut iter = Vec::<i32>::new().into_iter();
    let next = iter.next();
    let _v = Peekable {
        _iter: iter,
        _next : next,
    };
}

With this error:

error: internal compiler error: get_unique_type_id_of_type() - unexpected type: <collections::vec::IntoIter<i32> as core::iter::Iterator>::Item, ty_projection(ProjectionTy { trait_ref: Rc(TraitRef { def_id: DefId { krate: 2u32, node: 42866u32 }, substs: Substs { types: VecPerParamSpace {TypeSpace: [], SelfSpace: [TyS { sty: ty_struct(DefId { krate: 3u32, node: 36733u32 }, Substs { types: VecPerParamSpace {TypeSpace: [TyS { sty: ty_int(i32), flags: 0, region_depth: 0u32 }], SelfSpace: [], FnSpace: [], }, regions: ErasedRegions }), flags: 0, region_depth: 0u32 }], FnSpace: [], }, regions: NonerasedRegions(VecPerParamSpace {TypeSpace: [], SelfSpace: [], FnSpace: [], }) } }), item_name: "Item"(67) })
note: the compiler unexpectedly panicked. 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
thread 'rustc' panicked at 'Box<Any>', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/libsyntax/diagnostic.rs:182

stack backtrace:
   1:        0x1113f24b5 - sys::backtrace::write::h64ca2fb259c4ae97lCt
   2:        0x11141494f - failure::on_fail::h64ff5ae6887860cc0Hz
   3:        0x1113805ca - rt::unwind::begin_unwind_inner::h1d4bc098fd350446Qpz
   4:        0x10f0880b7 - rt::unwind::begin_unwind::h1123425023578864118
   5:        0x10f088a28 - diagnostic::Handler::bug::h6d2bfe842975d6e0tWF
   6:        0x10e68c788 - session::Session::bug::h5da8d79b0a6f5276iRq
   7:        0x10deb5805 - trans::debuginfo::TypeMap<'tcx>::get_unique_type_id_of_type::hf00d365d13fe5f42rGD
   8:        0x10deb9557 - trans::debuginfo::TypeMap<'tcx>::get_unique_type_id_of_type::from_def_id_and_substs::h891ec143e99916f43PD
   9:        0x10deb5705 - trans::debuginfo::TypeMap<'tcx>::get_unique_type_id_of_type::hf00d365d13fe5f42rGD
  10:        0x10debb7cb - trans::debuginfo::type_metadata::h9edd372a193ff094RSF
  11:        0x10dec3cf5 - trans::debuginfo::StructMemberDescriptionFactory<'tcx>::create_member_descriptions::unboxed_closure.45659
  12:        0x10dec37b2 - vec::Vec<T>.FromIterator<T>::from_iter::h4078323428656498456
  13:        0x10debf54d - trans::debuginfo::StructMemberDescriptionFactory<'tcx>::create_member_descriptions::he532502aebbbff41j9E
  14:        0x10dec23e2 - trans::debuginfo::RecursiveTypeDescription<'tcx>::finalize::h4e94b4649bcaa46e26E
  15:        0x10debc539 - trans::debuginfo::type_metadata::h9edd372a193ff094RSF
  16:        0x10debdad2 - trans::debuginfo::declare_local::h82cfc8c7fa3e6298CPE
  17:        0x10debd32d - ast_util::walk_pat::walk_pat_::h14410195268450947789
  18:        0x10dda22a7 - trans::controlflow::trans_block::h1b3762e019b88de7B3d
  19:        0x10de6ba39 - trans::base::trans_closure::h83147acece2ec0c6EYt
  20:        0x10dd8d5f5 - trans::base::trans_fn::h99bd3c17ad60972dj9t
  21:        0x10dd88d4e - trans::base::trans_item::hdbddd5abd5742b0cEwu
  22:        0x10de7202c - trans::base::trans_crate::h6077c32a4f7ba4e9lsv
  23:        0x10dc2eb3e - driver::phase_4_translate_to_llvm::ha92297f2357a645fPFa
  24:        0x10dc0af4b - driver::compile_input::h31580cbd7ea87613xba
  25:        0x10dcd5fda - monitor::unboxed_closure.22557
  26:        0x10dcd4735 - thunk::F.Invoke<A, R>::invoke::h6367419564961841226
  27:        0x10dcd3510 - rt::unwind::try::try_fn::h7763956589852599824
  28:        0x11147b2a9 - rust_try_inner
  29:        0x11147b296 - rust_try
  30:        0x10dcd3c0c - thunk::F.Invoke<A, R>::invoke::h16724184168577887652
  31:        0x111402154 - sys::thread::thread_start::hbd8f2f8bdd3a3baadrw
  32:     0x7fff9358c2fc - _pthread_body
  33:     0x7fff9358c279 - _pthread_body

@nikomatsakis nikomatsakis added the A-associated-items Area: Associated items (types, constants & functions) label Jan 11, 2015
erickt added a commit to erickt/rust that referenced this issue Jan 12, 2015
@michaelwoerister michaelwoerister added the A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) label Jan 12, 2015
bors added a commit that referenced this issue Jan 13, 2015
@kinghajj
Copy link
Author

bors should not have closed this issue, as I mentioned in #20960, my original example still causes an ICE even after that pull request was merged.

@jdm jdm reopened this Jan 13, 2015
@nikomatsakis
Copy link
Contributor

@kinghajj can you retest on the latest master? It seems to work for me, I suspect because of #20955

@kinghajj
Copy link
Author

No luck yet.

bash-3.2$ rustc -V
rustc 1.0.0-dev (170c4399e 2015-01-14 00:41:55 +0000)
bash-3.2$ RUST_BACKTRACE=1 cargo test
   Compiling subpaths v0.0.1 (file:///Users/samuel/Documents/Programming/filehash/src/subpaths)
error: internal compiler error: type_of with ty_projection
note: the compiler unexpectedly panicked. 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
thread 'rustc' panicked at 'Box<Any>', /Users/samuel/Documents/rust/src/libsyntax/diagnostic.rs:182

stack backtrace:
   1:        0x110640dec - sys::backtrace::write::h724c84ec96e82337RUt
   2:        0x110662a8f - failure::on_fail::h6f2a6126417d36beIYz
   3:        0x1105cf74e - rt::unwind::begin_unwind_inner::hb2d99935a1d8bde1yGz
   4:        0x10e30ac4f - rt::unwind::begin_unwind::h6101901676675217320
   5:        0x10e30b5bb - diagnostic::Handler::bug::ha27a4766170cb062A1F
   6:        0x10d8e1670 - metadata::tydecode::parse_existential_bounds_::h10742984024508526701
   7:        0x10d022c88 - trans::type_of::type_of::h6ebeadb230102bb3Y1o
   8:        0x10d023225 - trans::type_of::type_of::h6ebeadb230102bb3Y1o
   9:        0x10d022190 - trans::type_of::type_of::h6ebeadb230102bb3Y1o
  10:        0x10d13929c - trans::debuginfo::StructMemberDescriptionFactory<'tcx>::create_member_descriptions::unboxed_closure.45482
  11:        0x10d138e82 - vec::Vec<T>.FromIterator<T>::from_iter::h1395047669026947608
  12:        0x10d1358bd - trans::debuginfo::StructMemberDescriptionFactory<'tcx>::create_member_descriptions::h153e84111a2448b60fF
  13:        0x10d137b0d - trans::debuginfo::RecursiveTypeDescription<'tcx>::finalize::h0a20b015282159ecJdF
  14:        0x10d1327a3 - trans::debuginfo::type_metadata::h594d4c508338d95dyZF
  15:        0x10d1392d4 - trans::debuginfo::StructMemberDescriptionFactory<'tcx>::create_member_descriptions::unboxed_closure.45482
  16:        0x10d138e82 - vec::Vec<T>.FromIterator<T>::from_iter::h1395047669026947608
  17:        0x10d1358bd - trans::debuginfo::StructMemberDescriptionFactory<'tcx>::create_member_descriptions::h153e84111a2448b60fF
  18:        0x10d137b0d - trans::debuginfo::RecursiveTypeDescription<'tcx>::finalize::h0a20b015282159ecJdF
  19:        0x10d1327a3 - trans::debuginfo::type_metadata::h594d4c508338d95dyZF
  20:        0x10d1392d4 - trans::debuginfo::StructMemberDescriptionFactory<'tcx>::create_member_descriptions::unboxed_closure.45482
  21:        0x10d138e82 - vec::Vec<T>.FromIterator<T>::from_iter::h1395047669026947608
  22:        0x10d1358bd - trans::debuginfo::StructMemberDescriptionFactory<'tcx>::create_member_descriptions::h153e84111a2448b60fF
  23:        0x10d137b0d - trans::debuginfo::RecursiveTypeDescription<'tcx>::finalize::h0a20b015282159ecJdF
  24:        0x10d1327a3 - trans::debuginfo::type_metadata::h594d4c508338d95dyZF
  25:        0x10d13bc32 - trans::debuginfo::VariantMemberDescriptionFactory<'tcx>::create_member_descriptions::unboxed_closure.45516
  26:        0x10d13b7f2 - vec::Vec<T>.FromIterator<T>::from_iter::h5500603777858505790
  27:        0x10d13a28b - trans::debuginfo::EnumMemberDescriptionFactory<'tcx>::create_member_descriptions::unboxed_closure.45490
  28:        0x10d139da2 - vec::Vec<T>.FromIterator<T>::from_iter::h14361925877225366780
  29:        0x10d135b83 - trans::debuginfo::EnumMemberDescriptionFactory<'tcx>::create_member_descriptions::hdd1b6f55c4c7b16eYmF
  30:        0x10d137b2b - trans::debuginfo::RecursiveTypeDescription<'tcx>::finalize::h0a20b015282159ecJdF
  31:        0x10d131bf9 - trans::debuginfo::type_metadata::h594d4c508338d95dyZF
  32:        0x10d13eca8 - trans::debuginfo::subroutine_type_metadata::h9bff0740736a5de7cVF
  33:        0x10d13262f - trans::debuginfo::type_metadata::h594d4c508338d95dyZF
  34:        0x10d0dba0b - trans::debuginfo::create_function_debug_context::h447bd3a847c41d0adzE
  35:        0x10d03fb3e - trans::base::new_fn_ctxt::h80d01085022bea25Tzt
  36:        0x10d0e04cd - trans::base::trans_closure::h32d8ee0946ac5386y0t
  37:        0x10d006197 - trans::base::trans_fn::ha19d856a27ef8fdadbu
  38:        0x10d007d13 - trans::monomorphize::monomorphic_fn::he3114699339f1503Fpd
  39:        0x10d0578e9 - trans::callee::trans_fn_ref_with_substs::h8ab7a417361225b5Ixg
  40:        0x10d0553e3 - trans::callee::trans_fn_ref::haab38ef68aad01e0Tlg
  41:        0x10d052edc - trans::callee::trans::h30cee5a1ce99c1e8Aag
  42:        0x10d05bbee - trans::callee::trans_call_inner::h17375577365636780878
  43:        0x10d062823 - trans::expr::trans_rvalue_dps_unadjusted::h698caf6d437867f53Si
  44:        0x10d06026a - trans::expr::trans_unadjusted::h527db00c397125ebQji
  45:        0x10d01af76 - trans::expr::trans::he91bdea9edc285d3gCh
  46:        0x10d02bda1 - trans::callee::trans_args::h5d1792d9a12db34czch
  47:        0x10d05e00e - trans::callee::trans_call_inner::h15873392703759300422
  48:        0x10d061296 - trans::expr::trans_rvalue_dps_unadjusted::h698caf6d437867f53Si
  49:        0x10d019f6b - trans::expr::trans_into::hd03a9a170d995fabMyh
  50:        0x10d115669 - trans::_match::mk_binding_alloca::h5771621100645690575
  51:        0x10d019564 - trans::base::init_local::ha40ddf9a1cd925e6w9s
  52:        0x10d01a826 - trans::controlflow::trans_block::h382e5b424a79fcedC3d
  53:        0x10d0e290c - trans::base::trans_closure::h32d8ee0946ac5386y0t
  54:        0x10d006197 - trans::base::trans_fn::ha19d856a27ef8fdadbu
  55:        0x10d00183b - trans::base::trans_item::h5af943f055925df9yyu
  56:        0x10d0e8a8c - trans::base::trans_crate::h1ae727bd77425dc1fuv
  57:        0x10ceb5d74 - driver::phase_4_translate_to_llvm::h5abdfc397f265750YMa
  58:        0x10ce97a36 - driver::compile_input::hb8b4e569f22b04afAba
  59:        0x10cf54c40 - run_compiler::hfcb743c274cb2b48e5b
  60:        0x10cf51fe3 - thunk::F.Invoke<A, R>::invoke::h5297055281723610762
  61:        0x10cf50e48 - rt::unwind::try::try_fn::h6169901515804371881
  62:        0x1106cf149 - rust_try_inner
  63:        0x1106cf136 - rust_try
  64:        0x10cf51486 - thunk::F.Invoke<A, R>::invoke::h14156849340732247684
  65:        0x110650162 - sys::thread::thread_start::hd3418b70b5ddcf22IJw
  66:     0x7fff8d7932fc - _pthread_body
  67:     0x7fff8d793279 - _pthread_body

Could not compile `subpaths`.

@michaelwoerister
Copy link
Member

I'll take a closer look at this asap.

@erickt
Copy link
Contributor

erickt commented Jan 14, 2015

@nikomatsakis / @michaelwoerister: I just ran into this other error as well. Here's my reduced test case:

trait DeclaredTrait {
    type Type;
}
impl DeclaredTrait for i32 {
    type Type = i32;
}
struct Struct<B: DeclaredTrait> {
    b: B,
    b1: B::Type,
}
fn main() {
    let e = Struct {
        b: 0,
        b1: 0,
    };
}

Errors with:

% rustc --version
rustc 1.0.0-nightly (3d0d9bb6f 2015-01-12 22:56:20 +0000)
% rustc -g bad.rs
bad.rs:8:5: 8:10 warning: struct field is never used: `b`, #[warn(dead_code)] on by default
bad.rs:8     b : B,
             ^~~~~
bad.rs:9:5: 9:17 warning: struct field is never used: `b1`, #[warn(dead_code)] on by default
bad.rs:9     b1 : B::Type,
             ^~~~~~~~~~~~
bad.rs:12:9: 12:10 warning: unused variable: `e`, #[warn(unused_variables)] on by default
bad.rs:12     let e = Struct {
                  ^
error: internal compiler error: type_of with ty_projection
note: the compiler unexpectedly panicked. 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
thread 'rustc' panicked at 'Box<Any>', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/libsyntax/diagnostic.rs:182

stack backtrace:
   1:        0x105ca1a2c - sys::backtrace::write::h27c3ddb426dd9587RUt
   2:        0x105cc3a4f - failure::on_fail::h63fb027d8b3cc19ca1z
   3:        0x105c302de - rt::unwind::begin_unwind_inner::hafe5720113b93d950Iz
   4:        0x10394cdcf - rt::unwind::begin_unwind::h11195957873796278085
   5:        0x10394d73b - diagnostic::Handler::bug::h8c0937a4743d025ctWF
   6:        0x102f4bce0 - metadata::tydecode::parse_existential_bounds_::h1282082665815765083
   7:        0x10268be98 - trans::type_of::type_of::h77cc5a392ec4c7efX1o
   8:        0x10268b3a0 - trans::type_of::type_of::h77cc5a392ec4c7efX1o
   9:        0x1027a391c - trans::debuginfo::StructMemberDescriptionFactory<'tcx>::create_member_descriptions::unboxed_closure.45662
  10:        0x1027a3502 - vec::Vec<T>.FromIterator<T>::from_iter::h6250772183958048706
  11:        0x10279f68d - trans::debuginfo::StructMemberDescriptionFactory<'tcx>::create_member_descriptions::hf67e5668f84ac65cZeF
  12:        0x1027a218d - trans::debuginfo::RecursiveTypeDescription<'tcx>::finalize::h0585555c78b3f769IcF
  13:        0x10279c5b3 - trans::debuginfo::type_metadata::h08ada392314e61a8xYF
  14:        0x10279dc77 - trans::debuginfo::declare_local::hcf0a2c0d72819844iVE
  15:        0x10279d4d3 - ast_util::walk_pat::walk_pat_::h4796394502832644510
  16:        0x102683aef - trans::controlflow::trans_block::h9179bd0e311bbf71B3d
  17:        0x10274d0ac - trans::base::trans_closure::h0a187eeead3ee5f9E0t
  18:        0x10266f387 - trans::base::trans_fn::h5f00e8761486c618jbu
  19:        0x10266a9cb - trans::base::trans_item::hb876c423cf52a967Eyu
  20:        0x10275322c - trans::base::trans_crate::hd8e597ceb97fa3f8luv
  21:        0x102516c44 - driver::phase_4_translate_to_llvm::hf1a267085ea57e05YMa
  22:        0x1024f3a91 - driver::compile_input::ha4f10a5f4de94c11Aba
  23:        0x1025bb380 - run_compiler::h0e39ba09c41b0c3de5b
  24:        0x1025b8723 - thunk::F.Invoke<A, R>::invoke::h7667196022708996715
  25:        0x1025b7588 - rt::unwind::try::try_fn::h602527677678223085
  26:        0x105d2d8e9 - rust_try_inner
  27:        0x105d2d8d6 - rust_try
  28:        0x1025b7bc6 - thunk::F.Invoke<A, R>::invoke::h5116215899158159820
  29:        0x105cb1232 - sys::thread::thread_start::hd67e9dc06fcd0bebIJw
  30:     0x7fff9358c2fc - _pthread_body
  31:     0x7fff9358c279 - _pthread_body

@michaelwoerister
Copy link
Member

@nikomatsakis Is it expected behaviour that there are still ty_projection instances around in trans or should they all have been normalized away?

If ty_projection still does occur in trans then the debuginfo-related part of this issue should be easy to fix. If not then debuginfo is just the first piece of code to run into this error.

@erickt
Copy link
Contributor

erickt commented Jan 14, 2015

@michaelwoerister: not sure if you've talked to @nikomatsakis outside of github, but he told me yesterday that ty_projections should be normalized away before it gets to debuginfo. So even though my "fix" in #20960 got things to compile, it wasn't actually the right way to fix this problem.

@michaelwoerister
Copy link
Member

@erickt That answers my question then :) Anyway, I've thought about your fix a bit more and it isn't quite correct. It should always be the actual (i.e. normalized) type that goes into the unique type id. Once the associated types bugs are weeded out, I'll change the implementation there and make it ICE again when a ty_projection variant is encountered.

@erickt
Copy link
Contributor

erickt commented Jan 14, 2015

@michaelwoerister: chatting with @nikomatsakis just now in IRC and he says he believes he has already fixed it in his #20797 PR.

@nikomatsakis
Copy link
Contributor

Note that the original example as well as @erickt's example compiles for me when this PR is included: #21107

@nikomatsakis
Copy link
Contributor

er, what @erickt said :)

@michaelwoerister
Copy link
Member

All the better then :)

@kinghajj
Copy link
Author

@nikomatsakis, I just tried my example with master@865e61c7 merged with your assoc-type-ice-hunt-take-1@2479dfcb, and still get an ICE.

@nikomatsakis
Copy link
Contributor

@kinghajj not sure what to say, it certainly works for me.

@nikomatsakis
Copy link
Contributor

(Using a slightly modified version of ee2bfae)

@bluss
Copy link
Member

bluss commented Jan 16, 2015

@kinghajj Using rustc 1.0.0-dev (ee2bfae 2015-01-16 13:10:59 +0000), your testcase does compile and the test passes. Compiled using rustc --test testcase.rs.

@kinghajj
Copy link
Author

I've started building the latest rustc master, I'll get back when I can with my result. I'm sure you guys are right, though, and thanks for all your support!

@kinghajj
Copy link
Author

I was about to give some bad news, but bluss's command gave me an insight. I'm using rustc 1.0.0-dev (ed530d7 2015-01-16 22:41:16 +0000), and while rustc --test lib.rs does indeed work, cargo test still produces that error! I'm on cargo 0.0.1-pre-nightly (85b58e3 2015-01-13 22:14:44 +0000), for reference.

@cuviper
Copy link
Member

cuviper commented Jan 17, 2015

Add -g to include debuginfo, as cargo would. I can reproduce the ICE with -g, and indeed it's fine without.

@bluss
Copy link
Member

bluss commented Jan 17, 2015

@kinghajj We don't have your cargo project, so we can't try reproduce.

@ruuda
Copy link
Contributor

ruuda commented Jan 17, 2015

I ran into an ICE which looks like #21292, so I am posting the details here.

rustc --version --verbose:

rustc 1.0.0-nightly (8903c21d6 2015-01-15 22:42:58 +0000)
binary: rustc
commit-hash: 8903c21d618fd25dca61d9bb668c5299d21feac9
commit-date: 2015-01-15 22:42:58 +0000
host: x86_64-pc-windows-gnu
release: 1.0.0-nightly

Backtrace:

error: internal compiler error: type_of with ty_projection
note: the compiler unexpectedly panicked. 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
thread 'rustc' panicked at 'Box<Any>', C:\bot\slave\nightly-dist-rustc-win-64\build\src\libsyntax\diagnostic.rs:182

stack backtrace:
   1:         0x69beba0b - sys::backtrace::write::h2c4bbe6a26c9ec2cw9t
   2:         0x69bff0a3 - rt::unwind::register::hcae04167a6124eaaeTz
   3:         0x69b8363f - rt::unwind::begin_unwind_inner::h08078ef443debc4eNQz
   4:         0x6f89baec - diagnostic::SpanHandler::span_bug::h1e8e97aea6f54bd6M0F
   5:         0x6f89c421 - diagnostic::Handler::bug::h60d532eb9dd277d9S6F
   6:           0x711f59 - session::Session::bug::h046df32b27f83592cbr
   7:           0xfb9d68 - trans::cleanup::FunctionContext<'blk, 'tcx>.CleanupMethods<'blk, 'tcx>::push_custom_cleanup_scope::h464d2d3abcefaeb9VWK
   8:           0xfba2ba - trans::cleanup::FunctionContext<'blk, 'tcx>.CleanupMethods<'blk, 'tcx>::push_custom_cleanup_scope::h464d2d3abcefaeb9VWK
   9:           0xfb9fd0 - trans::cleanup::FunctionContext<'blk, 'tcx>.CleanupMethods<'blk, 'tcx>::push_custom_cleanup_scope::h464d2d3abcefaeb9VWK
  10:           0xfb9aec - trans::cleanup::FunctionContext<'blk, 'tcx>.CleanupMethods<'blk, 'tcx>::push_custom_cleanup_scope::h464d2d3abcefaeb9VWK
  11:          0x10cff05 - trans::debuginfo::UniqueTypeId...std..fmt..Show::fmt::h2fdc29f4a21f53d3PTD
  12:          0x10cfb6a - trans::debuginfo::UniqueTypeId...std..fmt..Show::fmt::h2fdc29f4a21f53d3PTD
  13:          0x10cc76f - trans::debuginfo::UniqueTypeId...std..fmt..Show::fmt::h2fdc29f4a21f53d3PTD
  14:          0x10ce790 - trans::debuginfo::UniqueTypeId...std..fmt..Show::fmt::h2fdc29f4a21f53d3PTD
  15:          0x10c9442 - trans::debuginfo::UniqueTypeId...std..fmt..Show::fmt::h2fdc29f4a21f53d3PTD
  16:          0x10cff30 - trans::debuginfo::UniqueTypeId...std..fmt..Show::fmt::h2fdc29f4a21f53d3PTD
  17:          0x10cfb6a - trans::debuginfo::UniqueTypeId...std..fmt..Show::fmt::h2fdc29f4a21f53d3PTD
  18:          0x10cc76f - trans::debuginfo::UniqueTypeId...std..fmt..Show::fmt::h2fdc29f4a21f53d3PTD
  19:          0x10ce790 - trans::debuginfo::UniqueTypeId...std..fmt..Show::fmt::h2fdc29f4a21f53d3PTD
  20:          0x10c9442 - trans::debuginfo::UniqueTypeId...std..fmt..Show::fmt::h2fdc29f4a21f53d3PTD
  21:          0x10d5996 - trans::debuginfo::UniqueTypeId...std..fmt..Show::fmt::h2fdc29f4a21f53d3PTD
  22:          0x10c8958 - trans::debuginfo::UniqueTypeId...std..fmt..Show::fmt::h2fdc29f4a21f53d3PTD
  23:          0x10723ea - trans::base::FindNestedReturn.Visitor<'v>::visit_expr::h2e47fdc8586e307bWut
  24:           0xfd7608 - trans::base::StatRecorder<'a, 'tcx>.Drop::drop::h2388b1c31fcc139emWr
  25:          0x1077252 - trans::base::IsUnboxedClosureFlag...std..clone..Clone::clone::h5e97d8ec7e80ca9e60t
  26:           0xf9df82 - trans::context::CrateContext<'b, 'tcx>::sess::hd6cb1cf9ebd5d9301tm
  27:           0xf9f54a - trans::context::CrateContext<'b, 'tcx>::sess::hd6cb1cf9ebd5d9301tm
  28:           0xfee9ab - trans::common::ExprOrMethodCall...std..fmt..Show::fmt::haf69276d9baa0715WWl
  29:           0xfec47e - trans::context::CrateContext<'b, 'tcx>::tn::hd0cb0f6fe17abe9eSwm
  30:           0xfca539 - trans::cleanup::FunctionContext<'blk, 'tcx>.CleanupMethods<'blk, 'tcx>::pop_and_trans_custom_cleanup_scope::hfe6e646bf95998a716K
  31:           0xff45e3 - trans::type_::Type...std..cmp..PartialEq::ne::h12a4f5f13238ba78UZJ
  32:           0xff88ac - trans::type_::Type...std..cmp..PartialEq::ne::h12a4f5f13238ba78UZJ
  33:           0xff76b9 - trans::type_::Type...std..cmp..PartialEq::ne::h12a4f5f13238ba78UZJ
  34:           0xfb2d75 - trans::expr::Dest...std..cmp..PartialEq::eq::h3d06ba9fd9435851Mvh
  35:           0xfc3b08 - trans::cleanup::FunctionContext<'blk, 'tcx>.CleanupMethods<'blk, 'tcx>::pop_custom_cleanup_scope::h7a9d35dce2d79c8834K
  36:           0xff553a - trans::type_::Type...std..cmp..PartialEq::ne::h12a4f5f13238ba78UZJ
  37:           0xff88ac - trans::type_::Type...std..cmp..PartialEq::ne::h12a4f5f13238ba78UZJ
  38:           0xff76b9 - trans::type_::Type...std..cmp..PartialEq::ne::h12a4f5f13238ba78UZJ
  39:           0xfb2d75 - trans::expr::Dest...std..cmp..PartialEq::eq::h3d06ba9fd9435851Mvh
  40:           0xfff0fd - trans::type_::Type...std..cmp..PartialEq::ne::h12a4f5f13238ba78UZJ
  41:           0xfb2006 - trans::cleanup::FunctionContext<'blk, 'tcx>.CleanupMethods<'blk, 'tcx>::pop_and_trans_ast_cleanup_scope::h571d6783ced12feft0K
  42:           0xfb1158 - trans::cleanup::FunctionContext<'blk, 'tcx>.CleanupMethods<'blk, 'tcx>::push_ast_cleanup_scope::hb93f7672cd708912NPK
  43:           0xfb262d - trans::cleanup::FunctionContext<'blk, 'tcx>.CleanupMethods<'blk, 'tcx>::pop_and_trans_ast_cleanup_scope::h571d6783ced12feft0K
  44:          0x1079562 - trans::base::IsUnboxedClosureFlag...std..clone..Clone::clone::h5e97d8ec7e80ca9e60t
  45:           0xf9df82 - trans::context::CrateContext<'b, 'tcx>::sess::hd6cb1cf9ebd5d9301tm
  46:           0xf9f54a - trans::context::CrateContext<'b, 'tcx>::sess::hd6cb1cf9ebd5d9301tm
  47:           0xfee9ab - trans::common::ExprOrMethodCall...std..fmt..Show::fmt::haf69276d9baa0715WWl
  48:           0xfccab3 - trans::cleanup::FunctionContext<'blk, 'tcx>.CleanupMethods<'blk, 'tcx>::pop_and_trans_custom_cleanup_scope::hfe6e646bf95998a716K
  49:           0xff45e3 - trans::type_::Type...std..cmp..PartialEq::ne::h12a4f5f13238ba78UZJ
  50:           0xff88ac - trans::type_::Type...std..cmp..PartialEq::ne::h12a4f5f13238ba78UZJ
  51:           0xfb1db1 - trans::cleanup::FunctionContext<'blk, 'tcx>.CleanupMethods<'blk, 'tcx>::pop_and_trans_ast_cleanup_scope::h571d6783ced12feft0K
  52:           0xfb291f - trans::cleanup::FunctionContext<'blk, 'tcx>.CleanupMethods<'blk, 'tcx>::pop_and_trans_ast_cleanup_scope::h571d6783ced12feft0K
  53:           0xff9944 - trans::type_::Type...std..cmp..PartialEq::ne::h12a4f5f13238ba78UZJ
  54:           0xfb1db1 - trans::cleanup::FunctionContext<'blk, 'tcx>.CleanupMethods<'blk, 'tcx>::pop_and_trans_ast_cleanup_scope::h571d6783ced12feft0K
  55:          0x1095233 - trans::cleanup::FunctionContext<'blk, 'tcx>.CleanupMethods<'blk, 'tcx>::schedule_drop_and_zero_mem::hed712752bdc94a84KeL
  56:           0xff9614 - trans::type_::Type...std..cmp..PartialEq::ne::h12a4f5f13238ba78UZJ
  57:           0xfb1db1 - trans::cleanup::FunctionContext<'blk, 'tcx>.CleanupMethods<'blk, 'tcx>::pop_and_trans_ast_cleanup_scope::h571d6783ced12feft0K
  58:           0xfb291f - trans::cleanup::FunctionContext<'blk, 'tcx>.CleanupMethods<'blk, 'tcx>::pop_and_trans_ast_cleanup_scope::h571d6783ced12feft0K
  59:          0x1079562 - trans::base::IsUnboxedClosureFlag...std..clone..Clone::clone::h5e97d8ec7e80ca9e60t
  60:           0xf9df82 - trans::context::CrateContext<'b, 'tcx>::sess::hd6cb1cf9ebd5d9301tm
  61:           0xf9a231 - trans::context::CrateContext<'b, 'tcx>::stats::h064e64c108f865e3XGm
  62:          0x107af88 - trans::cleanup::FunctionContext<'blk, 'tcx>.CleanupMethods<'blk, 'tcx>::push_custom_cleanup_scope_with_debug_loc::h76b9726feef793e0NYK
  63:           0xf99722 - trans::context::CrateContext<'b, 'tcx>::stats::h064e64c108f865e3XGm
  64:          0x107f6c8 - trans::base::trans_crate::h3ae41358cc04fdd1cvv
  65:         0x70b240ca - driver::phase_4_translate_to_llvm::h1e5993987ab6d536YMa
  66:         0x70b0264d - driver::compile_input::ha5dff1685b5f89bbAba
  67:         0x70bc0037 - run::he5c8e3699f0298dcM4b
  68:         0x70bbe3b8 - run::he5c8e3699f0298dcM4b
  69:         0x70bbd23a - run::he5c8e3699f0298dcM4b
  70:         0x69c28c0c - rust_try
  71:         0x69c28be9 - rust_try
  72:         0x70bbd86f - run::he5c8e3699f0298dcM4b
  73:         0x69bf1002 - sys::tcp::TcpListener::bind::he3cbb57691b44c3fZGw
  74:         0x774f59ed - BaseThreadInitThunk

The code that ICEs is here: https://github.com/ruud-v-a/image/tree/ice-8903c21d6. cargo build (for cargo 0.0.1-pre-nightly (8154255 2015-01-14 19:14:12 +0000)) triggers the ICE. I am sorry for not producing a minimal example, but I hope this information might still be useful. Edit: While it does ICE for cargo build, it does not for cargo build --release.

@michaelwoerister
Copy link
Member

Here is a debugging output trace of compiling the initial example:

DEBUG:rustc_trans::trans::debuginfo: type_metadata: fn(&std::path::posix::Path) -> core::result::Result<Subpaths<Recursive>, std::io::IoError> {Subpaths<S>::walk}
DEBUG:rustc_trans::trans::debuginfo: type_metadata: core::result::Result<Subpaths<Recursive>, std::io::IoError>
DEBUG:rustc_trans::trans::debuginfo: type_metadata: Subpaths<Recursive>
DEBUG:rustc_trans::trans::debuginfo: debuginfo: Create struct member description for field 'stack' at index 0 with type collections::vec::Vec<<Recursive as Strategy>::P>
DEBUG:rustc_trans::trans::debuginfo: type_metadata: collections::vec::Vec<<Recursive as Strategy>::P>
DEBUG:rustc_trans::trans::debuginfo: debuginfo: Create struct member description for field 'ptr' at index 0 with type core::nonzero::NonZero<*mut <Recursive as Strategy>::P>
DEBUG:rustc_trans::trans::debuginfo: type_metadata: core::nonzero::NonZero<*mut <Recursive as Strategy>::P>
DEBUG:rustc_trans::trans::debuginfo: debuginfo: Create struct member description for unnamed field at index 0 with type *mut <Recursive as Strategy>::P

The problem is the ty_projection instance within the type of the field. It would be easy to fix this by 'normalizing' the field type then and there but I don't know if ty_projection should still show up this late in the compilation process, or if all instances should have been normalized out before.

@nikomatsakis, I'm assuming you are the one to make this call: Should I normalize in trans::debuginfo or is this something that should be fixed in an earlier phase?

@sfackler
Copy link
Member

@bluss rustc -g --test <the code in the original post>.

@nikomatsakis
Copy link
Contributor

(Ah, I no doubt wasn't running with -g.)

@nikomatsakis
Copy link
Contributor

@michaelwoerister you can and should normalize in the debuginfo pass, basically at the same times when you apply substitutes (e.g., when you extract the field out of a struct definition and monomorphize it by substituting the values for the struct's type parameters)

@carllerche
Copy link
Member

cc me, I started hitting this issue as well.

Rust version: rustc 1.0.0-nightly (29bd9a0 2015-01-20 23:03:09 +0000)

@nikomatsakis
Copy link
Contributor

I'm going to re-open this issue, I think that the regression test failed to cover the use of -g

@nikomatsakis nikomatsakis reopened this Jan 22, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this issue Jan 22, 2015
…r=alexcrichton

This should fix issue rust-lang#20797 (but I don't want to close it automatically).
As the actual fix is very small this would be a perfect candidate for a rollup.
@jpernst
Copy link

jpernst commented Jan 23, 2015

cc me, started getting this after a large refactor.

@kinghajj
Copy link
Author

I'm very happy to report that my example now compiles without error using rustc 1.0.0-dev (86fbdbfbc 2015-01-23 12:02:27 +0000). I was able to change PathExtensions::is_dir(&path) to path.is_dir(), too. Thanks to all involved!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items (types, constants & functions) A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.