Enum arithmetic_typing::ast::AstConversionError
source · #[non_exhaustive]pub enum AstConversionError {
EmbeddedQuantifier,
FreeLengthVar(String),
FreeTypeVar(String),
UnusedLength(String),
UnusedTypeParam(String),
UnknownType(String),
UnknownConstraint(String),
InvalidSomeType,
InvalidSomeLength,
DuplicateField(String),
NotObjectSafe(String),
}
Expand description
Kinds of errors that can occur when converting *Ast
types into their “main” counterparts.
During type inference, errors of this type are wrapped into the AstConversion
variant of typing errors.
§Examples
use arithmetic_parser::grammars::{Parse, F32Grammar};
use arithmetic_typing::{
ast::AstConversionError, error::ErrorKind, Annotated, TypeEnvironment,
};
let code = "bogus_slice: ['T; _] = (1, 2, 3);";
let ast = Annotated::<F32Grammar>::parse_statements(code)?;
let errors = TypeEnvironment::new().process_statements(&ast).unwrap_err();
let err = errors.into_iter().next().unwrap();
assert_eq!(err.main_location().span(code), "'T");
assert_matches!(
err.kind(),
ErrorKind::AstConversion(AstConversionError::FreeTypeVar(id))
if id == "T"
);
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
EmbeddedQuantifier
Embedded param quantifiers.
FreeLengthVar(String)
Length param not scoped by a function.
FreeTypeVar(String)
Type param not scoped by a function.
UnusedLength(String)
Unused length param.
UnusedTypeParam(String)
Unused length param.
UnknownType(String)
Unknown type name.
UnknownConstraint(String)
Unknown constraint.
InvalidSomeType
Some type (_
) encountered when parsing a standalone type.
_
types are only allowed in the context of a TypeEnvironment
. It is a logical
error to use them when parsing standalone types.
InvalidSomeLength
Some length (_
) encountered when parsing a standalone type.
_
lengths are only allowed in the context of a TypeEnvironment
. It is a logical
error to use them when parsing standalone types.
DuplicateField(String)
Field with the same name is defined multiple times in an object type.
NotObjectSafe(String)
Constraint is not object-safe.
Trait Implementations§
source§impl Clone for AstConversionError
impl Clone for AstConversionError
source§fn clone(&self) -> AstConversionError
fn clone(&self) -> AstConversionError
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for AstConversionError
impl Debug for AstConversionError
source§impl Display for AstConversionError
impl Display for AstConversionError
source§impl Error for AstConversionError
impl Error for AstConversionError
1.30.0 · 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
Auto Trait Implementations§
impl Freeze for AstConversionError
impl RefUnwindSafe for AstConversionError
impl Send for AstConversionError
impl Sync for AstConversionError
impl Unpin for AstConversionError
impl UnwindSafe for AstConversionError
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)