diff --git a/frontend/src/lib.rs b/frontend/src/lib.rs index f403097e..ac5fbcab 100644 --- a/frontend/src/lib.rs +++ b/frontend/src/lib.rs @@ -1,9 +1,6 @@ //! Quon frontend — lexer, parser, type checker, and AST→IR lowering. -//! -//! Stub implementations in this crate are expanded in issues #5–#16. #![allow( - dead_code, clippy::new_without_default, clippy::large_enum_variant, // `TypeError` carries resolved `Ty`s (with symbolic `Circuit`/`QReg` dimensions) for diff --git a/frontend/src/lower.rs b/frontend/src/lower.rs index b996c6e9..592be693 100644 --- a/frontend/src/lower.rs +++ b/frontend/src/lower.rs @@ -99,8 +99,6 @@ pub struct LoweringCtx<'c> { struct FuncMeta { depth: DepthExpr, clifford: bool, - in_qubits: i64, - out_qubits: i64, } struct GateSpec { @@ -149,7 +147,7 @@ impl<'c> LoweringCtx<'c> { && let Ok(ret_ty @ Ty::Circuit { .. }) = self.checker.resolve_type(ret) { if params.is_empty() { - let Ty::Circuit { n, m, d, c } = ret_ty else { + let Ty::Circuit { n: _, m: _, d, c } = ret_ty else { unreachable!("matched above"); }; self.func_meta.insert( @@ -157,8 +155,6 @@ impl<'c> LoweringCtx<'c> { FuncMeta { depth: d, clifford: matches!(c, CliffordClass::Clifford), - in_qubits: const_width(&n, "in_qubits")?, - out_qubits: const_width(&m, "out_qubits")?, }, ); Arc::make_mut(&mut self.bodies).insert(name.0.clone(), body.clone()); @@ -287,8 +283,6 @@ impl<'c> LoweringCtx<'c> { FuncMeta { depth: depth.clone(), clifford, - in_qubits, - out_qubits, }, ); Arc::make_mut(&mut self.bodies).insert(name.to_string(), body.clone()); diff --git a/frontend/src/specialized_circuit.rs b/frontend/src/specialized_circuit.rs index 571fb381..6d72ee3b 100644 --- a/frontend/src/specialized_circuit.rs +++ b/frontend/src/specialized_circuit.rs @@ -26,6 +26,7 @@ use std::collections::HashMap; +#[cfg(test)] use chumsky::span::SimpleSpan; use quon_core::DepthExpr; use thiserror::Error; @@ -390,6 +391,7 @@ fn literal_usize(expr: &Expr) -> Option { } } +#[cfg(test)] fn no_span() -> SimpleSpan { SimpleSpan::from(0..0) } diff --git a/frontend/src/typecheck/mod.rs b/frontend/src/typecheck/mod.rs index 4ae2f92e..93f10dee 100644 --- a/frontend/src/typecheck/mod.rs +++ b/frontend/src/typecheck/mod.rs @@ -1419,15 +1419,6 @@ impl TypeChecker { } } - /// Evaluate a `Nat` expression to a concrete `u64`, when it is closed and literal. - /// Symbolic naturals are rejected — the classical fragment has no value-dependent types. - fn eval_nat(&self, n: &Sp) -> Result { - eval_nat(&n.0).ok_or(TypeError::Unsupported { - construct: "symbolic Nat in type", - span: n.1, - }) - } - /// Convert a surface depth annotation to a [`DepthExpr`]. Best-effort for the classical /// fragment: literals/vars/`+`/`*` map directly; richer forms defer to issue #13. /// Rejects `CodeFamily` tags and `F: CodeFamily` params in Nat position. @@ -2301,27 +2292,6 @@ fn eval_angle(e: &Sp) -> Option { } } -fn eval_nat(n: &NatExpr) -> Option { - Some(match n { - NatExpr::Lit(v) => *v, - NatExpr::Var(_) | NatExpr::Hole => return None, - NatExpr::Add(a, b) => eval_nat(&a.0)?.checked_add(eval_nat(&b.0)?)?, - NatExpr::Mul(a, b) => eval_nat(&a.0)?.checked_mul(eval_nat(&b.0)?)?, - NatExpr::Sub(a, b) => eval_nat(&a.0)?.saturating_sub(eval_nat(&b.0)?), - NatExpr::Div(a, b) => { - let d = eval_nat(&b.0)?; - if d == 0 { - return None; - } - eval_nat(&a.0)? / d - } - NatExpr::Exp(a, b) => { - let exp = u32::try_from(eval_nat(&b.0)?).ok()?; - eval_nat(&a.0)?.checked_pow(exp)? - } - }) -} - fn nat_to_depth(n: &NatExpr) -> Option { Some(match n { NatExpr::Lit(v) => DepthExpr::Nat(*v), diff --git a/frontend/tests/support/mod.rs b/frontend/tests/support/mod.rs index b6b404b4..b988cb2e 100644 --- a/frontend/tests/support/mod.rs +++ b/frontend/tests/support/mod.rs @@ -1,11 +1,10 @@ // Shared test support: normalize every span in an AST to 0..0 so that structural // equality (derived PartialEq) compares trees while ignoring source positions. -#![allow(dead_code)] - use frontend::ast::*; use frontend::lexer::{SimpleSpan, Sp}; +#[allow(dead_code)] // shared test helper — not every test uses every strip helper fn z() -> SimpleSpan { (0..0).into() } @@ -18,16 +17,19 @@ macro_rules! go { }}; } +#[allow(dead_code)] // shared test helper — not every test uses every strip helper pub fn strip_decls(decls: &mut [Sp]) { for d in decls.iter_mut() { go!(d, strip_decl); } } +#[allow(dead_code)] // shared test helper — not every test uses every strip helper fn strip_sp_name(n: &mut Sp) { n.1 = z(); } +#[allow(dead_code)] // shared test helper — not every test uses every strip helper fn strip_decl(d: &mut Decl) { match d { Decl::Fn { @@ -65,6 +67,7 @@ fn strip_decl(d: &mut Decl) { } } +#[allow(dead_code)] // shared test helper — not every test uses every strip helper fn strip_nat(n: &mut NatExpr) { match n { NatExpr::Lit(_) | NatExpr::Var(_) | NatExpr::Hole => {} @@ -79,6 +82,7 @@ fn strip_nat(n: &mut NatExpr) { } } +#[allow(dead_code)] // shared test helper — not every test uses every strip helper fn strip_ty(t: &mut Type) { match t { Type::Qubit @@ -122,6 +126,7 @@ fn strip_ty(t: &mut Type) { } } +#[allow(dead_code)] // shared test helper — not every test uses every strip helper fn strip_pat(p: &mut Pat) { match p { Pat::Wildcard | Pat::Var(_) | Pat::Lit(_) => {} @@ -133,6 +138,7 @@ fn strip_pat(p: &mut Pat) { } } +#[allow(dead_code)] // shared test helper — not every test uses every strip helper fn strip_stmt(s: &mut Stmt) { match s { Stmt::Bind { pat, rhs } | Stmt::Let { pat, rhs } => { @@ -143,6 +149,7 @@ fn strip_stmt(s: &mut Stmt) { } } +#[allow(dead_code)] // shared test helper — not every test uses every strip helper fn strip_expr(e: &mut Expr) { match e { Expr::Int(_) | Expr::Float(_) | Expr::Bool(_) | Expr::Unit | Expr::Var(_) => {} @@ -239,6 +246,7 @@ fn strip_expr(e: &mut Expr) { } /// Parse source into a span-stripped AST, panicking with diagnostics on failure. +#[allow(dead_code)] // shared test helper — not every test uses every strip helper pub fn parse_stripped(src: &str) -> Vec> { let mut decls = frontend::parse_program(src).expect("parse failed"); strip_decls(&mut decls); diff --git a/mlir_bridge/src/emit/openqasm3.rs b/mlir_bridge/src/emit/openqasm3.rs index c244f2e2..5465064c 100644 --- a/mlir_bridge/src/emit/openqasm3.rs +++ b/mlir_bridge/src/emit/openqasm3.rs @@ -117,8 +117,6 @@ fn is_rotation(name: &str) -> bool { struct Reifier<'t> { qubits: HashMap, bits: HashMap, - num_qubits: usize, - num_bits: usize, next_qubit: usize, next_bit: usize, native: HashSet, @@ -337,8 +335,6 @@ pub fn reify(module: &Module, target: &BackendTarget) -> Result { kind: DefKind, } -struct QubitUse<'c> { +struct QubitUse { user_name: String, - location: Location<'c>, is_measure: bool, } @@ -79,7 +78,7 @@ fn is_measure_op(name: &str) -> bool { pub fn check_dynamic_linearity<'c>(region: RegionRef<'c, '_>) -> Diagnostics<'c> { let mut diagnostics = Diagnostics::new(); let mut defs = Vec::new(); - let mut uses: HashMap>> = HashMap::new(); + let mut uses: HashMap> = HashMap::new(); collect_dynamic_scope(region, &mut defs, &mut uses, &mut diagnostics); check_scope(&defs, &uses, &mut diagnostics); diagnostics @@ -88,7 +87,7 @@ pub fn check_dynamic_linearity<'c>(region: RegionRef<'c, '_>) -> Diagnostics<'c> fn collect_dynamic_scope<'c>( region: RegionRef<'c, '_>, defs: &mut Vec>, - uses: &mut HashMap>>, + uses: &mut HashMap>, diagnostics: &mut Diagnostics<'c>, ) { let mut block = region.first_block(); @@ -150,7 +149,7 @@ fn collect_dynamic_scope<'c>( fn check_scope<'c>( defs: &[QubitDef<'c>], - uses: &HashMap>>, + uses: &HashMap>, diagnostics: &mut Diagnostics<'c>, ) { for def in defs { @@ -185,14 +184,13 @@ fn check_scope<'c>( fn record_qubit_operands<'c: 'a, 'a, O: OperationLike<'c, 'a>>( operation: &O, - uses: &mut HashMap>>, + uses: &mut HashMap>, ) { let name = op_name(operation); for operand in operation.operands() { if is_qubit(&operand) { uses.entry(value_key(&operand)).or_default().push(QubitUse { user_name: name.clone(), - location: operand.location(), is_measure: is_measure_op(&name), }); } diff --git a/mlir_bridge/src/passes/native_gate_decomp.rs b/mlir_bridge/src/passes/native_gate_decomp.rs index bbd731b7..149c3408 100644 --- a/mlir_bridge/src/passes/native_gate_decomp.rs +++ b/mlir_bridge/src/passes/native_gate_decomp.rs @@ -64,10 +64,6 @@ fn read_f64_attr<'c: 'a, 'a, O: OperationLike<'c, 'a>>(operation: &O, key: &str) FloatAttribute::try_from(value).ok().map(|f| f.value()) } -fn value_key<'a>(value: &impl ValueLike<'a>) -> usize { - value.to_raw().ptr as usize -} - fn native_gate_names(target: &FixedTarget) -> Vec { target.native_gates.iter().map(|g| g.name.clone()).collect() } diff --git a/mlir_bridge/tests/support/mod.rs b/mlir_bridge/tests/support/mod.rs index bcba3142..a569c5b6 100644 --- a/mlir_bridge/tests/support/mod.rs +++ b/mlir_bridge/tests/support/mod.rs @@ -21,6 +21,7 @@ use mlir_bridge::dialect::quantum_dynamic as qd; use quon_core::DepthExpr; /// A context with the `quantum.circ` dialect registered. +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn context() -> Context { let context = Context::new(); qc::register_dialect(&context); @@ -28,6 +29,7 @@ pub fn context() -> Context { } /// A context with both `quantum.circ` and `quantum.dynamic` registered. +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn dynamic_context() -> Context { let context = Context::new(); qc::register_dialect(&context); @@ -35,39 +37,47 @@ pub fn dynamic_context() -> Context { context } +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn i64_attr(context: &Context, value: i64) -> Attribute<'_> { IntegerAttribute::new(IntegerType::new(context, 64).into(), value).into() } +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn str_attr<'c>(context: &'c Context, value: &str) -> Attribute<'c> { StringAttribute::new(context, value).into() } +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn bool_attr(context: &Context, value: bool) -> Attribute<'_> { BoolAttribute::new(context, value).into() } +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn i32_attr(context: &Context, value: i32) -> Attribute<'_> { IntegerAttribute::new(IntegerType::new(context, 32).into(), i64::from(value)).into() } +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn f64_attr(context: &Context, value: f64) -> Attribute<'_> { let float_type = Type::parse(context, "f64").unwrap_or_else(|| Type::none(context)); FloatAttribute::new(context, float_type, value).into() } +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn f32_attr(context: &Context, value: f64) -> Attribute<'_> { let float_type = Type::parse(context, "f32").unwrap_or_else(|| Type::none(context)); FloatAttribute::new(context, float_type, value).into() } /// A serialized depth attribute (a string, per ADR-0002). +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn depth_attr<'c>(context: &'c Context, depth: &DepthExpr) -> Attribute<'c> { str_attr(context, &depth.to_sexpr()) } /// A detached block whose arguments source SSA values of the requested types. /// Keep the returned block alive for as long as the values are used. +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn scratch_block<'c>(types: &[Type<'c>], location: Location<'c>) -> Block<'c> { let args: Vec<(Type, Location)> = types.iter().map(|t| (*t, location)).collect(); Block::new(&args) @@ -75,6 +85,8 @@ pub fn scratch_block<'c>(types: &[Type<'c>], location: Location<'c>) -> Block<'c /// Appends a verified `quantum.dynamic.alloc` op producing one fresh /// `!quantum.qubit` (issue #401 — replaces the unregistered `test.qubit`). +/// Appends a foreign op to `body` that produces one `!quantum.qubit`. +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn append_foreign_qubit<'c: 'a, 'a, B: BlockLike<'c, 'a>>( context: &'c Context, body: &B, @@ -88,12 +100,14 @@ pub fn append_foreign_qubit<'c: 'a, 'a, B: BlockLike<'c, 'a>>( } /// The module's top-level region — the linearity scope for dynamic tests. +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn module_region<'c>(module: &'c Module<'c>) -> melior::ir::RegionRef<'c, 'c> { module.as_operation().region(0).expect("module region") } /// Builds an op in MLIR's generic form **without** running the dialect verifier. /// Used to construct deliberately-malformed ops for verifier tests. +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn generic_op<'c>( context: &'c Context, name: &str, @@ -117,6 +131,7 @@ pub fn generic_op<'c>( } /// A region containing a single empty block — a minimal well-formed body. +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn empty_body() -> Region<'static> { let region = Region::new(); region.append_block(Block::new(&[])); @@ -124,6 +139,7 @@ pub fn empty_body() -> Region<'static> { } /// Builds `func @main(%q: !qubit) -> !qubit { %r = gate "H" %q; return %r }`. +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn bell_like_module(context: &Context) -> Module<'_> { let location = Location::unknown(context); let qubit = qc::qubit_type(context); diff --git a/quon_lsp/tests/support/fixture.rs b/quon_lsp/tests/support/fixture.rs index 683a5b66..7dc96a50 100644 --- a/quon_lsp/tests/support/fixture.rs +++ b/quon_lsp/tests/support/fixture.rs @@ -10,14 +10,17 @@ use quon_lsp::intel::{ semantic_tokens_full, signature_help_at, }; +#[allow(dead_code)] // shared test helper — not every integration test uses every helper fn fixture_url() -> Url { Url::parse("file:///test.qn").expect("url") } +#[allow(dead_code)] // shared test helper — not every integration test uses every helper fn analyze_fixture(src: &str) -> frontend::AnalysisResult { analyze(src) } +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn position_after_marker(src: &str) -> Position { let offset = cursor_at(src, "/*cursor*/"); let before = src[..offset].replace("/*cursor*/", ""); @@ -32,10 +35,12 @@ pub fn position_after_marker(src: &str) -> Position { } } +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn src_without_marker(src: &str) -> String { src.replace("/*cursor*/", "") } +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn hover_markdown(src: &str) -> Option { let clean = src_without_marker(src); let pos = position_after_marker(src); @@ -47,6 +52,7 @@ pub fn hover_markdown(src: &str) -> Option { } } +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn definition_at_marker(src: &str) -> Option { let clean = src_without_marker(src); let pos = position_after_marker(src); @@ -59,6 +65,7 @@ pub fn definition_at_marker(src: &str) -> Option { } } +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn references_at_marker( src: &str, include_declaration: bool, @@ -70,6 +77,7 @@ pub fn references_at_marker( references_at(&result.intelligence, &uri, pos, include_declaration) } +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn highlights_at_marker(src: &str) -> Option> { let clean = src_without_marker(src); let pos = position_after_marker(src); @@ -77,6 +85,7 @@ pub fn highlights_at_marker(src: &str) -> Option tower_lsp::jsonrpc::Result> { @@ -86,6 +95,7 @@ pub fn prepare_rename_at_marker( prepare_rename_at(&result.intelligence, pos) } +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn rename_at_marker( src: &str, new_name: &str, @@ -97,6 +107,7 @@ pub fn rename_at_marker( rename_at(&result.intelligence, &uri, pos, new_name) } +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn completion_items(src: &str) -> Vec { let clean = src_without_marker(src); let pos = position_after_marker(src); @@ -108,10 +119,12 @@ pub fn completion_items(src: &str) -> Vec { } } +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn completion_labels(src: &str) -> Vec { completion_items(src).into_iter().map(|i| i.label).collect() } +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn signature_help_at_marker(src: &str) -> Option { let clean = src_without_marker(src); let pos = position_after_marker(src); @@ -119,6 +132,7 @@ pub fn signature_help_at_marker(src: &str) -> Option { signature_help_at(&result.intelligence, pos) } +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn semantic_token_count(src: &str) -> usize { let result = analyze_fixture(src); let tokens = semantic_tokens_full( @@ -135,6 +149,7 @@ pub fn semantic_token_count(src: &str) -> usize { } } +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn document_symbol_names(src: &str) -> Vec { let result = analyze_fixture(src); let resp = document_symbols(&result.intelligence).expect("document symbols"); @@ -148,6 +163,7 @@ pub fn document_symbol_names(src: &str) -> Vec { names } +#[allow(dead_code)] // shared test helper — not every integration test uses every helper fn collect_symbol_names(syms: &[tower_lsp::lsp_types::DocumentSymbol], out: &mut Vec) { for s in syms { out.push(s.name.clone()); @@ -157,6 +173,7 @@ fn collect_symbol_names(syms: &[tower_lsp::lsp_types::DocumentSymbol], out: &mut } } +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn folding_range_count(src: &str) -> usize { let result = analyze_fixture(src); folding_ranges(&result.intelligence) @@ -164,6 +181,7 @@ pub fn folding_range_count(src: &str) -> usize { .unwrap_or(0) } +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn inlay_hint_labels(src: &str) -> Vec { let result = analyze_fixture(src); let range = full_document_range(&result.intelligence.src); @@ -179,7 +197,7 @@ pub fn inlay_hint_labels(src: &str) -> Vec { .collect() } -#[allow(dead_code)] +#[allow(dead_code)] // shared test helper — used by integration tests that need a full document range pub fn full_range(src: &str) -> Range { full_document_range(src) } diff --git a/quon_lsp/tests/support/lsp_client.rs b/quon_lsp/tests/support/lsp_client.rs index 03b7dc5f..9e435e73 100644 --- a/quon_lsp/tests/support/lsp_client.rs +++ b/quon_lsp/tests/support/lsp_client.rs @@ -1,5 +1,4 @@ //! JSON-RPC framing client for integration tests. -#![allow(dead_code)] use std::io::{BufRead, BufReader, Read, Write}; use std::process::{Child, Command, Stdio}; @@ -25,10 +24,12 @@ pub struct LspClient { } impl LspClient { +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn spawn() -> Self { Self::spawn_with_env(&[]) } +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn spawn_with_env(extra_env: &[(&str, &str)]) -> Self { let mut cmd = Command::new(env!("CARGO_BIN_EXE_quon_lsp")); cmd.stdin(Stdio::piped()) @@ -57,6 +58,7 @@ impl LspClient { } } +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn send_request(&mut self, method: &str, params: Option) { let id = self.next_id; self.next_id += 1; @@ -71,17 +73,20 @@ impl LspClient { self.pending_response_id = Some(id); } +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn recv_response(&mut self) -> Value { let id = self.pending_response_id.expect("no pending request"); self.pending_response_id = None; self.wait_response(id) } +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn send_request_with_response(&mut self, method: &str, params: Option) -> Value { self.send_request(method, params); self.recv_response() } +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn send_notification(&mut self, method: &str, params: Value) { let msg = json!({ "jsonrpc": "2.0", @@ -91,6 +96,7 @@ impl LspClient { write_message(&mut self.stdin, &msg); } +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn wait_notification(&self, method: &str, timeout: Duration) -> Option { let deadline = std::time::Instant::now() + timeout; while std::time::Instant::now() < deadline { @@ -103,6 +109,7 @@ impl LspClient { None } +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn wait_publish_diagnostics(&self, uri: &str, timeout: Duration) -> Option { let deadline = std::time::Instant::now() + timeout; while std::time::Instant::now() < deadline { @@ -118,6 +125,7 @@ impl LspClient { None } +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn shutdown_and_exit(mut self) { self.send_request("shutdown", None); let _ = self.recv_response(); @@ -127,6 +135,7 @@ impl LspClient { let _ = self.child.wait(); } +#[allow(dead_code)] // shared test helper — not every integration test uses every helper fn wait_response(&self, id: i64) -> Value { let deadline = std::time::Instant::now() + Duration::from_secs(10); while std::time::Instant::now() < deadline { @@ -144,6 +153,7 @@ impl LspClient { } impl Drop for LspClient { +#[allow(dead_code)] // shared test helper — not every integration test uses every helper fn drop(&mut self) { if !self.graceful_shutdown { let _ = self.child.kill(); @@ -151,6 +161,7 @@ impl Drop for LspClient { } } +#[allow(dead_code)] // shared test helper — not every integration test uses every helper fn write_message(stdin: &mut Option, msg: &Value) { let body = serde_json::to_string(msg).expect("serialize"); let header = format!("Content-Length: {}\r\n\r\n", body.len()); @@ -160,6 +171,7 @@ fn write_message(stdin: &mut Option, msg: &Value) { stdin.flush().expect("flush"); } +#[allow(dead_code)] // shared test helper — not every integration test uses every helper fn read_loop( stdout: impl Read + Send + 'static, responses: Sender, diff --git a/quon_lsp/tests/support/mod.rs b/quon_lsp/tests/support/mod.rs index ce32f337..90b74ff7 100644 --- a/quon_lsp/tests/support/mod.rs +++ b/quon_lsp/tests/support/mod.rs @@ -1,4 +1,2 @@ -#![allow(dead_code)] - pub mod fixture; pub mod lsp_client; diff --git a/quon_na/src/movement/bank.rs b/quon_na/src/movement/bank.rs index 570b93d4..f4ad3122 100644 --- a/quon_na/src/movement/bank.rs +++ b/quon_na/src/movement/bank.rs @@ -7,10 +7,9 @@ //! - [`ensure_interaction_pairs`] is idempotent: if a bank already exists with //! enough pairs, it returns them without appending. -use std::collections::{BTreeMap, BTreeSet}; +use std::collections::BTreeMap; use crate::layout::{AtomSite, NeutralAtomLayout, Position, SiteId, TrapBinding}; -use crate::movement::geometry::POS_EPS_UM; use crate::movement::types::{ BANK_ISOLATION_EPS_UM, InteractionPair, MovementParams, MovementPlanError, }; @@ -231,14 +230,3 @@ pub(crate) fn free_interaction_pairs( .collect() } -// Unused but kept for parity with original code's internal helpers. -#[allow(dead_code)] -pub(crate) fn _pos_eps() -> f64 { - POS_EPS_UM -} - -// Re-export BTreeSet for callers that need the OrderedF64 type. -#[allow(dead_code)] -pub(crate) fn _ordered_f64_set() -> BTreeSet { - BTreeSet::new() -} diff --git a/quon_qec/src/expand.rs b/quon_qec/src/expand.rs index dcf2e729..8edc86c1 100644 --- a/quon_qec/src/expand.rs +++ b/quon_qec/src/expand.rs @@ -778,7 +778,7 @@ pub(crate) fn surface_memory_round(layout: &ExpandedBlock) -> PhysicalRound { } // Kept as a regression reference path (issue #281 — now routed through patch_ops). -#[allow(dead_code)] +#[allow(dead_code)] // regression reference (issue #281); production path routes through patch_ops fn measure_logical_round(layout: &ExpandedBlock, basis: LogicalBasis) -> PhysicalRound { let terminal = layout .data_atoms diff --git a/quonfmt/src/config.rs b/quonfmt/src/config.rs index 0c492139..766f13a3 100644 --- a/quonfmt/src/config.rs +++ b/quonfmt/src/config.rs @@ -18,9 +18,3 @@ impl Default for StyleConfig { } } -#[allow(dead_code)] -pub const INDENT: &str = " "; -#[allow(dead_code)] -pub const MAX_WIDTH: usize = 100; -#[allow(dead_code)] -pub const DECL_SEP: &str = "\n\n"; diff --git a/quonfmt/src/doc.rs b/quonfmt/src/doc.rs index 6e93f9e3..fdd48754 100644 --- a/quonfmt/src/doc.rs +++ b/quonfmt/src/doc.rs @@ -1,7 +1,5 @@ //! Wadler-style pretty-printing algebra with width-aware layout. -#![allow(dead_code)] - #[derive(Debug, Clone)] pub enum Doc { Nil, @@ -12,6 +10,10 @@ pub enum Doc { Group(Box), } +// `Hard` and `Flat` are part of the Wadler break algebra; the layout engine +// handles them, but the current printer only emits `Soft` breaks. Kept so the +// algebra stays complete for future formatter rules. +#[allow(dead_code)] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum BreakKind { /// Emit a space when flat, newline when broken. @@ -53,15 +55,21 @@ impl Doc { pub fn soft_break() -> Self { Self::Break(BreakKind::Soft) } - + /// Part of the Wadler break algebra; unused by the current printer but kept + /// for completeness. See [`BreakKind`] for rationale. + #[allow(dead_code)] pub fn hard_break() -> Self { Self::Break(BreakKind::Hard) } - + /// Part of the Wadler break algebra; unused by the current printer but kept + /// for completeness. See [`BreakKind`] for rationale. + #[allow(dead_code)] pub fn flat_break() -> Self { Self::Break(BreakKind::Flat) } - + /// Part of the Wadler break algebra; unused by the current printer but kept + /// for completeness. See [`BreakKind`] for rationale. + #[allow(dead_code)] pub fn space() -> Self { Self::flat_break() } diff --git a/quonfmt/tests/support/mod.rs b/quonfmt/tests/support/mod.rs index f49b4cd9..a4d5ed1b 100644 --- a/quonfmt/tests/support/mod.rs +++ b/quonfmt/tests/support/mod.rs @@ -1,16 +1,16 @@ -#![allow(dead_code)] - #[path = "../../../frontend/tests/support/mod.rs"] mod strip_support; use strip_support::parse_stripped; +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn assert_ast_stable(before: &str, after: &str) { let a = parse_stripped(before); let b = parse_stripped(after); assert_eq!(a, b, "AST changed after format"); } +#[allow(dead_code)] // shared test helper — not every integration test uses every helper pub fn all_corpus() -> Vec<(&'static str, String)> { [ ("decls.qn", include_str!("../corpus/input/decls.qn")), diff --git a/quonlint/tests/support/mod.rs b/quonlint/tests/support/mod.rs index 7a91e01f..a7c355c8 100644 --- a/quonlint/tests/support/mod.rs +++ b/quonlint/tests/support/mod.rs @@ -6,7 +6,7 @@ pub fn lint_snippet(src: &str) -> Vec { lint_source(Path::new("test.qn"), src, &LintConfig::default()) } -#[allow(dead_code)] +#[allow(dead_code)] // shared test helper — used by integration tests that pass custom configs pub fn lint_snippet_with_config(src: &str, config: &LintConfig) -> Vec { lint_source(Path::new("test.qn"), src, config) } diff --git a/zx/src/rewrite.rs b/zx/src/rewrite.rs index 7e2d80ff..4b7a3d8d 100644 --- a/zx/src/rewrite.rs +++ b/zx/src/rewrite.rs @@ -1,4 +1,11 @@ -// ZX-calculus rewrite rules — issue #20, SPEC.md §7.2 +// ZX-calculus rewrite rules — issue #20, SPEC.md §7.2. +// +// Implemented: spider fusion, identity removal (the two rules needed to +// normalise a circuit-shaped ZX graph today). The remaining SPEC §7.2 rules +// (π-copy, bialgebra, Euler decomposition, colour-change, state-copy) are +// deliberately unsupported in v1: they are not wired into `simplify` and no +// correctness path depends on them. Add a real implementation here, behind a +// rule gate in `simplify`, when a downstream consumer needs it. use std::collections::VecDeque; use std::f64::consts::PI; @@ -103,27 +110,6 @@ fn normalize_phase(phase: f64) -> f64 { value } -#[allow(dead_code)] // remaining SPEC rules — wired in follow-up -fn pi_copy(_zx: &mut ZXGraph) -> bool { - false -} -#[allow(dead_code)] // remaining SPEC rules — wired in follow-up -fn bialgebra(_zx: &mut ZXGraph) -> bool { - false -} -#[allow(dead_code)] // remaining SPEC rules — wired in follow-up -fn euler_decomposition(_zx: &mut ZXGraph) -> bool { - false -} -#[allow(dead_code)] // remaining SPEC rules — wired in follow-up -fn color_change(_zx: &mut ZXGraph) -> bool { - false -} -#[allow(dead_code)] // remaining SPEC rules — wired in follow-up -fn state_copy(_zx: &mut ZXGraph) -> bool { - false -} - #[cfg(test)] mod tests { use super::*;