Skip to content

Commit dd5137b

Browse files
authored
Rollup merge of rust-lang#35883 - durka:gh35849, r=eddyb
typeck: use NoExpectation to check return type of diverging fn Fixes rust-lang#35849. Thanks @eddyb.
2 parents 47b891a + 9d53faf commit dd5137b

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/librustc_typeck/check/mod.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,12 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
708708

709709
inherited.tables.borrow_mut().liberated_fn_sigs.insert(fn_id, fn_sig);
710710

711-
fcx.check_block_with_expected(body, ExpectHasType(fcx.ret_ty));
711+
let expected = if fcx.ret_ty.is_never() {
712+
NoExpectation
713+
} else {
714+
ExpectHasType(fcx.ret_ty)
715+
};
716+
fcx.check_block_with_expected(body, expected);
712717

713718
fcx
714719
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn _assert_sizeof() -> ! {
12+
unsafe {
13+
::std::mem::transmute::<f64, [u8; 8]>(panic!())
14+
}
15+
}
16+
17+
fn main() { }
18+

0 commit comments

Comments
 (0)