Enum erg_common::error::Location
source · pub enum Location {
Range {
ln_begin: u32,
col_begin: u32,
ln_end: u32,
col_end: u32,
},
LineRange(u32, u32),
Line(u32),
Unknown,
}
Expand description
Points the location (of an error) in a code. The beginning and end of each row and column where the error occurred. Basically, the beginning and end of each row and column where the error occurred is kept.
Variants§
Range
Location used for basic errors
# erg
a = 1
a = 2 # Error, `a` is assigned twice
// Value assigned to the structure
Location::Range {
ln_begin: 2,
col_begin: 0,
ln_end: 2,
col_end: 1,
}
LineRange(u32, u32)
Used for loss of location information when desugared. If there are guaranteed to be multiple rows
Line(u32)
Used when Location information is lost when desugared If it is guaranteed to be a single line
Unknown
Used by default in case of loss of Location information
Implementations§
source§impl Location
impl Location
pub fn concat<L: Locational, R: Locational>(l: &L, r: &R) -> Self
pub fn left_main_concat<L: Locational, R: Locational>(l: &L, r: &R) -> Self
pub fn stream<L: Locational>(ls: &[L]) -> Self
pub const fn range( ln_begin: u32, col_begin: u32, ln_end: u32, col_end: u32 ) -> Self
pub const fn is_unknown(&self) -> bool
pub const fn is_real(&self) -> bool
pub const fn unknown_or(&self, other: Self) -> Self
pub const fn ln_end(&self) -> Option<u32>
pub const fn col_end(&self) -> Option<u32>
pub const fn length(&self) -> Option<u32>
sourcepub fn contains(&self, other: Self) -> bool
pub fn contains(&self, other: Self) -> bool
let loc = Location::range(1, 3, 1, 7);
assert_eq!(loc.ln_begin(), Some(1));
assert!(loc.contains(Location::range(1, 4, 1, 5)));
let loc = Location::range(1, 3, 3, 2);
assert!(loc.contains(Location::range(1, 4, 1, 5)));
assert!(!loc.contains(Location::range(1, 4, 3, 5)));
assert!(loc.contains(Location::range(1, 4, 2, 5)));
assert!(!loc.contains(Location::range(1, 2, 2, 5)));
Trait Implementations§
source§impl Locational for Location
impl Locational for Location
source§impl Ord for Location
impl Ord for Location
source§impl PartialEq for Location
impl PartialEq for Location
source§impl PartialOrd for Location
impl PartialOrd for Location
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Copy for Location
impl Eq for Location
impl StructuralPartialEq for Location
Auto Trait Implementations§
impl Freeze for Location
impl RefUnwindSafe for Location
impl Send for Location
impl Sync for Location
impl Unpin for Location
impl UnwindSafe for Location
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