mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Shrink ra_parser::Event from 32 bytes to 16 bytes
This boxes the Error variant with the assumption that it is rarely constructed
This commit is contained in:
parent
ebaa05a447
commit
ef6d53521f
3 changed files with 3 additions and 3 deletions
|
@ -25,7 +25,7 @@ pub(crate) use token_set::TokenSet;
|
||||||
pub use syntax_kind::SyntaxKind;
|
pub use syntax_kind::SyntaxKind;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct ParseError(pub String);
|
pub struct ParseError(pub Box<String>);
|
||||||
|
|
||||||
/// `TokenSource` abstracts the source of the tokens parser operates on.
|
/// `TokenSource` abstracts the source of the tokens parser operates on.
|
||||||
///
|
///
|
||||||
|
|
|
@ -192,7 +192,7 @@ impl<'t> Parser<'t> {
|
||||||
/// structured errors with spans and notes, like rustc
|
/// structured errors with spans and notes, like rustc
|
||||||
/// does.
|
/// does.
|
||||||
pub(crate) fn error<T: Into<String>>(&mut self, message: T) {
|
pub(crate) fn error<T: Into<String>>(&mut self, message: T) {
|
||||||
let msg = ParseError(message.into());
|
let msg = ParseError(Box::new(message.into()));
|
||||||
self.push_event(Event::Error { msg })
|
self.push_event(Event::Error { msg })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,6 @@ impl SyntaxTreeBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn error(&mut self, error: ra_parser::ParseError, text_pos: TextSize) {
|
pub fn error(&mut self, error: ra_parser::ParseError, text_pos: TextSize) {
|
||||||
self.errors.push(SyntaxError::new_at_offset(error.0, text_pos))
|
self.errors.push(SyntaxError::new_at_offset(*error.0, text_pos))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue