{"action":"closed","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/20535","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/20535/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/20535/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/20535/events","html_url":"https://github.com/rust-lang/rust/issues/20535","id":53345127,"number":20535,"title":"Associated type as struct field causes type-checking error","user":{"login":"murarth","id":1332722,"avatar_url":"https://avatars.githubusercontent.com/u/1332722?v=3","gravatar_id":"","url":"https://api.github.com/users/murarth","html_url":"https://github.com/murarth","followers_url":"https://api.github.com/users/murarth/followers","following_url":"https://api.github.com/users/murarth/following{/other_user}","gists_url":"https://api.github.com/users/murarth/gists{/gist_id}","starred_url":"https://api.github.com/users/murarth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/murarth/subscriptions","organizations_url":"https://api.github.com/users/murarth/orgs","repos_url":"https://api.github.com/users/murarth/repos","events_url":"https://api.github.com/users/murarth/events{/privacy}","received_events_url":"https://api.github.com/users/murarth/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/I-ICE","name":"I-ICE","color":"e10c02"}],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/rust-lang/rust/milestones/21","labels_url":"https://api.github.com/repos/rust-lang/rust/milestones/21/labels","id":923804,"number":21,"title":"1.0 alpha","description":"","creator":{"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},"open_issues":7,"closed_issues":7,"state":"open","created_at":"2015-01-06T14:12:27Z","updated_at":"2015-01-08T07:35:55Z","due_on":"2015-01-09T05:00:00Z","closed_at":null},"comments":1,"created_at":"2015-01-04T19:09:29Z","updated_at":"2015-01-08T07:35:55Z","closed_at":"2015-01-08T07:35:55Z","body":"The following causes an error (indicated in the comment):\r\n\r\n```rust\r\n#![feature(associated_types)]\r\n\r\npub trait Foo {\r\n    type Bar;\r\n}\r\n\r\nimpl Foo for int {\r\n    type Bar = int;\r\n}\r\n\r\nstruct Thing<F: Foo> {\r\n    a: F,\r\n    b: F::Bar,\r\n}\r\n\r\nfn main() {\r\n    let _ = Thing{a: 1i, b: 2i};\r\n    //                      ^~\r\n    // error: mismatched types: expected `<int as Foo>::Bar`,\r\n    // found `int` (expected associated type, found int)\r\n}\r\n```\r\n\r\nAnd this closely related case causes an ICE:\r\n\r\n```rust\r\n#![feature(associated_types)]\r\n\r\npub trait Foo {\r\n    type Bar;\r\n}\r\n\r\nimpl Foo for int {\r\n    type Bar = int;\r\n}\r\n\r\nstruct Thing<F: Foo> {\r\n    a: F,\r\n    b: Option<F::Bar>,\r\n}\r\n\r\nfn main() {\r\n    let _ = Thing{a: 1i, b: None};\r\n}\r\n```\r\n\r\nBacktrace:\r\n\r\n```\r\nerror: internal compiler error: trying to take the sizing type of <int as Foo>::Bar, an unsized type\r\nnote: the compiler unexpectedly panicked. this is a bug.\r\nnote: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html\r\nnote: run with `RUST_BACKTRACE=1` for a backtrace\r\nthread 'rustc' panicked at 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:182\r\n\r\nstack backtrace:\r\n   1:     0x7f22c6fb32d0 - sys::backtrace::write::h8532e701ef86014f4it\r\n   2:     0x7f22c6fd8b00 - failure::on_fail::h7532e1f79d134d5dzvz\r\n   3:     0x7f22c6f3e1c0 - rt::unwind::begin_unwind_inner::h97b151606151d62deaz\r\n   4:     0x7f22c1defc60 - rt::unwind::begin_unwind::h15809447133099964284\r\n   5:     0x7f22c1df0510 - diagnostic::Handler::bug::h8818b567cf47e6a0DLF\r\n   6:     0x7f22c512acf0 - session::Session::bug::h251da16737c526c0lrq\r\n   7:     0x7f22c5dfd020 - trans::type_of::sizing_type_of::he06887b02c649aebXRo\r\n   8:     0x7f22c5f1cb10 - trans::adt::represent_type_uncached::h6b884b95692379c1oxH\r\n   9:     0x7f22c5df7b30 - trans::adt::represent_type::ha0c2ea2716678100YtH\r\n  10:     0x7f22c5de2fb0 - trans::type_of::type_of::h7caa699265884e0bFYo\r\n  11:     0x7f22c5de2fb0 - trans::type_of::type_of::h7caa699265884e0bFYo\r\n  12:     0x7f22c5f22b20 - vec::Vec<T>.FromIterator<T>::from_iter::h11585473372288691594\r\n  13:     0x7f22c5de2fb0 - trans::type_of::type_of::h7caa699265884e0bFYo\r\n  14:     0x7f22c5de2fb0 - trans::type_of::type_of::h7caa699265884e0bFYo\r\n  15:     0x7f22c5decf50 - trans::base::alloc_ty::h29690970a9e20515oft\r\n  16:     0x7f22c5ee6800 - trans::_match::mk_binding_alloca::h2686137581982254550\r\n  17:     0x7f22c5ddcb70 - trans::base::init_local::h9a5509ab5cb7df8eB1s\r\n  18:     0x7f22c5dddd10 - trans::controlflow::trans_block::hfd89f3a5d0ddcbbdQ1d\r\n  19:     0x7f22c5ea8f60 - trans::base::trans_closure::hbecde8c2bc5f7b2fsSt\r\n  20:     0x7f22c5dc9120 - trans::base::trans_fn::hba312ea6d66cf757Z2t\r\n  21:     0x7f22c5dc4300 - trans::base::trans_item::ha0e598b4af14d13fQpu\r\n  22:     0x7f22c5eb1a60 - trans::base::trans_crate::hf12b6e99a3af9ab9blv\r\n  23:     0x7f22c7513250 - driver::phase_4_translate_to_llvm::h40ce54ee4a878885vFa\r\n  24:     0x7f22c74f2ae0 - driver::compile_input::h68b8602933aad8d7wba\r\n  25:     0x7f22c75bdeb0 - thunk::F.Invoke<A, R>::invoke::h18029802347644288836\r\n  26:     0x7f22c75bcc60 - rt::unwind::try::try_fn::h6518866316425934196\r\n  27:     0x7f22c703f400 - rust_try_inner\r\n  28:     0x7f22c703f3f0 - rust_try\r\n  29:     0x7f22c75bcfb0 - thunk::F.Invoke<A, R>::invoke::h15513809553472565307\r\n  30:     0x7f22c6fc4e40 - sys::thread::thread_start::h5ea7ba97235331d5a9v\r\n  31:     0x7f22c16130c0 - start_thread\r\n  32:     0x7f22c6be4ec9 - __clone\r\n  33:                0x0 - <unknown>\r\n```"}}