about summary refs log tree commit diff
path: root/compiler/rustc_session/src/utils.rs
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2022-02-11 15:08:35 +0800
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2022-03-30 23:53:21 +0300
commit1004783ef9bdcf006f0ed33badacf83a5934feb2 (patch)
tree9db8e33f5809076953c29ae6e7bc569266f48130 /compiler/rustc_session/src/utils.rs
parentbb5c437a2ce9ccf2204c974300c5ea9eb32d3635 (diff)
downloadrust-1004783ef9bdcf006f0ed33badacf83a5934feb2.tar.gz
rust-1004783ef9bdcf006f0ed33badacf83a5934feb2.zip
Stabilize native library modifier syntax and the `whole-archive` modifier specifically
Diffstat (limited to 'compiler/rustc_session/src/utils.rs')
-rw-r--r--compiler/rustc_session/src/utils.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/compiler/rustc_session/src/utils.rs b/compiler/rustc_session/src/utils.rs
index a33f94013d2..6a8775bd10b 100644
--- a/compiler/rustc_session/src/utils.rs
+++ b/compiler/rustc_session/src/utils.rs
@@ -43,6 +43,20 @@ pub enum NativeLibKind {
     Unspecified,
 }
 
+impl NativeLibKind {
+    pub fn has_modifiers(&self) -> bool {
+        match self {
+            NativeLibKind::Static { bundle, whole_archive } => {
+                bundle.is_some() || whole_archive.is_some()
+            }
+            NativeLibKind::Dylib { as_needed } | NativeLibKind::Framework { as_needed } => {
+                as_needed.is_some()
+            }
+            NativeLibKind::RawDylib | NativeLibKind::Unspecified => false,
+        }
+    }
+}
+
 rustc_data_structures::impl_stable_hash_via_hash!(NativeLibKind);
 
 #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Encodable, Decodable)]
@@ -53,6 +67,12 @@ pub struct NativeLib {
     pub verbatim: Option<bool>,
 }
 
+impl NativeLib {
+    pub fn has_modifiers(&self) -> bool {
+        self.verbatim.is_some() || self.kind.has_modifiers()
+    }
+}
+
 rustc_data_structures::impl_stable_hash_via_hash!(NativeLib);
 
 /// A path that has been canonicalized along with its original, non-canonicalized form