Skip to content

Commit e37dd19

Browse files
committed
refactor: tighten dead-code allows post-integration
Module-wide #![allow(dead_code)] on change_tracker and structure_tracker was a rollout-time concession ("many items public for the upcoming UI integration"). Integration is done; replace the broad allows with targeted ones that document the actual reason each survivor stays around. - change_tracker: drop module #![allow], drop function-level allows on open_tab / close_tab / any_pending_globally / pending_tabs (all now used in production), keep test-only `new` / `can_undo` / `can_redo` behind #[cfg(test)] so they compile out of release. - structure_tracker: same pattern; RenameColumn / ReorderColumn ops remain because materialize knows them but the UI doesn't yet emit, so each carries a documented #[allow(dead_code)] with a comment instead of the module-wide silence. - structure_tab: drop the placeholder #[allow(dead_code)] on StructureTabOutput — every variant has an emit site now. - error_text: build_sql_message is test-only, gate via #[cfg(test)] + matching #[cfg(test)] use of BuildSqlError. driver_message is used in three production sites; drop the allow. - app/mod TableTabSlot: drop struct-level allow; every field is read. - AppMsg: drop the enum-level allow that hid every variant; keep two narrow item-level allows on UndoActiveStructureTab / RedoActiveStructureTab (handlers exist, no emit-site yet) so any future stale variant surfaces as a real warning. Net effect: the codebase compiles with `cargo build --workspace` clean of warnings, AND `cargo clippy -D warnings` passes. Future dead code now surfaces immediately instead of being absorbed by broad allows.
1 parent cc18bce commit e37dd19

5 files changed

Lines changed: 26 additions & 24 deletions

File tree

linux/crates/app/src/services/change_tracker.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@
2525
//! Tests should construct a fresh `ChangeTrackerRegistry::new()` to
2626
//! avoid contaminating each other through the thread-local global.
2727
28-
// Many items are public for the upcoming UI integration but unused
29-
// at this point of the rollout — silence dead-code warnings module-
30-
// wide rather than annotating each item.
31-
#![allow(dead_code)]
32-
3328
use std::cell::RefCell;
3429
use std::collections::{HashMap, VecDeque};
3530

@@ -204,6 +199,7 @@ pub struct TabChangeTracker {
204199
}
205200

206201
impl TabChangeTracker {
202+
#[cfg(test)]
207203
pub fn new() -> Self {
208204
Self::default()
209205
}
@@ -416,10 +412,12 @@ impl TabChangeTracker {
416412
Some(op)
417413
}
418414

415+
#[cfg(test)]
419416
pub fn can_undo(&self) -> bool {
420417
!self.undo.is_empty()
421418
}
422419

420+
#[cfg(test)]
423421
pub fn can_redo(&self) -> bool {
424422
!self.redo.is_empty()
425423
}
@@ -753,26 +751,22 @@ where
753751
}
754752

755753
/// Open a tracker for a tab. Idempotent.
756-
#[allow(dead_code)]
757754
pub fn open_tab(tab_id: Uuid) {
758755
REGISTRY.with(|reg| reg.borrow_mut().open_tab(tab_id));
759756
}
760757

761758
/// Drop a tab's tracker. Called when the BrowseTab is closed.
762-
#[allow(dead_code)]
763759
pub fn close_tab(tab_id: Uuid) {
764760
REGISTRY.with(|reg| reg.borrow_mut().close_tab(tab_id));
765761
}
766762

767763
/// True if any open tab has pending changes — used by the app-level
768764
/// quit guard to decide whether to show the "Unsaved changes" dialog.
769-
#[allow(dead_code)]
770765
pub fn any_pending_globally() -> bool {
771766
REGISTRY.with(|reg| reg.borrow().any_pending())
772767
}
773768

774769
/// Tabs with pending changes — ordered arbitrary (HashMap iteration).
775-
#[allow(dead_code)]
776770
pub fn pending_tabs() -> Vec<Uuid> {
777771
REGISTRY.with(|reg| reg.borrow().pending_tabs())
778772
}

linux/crates/app/src/services/structure_tracker.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
//! `StructureTrackerRegistry::new()` instances to avoid contaminating
1515
//! each other through the thread-local global.
1616
17-
#![allow(dead_code)]
18-
1917
use std::cell::RefCell;
2018
use std::collections::{HashMap, VecDeque};
2119

