mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
feat: report errors in macro definition
Reporting macro *definition* error at the macro *call site* is a rather questionable approach, but at least we don't erase the errors altogether!
This commit is contained in:
parent
b3d1de93af
commit
ef1251f696
10 changed files with 121 additions and 95 deletions
|
@ -30,7 +30,7 @@ use crate::{
|
|||
pub use ::parser::ParserEntryPoint;
|
||||
pub use tt::{Delimiter, DelimiterKind, Punct};
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
pub enum ParseError {
|
||||
UnexpectedToken(String),
|
||||
Expected(String),
|
||||
|
@ -38,6 +38,17 @@ pub enum ParseError {
|
|||
RepetitionEmptyTokenTree,
|
||||
}
|
||||
|
||||
impl fmt::Display for ParseError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
ParseError::UnexpectedToken(it) => f.write_str(it),
|
||||
ParseError::Expected(it) => f.write_str(it),
|
||||
ParseError::InvalidRepeat => f.write_str("invalid repeat"),
|
||||
ParseError::RepetitionEmptyTokenTree => f.write_str("empty token tree in repetition"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
pub enum ExpandError {
|
||||
NoMatchingRule,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue