pub struct Label { /* private fields */ }Expand description
A labeled span in source code.
Labels attach messages to specific locations in the source, helping users understand where problems occurred and why.
§Primary vs Secondary Labels
- Primary labels mark the main location of an error or warning. There should typically be one primary label per diagnostic.
- Secondary labels provide additional context, such as “first defined here” or “also referenced here”.
§Example
error[E301]: cannot override built-in type `Rectangle`
--> src/main.orr:10:1
|
10 | type Rectangle = Oval[fill_color="red"];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type override not supportedImplementations§
Source§impl Label
impl Label
Sourcepub fn primary(span: Span, message: impl Into<String>) -> Self
pub fn primary(span: Span, message: impl Into<String>) -> Self
Create a new primary label.
Primary labels mark the main location of an error or warning.
Sourcepub fn secondary(span: Span, message: impl Into<String>) -> Self
pub fn secondary(span: Span, message: impl Into<String>) -> Self
Create a new secondary label.
Secondary labels provide additional context for the diagnostic.
Sourcepub fn is_primary(&self) -> bool
pub fn is_primary(&self) -> bool
Check if this is a primary label.
Sourcepub fn is_secondary(&self) -> bool
pub fn is_secondary(&self) -> bool
Check if this is a secondary label.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Label
impl RefUnwindSafe for Label
impl Send for Label
impl Sync for Label
impl Unpin for Label
impl UnsafeUnpin for Label
impl UnwindSafe for Label
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
Mutably borrows from an owned value. Read more
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>
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 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>
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