Skip to content

Commit da1b04d

Browse files
committed
More rust cleanup
- Fixed the documentation icon using local files (thank you @mkrasnitski) - Fixed labels being updated and overwriting the label location used to update the label map
1 parent 2a7195f commit da1b04d

File tree

3 files changed

+27
-18
lines changed

3 files changed

+27
-18
lines changed

rust/build.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
use std::path::PathBuf;
22

33
fn main() {
4-
// TODO : Enable the following when https://github.com/rust-lang/rust/issues/43781 stabilizes
5-
// #[cfg(doc)]
6-
let _ = std::fs::create_dir("target");
7-
let _ = std::fs::create_dir("target/doc");
8-
let _ = std::fs::copy("../docs/img/favicon.ico", "target/doc/favicon.ico");
9-
let _ = std::fs::copy("../docs/img/logo.png", "target/doc/logo.png");
10-
114
let link_path =
125
std::env::var_os("DEP_BINARYNINJACORE_PATH").expect("DEP_BINARYNINJACORE_PATH specified");
136

rust/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#![allow(clippy::too_many_arguments)]
2020
#![allow(clippy::needless_doctest_main)]
2121
#![doc(html_root_url = "https://dev-rust.binary.ninja/")]
22-
#![doc(html_favicon_url = "/favicon.ico")]
23-
#![doc(html_logo_url = "/logo.png")]
22+
#![doc(html_favicon_url = "https://binary.ninja/icons/favicon-32x32.png")]
23+
#![doc(html_logo_url = "https://binary.ninja/icons/android-chrome-512x512.png")]
2424
#![doc(issue_tracker_base_url = "https://github.com/Vector35/binaryninja-api/issues/")]
2525
#![doc = include_str!("../README.md")]
2626

rust/src/low_level_il/lifting.rs

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,11 +1119,19 @@ where
11191119
};
11201120

11211121
// Update the labels after they have been resolved.
1122-
*true_label = LowLevelILLabel::from(raw_true_label);
1123-
*false_label = LowLevelILLabel::from(raw_false_label);
1124-
self.update_label_map_for_label(true_label);
1125-
self.update_label_map_for_label(false_label);
1126-
1122+
let mut new_true_label = LowLevelILLabel::from(raw_true_label);
1123+
let mut new_false_label = LowLevelILLabel::from(raw_false_label);
1124+
if let Some(location) = true_label.location {
1125+
new_true_label.location = Some(location);
1126+
self.update_label_map_for_label(&new_true_label);
1127+
}
1128+
if let Some(location) = false_label.location {
1129+
new_false_label.location = Some(location);
1130+
self.update_label_map_for_label(&new_false_label);
1131+
}
1132+
*true_label = new_true_label;
1133+
*false_label = new_false_label;
1134+
11271135
LowLevelILExpression::new(self, LowLevelExpressionIndex(expr_idx))
11281136
}
11291137

@@ -1138,8 +1146,12 @@ where
11381146
let expr_idx = unsafe { BNLowLevelILGoto(self.handle, &mut raw_label) };
11391147

11401148
// Update the labels after they have been resolved.
1141-
*label = LowLevelILLabel::from(raw_label);
1142-
self.update_label_map_for_label(label);
1149+
let mut new_label = LowLevelILLabel::from(raw_label);
1150+
if let Some(location) = label.location {
1151+
new_label.location = Some(location);
1152+
self.update_label_map_for_label(&new_label);
1153+
}
1154+
*label = new_label;
11431155

11441156
LowLevelILExpression::new(self, LowLevelExpressionIndex(expr_idx))
11451157
}
@@ -1594,8 +1606,12 @@ where
15941606

15951607
let mut raw_label = BNLowLevelILLabel::from(*label);
15961608
unsafe { BNLowLevelILMarkLabel(self.handle, &mut raw_label) };
1597-
*label = LowLevelILLabel::from(raw_label);
1598-
self.update_label_map_for_label(label);
1609+
let mut new_label = LowLevelILLabel::from(raw_label);
1610+
if let Some(location) = label.location {
1611+
new_label.location = Some(location);
1612+
self.update_label_map_for_label(&new_label);
1613+
}
1614+
*label = new_label;
15991615
}
16001616
}
16011617

0 commit comments

Comments
 (0)