@@ -5,7 +5,7 @@ use miette::SourceSpan;
55use std:: fmt;
66
77fn to_source_span ( span : logos:: Span ) -> SourceSpan {
8- SourceSpan :: new ( span. start . into ( ) , ( span. end - span. start ) . into ( ) )
8+ SourceSpan :: new ( span. start . into ( ) , span. end - span. start )
99}
1010
1111/// Represents a lexer error.
@@ -52,7 +52,7 @@ fn detect_invalid_input(source: &str) -> Result<(), (Error, SourceSpan)> {
5252 | '\u{2067}' | '\u{2068}' | '\u{2069}' => {
5353 return Err ( (
5454 Error :: DisallowedBidirectionalOverride ( ch) ,
55- SourceSpan :: new ( offset. into ( ) , ch. len_utf8 ( ) . into ( ) ) ,
55+ SourceSpan :: new ( offset. into ( ) , ch. len_utf8 ( ) ) ,
5656 ) ) ;
5757 }
5858
@@ -67,7 +67,7 @@ fn detect_invalid_input(source: &str) -> Result<(), (Error, SourceSpan)> {
6767 | '\u{17b4}' | '\u{17b5}' => {
6868 return Err ( (
6969 Error :: DiscouragedUnicodeCodepoint ( ch) ,
70- SourceSpan :: new ( offset. into ( ) , ch. len_utf8 ( ) . into ( ) ) ,
70+ SourceSpan :: new ( offset. into ( ) , ch. len_utf8 ( ) ) ,
7171 ) ) ;
7272 }
7373
@@ -77,7 +77,7 @@ fn detect_invalid_input(source: &str) -> Result<(), (Error, SourceSpan)> {
7777 ch if ch. is_control ( ) => {
7878 return Err ( (
7979 Error :: DisallowedControlCode ( ch) ,
80- SourceSpan :: new ( offset. into ( ) , ch. len_utf8 ( ) . into ( ) ) ,
80+ SourceSpan :: new ( offset. into ( ) , ch. len_utf8 ( ) ) ,
8181 ) ) ;
8282 }
8383
@@ -480,21 +480,21 @@ impl<'a> Lexer<'a> {
480480
481481 /// Peeks at the next token.
482482 pub fn peek ( & self ) -> Option < ( LexerResult < Token > , SourceSpan ) > {
483- let mut lexer = self . 0 . clone ( ) . spanned ( ) ;
483+ let mut lexer = self . 0 . clone ( ) ;
484484 lexer. next ( ) . map ( |( r, s) | ( r, to_source_span ( s) ) )
485485 }
486486
487487 /// Peeks at the token after the next token.
488488 pub fn peek2 ( & self ) -> Option < ( LexerResult < Token > , SourceSpan ) > {
489- let mut lexer = self . 0 . clone ( ) . spanned ( ) ;
489+ let mut lexer = self . 0 . clone ( ) ;
490490 lexer. next ( ) ;
491491 lexer. next ( ) . map ( |( r, s) | ( r, to_source_span ( s) ) )
492492 }
493493
494494 /// Consumes available documentation comment tokens.
495- pub fn comments < ' b > ( & ' b self ) -> Result < Vec < ( & ' a str , SourceSpan ) > , ( Error , SourceSpan ) > {
495+ pub fn comments ( & self ) -> Result < Vec < ( & ' a str , SourceSpan ) > , ( Error , SourceSpan ) > {
496496 let mut comments = Vec :: new ( ) ;
497- let mut lexer = self . 0 . clone ( ) . morph :: < helpers:: CommentToken > ( ) . spanned ( ) ;
497+ let mut lexer = ( * self . 0 ) . clone ( ) . morph :: < helpers:: CommentToken > ( ) . spanned ( ) ;
498498 while let Some ( ( Ok ( token) , span) ) = lexer. next ( ) {
499499 match token {
500500 helpers:: CommentToken :: Comment ( c) | helpers:: CommentToken :: BlockComment ( c) => {
@@ -537,7 +537,7 @@ mod test {
537537 source : & ' a Token :: Source ,
538538 tokens : & [ (
539539 Result < Token , Token :: Error > ,
540- & ' a <Token :: Source as Source >:: Slice ,
540+ <Token :: Source as Source >:: Slice < ' a > ,
541541 Range < usize > ,
542542 ) ] ,
543543 ) where
0 commit comments