@@ -518,6 +518,12 @@ pub struct ExternEntry {
518518 /// `--extern nounused:std=/path/to/lib/libstd.rlib`. This is used to
519519 /// suppress `unused-crate-dependencies` warnings.
520520 pub nounused_dep : bool ,
521+ /// If the extern entry is not referenced in the crate, force it to be resolved anyway.
522+ ///
523+ /// Allows a dependency satisfying, for instance, a missing panic handler to be injected
524+ /// without modifying source:
525+ /// `--extern force:extras=/path/to/lib/libstd.rlib`
526+ pub force : bool ,
521527}
522528
523529#[ derive( Clone , Debug ) ]
@@ -556,7 +562,13 @@ impl Externs {
556562
557563impl ExternEntry {
558564 fn new ( location : ExternLocation ) -> ExternEntry {
559- ExternEntry { location, is_private_dep : false , add_prelude : false , nounused_dep : false }
565+ ExternEntry {
566+ location,
567+ is_private_dep : false ,
568+ add_prelude : false ,
569+ nounused_dep : false ,
570+ force : false ,
571+ }
560572 }
561573
562574 pub fn files ( & self ) -> Option < impl Iterator < Item = & CanonicalizedPath > > {
@@ -2261,6 +2273,7 @@ pub fn parse_externs(
22612273 let mut is_private_dep = false ;
22622274 let mut add_prelude = true ;
22632275 let mut nounused_dep = false ;
2276+ let mut force = false ;
22642277 if let Some ( opts) = options {
22652278 if !is_unstable_enabled {
22662279 early_error (
@@ -2283,6 +2296,7 @@ pub fn parse_externs(
22832296 }
22842297 }
22852298 "nounused" => nounused_dep = true ,
2299+ "force" => force = true ,
22862300 _ => early_error ( error_format, & format ! ( "unknown --extern option `{opt}`" ) ) ,
22872301 }
22882302 }
@@ -2293,6 +2307,8 @@ pub fn parse_externs(
22932307 entry. is_private_dep |= is_private_dep;
22942308 // likewise `nounused`
22952309 entry. nounused_dep |= nounused_dep;
2310+ // and `force`
2311+ entry. force |= force;
22962312 // If any flag is missing `noprelude`, then add to the prelude.
22972313 entry. add_prelude |= add_prelude;
22982314 }
0 commit comments