Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions compiler/rustc_codegen_ssa/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,19 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
caller_location: None,
};

if mir.args_iter().any(|arg| {
// Find the monomorphized type of our argument
let arg_decl = &mir.local_decls[arg];
let arg_ty = fx.monomorphize(arg_decl.ty);

// And check if it is a reference to an uninhabited type
let ty = arg_ty.peel_refs();
start_bx.layout_of(ty).abi.is_uninhabited()
}) {
start_bx.unreachable();
return;
}

// It may seem like we should iterate over `required_consts` to ensure they all successfully
// evaluate; however, the `MirUsedCollector` already did that during the collection phase of
// monomorphization so we don't have to do it again.
Expand Down