Skip to content

Commit ae59413

Browse files
committed
fix(desktop): restore const fn AppState::new for clippy 1.95
clippy 1.95's missing_const_for_fn correctly identifies AppState::new as a pure field-assignment body. The Batch I WHY comment about WorkerGuard blocking const was wrong — WorkerGuard construction happens in the caller, not inside new().
1 parent ce4c704 commit ae59413

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

crates/desktop/src/state.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl AppState {
9292
/// invariant — callers that forget to pass `container` get a compile
9393
/// error rather than a silently missing dependency.
9494
#[must_use]
95-
pub fn new(
95+
pub const fn new(
9696
data_dir: PathBuf,
9797
device_id: DeviceId,
9898
metadata_repo: Arc<SqliteMetadataRepository>,
@@ -101,8 +101,10 @@ impl AppState {
101101
container: Arc<AppContainer>,
102102
log_guard: tracing_appender::non_blocking::WorkerGuard,
103103
) -> Self {
104-
// WHY `const` removed: `WorkerGuard` involves heap allocation and a
105-
// background-thread spawn — neither is const-constructible. (Batch I Task 4.)
104+
// WHY const restored: clippy 1.95's missing_const_for_fn fires here
105+
// because the body is purely field assignment — no heap alloc inside
106+
// this fn. The earlier WHY ("WorkerGuard blocks const") was wrong:
107+
// construction of WorkerGuard happens in the *caller*, not here.
106108
Self {
107109
data_dir,
108110
device_id,

0 commit comments

Comments
 (0)