Skip to content

Commit 98d65f2

Browse files
authored
Merge pull request #722 from FractalFir/func_refactor
Remove unnecesary uses of the 'current_func' field, replacing it with a call to function.
2 parents 79564c8 + 413821f commit 98d65f2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/intrinsic/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc
426426
match int_type_width_signed(ty, self) {
427427
Some((width, signed)) => match name {
428428
sym::ctlz | sym::cttz => {
429-
let func = self.current_func.borrow().expect("func");
429+
let func = self.current_func();
430430
let then_block = func.new_block("then");
431431
let else_block = func.new_block("else");
432432
let after_block = func.new_block("after");
@@ -1108,7 +1108,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
11081108
// for (int counter = 0; value != 0; counter++) {
11091109
// value &= value - 1;
11101110
// }
1111-
let func = self.current_func.borrow().expect("func");
1111+
let func = self.current_func();
11121112
let loop_head = func.new_block("head");
11131113
let loop_body = func.new_block("body");
11141114
let loop_tail = func.new_block("tail");
@@ -1187,7 +1187,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
11871187
let result_type = lhs.get_type();
11881188
if signed {
11891189
// Based on algorithm from: https://stackoverflow.com/a/56531252/389119
1190-
let func = self.current_func.borrow().expect("func");
1190+
let func = self.current_func();
11911191
let res = func.new_local(self.location, result_type, "saturating_sum");
11921192
let supports_native_type = self.is_native_int_type(result_type);
11931193
let overflow = if supports_native_type {
@@ -1258,7 +1258,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
12581258
let result_type = lhs.get_type();
12591259
if signed {
12601260
// Based on algorithm from: https://stackoverflow.com/a/56531252/389119
1261-
let func = self.current_func.borrow().expect("func");
1261+
let func = self.current_func();
12621262
let res = func.new_local(self.location, result_type, "saturating_diff");
12631263
let supports_native_type = self.is_native_int_type(result_type);
12641264
let overflow = if supports_native_type {

0 commit comments

Comments
 (0)