mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 21:35:20 +00:00
Rename ra_ssr -> ssr
This commit is contained in:
parent
bb5c189b7d
commit
ae3abd6e57
18 changed files with 95 additions and 110 deletions
29
crates/ssr/src/errors.rs
Normal file
29
crates/ssr/src/errors.rs
Normal file
|
@ -0,0 +1,29 @@
|
|||
//! Code relating to errors produced by SSR.
|
||||
|
||||
/// Constructs an SsrError taking arguments like the format macro.
|
||||
macro_rules! _error {
|
||||
($fmt:expr) => {$crate::SsrError::new(format!($fmt))};
|
||||
($fmt:expr, $($arg:tt)+) => {$crate::SsrError::new(format!($fmt, $($arg)+))}
|
||||
}
|
||||
pub(crate) use _error as error;
|
||||
|
||||
/// Returns from the current function with an error, supplied by arguments as for format!
|
||||
macro_rules! _bail {
|
||||
($($tokens:tt)*) => {return Err(crate::errors::error!($($tokens)*))}
|
||||
}
|
||||
pub(crate) use _bail as bail;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct SsrError(pub(crate) String);
|
||||
|
||||
impl std::fmt::Display for SsrError {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
write!(f, "Parse error: {}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl SsrError {
|
||||
pub(crate) fn new(message: impl Into<String>) -> SsrError {
|
||||
SsrError(message.into())
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue