@@ -518,6 +518,12 @@ pub struct ExternEntry {
518
518
/// `--extern nounused:std=/path/to/lib/libstd.rlib`. This is used to
519
519
/// suppress `unused-crate-dependencies` warnings.
520
520
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 ,
521
527
}
522
528
523
529
#[ derive( Clone , Debug ) ]
@@ -556,7 +562,13 @@ impl Externs {
556
562
557
563
impl ExternEntry {
558
564
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
+ }
560
572
}
561
573
562
574
pub fn files ( & self ) -> Option < impl Iterator < Item = & CanonicalizedPath > > {
@@ -2261,6 +2273,7 @@ pub fn parse_externs(
2261
2273
let mut is_private_dep = false ;
2262
2274
let mut add_prelude = true ;
2263
2275
let mut nounused_dep = false ;
2276
+ let mut force = false ;
2264
2277
if let Some ( opts) = options {
2265
2278
if !is_unstable_enabled {
2266
2279
early_error (
@@ -2283,6 +2296,7 @@ pub fn parse_externs(
2283
2296
}
2284
2297
}
2285
2298
"nounused" => nounused_dep = true ,
2299
+ "force" => force = true ,
2286
2300
_ => early_error ( error_format, & format ! ( "unknown --extern option `{opt}`" ) ) ,
2287
2301
}
2288
2302
}
@@ -2293,6 +2307,8 @@ pub fn parse_externs(
2293
2307
entry. is_private_dep |= is_private_dep;
2294
2308
// likewise `nounused`
2295
2309
entry. nounused_dep |= nounused_dep;
2310
+ // and `force`
2311
+ entry. force |= force;
2296
2312
// If any flag is missing `noprelude`, then add to the prelude.
2297
2313
entry. add_prelude |= add_prelude;
2298
2314
}
0 commit comments