forked from Orchid/orchid
Most files suffered major changes
- Less ambiguous syntax - Better parser (Chumsky only does tokenization now) - Tidy(|ier) error handling - Facade for simplified embedding - External code grouped in (fairly) self-contained Systems - Dynamic action dispatch - Many STL additions
This commit is contained in:
43
src/error/too_many_supers.rs
Normal file
43
src/error/too_many_supers.rs
Normal file
@@ -0,0 +1,43 @@
|
||||
use std::rc::Rc;
|
||||
|
||||
use super::{ErrorPosition, ProjectError};
|
||||
use crate::representations::location::Location;
|
||||
use crate::utils::iter::box_once;
|
||||
use crate::utils::BoxedIter;
|
||||
use crate::{Interner, VName};
|
||||
|
||||
/// Error produced when an import path starts with more `super` segments
|
||||
/// than the current module's absolute path
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct TooManySupers {
|
||||
/// The offending import path
|
||||
pub path: VName,
|
||||
/// The file containing the offending import
|
||||
pub offender_file: VName,
|
||||
/// The module containing the offending import
|
||||
pub offender_mod: VName,
|
||||
}
|
||||
impl ProjectError for TooManySupers {
|
||||
fn description(&self) -> &str {
|
||||
"an import path starts with more `super` segments than the current \
|
||||
module's absolute path"
|
||||
}
|
||||
fn message(&self, i: &Interner) -> String {
|
||||
format!(
|
||||
"path {} in {} contains too many `super` steps.",
|
||||
i.extern_all(&self.path).join("::"),
|
||||
i.extern_all(&self.offender_mod).join("::")
|
||||
)
|
||||
}
|
||||
|
||||
fn positions(&self, i: &Interner) -> BoxedIter<ErrorPosition> {
|
||||
box_once(ErrorPosition {
|
||||
location: Location::File(Rc::new(i.extern_all(&self.offender_file))),
|
||||
message: Some(format!(
|
||||
"path {} in {} contains too many `super` steps.",
|
||||
i.extern_all(&self.path).join("::"),
|
||||
i.extern_all(&self.offender_mod).join("::")
|
||||
)),
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user