Enum cedar_policy_core::parser::err::ToASTErrorKind

source ·
#[non_exhaustive]
pub enum ToASTErrorKind {
Show 56 variants DuplicateTemplateId(PolicyID), DuplicatePolicyId(PolicyID), UnexpectedTemplate { slot: Slot, }, DuplicateAnnotation(AnyId), SlotsInConditionClause { slot: Slot, clausetype: &'static str, }, MissingScopeConstraint(Var), ExtraHeadConstraints(VariableDef), ReservedIdentifier(Ident), InvalidIdentifier(String), InvalidSingleEq, InvalidEffect(Ident), InvalidCondition(Ident), InvalidScopeConstraintVariable(Ident), InvalidMethodName(String), IncorrectVariable { expected: Var, got: Var, }, InvalidConstraintOperator(RelOp), InvalidScopeEqualityRHS, InvalidActionType(EntityUID), EmptyClause(Option<Ident>), AnnotationInvariantViolation, MembershipInvariantViolation, InvalidString(String), ArbitraryVariable(SmolStr), InvalidAttribute(SmolStr), InvalidAttributesInRecordLiteral, PathAsAttribute(String), FunctionCallOnMethod(Id), MethodCallOnFunction(Id), InvalidPattern(String), IsInvalidName(String), WrongNode { expected: &'static str, got: String, suggestion: Option<String>, }, AmbiguousOperators, UnsupportedDivision, UnsupportedModulo, ExprConstructionError(ExprConstructionError), IntegerLiteralTooLarge(u64), UnaryOpLimit(UnaryOp), VariableCall(Var), NoMethods(Name, Id), NotAFunction(Name), UnsupportedEntityLiterals, ExpressionCall, InvalidAccess(Name, SmolStr), InvalidIndex(Name, SmolStr), NonStringIndex, TypeConstraints, InvalidPath, NonNormalizedString { kind: &'static str, src: String, normalized_src: String, }, MissingNodeData, HasNonLiteralRHS, InvalidExpression(Name), WrongArity { name: &'static str, expected: usize, got: usize, }, Unescape(UnescapeError), RefCreation(RefCreationError), InvalidIs(InvalidIsError), InvalidSlot(SmolStr),
}
Expand description

Details about a particular kind of ToASTError.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

DuplicateTemplateId(PolicyID)

Returned when we attempt to parse a template with a conflicting id

§

DuplicatePolicyId(PolicyID)

Returned when we attempt to parse a policy with a conflicting id

§

UnexpectedTemplate

Returned when a template is encountered but a static policy is expected

Fields

§slot: Slot

Slot that was found (which is not valid in a static policy)

§

DuplicateAnnotation(AnyId)

Returned when we attempt to parse a policy or template with duplicate or conflicting annotations

§

SlotsInConditionClause

Returned when a policy contains template slots in a when/unless clause. This is not currently supported. See RFC 3

Fields

§slot: Slot

Slot that was found in a when/unless clause

§clausetype: &'static str

Clause type, e.g. “when” or “unless”

§

MissingScopeConstraint(Var)

Returned when a policy is missing one of the 3 required scope clauses. (principal, action, and resource)

§

ExtraHeadConstraints(VariableDef)

Returned when a policy has an extra scope clause. This is not valid syntax

§

ReservedIdentifier(Ident)

Returned when a policy uses a reserved keyword as an identifier.

§

InvalidIdentifier(String)

Returned when a policy contains an invalid identifier. This error is not currently returned, but is here for future-proofing. See cst::Ident::Invalid

§

InvalidSingleEq

Returned when a policy uses ‘=’ as a binary operator. ‘=’ is not an operator in Cedar; we can suggest ‘==’ instead.

§

InvalidEffect(Ident)

Returned when a policy uses a effect keyword beyond permit or forbid

§

InvalidCondition(Ident)

Returned when a policy uses a condition keyword beyond when or unless

§

InvalidScopeConstraintVariable(Ident)

Returned when a policy uses a variable in the scope beyond principal, action, or resource

§

InvalidMethodName(String)

Returned when a policy contains an invalid method name

§

IncorrectVariable

Returned when a policy scope clause contains the wrong variable. (principal must be in the first clause, etc…)

Fields

§expected: Var

The variable that is expected in this clause

§got: Var

The variable that was present in this clause

§

InvalidConstraintOperator(RelOp)

Returned when a policy scope clause uses an operator not allowed in scopes.

§

InvalidScopeEqualityRHS

Returned when the right hand side of == in a policy scope clause is not a single Entity UID or a template slot. This is valid in Cedar conditions, but not in the Scope

§

InvalidActionType(EntityUID)

Returned when an Entity UID used as an action does not have the type Action

§

EmptyClause(Option<Ident>)

Returned when a condition clause is empty

§

AnnotationInvariantViolation

Returned when the internal invariant around annotation info has been violated

§

MembershipInvariantViolation

Returned when membership chains do not resolve to an expression, violating an internal invariant

§

InvalidString(String)

Returned for a non-parse-able string literal

§

ArbitraryVariable(SmolStr)

Returned for attempting to use an arbitrary variable name. Cedar does not support arbitrary variables.

§

InvalidAttribute(SmolStr)

Returned for attempting to use an invalid attribute name

§

InvalidAttributesInRecordLiteral

Returned for attempting to use an invalid attribute name in a record name

§

PathAsAttribute(String)

Returned for attempting to use an attribute with a namespace

§

FunctionCallOnMethod(Id)

Returned when a policy attempts to call a method function-style

§

MethodCallOnFunction(Id)

Returned when a policy attempts to call a function in the method style

§

InvalidPattern(String)

Returned when the right hand side of a like expression is not a constant pattern literal

§

IsInvalidName(String)

Returned when the right hand side of a is expression is not an entity type name

§

WrongNode

Returned when an unexpected node is in the policy scope clause

Fields

§expected: &'static str

What the expected AST node kind was

§got: String

What AST node was present in the policy source

§suggestion: Option<String>

Optional free-form text with a suggestion for how to fix the problem

§

AmbiguousOperators

Returned when a policy contains ambiguous ordering of operators. This can be resolved by using parenthesis to make order explicit

§

UnsupportedDivision

Returned when a policy uses the division operator (/), which is not supported

§

UnsupportedModulo

Returned when a policy uses the remainder/modulo operator (%), which is not supported

§

ExprConstructionError(ExprConstructionError)

Any ExprConstructionError can also happen while converting CST to AST

§

IntegerLiteralTooLarge(u64)

Returned when a policy contains an integer literal that is out of range

§

UnaryOpLimit(UnaryOp)

Returned when a unary operator is chained more than 4 times in a row

§

VariableCall(Var)

Returned when a variable is called as a function, which is not allowed. Functions are not first class values in Cedar

§

NoMethods(Name, Id)

Returned when a policy attempts to call a method on a value that has no methods

§

NotAFunction(Name)

Returned when a policy attempts to call a function that does not exist

§

UnsupportedEntityLiterals

Returned when a policy attempts to write an entity literal

§

ExpressionCall

Returned when an expression is the target of a function call. Functions are not first class values in Cedar

§

InvalidAccess(Name, SmolStr)

Returned when a policy attempts to access the fields of a value with no fields

§

InvalidIndex(Name, SmolStr)

Returned when a policy attempts to index on a fields of a value with no fields

§

NonStringIndex

Returned when the contents of an indexing expression is not a string literal

§

TypeConstraints

Returned when a user attempts to use type-constraint : syntax. This syntax was not adopted, but is can be used to write type constraints in the policy scope.

§

InvalidPath

Returned when a policy uses a path in an invalid context

§

NonNormalizedString

Returned when a string needs to be fully normalized

Fields

§kind: &'static str

The kind of string we are expecting

§src: String

The source string passed in

