impl<'tcx> EnclosingBreakables<'tcx> {
fn find_breakable(&mut self, target_id: hir::HirId) -> &mut BreakableCtxt<'tcx> {
- let ix = *self.by_id.get(&target_id).unwrap_or_else(|| {
+ self.opt_find_breakable(target_id).unwrap_or_else(|| {
bug!("could not find enclosing breakable with id {}", target_id);
- });
- &mut self.stack[ix]
+ })
+ }
+
+ fn opt_find_breakable(&mut self, target_id: hir::HirId) -> Option<&mut BreakableCtxt<'tcx>> {
+ match self.by_id.get(&target_id) {
+ Some(ix) => Some(&mut self.stack[*ix]),
+ None => None,
+ }
}
}
fn report_unexpected_variant_res(tcx: TyCtxt<'_>, res: Res, span: Span, qpath: &QPath) {
span_err!(tcx.sess, span, E0533,
- "expected unit struct/variant or constant, found {} `{}`",
+ "expected unit struct, unit variant or constant, found {} `{}`",
res.descr(),
hir::print::to_string(tcx.hir(), |s| s.print_qpath(qpath, false)));
}
let mut opaque_types = self.opaque_types.borrow_mut();
for (ty, decl) in opaque_type_map {
- let old_value = opaque_types.insert(ty, decl);
- assert!(old_value.is_none(), "instantiated twice: {:?}/{:?}", ty, decl);
+ let _ = opaque_types.insert(ty, decl);
}
value