{"action":"opened","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/48751","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/48751/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/48751/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/48751/events","html_url":"https://github.com/rust-lang/rust/issues/48751","id":302356626,"number":48751,"title":"Cannot create local mono-item","user":{"login":"alecmocatta","id":1136246,"avatar_url":"https://avatars0.githubusercontent.com/u/1136246?v=4","gravatar_id":"","url":"https://api.github.com/users/alecmocatta","html_url":"https://github.com/alecmocatta","followers_url":"https://api.github.com/users/alecmocatta/followers","following_url":"https://api.github.com/users/alecmocatta/following{/other_user}","gists_url":"https://api.github.com/users/alecmocatta/gists{/gist_id}","starred_url":"https://api.github.com/users/alecmocatta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alecmocatta/subscriptions","organizations_url":"https://api.github.com/users/alecmocatta/orgs","repos_url":"https://api.github.com/users/alecmocatta/repos","events_url":"https://api.github.com/users/alecmocatta/events{/privacy}","received_events_url":"https://api.github.com/users/alecmocatta/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-05T16:00:50Z","updated_at":"2018-03-05T16:00:50Z","closed_at":null,"author_association":"NONE","body":"I'm getting the following ICE on at least various nightlies going back a month.\r\n\r\n```\r\nerror: internal compiler error: librustc_mir/monomorphize/collector.rs:747: Cannot create local mono-item for DefId(18/0:171 ~ my_lib_crate[8418]::my_lib_submod[0]::{{impl}}[18]::new[0])\r\n\r\nthread 'rustc' panicked at 'Box<Any>', librustc_errors/lib.rs:535:9\r\nstack backtrace:\r\n   0:     0x7f1f4999ee83 - std::sys::unix::backtrace::tracing::imp::unwind_backtrace::h06394d49c249a4bb\r\n                               at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49\r\n   1:     0x7f1f49995d64 - std::sys_common::backtrace::_print::h9b103b13339f9058\r\n                               at libstd/sys_common/backtrace.rs:71\r\n   2:     0x7f1f4999b72d - std::panicking::default_hook::{{closure}}::h098a999e0c1b279e\r\n                               at libstd/sys_common/backtrace.rs:59\r\n                               at libstd/panicking.rs:207\r\n   3:     0x7f1f4999b429 - std::panicking::default_hook::hd2f541195ebc1dea\r\n                               at libstd/panicking.rs:223\r\n   4:     0x7f1f463f725d - core::ops::function::Fn::call::h0946a0c3275debde\r\n   5:     0x7f1f4999bbc9 - std::panicking::rust_panic_with_hook::h127f3d328cb9c946\r\n                               at libstd/panicking.rs:403\r\n   6:     0x7f1f4551069a - std::panicking::begin_panic::hbfebf35e964b9da1\r\n   7:     0x7f1f45534ce5 - rustc_errors::Handler::bug::hf13b4cd4ede3ee59\r\n   8:     0x7f1f466f01bf - rustc::session::opt_span_bug_fmt::{{closure}}::hfee030be9b8ff1e8\r\n   9:     0x7f1f467a9ef5 - rustc::ty::context::tls::with_opt::{{closure}}::h88a2cfeee7591ffa\r\n  10:     0x7f1f463ef78f - <std::thread::local::LocalKey<T>>::try_with::h8e6e81c50519f79b\r\n  11:     0x7f1f463ef3c6 - <std::thread::local::LocalKey<T>>::with::h3efd74c0542fa548\r\n  12:     0x7f1f467a9cf6 - rustc::ty::context::tls::with::h4e7056c46f6be47e\r\n  13:     0x7f1f467a9ea7 - rustc::ty::context::tls::with_opt::hcf162eb7c7be45bb\r\n  14:     0x7f1f466f00c4 - rustc::session::opt_span_bug_fmt::h275dfefeda53d72f\r\n  15:     0x7f1f466f0036 - rustc::session::bug_fmt::he81ec97ba9fd393d\r\n  16:     0x7f1f473ccd02 - rustc_mir::monomorphize::collector::should_monomorphize_locally::hadc53c23cf2ecd35\r\n  17:     0x7f1f473ccad4 - rustc_mir::monomorphize::collector::visit_instance_use::h2eba081f4558be70\r\n  18:     0x7f1f473cca9e - rustc_mir::monomorphize::collector::visit_fn_use::he4b23b23a4337853\r\n  19:     0x7f1f473cc5ac - <rustc_mir::monomorphize::collector::MirNeighborCollector<'a, 'tcx> as rustc::mir::visit::Visitor<'tcx>>::visit_terminator_kind::hddb5a5bfa62a6bdc\r\n  20:     0x7f1f47230909 - rustc::mir::visit::Visitor::visit_mir::h557b1066eb9ca420\r\n  21:     0x7f1f473c94d2 - rustc_mir::monomorphize::collector::collect_items_rec::hde05f88e26b073e8\r\n  22:     0x7f1f473ca2f1 - rustc_mir::monomorphize::collector::collect_items_rec::hde05f88e26b073e8\r\n  23:     0x7f1f473ca2f1 - rustc_mir::monomorphize::collector::collect_items_rec::hde05f88e26b073e8\r\n  24:     0x7f1f473ca2f1 - rustc_mir::monomorphize::collector::collect_items_rec::hde05f88e26b073e8\r\n  25:     0x7f1f473ca2f1 - rustc_mir::monomorphize::collector::collect_items_rec::hde05f88e26b073e8\r\n  26:     0x7f1f473ca2f1 - rustc_mir::monomorphize::collector::collect_items_rec::hde05f88e26b073e8\r\n  27:     0x7f1f473ca2f1 - rustc_mir::monomorphize::collector::collect_items_rec::hde05f88e26b073e8\r\n  28:     0x7f1f473ca2f1 - rustc_mir::monomorphize::collector::collect_items_rec::hde05f88e26b073e8\r\n  29:     0x7f1f473ca2f1 - rustc_mir::monomorphize::collector::collect_items_rec::hde05f88e26b073e8\r\n  30:     0x7f1f473ca2f1 - rustc_mir::monomorphize::collector::collect_items_rec::hde05f88e26b073e8\r\n  31:     0x7f1f473ca2f1 - rustc_mir::monomorphize::collector::collect_items_rec::hde05f88e26b073e8\r\n  32:     0x7f1f473ca2f1 - rustc_mir::monomorphize::collector::collect_items_rec::hde05f88e26b073e8\r\n  33:     0x7f1f473ca2f1 - rustc_mir::monomorphize::collector::collect_items_rec::hde05f88e26b073e8\r\n  34:     0x7f1f473ca2f1 - rustc_mir::monomorphize::collector::collect_items_rec::hde05f88e26b073e8\r\n  35:     0x7f1f473ca2f1 - rustc_mir::monomorphize::collector::collect_items_rec::hde05f88e26b073e8\r\n  36:     0x7f1f473ca2f1 - rustc_mir::monomorphize::collector::collect_items_rec::hde05f88e26b073e8\r\n  37:     0x7f1f473ca2f1 - rustc_mir::monomorphize::collector::collect_items_rec::hde05f88e26b073e8\r\n  38:     0x7f1f473ca2f1 - rustc_mir::monomorphize::collector::collect_items_rec::hde05f88e26b073e8\r\n  39:     0x7f1f473ca2f1 - rustc_mir::monomorphize::collector::collect_items_rec::hde05f88e26b073e8\r\n  40:     0x7f1f473ca2f1 - rustc_mir::monomorphize::collector::collect_items_rec::hde05f88e26b073e8\r\n  41:     0x7f1f473ca2f1 - rustc_mir::monomorphize::collector::collect_items_rec::hde05f88e26b073e8\r\n  42:     0x7f1f473ca2f1 - rustc_mir::monomorphize::collector::collect_items_rec::hde05f88e26b073e8\r\n  43:     0x7f1f473ca2f1 - rustc_mir::monomorphize::collector::collect_items_rec::hde05f88e26b073e8\r\n  44:     0x7f1f473ca2f1 - rustc_mir::monomorphize::collector::collect_items_rec::hde05f88e26b073e8\r\n  45:     0x7f1f473ca2f1 - rustc_mir::monomorphize::collector::collect_items_rec::hde05f88e26b073e8\r\n  46:     0x7f1f473ca2f1 - rustc_mir::monomorphize::collector::collect_items_rec::hde05f88e26b073e8\r\n  47:     0x7f1f473ca2f1 - rustc_mir::monomorphize::collector::collect_items_rec::hde05f88e26b073e8\r\n  48:     0x7f1f473c8d62 - rustc_mir::monomorphize::collector::collect_crate_mono_items::h7d3fa603ca193ea1\r\n  49:     0x7f1f3eef6391 - rustc_trans::base::collect_and_partition_translation_items::hbc56d9acdbfb8fce\r\n  50:     0x7f1f46591055 - rustc::dep_graph::graph::DepGraph::with_task_impl::haab752cf4b04a9d9\r\n  51:     0x7f1f469468c1 - rustc::ty::maps::<impl rustc::ty::maps::queries::collect_and_partition_translation_items<'tcx>>::force::h173e27a678062fc0\r\n  52:     0x7f1f46947434 - rustc::ty::maps::<impl rustc::ty::maps::queries::collect_and_partition_translation_items<'tcx>>::try_get::h8458681d3977b430\r\n  53:     0x7f1f469743c5 - rustc::ty::maps::TyCtxtAt::collect_and_partition_translation_items::h7e54fb221877b03e\r\n  54:     0x7f1f4696d45e - rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::collect_and_partition_translation_items::h0fe8a60b44cc74e1\r\n  55:     0x7f1f3eef1d5b - rustc_trans::base::trans_crate::h95abd4e4789925dc\r\n  56:     0x7f1f3ef4f497 - <rustc_trans::LlvmTransCrate as rustc_trans_utils::trans_crate::TransCrate>::trans_crate::h4fb823522ed0f41d\r\n  57:     0x7f1f49d5eaa2 - rustc_driver::driver::phase_4_translate_to_llvm::h040f62e78a90a498\r\n  58:     0x7f1f49d57a2e - rustc_driver::driver::compile_input::{{closure}}::he9c5443356997304\r\n  59:     0x7f1f49ce44b4 - rustc::ty::context::TyCtxt::create_and_enter::h010c9fa8ed1d20fc\r\n  60:     0x7f1f49d55a5e - rustc_driver::driver::compile_input::hd0a77987b3f07ae0\r\n  61:     0x7f1f49d7244a - rustc_driver::run_compiler::h7e92d64f306a4def\r\n  62:     0x7f1f49c9d9f0 - std::sys_common::backtrace::__rust_begin_short_backtrace::hcea77d6abfa0c596\r\n  63:     0x7f1f499b4a6e - __rust_maybe_catch_panic\r\n                               at libpanic_unwind/lib.rs:102\r\n  64:     0x7f1f49cd6db6 - <F as alloc::boxed::FnBox<A>>::call_box::h45c47cff726094f9\r\n  65:     0x7f1f499abd1b - std::sys::unix::thread::Thread::new::thread_start::h2ff3c08e553ac72c\r\n                               at /checkout/src/liballoc/boxed.rs:793\r\n                               at libstd/sys_common/thread.rs:24\r\n                               at libstd/sys/unix/thread.rs:90\r\n  66:     0x7f1f4486f7fb - start_thread\r\n  67:     0x7f1f49660b5e - clone\r\n  68:                0x0 - <unknown>\r\n\r\nnote: the compiler unexpectedly panicked. this is a bug.\r\n\r\nnote: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports\r\n\r\nnote: rustc 1.26.0-nightly (259e4a678 2018-03-04) running on x86_64-unknown-linux-gnu\r\n\r\nnote: compiler flags: -C opt-level=3 -C target-cpu=native\r\n\r\nnote: some of the compiler flags provided by cargo are hidden\r\n```\r\n\r\nI've tried to get a smaller repro but as yet haven't been successful. Below is some code to give an idea of what's going on in case it's useful, but as mentioned something's missing as it doesn't repro.\r\n```\r\nuse std::{thread};\r\nuse std::sync::Arc;\r\nuse std::convert::AsRef;\r\n\r\n#[derive(Debug)]\r\nstruct A(usize);\r\nimpl A {\r\n    fn hello(&self) {\r\n        println!(\"hello {}\", self.0);\r\n    }\r\n    // fn run(abc: Arc<Self>) -> thread::JoinHandle<()> { // works fine\r\n    fn run<X:AsRef<Self>+Send+'static>(abc: X) -> thread::JoinHandle<()> { // ICE\r\n        abc.as_ref().hello();\r\n        thread::spawn(move||{\r\n            let abc = abc;\r\n            let abc: &A = abc.as_ref();\r\n            abc.hello();\r\n        })\r\n    }\r\n}\r\n```\r\nAnd in another crate (if same crate then it works fine):\r\n```\r\nuse std::sync::Arc;\r\nfn main() {\r\n    let abc = A(123);\r\n    A::run(Arc::new(abc)).join().unwrap();\r\n}\r\n```"}}
{"actor":{"display_login":"alecmocatta"}}