Change:
I tried this code: I expected to see this happen: for this code to compile, or throw an error Instead, this happened: i broke the compiler : rustc 1.26.1 ( 2018-05-25) binary: rustc commit-hash: commit-date: 2018-05-25 host: x86_64-unknown-linux-gnu release: 1.26.1 LLVM version: 6.0 Backtrace:
Latest nightly seems to give more information, it might be a issue. thread 'main' panicked at 'called on an value: (MoveData { movepaths: [MovePath { place: 0 }, MovePath { place: 1 }, MovePath { place: 2 }, MovePath { place: 3 }, MovePath { place: 4 }, MovePath { place: 5 }], moves: [mp4 mp5 mp5 mp4 mp3 mp3 mp3 mp0 locmap: LocationMap { map: [[[], [], [], [], [], [], [mo0, mo1]], [[]], [[mo2], [mo3], [mo4]], [[mo5]], [[mo6], [mo7]]] }, pathmap: [[mo7], [], [], [mo4, mo5, mo6], [mo0, mo3], [mo1, mo2]], revlookup: MovePathLookup { locals: [mp0, mp1, mp2, mp3, mp4, mp5], projections: {} }, inits: [ 40:57 (Deep), 40:36 (Deep), 40:32 (Deep), 40:43 (Deep), 40:57 (Deep), 40:57 (NonPanicPathOnly)], initlocmap: LocationMap { map: [[[], [in2], [], [in3], [], [in4], [in5]], [[]], [[], [], []], [[]], [[], []]] }, initpathmap: [[in5], [in0], [in1], [in2], [in3], [in4]] }, [IllegalMove { cannotmoveoutof: IllegalMoveOrigin { span: 40:32, kind: BorrowedContent } }])', stack backtrace: 0: std::sys::unix::backtrace::tracing::imp::unwindbacktrace at 1: std::syscommon::backtrace::print at at 2: std::panicking::defaulthook::{{closure}} at 3: std::panicking::defaulthook at 4: rustc::util::common::panichook 5: std::panicking::rustpanicwithhook at 6: std::panicking::continuepanicfmt at 7: rustbeginunwind at 8: core::panicking::panicfmt at 9: core::result::unwrapfailed 10: <rustcmir::transform::elaboratedrops::ElaborateDrops as rustcmir::transform::MirPass::runpass 11: rustcmir::transform::optimizedmir::{{closure}} 12: rustcmir::transform::optimizedmir 13: rustc::ty::maps::querycompute::optimizedmir 14: rustc::ty::maps::<impl rustc::ty::maps::config::QueryConfig<'tcxfor rustc::ty::maps::queries::optimizedmir<'tcx::compute 15: rustc::ty::context::tls::withcontext 16: rustc::depgraph::graph::DepGraph::withtaskimpl 17: rustc::ty::context::tls::withrelatedcontext 18: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx::forcequerywithjob 19: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx::getquery 20: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx::optimizedmir 21: rustcmetadata::encoder::<impl rustcmetadata::isolatedencoder::IsolatedEncoder<'a, 'b, 'tcx::encodeoptimizedmir 22: rustcmetadata::encoder::<impl rustcmetadata::isolatedencoder::IsolatedEncoder<'a, 'b, 'tcx::encodeinfoforclosure 23: rustc::ty::context::tls::withcontext 24: rustcmetadata::encoder::<impl rustcmetadata::indexbuilder::IndexBuilder<'a, 'b, 'tcx::encodeinfoforexpr 25: rustc::hir::intravisit::walkexpr 26: rustc::hir::intravisit::walkexpr 27: rustc::hir::intravisit::walkexpr 28: rustc::hir::intravisit::walkexpr 29: rustc::hir::intravisit::walkexpr 30: rustc::hir::intravisit::walklocal 31: rustc::hir::intravisit::walkexpr 32: rustc::hir::intravisit::Visitor::visitnestedbody 33: rustc::hir::Crate::visitallitemlikes 34: rustcmetadata::encoder::encodemetadata 35: rustcmetadata::cstoreimpl::<impl rustc::middle::cstore::CrateStore for rustcmetadata::cstore::CStore::encodemetadata 36: rustc::ty::context::TyCtxt::encodemetadata 37: rustccodegenllvm::base::writemetadata 38: rustc::util::common::time 39: rustccodegenllvm::base::codegencrate 40: <rustccodegenllvm::LlvmCodegenBackend as rustccodegenutils::codegenbackend::CodegenBackend::codegencrate 41: rustc::util::common::time 42: rustcdriver::driver::phase4codegen 43: rustcdriver::driver::compileinput::{{closure}} 44: rustc::ty::context::tls::entercontext 45: <std::thread::local::LocalKey<T::with 46: rustc::ty::context::TyCtxt::createandenter 47: rustcdriver::driver::compileinput 48: rustcdriver::runcompilerwithpool 49: <scopedtls::ScopedKey<T::set 50: syntax::withglobals 51: <std::panic::AssertUnwindSafe<Fas core::ops::function::FnOnce<()::callonce 52: rustmaybecatchpanic at 53: rustcdriver::run 54: rustcdriver::main 55: std::rt::langstart::{{closure}} 56: std::panicking::try::docall at at 57: rustmaybecatchpanic at 58: std::rt::langstartinternal at at at 59: main 60: libcstartmain 61: <unknownquery stack during panic: [optimizedmir] processing end of query stack error: internal compiler error: unexpected panic note: the compiler unexpectedly panicked. this is a bug. note: we would appreciate a bug report: note: rustc 1.28.0-nightly ( 2018-06-03) running on x8664-unknown-linux-gnu note: compiler flags: -C debuginfo=2 -C incremental --crate-type lib note: some of the compiler flags provided by cargo are hidden error: Could not compile .
():
Is this test OK? Where can I store this?
That seems about right add the file to and run .

Discussion:
<ins> use std::any::TypeId; use std::collections::HashMap; use std::hash::Hash; trait State { type EventType; fn get_type_id_of_state(&self) -> TypeId; } struct StateMachine<EventType: Hash + Eq> { current_state: Box<dyn State<EventType = EventType>>, transition_table: HashMap<TypeId, HashMap<EventType, fn() -> Box<dyn State<EventType = EventType>>>>, } impl<EventType: Hash + Eq> StateMachine<EventType> { fn inner_process_event(&mut self, event: EventType) -> Result<(), i8> { let new_state_creation_function = self .transition_table .iter() .find(|(&event_typeid, _)| event_typeid == self.current_state.get_type_id_of_state()) .ok_or(1)? .1 .iter() .find(|(&event_type, _)| event == event_type) //~^ ERROR cannot move out of a shared reference .ok_or(2)? .1; self.current_state = new_state_creation_function(); Ok(()) } } fn main() {} </ins>

<ins> error[E0507]: cannot move out of a shared reference --> $DIR/issue-51301.rs:25:20 | LL |             .find(|(&event_type, _)| event == event_type) |                    ^^----------^^^^ |                      | |                      data moved here |                      move occurs because `event_type` has type `EventType`, which does not implement the `Copy` trait error: aborting due to previous error For more information about this error, try `rustc --explain E0507`. </ins>