From c22f154e3fb6eca7dd1e83575564a5ea44d661bc Mon Sep 17 00:00:00 2001 From: yukang Date: Fri, 17 Mar 2023 07:59:08 +0800 Subject: [PATCH] Do not ICE for native_lib without name --- compiler/rustc_metadata/src/native_libs.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_metadata/src/native_libs.rs b/compiler/rustc_metadata/src/native_libs.rs index d6f68b2e140..6b6aa78575a 100644 --- a/compiler/rustc_metadata/src/native_libs.rs +++ b/compiler/rustc_metadata/src/native_libs.rs @@ -53,12 +53,13 @@ fn find_bundled_library( sess: &Session, ) -> Option { if let NativeLibKind::Static { bundle: Some(true) | None, whole_archive } = kind + && let Some(name) = name && sess.crate_types().iter().any(|t| matches!(t, &CrateType::Rlib | CrateType::Staticlib)) && (sess.opts.unstable_opts.packed_bundled_libs || has_cfg || whole_archive == Some(true)) { let verbatim = verbatim.unwrap_or(false); let search_paths = &sess.target_filesearch(PathKind::Native).search_path_dirs(); - return find_native_static_library(name.unwrap().as_str(), verbatim, search_paths, sess) + return find_native_static_library(name.as_str(), verbatim, search_paths, sess) .file_name() .and_then(|s| s.to_str()) .map(Symbol::intern);