Skip to content

Commit 0c7868a

Browse files
committed
rustc_codegen_ssa: simplify test for incompatible dependency formats
thanks @kadiwa4
1 parent 7b3e69e commit 0c7868a

File tree

1 file changed

+10
-15
lines changed
  • compiler/rustc_codegen_ssa/src/back

1 file changed

+10
-15
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

+10-15
Original file line numberDiff line numberDiff line change
@@ -244,22 +244,17 @@ pub fn each_linked_rlib(
244244

245245
fmts
246246
} else {
247-
for combination in info.dependency_formats.iter().combinations(2) {
248-
let (ty1, list1) = &combination[0];
249-
let (ty2, list2) = &combination[1];
250-
if list1 != list2 {
251-
return Err(errors::LinkRlibError::IncompatibleDependencyFormats {
252-
ty1: format!("{ty1:?}"),
253-
ty2: format!("{ty2:?}"),
254-
list1: format!("{list1:?}"),
255-
list2: format!("{list2:?}"),
256-
});
257-
}
258-
}
259-
if info.dependency_formats.is_empty() {
260-
return Err(errors::LinkRlibError::MissingFormat);
247+
let mut dep_formats = info.dependency_formats.iter();
248+
let (ty1, list1) = dep_formats.next().ok_or(errors::LinkRlibError::MissingFormat)?;
249+
if let Some((ty2, list2)) = dep_formats.find(|(_, list2)| list1 != *list2) {
250+
return Err(errors::LinkRlibError::IncompatibleDependencyFormats {
251+
ty1: format!("{ty1:?}"),
252+
ty2: format!("{ty2:?}"),
253+
list1: format!("{list1:?}"),
254+
list2: format!("{list2:?}"),
255+
});
261256
}
262-
info.dependency_formats.first().unwrap().1
257+
list1
263258
};
264259

265260
let used_dep_crates = info.used_crates.iter();

0 commit comments

Comments
 (0)