Skip to content

Commit b435eda

Browse files
committed
refactor(lints): Restrict new Manifest::rustflags to being lint_rustflags
This will avoid people reusing it in the future and expanding its use without updating fingerprinting/metadata.
1 parent e4b0136 commit b435eda

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/cargo/core/compiler/fingerprint/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
//! [^5]: Config settings that are not otherwise captured anywhere else.
8888
//! Currently, this is only `doc.extern-map`.
8989
//!
90-
//! [^6]: Via [`Manifest::rustflags`][crate::core::Manifest::rustflags]
90+
//! [^6]: Via [`Manifest::lint_rustflags`][crate::core::Manifest::lint_rustflags]
9191
//!
9292
//! When deciding what should go in the Metadata vs the Fingerprint, consider
9393
//! that some files (like dylibs) do not have a hash in their filename. Thus,
@@ -1417,7 +1417,7 @@ fn calculate_normal(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult<Finger
14171417
unit.mode,
14181418
cx.bcx.extra_args_for(unit),
14191419
cx.lto[unit],
1420-
unit.pkg.manifest().rustflags(),
1420+
unit.pkg.manifest().lint_rustflags(),
14211421
));
14221422
// Include metadata since it is exposed as environment variables.
14231423
let m = unit.pkg.manifest().metadata();

src/cargo/core/compiler/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ fn rustdoc(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult<Work> {
762762
add_error_format_and_color(cx, &mut rustdoc);
763763
add_allow_features(cx, &mut rustdoc);
764764

765-
rustdoc.args(unit.pkg.manifest().rustflags());
765+
rustdoc.args(unit.pkg.manifest().lint_rustflags());
766766
if let Some(args) = cx.bcx.extra_args_for(unit) {
767767
rustdoc.args(args);
768768
}
@@ -1075,7 +1075,7 @@ fn build_base_args(
10751075
cmd.arg("-C").arg(format!("debuginfo={}", debuginfo));
10761076
}
10771077

1078-
cmd.args(unit.pkg.manifest().rustflags());
1078+
cmd.args(unit.pkg.manifest().lint_rustflags());
10791079
if !rustflags.is_empty() {
10801080
cmd.args(&rustflags);
10811081
}

src/cargo/core/manifest.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub struct Manifest {
6363
default_run: Option<String>,
6464
metabuild: Option<Vec<String>>,
6565
resolve_behavior: Option<ResolveBehavior>,
66-
rustflags: Vec<String>,
66+
lint_rustflags: Vec<String>,
6767
}
6868

6969
/// When parsing `Cargo.toml`, some warnings should silenced
@@ -406,7 +406,7 @@ impl Manifest {
406406
original: Rc<TomlManifest>,
407407
metabuild: Option<Vec<String>>,
408408
resolve_behavior: Option<ResolveBehavior>,
409-
rustflags: Vec<String>,
409+
lint_rustflags: Vec<String>,
410410
) -> Manifest {
411411
Manifest {
412412
summary,
@@ -432,7 +432,7 @@ impl Manifest {
432432
default_run,
433433
metabuild,
434434
resolve_behavior,
435-
rustflags,
435+
lint_rustflags,
436436
}
437437
}
438438

@@ -517,9 +517,9 @@ impl Manifest {
517517
self.resolve_behavior
518518
}
519519

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

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

0 commit comments

Comments
 (0)