Skip to content

Commit b82e5a9

Browse files
orpuente-MSidavis
authored andcommitted
Cleanup TODO items (#2285)
Remove TODO comments from code and add them as Postponed items to the tracking PR.
1 parent 83cc9a5 commit b82e5a9

File tree

5 files changed

+16
-44
lines changed

5 files changed

+16
-44
lines changed

compiler/qsc_qasm3/src/compiler.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ impl QasmCompiler {
243243

244244
let ast_ty = map_qsharp_type_to_ast_ty(&output_ty);
245245
signature.output = format!("{output_ty}");
246-
// TODO: This can create a collision on multiple compiles when interactive
247-
// We also have issues with the new entry point inference logic
246+
// This can create a collision on multiple compiles when interactive
247+
// We also have issues with the new entry point inference logic.
248248
let input_desc = input
249249
.iter()
250250
.flat_map(|s| {
@@ -873,11 +873,8 @@ impl QasmCompiler {
873873
let symbol = &self.symbols[stmt.symbol_id];
874874

875875
// input decls should have been pushed to symbol table,
876-
// but should not be the stmts list.
877-
// TODO: This may be an issue for tooling as there isn't a way to have a forward
878-
// declared varible in Q#.
876+
// but should not be in the stmts list.
879877
if symbol.io_kind != IOKind::Output {
880-
//self.push_semantic_error(SemanticErrorKind::InvalidIODeclaration(stmt.span));
881878
return None;
882879
}
883880

compiler/qsc_qasm3/src/parser/ast.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ use std::{
1616
rc::Rc,
1717
};
1818

19-
// TODO: Profile this with iai-callgrind in a large OpenQASM3
20-
// sample to verify that is actually faster than using Vec<T>.
21-
// Even though Box<T> uses less stack space, it reduces cache
22-
// locality, because now you need to be jumping around in
23-
// memory to read contiguous elements of a list.
2419
/// An alternative to `Vec<T>` that uses less stack space.
2520
pub(crate) type List<T> = Box<[Box<T>]>;
2621

compiler/qsc_qasm3/src/parser/expr.rs

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,12 @@ enum OpKind {
5151
Index,
5252
}
5353

54-
// TODO: This seems to be an unnecessary wrapper.
55-
// OpName::Keyword is never used.
56-
// Consider removing.
5754
#[derive(Clone, Copy)]
5855
enum OpName {
5956
Token(TokenKind),
6057
Keyword(Keyword),
6158
}
6259

63-
// TODO: This seems to be an unnecessary wrapper.
64-
// We ended up removing the OpContext::Stmt variant.
65-
// Consider removing.
66-
#[derive(Clone, Copy)]
67-
enum OpContext {
68-
Precedence(u8),
69-
}
70-
7160
#[derive(Clone, Copy)]
7261
enum Assoc {
7362
Left,
@@ -77,18 +66,18 @@ enum Assoc {
7766
const RANGE_PRECEDENCE: u8 = 1;
7867

7968
pub(super) fn expr(s: &mut ParserContext) -> Result<Expr> {
80-
expr_op(s, OpContext::Precedence(0))
69+
expr_op(s, 0)
8170
}
8271

8372
pub(super) fn expr_with_lhs(s: &mut ParserContext, lhs: Expr) -> Result<Expr> {
84-
expr_op_with_lhs(s, OpContext::Precedence(0), lhs)
73+
expr_op_with_lhs(s, 0, lhs)
8574
}
8675

87-
fn expr_op(s: &mut ParserContext, context: OpContext) -> Result<Expr> {
76+
fn expr_op(s: &mut ParserContext, min_precedence: u8) -> Result<Expr> {
8877
let lo = s.peek().span.lo;
8978
let lhs = if let Some(op) = prefix_op(op_name(s)) {
9079
s.advance();
91-
let rhs = expr_op(s, OpContext::Precedence(op.precedence))?;
80+
let rhs = expr_op(s, op.precedence)?;
9281
Expr {
9382
span: s.span(lo),
9483
kind: Box::new(ExprKind::UnaryOp(UnaryOpExpr {
@@ -100,14 +89,12 @@ fn expr_op(s: &mut ParserContext, context: OpContext) -> Result<Expr> {
10089
expr_base(s)?
10190
};
10291

103-
expr_op_with_lhs(s, context, lhs)
92+
expr_op_with_lhs(s, min_precedence, lhs)
10493
}
10594

106-
fn expr_op_with_lhs(s: &mut ParserContext, context: OpContext, mut lhs: Expr) -> Result<Expr> {
95+
fn expr_op_with_lhs(s: &mut ParserContext, min_precedence: u8, mut lhs: Expr) -> Result<Expr> {
10796
let lo = lhs.span.lo;
10897

109-
let OpContext::Precedence(min_precedence) = context;
110-
11198
while let Some(op) = infix_op(op_name(s)) {
11299
if op.precedence < min_precedence {
113100
break;
@@ -117,7 +104,7 @@ fn expr_op_with_lhs(s: &mut ParserContext, context: OpContext, mut lhs: Expr) ->
117104
let kind = match op.kind {
118105
OpKind::Binary(kind, assoc) => {
119106
let precedence = next_precedence(op.precedence, assoc);
120-
let rhs = expr_op(s, OpContext::Precedence(precedence))?;
107+
let rhs = expr_op(s, precedence)?;
121108
Box::new(ExprKind::BinaryOp(BinaryOpExpr { op: kind, lhs, rhs }))
122109
}
123110
OpKind::Funcall => {

compiler/qsc_qasm3/src/semantic/ast/const_eval.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,6 @@ impl BinaryOpExpr {
299299
}
300300
Type::Float(..) => {
301301
rewrap_lit!((lhs, rhs), (Float(lhs), Float(rhs)), {
302-
// TODO: we need to issue the same lint in Q#.
303302
#[allow(clippy::float_cmp)]
304303
Bool(lhs == rhs)
305304
})
@@ -321,7 +320,6 @@ impl BinaryOpExpr {
321320
}
322321
Type::Float(..) => {
323322
rewrap_lit!((lhs, rhs), (Float(lhs), Float(rhs)), {
324-
// TODO: we need to issue the same lint in Q#.
325323
#[allow(clippy::float_cmp)]
326324
Bool(lhs != rhs)
327325
})
@@ -586,12 +584,11 @@ fn cast_to_int(cast: &Cast, ctx: &mut Lowerer) -> Option<LiteralKind> {
586584
Type::BitArray(..) => {
587585
rewrap_lit!(lit, Bitstring(val, _), Int(i64::try_from(val).ok()?))
588586
}
589-
// TODO: UInt Overflowing behavior.
590-
// This is tricky because the inner repersentation
591-
// already is a i64. Therefore, there is nothing to do?
587+
// UInt Overflowing behavior.
588+
// This is tricky because the inner representation of UInt
589+
// is already an i64. Therefore, there is nothing to do.
592590
Type::Int(..) | Type::UInt(..) => Some(lit),
593591
Type::Float(..) => rewrap_lit!(lit, Float(val), {
594-
// TODO: we need to issue the same lint in Q#.
595592
#[allow(clippy::cast_possible_truncation)]
596593
Int(val as i64)
597594
}),
@@ -616,13 +613,11 @@ fn cast_to_uint(cast: &Cast, ctx: &mut Lowerer) -> Option<LiteralKind> {
616613
Type::BitArray(..) => {
617614
rewrap_lit!(lit, Bitstring(val, _), Int(i64::try_from(val).ok()?))
618615
}
619-
// TODO: Int Overflowing behavior.
620-
// This is tricky because the inner representation
621-
// is a i64. Therefore, even we might end with the
622-
// same result anyways. Need to think through this.
616+
// UInt Overflowing behavior.
617+
// This is tricky because the inner representation of UInt
618+
// is already an i64. Therefore, there is nothing to do.
623619
Type::Int(..) | Type::UInt(..) => Some(lit),
624620
Type::Float(..) => rewrap_lit!(lit, Float(val), {
625-
// TODO: we need to issue the same lint in Q#.
626621
#[allow(clippy::cast_possible_truncation)]
627622
Int(val as i64)
628623
}),
@@ -644,7 +639,6 @@ fn cast_to_float(cast: &Cast, ctx: &mut Lowerer) -> Option<LiteralKind> {
644639
match &cast.expr.ty {
645640
Type::Bool(..) => rewrap_lit!(lit, Bool(val), Float(if val { 1.0 } else { 0.0 })),
646641
Type::Int(..) | Type::UInt(..) => rewrap_lit!(lit, Int(val), {
647-
// TODO: we need to issue the same lint in Q#.
648642
#[allow(clippy::cast_precision_loss)]
649643
Float(safe_i64_to_f64(val)?)
650644
}),

compiler/qsc_qasm3/src/semantic/lowerer.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3011,7 +3011,6 @@ impl Lowerer {
30113011
)
30123012
}
30133013

3014-
// TODO: which these are parsed as different types, they are effectively the same
30153014
fn lower_index_element(&mut self, index: &syntax::IndexElement) -> semantic::IndexElement {
30163015
match index {
30173016
syntax::IndexElement::DiscreteSet(set) => {

0 commit comments

Comments
 (0)