pub struct ImplicitPrecedence(/* private fields */);
Expand description
Extra information about sorting of implicit arguments of the function.
In most of the user written code, the implicits are not stated explicitly, but instead are inferred by the compiler. The order on how these implicit arguments are laid out on Sierra level is unspecified though for the users. Currently, the compiler sorts them alphabetically by name for reproducibility, but it can equally just randomize the order on each compilation.
Some compilation targets tend to expect that particular functions accept particular implicit arguments at fixed positions. For example, the Starknet OS has such assumptions. By reading the implicit precedence information attached to functions, the compiler can now reliably generate compatible code.
To set, add the #[implicit_precedence(...)]
attribute to function declaration. Only free or
impl functions can have this information defined. For extern functions, the compiler raises an
error. It is recommended to always create this attribute from compiler plugins, and not force
users to write it manually.
Use ImplicitPrecedence::UNSPECIFIED to represent lack of information.
Implementations§
source§impl ImplicitPrecedence
impl ImplicitPrecedence
sourcepub const UNSPECIFIED: Self = _
pub const UNSPECIFIED: Self = _
A precedence that does not actually prefer any implicit.
When applied to a sequence of implicits, they will just be reordered alphabetically.
sourcepub fn apply(&self, implicits: &mut [TypeId], db: &dyn SemanticGroup)
pub fn apply(&self, implicits: &mut [TypeId], db: &dyn SemanticGroup)
Sort implicits according to this precedence: first the ones with precedence (according to it), then the others by their name.
Trait Implementations§
source§impl Clone for ImplicitPrecedence
impl Clone for ImplicitPrecedence
source§fn clone(&self) -> ImplicitPrecedence
fn clone(&self) -> ImplicitPrecedence
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ImplicitPrecedence
impl Debug for ImplicitPrecedence
source§impl Default for ImplicitPrecedence
impl Default for ImplicitPrecedence
source§fn default() -> ImplicitPrecedence
fn default() -> ImplicitPrecedence
source§impl FromIterator<TypeId> for ImplicitPrecedence
impl FromIterator<TypeId> for ImplicitPrecedence
source§impl PartialEq for ImplicitPrecedence
impl PartialEq for ImplicitPrecedence
impl Eq for ImplicitPrecedence
impl StructuralPartialEq for ImplicitPrecedence
Auto Trait Implementations§
impl Freeze for ImplicitPrecedence
impl RefUnwindSafe for ImplicitPrecedence
impl Send for ImplicitPrecedence
impl Sync for ImplicitPrecedence
impl Unpin for ImplicitPrecedence
impl UnwindSafe for ImplicitPrecedence
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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