§normalized_src: String

The normalized form of the string

§

MissingNodeData

Returned when a CST node is empty

§

HasNonLiteralRHS

Returned when the right hand side of a has expression is neither a field name or a string literal

§

InvalidExpression(Name)

Returned when a CST expression is invalid

§

WrongArity

Returned when a function or method is called with the wrong arity

Fields

§name: &'static str

Name of the function or method being called

§expected: usize

The expected number of arguments

§got: usize

The number of arguments present in source

§

Unescape(UnescapeError)

Returned when a string contains invalid escapes

§

RefCreation(RefCreationError)

Returns when a policy scope has incorrect EntityUIDs/Template Slots

§

InvalidIs(InvalidIsError)

Returned when an is appears in an invalid position in the policy scope

§

InvalidSlot(SmolStr)

Returned when a policy contains a template slot other than ?principal or ?resource

Implementations§

source§

impl ToASTErrorKind

source

pub fn wrong_node( expected: &'static str, got: impl Into<String>, suggestion: Option<impl Into<String>> ) -> Self

Constructor for the ToASTErrorKind::WrongNode error

source

pub fn wrong_arity(name: &'static str, expected: usize, got: usize) -> Self

Constructor for the ToASTErrorKind::WrongArity error

Trait Implementations§

source§

impl Clone for ToASTErrorKind

source§

fn clone(&self) -> ToASTErrorKind

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ToASTErrorKind

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Diagnostic for ToASTErrorKind

source§

fn code(&self) -> Option<Box<dyn Display + '_>>

Unique diagnostic code that can be used to look up more information about this Diagnostic. Ideally also globally unique, and documented in the toplevel crate’s documentation for easy searching. Rust path format (foo::bar::baz) is recommended, but more classic codes like E0123 or enums will work just fine.
source§

fn help(&self) -> Option<Box<dyn Display + '_>>

Additional help text related to this Diagnostic. Do you have any advice for the poor soul who’s just run into this issue?
source§

fn severity(&self) -> Option<Severity>

Diagnostic severity. This may be used by ReportHandlers to change the display format of this diagnostic. Read more
source§

fn labels(&self) -> Option<Box<dyn Iterator<Item = LabeledSpan> + '_>>

Labels to apply to this Diagnostic’s Diagnostic::source_code
source§

fn source_code(&self) -> Option<&dyn SourceCode>

Source code to apply this Diagnostic’s Diagnostic::labels to.
source§

fn related(&self) -> Option<Box<dyn Iterator<Item = &dyn Diagnostic> + '_>>

Additional related Diagnostics.
source§

fn url(&self) -> Option<Box<dyn Display + '_>>

URL to visit for a more detailed explanation/help about this Diagnostic.
source§

fn diagnostic_source(&self) -> Option<&dyn Diagnostic>

The cause of the error.
source§

impl Display for ToASTErrorKind

source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Error for ToASTErrorKind

source§

fn source(&self) -> Option<&(dyn Error + 'static)>

The lower-level source of this error, if any. Read more
1.0.0 · source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type based access to context intended for error reports. Read more
source§

impl From<ExprConstructionError> for ToASTErrorKind

source§

fn from(source: ExprConstructionError) -> Self

Converts to this type from the input type.
source§

impl From<InvalidIsError> for ToASTErrorKind

source§

fn from(source: InvalidIsError) -> Self

Converts to this type from the input type.
source§

impl From<RefCreationError> for ToASTErrorKind

source§

fn from(source: RefCreationError) -> Self

Converts to this type from the input type.
source§

impl From<UnescapeError> for ToASTErrorKind

source§

fn from(source: UnescapeError) -> Self

Converts to this type from the input type.
source§

impl PartialEq for ToASTErrorKind

source§

fn eq(&self, other: &ToASTErrorKind) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for ToASTErrorKind

source§

impl StructuralPartialEq for ToASTErrorKind

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToSmolStr for T
where T: Display + ?Sized,

source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.