pub enum CircuitError {
Show 24 variants
DuplicateQubits,
QubitNotFound(u32),
QubitCountMismatch {
expected: usize,
actual: usize,
},
ParameterCountMismatch {
expected: usize,
actual: usize,
},
InvalidParameter(ParameterError),
NoMatrixRepresentation,
ParamEvaluationFailed(EvalError),
IrreversibleOperation,
InvalidControlOperation(String),
SymbolicParameterError,
UnresolvedParameter(String),
InvalidParameterIndex(u32),
OperationIndexOutOfBounds {
index: usize,
len: usize,
},
ClassicalValueStillInUse {
index: u32,
context: String,
},
InvalidParameterValue(usize, f64),
InvalidControlFlow(String),
InvalidDag(String),
ForeignClassicalHandle {
kind: &'static str,
index: u32,
},
UndefinedClassicalValue {
index: u32,
context: String,
},
DuplicateClassicalValueDefinition {
index: u32,
first: String,
second: String,
},
ClassicalValueOutOfScope {
index: u32,
context: String,
},
NonTerminalControlTransfer {
operation: &'static str,
context: String,
},
ControlFlowPresent,
InvalidOperation(String),
}Expand description
A comprehensive error type for operations involving Quantum Circuits.
This enum aggregates errors from circuit construction, validation, and manipulation.
It serves as the primary error type for the Circuit struct and its related methods.
Variants§
DuplicateQubits
Thrown when attempting to add qubits that share the same unique identifier (index).
Qubit indices within a circuit must be unique to ensure unambiguous addressing.
QubitNotFound(u32)
Thrown when an operation references a qubit that is not part of the circuit.
All qubits used in operations (gates, measurements) must be explicitly added to the circuit
via add_qubits or new before use.
QubitCountMismatch
Thrown when the number of qubits provided for an operation does not match its definition.
For example, applying a 2-qubit CNOT gate to 3 qubits, or a 1-qubit Custom Unitary to 2 qubits.
ParameterCountMismatch
Thrown when the number of parameters supplied to a fixed-arity instruction does not match its definition.
InvalidParameter(ParameterError)
Wraps errors raised while simplifying or evaluating symbolic parameters.
NoMatrixRepresentation
Thrown when an operation is requested to provide a unitary matrix, but none exists.
This typically happens when calling .matrix() on non-unitary instructions such as:
MeasureBarrierReset
ParamEvaluationFailed(EvalError)
Wraps errors that occur during the evaluation of circuit parameters.
This variant propagates EvalErrors up the stack when operations like matrix generation
or gate inversion fail due to invalid parameter bindings.
IrreversibleOperation
Thrown when inversion is requested for a non-unitary operation or circuit.
InvalidControlOperation(String)
Thrown when an instruction cannot be promoted to a controlled operation.
SymbolicParameterError
Thrown when a numeric result is requested from an operation whose circuit-local symbolic parameters have not been resolved.
UnresolvedParameter(String)
Thrown when a parameter cannot be resolved during circuit decomposition.
This occurs when a sub-circuit or control flow body contains symbolic parameters that are not bound to concrete values and cannot be evaluated.
InvalidParameterIndex(u32)
Thrown when a parameter index is out of range.
This indicates internal data corruption or an inconsistency between the circuit’s parameter table and the indices stored in operations.
OperationIndexOutOfBounds
Thrown when an operation index is outside the circuit operation list.
index is the requested zero-based index and len is the operation
count at the time of the request.
Fields
ClassicalValueStillInUse
Thrown when deleting an operation would remove a classical value that is still read by another operation.
InvalidParameterValue(usize, f64)
Thrown when a gate parameter has an invalid value (NaN or Infinity).
This occurs when appending or evaluating a gate with a non-finite fixed parameter. The tuple stores the parameter position and rejected value.
InvalidControlFlow(String)
Thrown when the control flow graph (CFG) has an invalid or inconsistent structure.
This error indicates that the DAG representation of the circuit is malformed, which can occur when:
- A Branch terminator lacks required TrueBranch or FalseBranch edges
- A Jump terminator references a non-existent block
- The entry block is not set
- Edges reference nodes that don’t exist in the graph
§Examples
This error is returned when converting an invalid CircuitDag back to a Circuit
if the DAG structure was manually modified and left in an inconsistent state.
InvalidDag(String)
Thrown when the circuit dependency DAG has an invalid or inconsistent structure.
ForeignClassicalHandle
Thrown when a classical handle was created by a different circuit.
UndefinedClassicalValue
Thrown when a classical value is read before it is available at a use site.
DuplicateClassicalValueDefinition
Thrown when validation finds multiple producers for one immutable value.
Fields
ClassicalValueOutOfScope
Thrown when a classical value is used outside its defining control-flow region.
NonTerminalControlTransfer
Thrown when break or continue is followed by another operation in the same body.
Fields
ControlFlowPresent
Thrown when Circuit::depth(recurse=false) is called on a circuit that
contains any classical control-flow operation (if/while/for/
switch/break/continue) at any nesting depth. Pass recurse = true
to obtain an estimated depth that unfolds control flow.
InvalidOperation(String)
Catch-all for an invalid operation that has no more specific error variant.
Trait Implementations§
Source§impl Debug for CircuitError
impl Debug for CircuitError
Source§impl Display for CircuitError
impl Display for CircuitError
Source§impl Error for CircuitError
impl Error for CircuitError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<CircuitError> for CompilerError
impl From<CircuitError> for CompilerError
Source§fn from(source: CircuitError) -> Self
fn from(source: CircuitError) -> Self
Source§impl From<CircuitError> for VerifyError
impl From<CircuitError> for VerifyError
Source§fn from(source: CircuitError) -> Self
fn from(source: CircuitError) -> Self
Source§impl From<CircuitError> for ErrorMitigationError
impl From<CircuitError> for ErrorMitigationError
Source§fn from(source: CircuitError) -> Self
fn from(source: CircuitError) -> Self
Source§impl From<CircuitError> for QasmParseError
impl From<CircuitError> for QasmParseError
Source§fn from(value: CircuitError) -> Self
fn from(value: CircuitError) -> Self
Source§impl From<CircuitError> for Qasm3ParseError
impl From<CircuitError> for Qasm3ParseError
Source§fn from(value: CircuitError) -> Self
fn from(value: CircuitError) -> Self
Source§impl From<CircuitError> for QisError
impl From<CircuitError> for QisError
Source§fn from(source: CircuitError) -> Self
fn from(source: CircuitError) -> Self
Source§impl From<CircuitError> for VisualizationError
impl From<CircuitError> for VisualizationError
Source§fn from(source: CircuitError) -> Self
fn from(source: CircuitError) -> Self
Source§impl From<EvalError> for CircuitError
impl From<EvalError> for CircuitError
Source§impl From<ParameterError> for CircuitError
impl From<ParameterError> for CircuitError
Source§fn from(source: ParameterError) -> Self
fn from(source: ParameterError) -> Self
Auto Trait Implementations§
impl Freeze for CircuitError
impl RefUnwindSafe for CircuitError
impl Send for CircuitError
impl Sync for CircuitError
impl Unpin for CircuitError
impl UnsafeUnpin for CircuitError
impl UnwindSafe for CircuitError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> StdoutFmt for Twhere
T: Display,
impl<T> StdoutFmt for Twhere
T: Display,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.