pub enum ArrayLenReason {
NotLiteralOrName,
NotAnIntegerLiteral,
IntegerOutOfRange,
NotABareName,
NotAMarkedConst,
ConstIsNotALiteral,
ForeignSourceConst {
const_crate: String,
item_crate: String,
},
}Expand description
Why an array length was refused.
Variants§
NotLiteralOrName
Not a literal and not a plain name: arithmetic, a cast, a call, a block,
a match, a closure — anything with structure the grammar lacks.
NotAnIntegerLiteral
A literal that is not a non-negative integer.
IntegerOutOfRange
An integer literal too large for usize.
NotABareName
A path with more than one segment, a qualified self, or a leading :: —
crate::limits::MAX, usize::MAX, <Holder>::N, ::MAX.
A length names a #[prebindgen] const, and those live in one flat,
uniquely-named namespace, so the bare name is the complete address. Any
longer path either restates that (crate::limits::MAX) or reaches
somewhere the frontend cannot follow — a module it does not index, an
associated const it never captured, a foreign crate. Neither can be
reduced to a number, and guessing between them is how a length silently
becomes the wrong one.
NotAMarkedConst
A bare name that is not a #[prebindgen] const.
The generated crate sees only what the macro exposed, so an unmarked const is not merely unqualifiable — it does not exist downstream.
ConstIsNotALiteral
A #[prebindgen] const whose own initializer is not an integer literal.
build.rs cannot evaluate it, and a destination language that needs the
count cannot either. Hoist the arithmetic into the value the const is
computed FROM, or write the number.
ForeignSourceConst
A #[prebindgen] const from a different source crate than the item
using it.
Uniqueness holds across the marked namespace only, so a bare name in one source crate can collide with an unmarked name of its own — the frontend would silently bind to the other crate’s value. Requiring the length’s const to come from the item’s own crate makes that unrepresentable.
Trait Implementations§
Source§impl Clone for ArrayLenReason
impl Clone for ArrayLenReason
Source§fn clone(&self) -> ArrayLenReason
fn clone(&self) -> ArrayLenReason
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ArrayLenReason
impl Debug for ArrayLenReason
impl Eq for ArrayLenReason
Source§impl PartialEq for ArrayLenReason
impl PartialEq for ArrayLenReason
impl StructuralPartialEq for ArrayLenReason
Auto Trait Implementations§
impl Freeze for ArrayLenReason
impl RefUnwindSafe for ArrayLenReason
impl Send for ArrayLenReason
impl Sync for ArrayLenReason
impl Unpin for ArrayLenReason
impl UnsafeUnpin for ArrayLenReason
impl UnwindSafe for ArrayLenReason
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§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 more