Add support for nounused
--extern flag
This adds `nounused` to the set of extern flags: `--extern nounused:core=/path/to/core/libcore.rlib`. The effect of this flag is to suppress `unused-crate-dependencies` warnings relating to the crate.
This commit is contained in:
parent
b21759f550
commit
9102edf208
6 changed files with 38 additions and 1 deletions
|
@ -474,6 +474,11 @@ pub struct ExternEntry {
|
|||
/// This can be disabled with the `noprelude` option like
|
||||
/// `--extern noprelude:name`.
|
||||
pub add_prelude: bool,
|
||||
/// The extern entry shouldn't be considered for unused dependency warnings.
|
||||
///
|
||||
/// `--extern nounused:std=/path/to/lib/libstd.rlib`. This is used to
|
||||
/// suppress `unused-crate-dependencies` warnings.
|
||||
pub nounused_dep: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -512,7 +517,7 @@ impl Externs {
|
|||
|
||||
impl ExternEntry {
|
||||
fn new(location: ExternLocation) -> ExternEntry {
|
||||
ExternEntry { location, is_private_dep: false, add_prelude: false }
|
||||
ExternEntry { location, is_private_dep: false, add_prelude: false, nounused_dep: false }
|
||||
}
|
||||
|
||||
pub fn files(&self) -> Option<impl Iterator<Item = &CanonicalizedPath>> {
|
||||
|
@ -2131,6 +2136,7 @@ pub fn parse_externs(
|
|||
|
||||
let mut is_private_dep = false;
|
||||
let mut add_prelude = true;
|
||||
let mut nounused_dep = false;
|
||||
if let Some(opts) = options {
|
||||
if !is_unstable_enabled {
|
||||
early_error(
|
||||
|
@ -2152,6 +2158,7 @@ pub fn parse_externs(
|
|||
);
|
||||
}
|
||||
}
|
||||
"nounused" => nounused_dep = true,
|
||||
_ => early_error(error_format, &format!("unknown --extern option `{opt}`")),
|
||||
}
|
||||
}
|
||||
|
@ -2160,6 +2167,8 @@ pub fn parse_externs(
|
|||
// Crates start out being not private, and go to being private `priv`
|
||||
// is specified.
|
||||
entry.is_private_dep |= is_private_dep;
|
||||
// likewise `nounused`
|
||||
entry.nounused_dep |= nounused_dep;
|
||||
// If any flag is missing `noprelude`, then add to the prelude.
|
||||
entry.add_prelude |= add_prelude;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue