@@ -1618,8 +1618,20 @@ fn select_debuginfo(
16181618 }
16191619}
16201620
1621- fn parse_native_lib_kind ( kind : & str , error_format : ErrorOutputType ) -> NativeLibKind {
1622- match kind {
1621+ fn parse_native_lib_kind (
1622+ matches : & getopts:: Matches ,
1623+ kind : & str ,
1624+ error_format : ErrorOutputType ,
1625+ ) -> ( NativeLibKind , Option < bool > ) {
1626+ let is_nightly = nightly_options:: match_is_nightly_build ( matches) ;
1627+ let enable_unstable = nightly_options:: is_unstable_enabled ( matches) ;
1628+
1629+ let ( kind, modifiers) = match kind. split_once ( ':' ) {
1630+ None => ( kind, None ) ,
1631+ Some ( ( kind, modifiers) ) => ( kind, Some ( modifiers) ) ,
1632+ } ;
1633+
1634+ let kind = match kind {
16231635 "dylib" => NativeLibKind :: Dylib { as_needed : None } ,
16241636 "framework" => NativeLibKind :: Framework { as_needed : None } ,
16251637 "static" => NativeLibKind :: Static { bundle : None , whole_archive : None } ,
@@ -1629,17 +1641,49 @@ fn parse_native_lib_kind(kind: &str, error_format: ErrorOutputType) -> NativeLib
16291641 "library kind `static-nobundle` has been superseded by specifying \
16301642 `-bundle` on library kind `static`. Try `static:-bundle`",
16311643 ) ;
1644+ if modifiers. is_some ( ) {
1645+ early_error (
1646+ error_format,
1647+ "linking modifier can't be used with library kind `static-nobundle`" ,
1648+ )
1649+ }
1650+ if !is_nightly {
1651+ early_error (
1652+ error_format,
1653+ "library kind `static-nobundle` are currently unstable and only accepted on \
1654+ the nightly compiler",
1655+ ) ;
1656+ }
16321657 NativeLibKind :: Static { bundle : Some ( false ) , whole_archive : None }
16331658 }
16341659 s => early_error (
16351660 error_format,
16361661 & format ! ( "unknown library kind `{}`, expected one of dylib, framework, or static" , s) ,
16371662 ) ,
1663+ } ;
1664+ match modifiers {
1665+ None => ( kind, None ) ,
1666+ Some ( modifiers) => {
1667+ if !is_nightly {
1668+ early_error (
1669+ error_format,
1670+ "linking modifiers are currently unstable and only accepted on \
1671+ the nightly compiler",
1672+ ) ;
1673+ }
1674+ if !enable_unstable {
1675+ early_error (
1676+ error_format,
1677+ "linking modifiers are currently unstable, \
1678+ the `-Z unstable-options` flag must also be passed to use it",
1679+ )
1680+ }
1681+ parse_native_lib_modifiers ( kind, modifiers, error_format)
1682+ }
16381683 }
16391684}
16401685
16411686fn parse_native_lib_modifiers (
1642- is_nightly : bool ,
16431687 mut kind : NativeLibKind ,
16441688 modifiers : & str ,
16451689 error_format : ErrorOutputType ,
@@ -1655,14 +1699,6 @@ fn parse_native_lib_modifiers(
16551699 ) ,
16561700 } ;
16571701
1658- if !is_nightly {
1659- early_error (
1660- error_format,
1661- "linking modifiers are currently unstable and only accepted on \
1662- the nightly compiler",
1663- ) ;
1664- }
1665-
16661702 match ( modifier, & mut kind) {
16671703 ( "bundle" , NativeLibKind :: Static { bundle, .. } ) => {
16681704 * bundle = Some ( value) ;
@@ -1709,7 +1745,6 @@ fn parse_native_lib_modifiers(
17091745}
17101746
17111747fn parse_libs ( matches : & getopts:: Matches , error_format : ErrorOutputType ) -> Vec < NativeLib > {
1712- let is_nightly = nightly_options:: match_is_nightly_build ( matches) ;
17131748 matches
17141749 . opt_strs ( "l" )
17151750 . into_iter ( )
@@ -1723,13 +1758,7 @@ fn parse_libs(matches: &getopts::Matches, error_format: ErrorOutputType) -> Vec<
17231758 let ( name, kind, verbatim) = match s. split_once ( '=' ) {
17241759 None => ( s, NativeLibKind :: Unspecified , None ) ,
17251760 Some ( ( kind, name) ) => {
1726- let ( kind, verbatim) = match kind. split_once ( ':' ) {
1727- None => ( parse_native_lib_kind ( kind, error_format) , None ) ,
1728- Some ( ( kind, modifiers) ) => {
1729- let kind = parse_native_lib_kind ( kind, error_format) ;
1730- parse_native_lib_modifiers ( is_nightly, kind, modifiers, error_format)
1731- }
1732- } ;
1761+ let ( kind, verbatim) = parse_native_lib_kind ( matches, kind, error_format) ;
17331762 ( name. to_string ( ) , kind, verbatim)
17341763 }
17351764 } ;
0 commit comments