Skip to content

Commit

Permalink
refactor(lints): Restrict new Manifest::rustflags to being lint_rustf…
Browse files Browse the repository at this point in the history
…lags

This will avoid people reusing it in the future and expanding its use
without updating fingerprinting/metadata.
  • Loading branch information
epage committed May 22, 2023
1 parent e4b0136 commit b435eda
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/cargo/core/compiler/fingerprint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
//! [^5]: Config settings that are not otherwise captured anywhere else.
//! Currently, this is only `doc.extern-map`.
//!
//! [^6]: Via [`Manifest::rustflags`][crate::core::Manifest::rustflags]
//! [^6]: Via [`Manifest::lint_rustflags`][crate::core::Manifest::lint_rustflags]
//!
//! When deciding what should go in the Metadata vs the Fingerprint, consider
//! that some files (like dylibs) do not have a hash in their filename. Thus,
Expand Down Expand Up @@ -1417,7 +1417,7 @@ fn calculate_normal(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult<Finger
unit.mode,
cx.bcx.extra_args_for(unit),
cx.lto[unit],
unit.pkg.manifest().rustflags(),
unit.pkg.manifest().lint_rustflags(),
));
// Include metadata since it is exposed as environment variables.
let m = unit.pkg.manifest().metadata();
Expand Down
4 changes: 2 additions & 2 deletions src/cargo/core/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ fn rustdoc(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult<Work> {
add_error_format_and_color(cx, &mut rustdoc);
add_allow_features(cx, &mut rustdoc);

rustdoc.args(unit.pkg.manifest().rustflags());
rustdoc.args(unit.pkg.manifest().lint_rustflags());
if let Some(args) = cx.bcx.extra_args_for(unit) {
rustdoc.args(args);
}
Expand Down Expand Up @@ -1075,7 +1075,7 @@ fn build_base_args(
cmd.arg("-C").arg(format!("debuginfo={}", debuginfo));
}

cmd.args(unit.pkg.manifest().rustflags());
cmd.args(unit.pkg.manifest().lint_rustflags());
if !rustflags.is_empty() {
cmd.args(&rustflags);
}
Expand Down
12 changes: 6 additions & 6 deletions src/cargo/core/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub struct Manifest {
default_run: Option<String>,
metabuild: Option<Vec<String>>,
resolve_behavior: Option<ResolveBehavior>,
rustflags: Vec<String>,
lint_rustflags: Vec<String>,
}

/// When parsing `Cargo.toml`, some warnings should silenced
Expand Down Expand Up @@ -406,7 +406,7 @@ impl Manifest {
original: Rc<TomlManifest>,
metabuild: Option<Vec<String>>,
resolve_behavior: Option<ResolveBehavior>,
rustflags: Vec<String>,
lint_rustflags: Vec<String>,
) -> Manifest {
Manifest {
summary,
Expand All @@ -432,7 +432,7 @@ impl Manifest {
default_run,
metabuild,
resolve_behavior,
rustflags,
lint_rustflags,
}
}

Expand Down Expand Up @@ -517,9 +517,9 @@ impl Manifest {
self.resolve_behavior
}

/// Package-wide RUSTFLAGS
pub fn rustflags(&self) -> &[String] {
self.rustflags.as_slice()
/// `RUSTFLAGS` from the `[lints]` table
pub fn lint_rustflags(&self) -> &[String] {
self.lint_rustflags.as_slice()
}

pub fn map_source(self, to_replace: SourceId, replace_with: SourceId) -> Manifest {
Expand Down

0 comments on commit b435eda

Please sign in to comment.