@@ -60,6 +58,12 @@ pub enum StructureOp {
6058
table: String,
6159
column_name: String,
6260
},
61+
/// Renames a column inline. The Structure tab UI doesn't yet
62+
/// expose this op as a dedicated affordance — column-name edits
63+
/// today round-trip through Drop+Add via the AlterColumn path —
64+
/// but `materialize` knows how to emit the SQL when a future UI
65+
/// flow pushes it.
66+
#[allow(dead_code)]
6367
RenameColumn {
6468
schema: Option<String>,
6569
table: String,
@@ -75,7 +79,11 @@ pub enum StructureOp {
7579
table: String,
7680
column: DraftColumn,
7781
},
78-
/// MySQL-only. `after = None` means FIRST.
82+
/// MySQL-only column reorder via `MODIFY COLUMN ... AFTER`.
83+
/// `after = None` means `FIRST`. Drag-reorder UI not yet wired —
84+
/// the materialize path is in place so adding the gesture later
85+
/// is one UI commit.
86+
#[allow(dead_code)]
7987
ReorderColumn {
8088
schema: Option<String>,
8189
table: String,
@@ -134,6 +142,7 @@ pub struct StructureChangeTracker {
134142
}
135143

136144
impl StructureChangeTracker {
145+
#[cfg(test)]
137146
pub fn new() -> Self {
138147
Self::default()
139148
}
@@ -213,10 +222,12 @@ impl StructureChangeTracker {
213222
Some(forward)
214223
}
215224

225+
#[cfg(test)]
216226
pub fn can_undo(&self) -> bool {
217227
!self.undo.is_empty()
218228
}
219229

230+
#[cfg(test)]
220231
pub fn can_redo(&self) -> bool {
221232
!self.redo.is_empty()
222233
}

linux/crates/app/src/ui/app/mod.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ pub enum TableMode {
151151
/// parallel inside an `AdwViewStack`. Switching `mode` flips the
152152
/// stack's visible child without destroying state on the inactive
153153
/// side; pending-change trackers, pagination, sort, search remain.
154-
#[allow(dead_code)]
155154
pub struct TableTabSlot {
156155
pub id: Uuid,
157156
pub page: adw::TabPage,
@@ -251,11 +250,6 @@ pub(super) fn read_workspace_tab_id(page: &adw::TabPage) -> Option<Uuid> {
251250
unsafe { page.qdata::<Uuid>(workspace_tab_id_quark()).map(|p| *p.as_ref()) }
252251
}
253252

254-
// `UndoActiveStructureTab` / `RedoActiveStructureTab` are the only
255-
// variants without a current emit site (Structure tab Ctrl+Z/Y will
256-
// fire them in a follow-up commit alongside the full UI). Carrying
257-
// the keep-alive on the enum is cheaper than annotating each variant.
258-
#[allow(dead_code)]
259253
#[derive(Debug)]
260254
pub enum AppMsg {
261255
OpenConnect,
@@ -475,9 +469,14 @@ pub enum AppMsg {
475469
/// the sidebar factory without going through the full Connected
476470
/// path.
477471
TablesReloaded(Vec<TableInfo>),
478-
/// Ctrl+Z on a Structure tab.
472+
/// Ctrl+Z on a Structure tab. The Structure-side Ctrl+Z UI is
473+
/// not yet wired; the handler is in place so the keybinding
474+
/// can be added in a one-line follow-up.
475+
#[allow(dead_code)]
479476
UndoActiveStructureTab,
480-
/// Ctrl+Y on a Structure tab.
477+
/// Ctrl+Y on a Structure tab. Same status as
478+
/// `UndoActiveStructureTab`.
479+
#[allow(dead_code)]
481480
RedoActiveStructureTab,
482481
}
483482

linux/crates/app/src/ui/error_text.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use tablepro_core::DriverError;
2-
2+
#[cfg(test)]
33
use tablepro_core::sql_dialect::BuildSqlError;
44

5-
#[allow(dead_code)]
5+
#[cfg(test)]
66
pub fn build_sql_message(error: &BuildSqlError) -> String {
77
match error {
88
BuildSqlError::NoPrimaryKey => crate::tr!("This table has no primary key. Use the modal Edit dialog instead."),
@@ -15,7 +15,6 @@ pub fn build_sql_message(error: &BuildSqlError) -> String {
1515
}
1616
}
1717

18-
#[allow(dead_code)]
1918
pub fn driver_message(error: &DriverError) -> String {
2019
match error {
2120
DriverError::ConnectionRefused => crate::tr!("Could not reach the database. Is it running?"),

linux/crates/app/src/ui/structure_tab.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ pub enum ColumnField {
239239
Default(Option<String>),
240240
}
241241

242-
#[allow(dead_code)]
243242
#[derive(Debug)]
244243
pub enum StructureTabOutput {
245244
DirtyChanged(bool),

0 commit comments

Comments
 (0)