diff options
| author | Yotam Ofek <yotam.ofek@gmail.com> | 2025-02-02 13:08:51 +0000 |
|---|---|---|
| committer | Yotam Ofek <yotam.ofek@gmail.com> | 2025-02-11 12:44:07 +0000 |
| commit | a82178564184c167954472f0079cf8773ee0b485 (patch) | |
| tree | b5f7a24055110ad8b3834f0a05866ed6d3bea9c2 /compiler/rustc_codegen_ssa/src/back | |
| parent | 9e5e6a9d0fc95d7f5a22ca8da0816d407977c674 (diff) | |
| download | rust-a82178564184c167954472f0079cf8773ee0b485.tar.gz rust-a82178564184c167954472f0079cf8773ee0b485.zip | |
rustc_codegen_ssa: simplify test for incompatible dependency formats
thanks @kadiwa4
Diffstat (limited to 'compiler/rustc_codegen_ssa/src/back')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/link.rs | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index c592cf347b5..6e30c6c1451 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -244,22 +244,17 @@ pub fn each_linked_rlib( fmts } else { - for combination in info.dependency_formats.iter().combinations(2) { - let (ty1, list1) = &combination[0]; - let (ty2, list2) = &combination[1]; - if list1 != list2 { - return Err(errors::LinkRlibError::IncompatibleDependencyFormats { - ty1: format!("{ty1:?}"), - ty2: format!("{ty2:?}"), - list1: format!("{list1:?}"), - list2: format!("{list2:?}"), - }); - } - } - if info.dependency_formats.is_empty() { - return Err(errors::LinkRlibError::MissingFormat); + let mut dep_formats = info.dependency_formats.iter(); + let (ty1, list1) = dep_formats.next().ok_or(errors::LinkRlibError::MissingFormat)?; + if let Some((ty2, list2)) = dep_formats.find(|(_, list2)| list1 != *list2) { + return Err(errors::LinkRlibError::IncompatibleDependencyFormats { + ty1: format!("{ty1:?}"), + ty2: format!("{ty2:?}"), + list1: format!("{list1:?}"), + list2: format!("{list2:?}"), + }); } - info.dependency_formats.first().unwrap().1 + list1 }; let used_dep_crates = info.used_crates.iter(); |
