Skip to content

Commit 6d2080c

Browse files
author
Jakub Bukaj
committed
Address review comments
1 parent 7f523e7 commit 6d2080c

File tree

4 files changed

+9
-12
lines changed

4 files changed

+9
-12
lines changed

src/librustc/middle/liveness.rs

+2
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@
104104
* fallthrough node. It is only live if the function could converge
105105
* via means other than an explicit `return` expression. That is, it is
106106
* only dead if the end of the function's block can never be reached.
107+
* It is the responsibility of typeck to ensure that there are no
108+
* `return` expressions in a function declared as diverging.
107109
*/
108110

109111
use middle::def::*;

src/librustc/middle/trans/callee.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -876,11 +876,8 @@ pub fn trans_call_inner<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
876876
_ => {}
877877
}
878878

879-
match ret_ty {
880-
ty::FnConverging(_) => {},
881-
ty::FnDiverging => {
882-
Unreachable(bcx);
883-
}
879+
if ret_ty == ty::FnDiverging {
880+
Unreachable(bcx);
884881
}
885882

886883
Result::new(bcx, llresult)

src/librustc/middle/trans/intrinsic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ pub fn trans_intrinsic_call<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, node: ast::N
204204

205205
fcx.pop_custom_cleanup_scope(cleanup_scope);
206206

207-
// The only intrinsic function that diverges.
207+
// These are the only intrinsic functions that diverge.
208208
if name.get() == "abort" {
209209
let llfn = ccx.get_intrinsic(&("llvm.trap"));
210210
Call(bcx, llfn, [], None);

src/librustc/util/ppaux.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -957,12 +957,10 @@ impl Repr for ty::FnSig {
957957
impl Repr for ty::FnOutput {
958958
fn repr(&self, tcx: &ctxt) -> String {
959959
match *self {
960-
ty::FnConverging(ty) => {
961-
format!("FnConverging({0})", ty.repr(tcx))
962-
}
963-
ty::FnDiverging => {
964-
"FnDiverging".to_string()
965-
}
960+
ty::FnConverging(ty) =>
961+
format!("FnConverging({0})", ty.repr(tcx)),
962+
ty::FnDiverging =>
963+
"FnDiverging".to_string()
966964
}
967965
}
968966
}

0 commit comments

Comments
 (0)