Skip to content

Commit

Permalink
Removed redundant method set_error
Browse files Browse the repository at this point in the history
Replaced usages with `set`
  • Loading branch information
mysteriouslyseeing committed Dec 11, 2024
1 parent 9835896 commit ac45573
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 17 deletions.
4 changes: 2 additions & 2 deletions logos-codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ pub fn generate(input: TokenStream) -> TokenStream {
fn make_error(mut lex: &mut #logos_path::Lexer<'s, Self>) {
use #logos_path::internal::LexerInternal;
let error = #label(&mut lex);
lex.set_error(error);
lex.set(Err(error));
}
}),
Some(leaf::Callback::Inline(inline)) => {
Expand All @@ -248,7 +248,7 @@ pub fn generate(input: TokenStream) -> TokenStream {
fn make_error(#arg: &mut #logos_path::Lexer<'s, Self>) {
use #logos_path::internal::LexerInternal;
let error = #body;
#arg.set_error(error)
#arg.set(Err(error))
}
})
}
Expand Down
2 changes: 0 additions & 2 deletions src/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ pub trait LexerInternal<'source> {
/// Guarantee that `token_end` is at char boundary for `&str`.
fn error(&mut self);

fn set_error(&mut self, error: <Self::Token as Logos<'source>>::Error);

fn end(&mut self);

fn set(
Expand Down
12 changes: 0 additions & 12 deletions src/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,18 +379,6 @@ where
Token::make_error(self);
}

#[inline]
fn set_error(&mut self, error: Token::Error) {
#[cfg(not(feature = "forbid_unsafe"))]
{
self.token = core::mem::ManuallyDrop::new(Some(Err(error)));
}
#[cfg(feature = "forbid_unsafe")]
{
self.token = Some(Err(error));
}
}

#[inline]
fn end(&mut self) {
self.token = Default::default();
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub trait Logos<'source>: Sized {
#[doc(hidden)]
fn make_error(lexer: &mut Lexer<'source, Self>) {
use internal::LexerInternal as _;
lexer.set_error(Self::Error::default())
lexer.set(Err(Self::Error::default()))
}
}

Expand Down

0 comments on commit ac45573

Please sign in to comment.