Make dependency_formats an FxIndexMap rather than a list of tuples · rust-lang/rust@6b595ee (original) (raw)

`@@ -236,7 +236,13 @@ pub fn each_linked_rlib(

`

236

236

`) -> Result<(), errors::LinkRlibError> {

`

237

237

`let crates = info.used_crates.iter();

`

238

238

``

239

``

`-

let fmts = if crate_type.is_none() {

`

``

239

`+

let fmts = if let Some(crate_type) = crate_type {

`

``

240

`+

let Some(fmts) = info.dependency_formats.get(&crate_type) else {

`

``

241

`+

return Err(errors::LinkRlibError::MissingFormat);

`

``

242

`+

};

`

``

243

+

``

244

`+

fmts

`

``

245

`+

} else {

`

240

246

`for combination in info.dependency_formats.iter().combinations(2) {

`

241

247

`let (ty1, list1) = &combination[0];

`

242

248

`let (ty2, list2) = &combination[1];

`

`@@ -252,18 +258,7 @@ pub fn each_linked_rlib(

`

252

258

`if info.dependency_formats.is_empty() {

`

253

259

`return Err(errors::LinkRlibError::MissingFormat);

`

254

260

`}

`

255

``

`-

&info.dependency_formats[0].1

`

256

``

`-

} else {

`

257

``

`-

let fmts = info

`

258

``

`-

.dependency_formats

`

259

``

`-

.iter()

`

260

``

`-

.find_map(|&(ty, ref list)| if Some(ty) == crate_type { Some(list) } else { None });

`

261

``

-

262

``

`-

let Some(fmts) = fmts else {

`

263

``

`-

return Err(errors::LinkRlibError::MissingFormat);

`

264

``

`-

};

`

265

``

-

266

``

`-

fmts

`

``

261

`+

info.dependency_formats.first().unwrap().1

`

267

262

`};

`

268

263

``

269

264

`for &cnum in crates {

`

`@@ -624,8 +619,7 @@ fn link_staticlib(

`

624

619

`let fmts = codegen_results

`

625

620

`.crate_info

`

626

621

`.dependency_formats

`

627

``

`-

.iter()

`

628

``

`-

.find_map(|&(ty, ref list)| if ty == CrateType::Staticlib { Some(list) } else { None })

`

``

622

`+

.get(&CrateType::Staticlib)

`

629

623

`.expect("no dependency formats for staticlib");

`

630

624

``

631

625

`let mut all_rust_dylibs = vec![];

`

`@@ -2355,11 +2349,10 @@ fn linker_with_args(

`

2355

2349

`// they are used within inlined functions or instantiated generic functions. We do this after

`

2356

2350

`// handling the raw-dylib symbols in the current crate to make sure that those are chosen first

`

2357

2351

`// by the linker.

`

2358

``

`-

let (_, dependency_linkage) = codegen_results

`

``

2352

`+

let dependency_linkage = codegen_results

`

2359

2353

`.crate_info

`

2360

2354

`.dependency_formats

`

2361

``

`-

.iter()

`

2362

``

`-

.find(|(ty, _)| *ty == crate_type)

`

``

2355

`+

.get(&crate_type)

`

2363

2356

`.expect("failed to find crate type in dependency format list");

`

2364

2357

``

2365

2358

`// We sort the libraries below

`

`@@ -2738,11 +2731,10 @@ fn add_upstream_rust_crates(

`

2738

2731

`// Linking to a rlib involves just passing it to the linker (the linker

`

2739

2732

`// will slurp up the object files inside), and linking to a dynamic library

`

2740

2733

`// involves just passing the right -l flag.

`

2741

``

`-

let (_, data) = codegen_results

`

``

2734

`+

let data = codegen_results

`

2742

2735

`.crate_info

`

2743

2736

`.dependency_formats

`

2744

``

`-

.iter()

`

2745

``

`-

.find(|(ty, _)| *ty == crate_type)

`

``

2737

`+

.get(&crate_type)

`

2746

2738

`.expect("failed to find crate type in dependency format list");

`

2747

2739

``

2748

2740

`if sess.target.is_like_aix {

`