{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/20797","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/20797/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/20797/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/20797/events","html_url":"https://github.com/rust-lang/rust/issues/20797","id":53839594,"number":20797,"title":"Associated types: ICE \"get_unique_type_id_of_type() - unexpected type\"","user":{"login":"kinghajj","id":3409,"avatar_url":"https://avatars.githubusercontent.com/u/3409?v=3","gravatar_id":"","url":"https://api.github.com/users/kinghajj","html_url":"https://github.com/kinghajj","followers_url":"https://api.github.com/users/kinghajj/followers","following_url":"https://api.github.com/users/kinghajj/following{/other_user}","gists_url":"https://api.github.com/users/kinghajj/gists{/gist_id}","starred_url":"https://api.github.com/users/kinghajj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kinghajj/subscriptions","organizations_url":"https://api.github.com/users/kinghajj/orgs","repos_url":"https://api.github.com/users/kinghajj/repos","events_url":"https://api.github.com/users/kinghajj/events{/privacy}","received_events_url":"https://api.github.com/users/kinghajj/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rust-lang/rust/labels/A-associated-items","name":"A-associated-items","color":"d7e102"},{"url":"https://api.github.com/repos/rust-lang/rust/labels/A-debuginfo","name":"A-debuginfo","color":"d7e102"},{"url":"https://api.github.com/repos/rust-lang/rust/labels/I-ICE","name":"I-ICE","color":"e10c02"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":28,"created_at":"2015-01-09T06:59:07Z","updated_at":"2015-01-22T10:50:32Z","closed_at":null,"body":"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:\r\n\r\n```rust\r\n    use std::default::Default;\r\n    use std::io::IoResult;\r\n    use std::io::fs;\r\n    use std::io::fs::PathExtensions;\r\n\r\n    /// A strategy for acquiring more subpaths to walk.\r\n    pub trait Strategy {\r\n      type P: PathExtensions;\r\n      /// Get additional subpaths from a given path.\r\n      fn get_more(&self, item: &Self::P) -> IoResult<Vec<Self::P>>;\r\n      /// Determine whether a path should be walked further.\r\n      /// This is run against each item from `get_more()`.\r\n      fn prune(&self, p: &Self::P) -> bool;\r\n    }\r\n\r\n    /// The basic fully-recursive strategy. Nothing is pruned.\r\n    #[derive(Copy, Default)]\r\n    pub struct Recursive;\r\n\r\n    impl Strategy for Recursive {\r\n      type P = Path;\r\n      fn get_more(&self, p: &Path) -> IoResult<Vec<Path>> { fs::readdir(p) }\r\n\r\n      fn prune(&self, _: &Path) -> bool { false }\r\n    }\r\n\r\n    /// A directory walker of `P` using strategy `S`.\r\n    pub struct Subpaths<S: Strategy> {\r\n        stack: Vec<S::P>,\r\n        strategy: S,\r\n    }\r\n\r\n    impl<S: Strategy> Subpaths<S> {\r\n      /// Create a directory walker with a root path and strategy.\r\n      pub fn new(p: &S::P, strategy: S) -> IoResult<Subpaths<S>> {\r\n        let stack = try!(strategy.get_more(p));\r\n        Ok(Subpaths { stack: stack, strategy: strategy })\r\n      }\r\n    }\r\n\r\n    impl<S: Default + Strategy> Subpaths<S> {\r\n      /// Create a directory walker with a root path and a default strategy.\r\n      pub fn walk(p: &S::P) -> IoResult<Subpaths<S>> {\r\n          Subpaths::new(p, Default::default())\r\n      }\r\n    }\r\n\r\n    impl<S: Default + Strategy> Default for Subpaths<S> {\r\n      fn default() -> Subpaths<S> {\r\n        Subpaths { stack: Vec::new(), strategy: Default::default() }\r\n      }\r\n    }\r\n\r\n    impl<S: Strategy> Iterator for Subpaths<S> {\r\n      type Item = S::P;\r\n      fn next (&mut self) -> Option<S::P> {\r\n        let mut opt_path = self.stack.pop();\r\n        while opt_path.is_some() && self.strategy.prune(opt_path.as_ref().unwrap()) {\r\n          opt_path = self.stack.pop();\r\n        }\r\n        match opt_path {\r\n          Some(path) => {\r\n            if PathExtensions::is_dir(&path) {\r\n              let result = self.strategy.get_more(&path);\r\n              match result {\r\n                Ok(dirs) => { self.stack.extend(dirs.into_iter()); },\r\n                Err(..) => { }\r\n              }\r\n            }\r\n            Some(path)\r\n          }\r\n          None => None,\r\n        }\r\n      }\r\n    }\r\n\r\n    #[test]\r\n    fn woot() {\r\n      let mut walker: Subpaths<Recursive> = Subpaths::walk(&Path::new(\"/home\")).unwrap();\r\n    }\r\n```\r\n\r\nHere's the error and backtrace:\r\n\r\n    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) })\r\n    note: the compiler unexpectedly panicked. this is a bug.\r\n    note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html\r\n    note: run with `RUST_BACKTRACE=1` for a backtrace\r\n    thread 'rustc' panicked at 'Box<Any>', /home/samuel/rust/src/libsyntax/diagnostic.rs:182\r\n\r\n    stack backtrace:\r\n       1:     0x7f4a265a0570 - sys::backtrace::write::h3452feb04e320bcfCzt\r\n       2:     0x7f4a265c2780 - failure::on_fail::hd0efae8686875716aPz\r\n       3:     0x7f4a26530300 - rt::unwind::begin_unwind_inner::h229232f5734654792tz\r\n       4:     0x7f4a214ada20 - rt::unwind::begin_unwind::h9438643137198476843\r\n       5:     0x7f4a214ae2d0 - diagnostic::Handler::bug::he657a4296d705a33tWF\r\n       6:     0x7f4a2488f180 - session::Session::bug::ha8836431c543757ciRq\r\n       7:     0x7f4a25673ba0 - trans::debuginfo::TypeMap<'tcx>::get_unique_type_id_of_type::h606c89215412cd5brGD\r\n       8:     0x7f4a256778d0 - trans::debuginfo::TypeMap<'tcx>::get_unique_type_id_of_type::from_def_id_and_substs::h9fa1f90635ed12d03PD\r\n       9:     0x7f4a25673ba0 - trans::debuginfo::TypeMap<'tcx>::get_unique_type_id_of_type::h606c89215412cd5brGD\r\n      10:     0x7f4a25679e30 - trans::debuginfo::type_metadata::h7557684678d0dd25RSF\r\n      11:     0x7f4a25682220 - trans::debuginfo::StructMemberDescriptionFactory<'tcx>::create_member_descriptions::unboxed_closure.45598\r\n      12:     0x7f4a25681e00 - vec::Vec<T>.FromIterator<T>::from_iter::h9648212210143919248\r\n      13:     0x7f4a2567dda0 - trans::debuginfo::StructMemberDescriptionFactory<'tcx>::create_member_descriptions::hf79fdc4d3167c5d0j9E\r\n      14:     0x7f4a25680980 - trans::debuginfo::RecursiveTypeDescription<'tcx>::finalize::h0ff9cf1ab1bdbcef26E\r\n      15:     0x7f4a25679e30 - trans::debuginfo::type_metadata::h7557684678d0dd25RSF\r\n      16:     0x7f4a25684fd0 - trans::debuginfo::VariantMemberDescriptionFactory<'tcx>::create_member_descriptions::unboxed_closure.45632\r\n      17:     0x7f4a25684be0 - vec::Vec<T>.FromIterator<T>::from_iter::h5453357870208096995\r\n      18:     0x7f4a25683270 - trans::debuginfo::EnumMemberDescriptionFactory<'tcx>::create_member_descriptions::unboxed_closure.45606\r\n      19:     0x7f4a25682e50 - vec::Vec<T>.FromIterator<T>::from_iter::h13188062602912948975\r\n      20:     0x7f4a2567de90 - trans::debuginfo::EnumMemberDescriptionFactory<'tcx>::create_member_descriptions::h1355d0387a727939hgF\r\n      21:     0x7f4a25680980 - trans::debuginfo::RecursiveTypeDescription<'tcx>::finalize::h0ff9cf1ab1bdbcef26E\r\n      22:     0x7f4a25679e30 - trans::debuginfo::type_metadata::h7557684678d0dd25RSF\r\n      23:     0x7f4a25688070 - trans::debuginfo::subroutine_type_metadata::haec4c13f9a5d7a59vOF\r\n      24:     0x7f4a25679e30 - trans::debuginfo::type_metadata::h7557684678d0dd25RSF\r\n      25:     0x7f4a25620ae0 - trans::debuginfo::create_function_debug_context::h985b11ad61da52fdwsE\r\n      26:     0x7f4a25580890 - trans::base::new_fn_ctxt::hbe79965b1049ecf2Zxt\r\n      27:     0x7f4a25626410 - trans::base::trans_closure::h5c0a7253f08a6c1bEYt\r\n      28:     0x7f4a255452b0 - trans::base::trans_fn::h84cc11dd50b05f50j9t\r\n      29:     0x7f4a25545710 - trans::monomorphize::monomorphic_fn::h44708ba9400c75dbFpd\r\n      30:     0x7f4a25597ff0 - trans::callee::trans_fn_ref_with_substs::h1741ea29b53c270fGxg\r\n      31:     0x7f4a25596590 - trans::callee::trans_fn_ref::h611f01f0cbdf2e42Rlg\r\n      32:     0x7f4a25593870 - trans::callee::trans::h2d6fbfb713fd152ayag\r\n      33:     0x7f4a2559da90 - trans::callee::trans_call_inner::h893956557312987459\r\n      34:     0x7f4a255a34b0 - trans::expr::trans_rvalue_dps_unadjusted::h4ab35d4af002299e1Si\r\n      35:     0x7f4a255a2790 - trans::expr::trans_unadjusted::h15f19eba475549d3Oji\r\n      36:     0x7f4a2555b000 - trans::expr::trans::ha962b869e642f0b8eCh\r\n      37:     0x7f4a2556c0b0 - trans::callee::trans_args::h2dbfd3d1c7128174xch\r\n      38:     0x7f4a2559f460 - trans::callee::trans_call_inner::h11730372111330536098\r\n      39:     0x7f4a255a34b0 - trans::expr::trans_rvalue_dps_unadjusted::h4ab35d4af002299e1Si\r\n      40:     0x7f4a25559d90 - trans::expr::trans_into::h70023b40e1df277dKyh\r\n      41:     0x7f4a2565e030 - trans::_match::mk_binding_alloca::h14708251032129145358\r\n      42:     0x7f4a25559390 - trans::base::init_local::h17113ff3a822f41bC7s\r\n      43:     0x7f4a2555a3e0 - trans::controlflow::trans_block::hd4046f45161d1f00B3d\r\n      44:     0x7f4a25626410 - trans::base::trans_closure::h5c0a7253f08a6c1bEYt\r\n      45:     0x7f4a255452b0 - trans::base::trans_fn::h84cc11dd50b05f50j9t\r\n      46:     0x7f4a25540840 - trans::base::trans_item::h560b1558a6cec5e6Ewu\r\n      47:     0x7f4a2562dc30 - trans::base::trans_crate::heb94c899d24982b8lsv\r\n      48:     0x7f4a26b09fa0 - driver::phase_4_translate_to_llvm::h4be77ff61772864dPFa\r\n      49:     0x7f4a26ae3f30 - driver::compile_input::hefa96b3bea08e00bxba\r\n      50:     0x7f4a26bb3bc0 - monitor::unboxed_closure.22498\r\n      51:     0x7f4a26bb3a20 - thunk::F.Invoke<A, R>::invoke::h2604081160332846052\r\n      52:     0x7f4a26bb27a0 - rt::unwind::try::try_fn::h10712615664574212328\r\n      53:     0x7f4a26630f00 - rust_try_inner\r\n      54:     0x7f4a26630ef0 - rust_try\r\n      55:     0x7f4a26bb2a90 - thunk::F.Invoke<A, R>::invoke::h6088602545528080049\r\n      56:     0x7f4a265b0630 - sys::thread::thread_start::h803dac673dcdb1abqrw\r\n      57:     0x7f4a20cc7250 - start_thread\r\n      58:     0x7f4a261e0219 - clone\r\n      59:                0x0 - <unknown>\r\n\r\n    Could not compile `subpaths`."},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/71002873","html_url":"https://github.com/rust-lang/rust/issues/20797#issuecomment-71002873","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/20797","id":71002873,"user":{"login":"nikomatsakis","id":155238,"avatar_url":"https://avatars.githubusercontent.com/u/155238?v=3","gravatar_id":"","url":"https://api.github.com/users/nikomatsakis","html_url":"https://github.com/nikomatsakis","followers_url":"https://api.github.com/users/nikomatsakis/followers","following_url":"https://api.github.com/users/nikomatsakis/following{/other_user}","gists_url":"https://api.github.com/users/nikomatsakis/gists{/gist_id}","starred_url":"https://api.github.com/users/nikomatsakis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikomatsakis/subscriptions","organizations_url":"https://api.github.com/users/nikomatsakis/orgs","repos_url":"https://api.github.com/users/nikomatsakis/repos","events_url":"https://api.github.com/users/nikomatsakis/events{/privacy}","received_events_url":"https://api.github.com/users/nikomatsakis/received_events","type":"User","site_admin":false},"created_at":"2015-01-22T10:50:32Z","updated_at":"2015-01-22T10:50:32Z","body":"I'm going to re-open this issue, "}}