}
fn visit_mir(&mut self, mir: &Mir<'tcx>) {
- if let ty::FnConverging(t) = mir.return_ty {
- self.sanitize_type(&"return type", t);
- }
+ self.sanitize_type(&"return type", mir.return_ty);
for var_decl in &mir.var_decls {
self.sanitize_type(var_decl, var_decl.ty);
}
Lvalue::Static(def_id) =>
LvalueTy::Ty { ty: self.tcx().lookup_item_type(def_id).ty },
Lvalue::ReturnPointer => {
- if let ty::FnConverging(return_ty) = self.mir.return_ty {
- LvalueTy::Ty { ty: return_ty }
- } else {
- LvalueTy::Ty {
- ty: span_mirbug_and_err!(
- self, lvalue, "return in diverging function")
- }
- }
+ LvalueTy::Ty { ty: self.mir.return_ty }
}
Lvalue::Projection(ref proj) => {
let base_ty = self.sanitize_lvalue(&proj.base);
sig: &ty::FnSig<'tcx>,
destination: &Option<(Lvalue<'tcx>, BasicBlock)>) {
let tcx = self.tcx();
- match (destination, sig.output) {
- (&Some(..), ty::FnDiverging) => {
- span_mirbug!(self, term, "call to diverging function {:?} with dest", sig);
- }
- (&Some((ref dest, _)), ty::FnConverging(ty)) => {
+ match *destination {
+ Some((ref dest, _)) => {
let dest_ty = dest.ty(mir, tcx).to_ty(tcx);
- if let Err(terr) = self.sub_types(self.last_span, ty, dest_ty) {
+ if let Err(terr) = self.sub_types(self.last_span, sig.output, dest_ty) {
span_mirbug!(self, term,
"call dest mismatch ({:?} <- {:?}): {:?}",
- dest_ty, ty, terr);
+ dest_ty, sig.output, terr);
}
- }
- (&None, ty::FnDiverging) => {}
- (&None, ty::FnConverging(..)) => {
- span_mirbug!(self, term, "call to converging function {:?} w/o dest", sig);
- }
+ },
+ None => {
+ // FIXME(canndrew): This is_never should probably be an is_uninhabited
+ if !sig.output.is_never() {
+ span_mirbug!(self, term, "call to converging function {:?} w/o dest", sig);
+ }
+ },
}
}