Skip to content

Commit 4595430

Browse files
committed
Update for API change in rust-lang#175.
Also remove unused imports.
1 parent b15b9e4 commit 4595430

File tree

1 file changed

+38
-40
lines changed

1 file changed

+38
-40
lines changed

tests/all/test_object_file.rs

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
extern crate inkwell;
22

33
use self::inkwell::context::Context;
4-
use self::inkwell::module::Module;
54
use self::inkwell::targets::{
6-
ByteOrdering, CodeModel, FileType, InitializationConfig, RelocMode, Target, TargetData,
7-
TargetMachine, TargetTriple,
5+
CodeModel, FileType, InitializationConfig, RelocMode, Target, TargetMachine,
86
};
97
use self::inkwell::values::BasicValue;
108
use self::inkwell::OptimizationLevel;
@@ -56,28 +54,26 @@ fn test_section_iterator() {
5654
let mut has_section_a = false;
5755
let mut has_section_b = false;
5856
let mut has_section_c = false;
59-
for (i, section) in object_file.get_sections().enumerate() {
60-
// TODO: the first section has no name, skip it.
61-
if i == 0 {
62-
continue;
63-
}
64-
match section.get_name().to_str().unwrap() {
65-
"A" => {
66-
assert!(!has_section_a);
67-
has_section_a = true;
68-
assert_eq!(section.size(), 1);
69-
}
70-
"B" => {
71-
assert!(!has_section_b);
72-
has_section_b = true;
73-
assert_eq!(section.size(), 2);
74-
}
75-
"C" => {
76-
assert!(!has_section_c);
77-
has_section_c = true;
78-
assert_eq!(section.size(), 4);
57+
for section in object_file.get_sections() {
58+
if let Some(name) = section.get_name() {
59+
match name.to_str().unwrap() {
60+
"A" => {
61+
assert!(!has_section_a);
62+
has_section_a = true;
63+
assert_eq!(section.size(), 1);
64+
}
65+
"B" => {
66+
assert!(!has_section_b);
67+
has_section_b = true;
68+
assert_eq!(section.size(), 2);
69+
}
70+
"C" => {
71+
assert!(!has_section_c);
72+
has_section_c = true;
73+
assert_eq!(section.size(), 4);
74+
}
75+
_ => {}
7976
}
80-
_ => {}
8177
}
8278
}
8379
assert!(has_section_a);
@@ -112,23 +108,25 @@ fn test_symbol_iterator() {
112108
let mut has_symbol_b = false;
113109
let mut has_symbol_c = false;
114110
for symbol in object_file.get_symbols() {
115-
match symbol.get_name().to_str().unwrap() {
116-
"a" => {
117-
assert!(!has_symbol_a);
118-
has_symbol_a = true;
119-
assert_eq!(symbol.size(), 1);
120-
}
121-
"b" => {
122-
assert!(!has_symbol_b);
123-
has_symbol_b = true;
124-
assert_eq!(symbol.size(), 2);
125-
}
126-
"c" => {
127-
assert!(!has_symbol_c);
128-
has_symbol_c = true;
129-
assert_eq!(symbol.size(), 4);
111+
if let Some(name) = symbol.get_name() {
112+
match name.to_str().unwrap() {
113+
"a" => {
114+
assert!(!has_symbol_a);
115+
has_symbol_a = true;
116+
assert_eq!(symbol.size(), 1);
117+
}
118+
"b" => {
119+
assert!(!has_symbol_b);
120+
has_symbol_b = true;
121+
assert_eq!(symbol.size(), 2);
122+
}
123+
"c" => {
124+
assert!(!has_symbol_c);
125+
has_symbol_c = true;
126+
assert_eq!(symbol.size(), 4);
127+
}
128+
_ => {}
130129
}
131-
_ => {}
132130
}
133131
}
134132
assert!(has_symbol_a);

0 commit comments

Comments
 (0)