Auto merge of #39485 - canndrew:inference-fix-39297, r=nikomatsakis
Ignore expected type in diverging blocks As per comment: https://github.com/rust-lang/rust/issues/39297#issuecomment-276810343
This commit is contained in:
commit
dc0bb3f283
5 changed files with 11 additions and 36 deletions
|
|
@ -4156,17 +4156,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
};
|
||||
|
||||
if self.diverges.get().always() {
|
||||
if let ExpectHasType(ety) = expected {
|
||||
// Avoid forcing a type (only `!` for now) in unreachable code.
|
||||
// FIXME(aburka) do we need this special case? and should it be is_uninhabited?
|
||||
if !ety.is_never() {
|
||||
if let Some(ref e) = blk.expr {
|
||||
// Coerce the tail expression to the right type.
|
||||
self.demand_coerce(e, ty, ety);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ty = self.next_diverging_ty_var(TypeVariableOrigin::DivergingBlockExpr(blk.span));
|
||||
} else if let ExpectHasType(ety) = expected {
|
||||
if let Some(ref e) = blk.expr {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue