Skip to content

Commit 2fb53c0

Browse files
committed
fix(materialized_artifact): build on Windows & allow reparameterized suffix lifetime
- `.executable()` was `fn(mut self)` with the write to `self.executable` inside `#[cfg(unix)]` — on Windows the `mut` was unused and tripped `-D unused_mut`. Added a `#[cfg_attr(not(unix), expect(unused_mut, ...))]`. - `.suffix(&str)` now re-parameterizes the builder's lifetime to the new suffix's so a `Materialize<'static>` can still accept a short-lived suffix. Lifetimes are elided to keep the signature tidy.
1 parent 51245da commit 2fb53c0

File tree

1 file changed

+9
-4
lines changed
  • crates/materialized_artifact/src

1 file changed

+9
-4
lines changed

crates/materialized_artifact/src/lib.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,21 @@ pub struct Materialize<'a> {
9191
executable: bool,
9292
}
9393

94-
impl<'a> Materialize<'a> {
94+
impl Materialize<'_> {
9595
/// Filename suffix appended after `{name}_{hash}` (e.g. `.dll`, `.dylib`).
9696
/// Defaults to empty.
97-
pub const fn suffix(mut self, suffix: &'a str) -> Self {
98-
self.suffix = suffix;
99-
self
97+
pub const fn suffix(self, suffix: &str) -> Materialize<'_> {
98+
Materialize {
99+
artifact: self.artifact,
100+
suffix,
101+
#[cfg(unix)]
102+
executable: self.executable,
103+
}
100104
}
101105

102106
/// Mark the materialized file as executable (`0o755` on Unix; no-op on
103107
/// Windows where the filesystem has no executable bit).
108+
#[cfg_attr(not(unix), expect(unused_mut, reason = "executable is Unix-only"))]
104109
pub const fn executable(mut self) -> Self {
105110
#[cfg(unix)]
106111
{

0 commit comments

Comments
 (0)