@@ -116,13 +116,13 @@ impl<'i, T> From<BasicParseError<'i>> for ParseError<'i, T> {
116
116
impl SourceLocation {
117
117
/// Create a new BasicParseError at this location for an unexpected token
118
118
#[ inline]
119
- pub fn new_basic_unexpected_token_error ( self , token : Token < ' _ > ) -> BasicParseError < ' _ > {
119
+ pub const fn new_basic_unexpected_token_error ( self , token : Token < ' _ > ) -> BasicParseError < ' _ > {
120
120
self . new_basic_error ( BasicParseErrorKind :: UnexpectedToken ( token) )
121
121
}
122
122
123
123
/// Create a new BasicParseError at this location
124
124
#[ inline]
125
- pub fn new_basic_error ( self , kind : BasicParseErrorKind < ' _ > ) -> BasicParseError < ' _ > {
125
+ pub const fn new_basic_error ( self , kind : BasicParseErrorKind < ' _ > ) -> BasicParseError < ' _ > {
126
126
BasicParseError {
127
127
kind,
128
128
location : self ,
@@ -131,13 +131,13 @@ impl SourceLocation {
131
131
132
132
/// Create a new ParseError at this location for an unexpected token
133
133
#[ inline]
134
- pub fn new_unexpected_token_error < E > ( self , token : Token < ' _ > ) -> ParseError < ' _ , E > {
134
+ pub const fn new_unexpected_token_error < E > ( self , token : Token < ' _ > ) -> ParseError < ' _ , E > {
135
135
self . new_error ( BasicParseErrorKind :: UnexpectedToken ( token) )
136
136
}
137
137
138
138
/// Create a new basic ParseError at the current location
139
139
#[ inline]
140
- pub fn new_error < E > ( self , kind : BasicParseErrorKind < ' _ > ) -> ParseError < ' _ , E > {
140
+ pub const fn new_error < E > ( self , kind : BasicParseErrorKind < ' _ > ) -> ParseError < ' _ , E > {
141
141
ParseError {
142
142
kind : ParseErrorKind :: Basic ( kind) ,
143
143
location : self ,
@@ -240,7 +240,7 @@ struct CachedToken<'i> {
240
240
241
241
impl < ' i > ParserInput < ' i > {
242
242
/// Create a new input for a parser.
243
- pub fn new ( input : & ' i str ) -> ParserInput < ' i > {
243
+ pub const fn new ( input : & ' i str ) -> ParserInput < ' i > {
244
244
ParserInput {
245
245
tokenizer : Tokenizer :: new ( input) ,
246
246
cached_token : None ,
@@ -383,7 +383,7 @@ macro_rules! expect {
383
383
impl < ' i : ' t , ' t > Parser < ' i , ' t > {
384
384
/// Create a new parser
385
385
#[ inline]
386
- pub fn new ( input : & ' t mut ParserInput < ' i > ) -> Parser < ' i , ' t > {
386
+ pub const fn new ( input : & ' t mut ParserInput < ' i > ) -> Parser < ' i , ' t > {
387
387
Parser {
388
388
input,
389
389
at_start_of : None ,
@@ -435,7 +435,7 @@ impl<'i: 't, 't> Parser<'i, 't> {
435
435
436
436
/// The current line number and column number.
437
437
#[ inline]
438
- pub fn current_source_location ( & self ) -> SourceLocation {
438
+ pub const fn current_source_location ( & self ) -> SourceLocation {
439
439
self . input . tokenizer . current_source_location ( )
440
440
}
441
441
@@ -459,13 +459,13 @@ impl<'i: 't, 't> Parser<'i, 't> {
459
459
460
460
/// Create a new BasicParseError at the current location
461
461
#[ inline]
462
- pub fn new_basic_error ( & self , kind : BasicParseErrorKind < ' i > ) -> BasicParseError < ' i > {
462
+ pub const fn new_basic_error ( & self , kind : BasicParseErrorKind < ' i > ) -> BasicParseError < ' i > {
463
463
self . current_source_location ( ) . new_basic_error ( kind)
464
464
}
465
465
466
466
/// Create a new basic ParseError at the current location
467
467
#[ inline]
468
- pub fn new_error < E > ( & self , kind : BasicParseErrorKind < ' i > ) -> ParseError < ' i , E > {
468
+ pub const fn new_error < E > ( & self , kind : BasicParseErrorKind < ' i > ) -> ParseError < ' i , E > {
469
469
self . current_source_location ( ) . new_error ( kind)
470
470
}
471
471
@@ -477,13 +477,13 @@ impl<'i: 't, 't> Parser<'i, 't> {
477
477
478
478
/// Create a new unexpected token BasicParseError at the current location
479
479
#[ inline]
480
- pub fn new_basic_unexpected_token_error ( & self , token : Token < ' i > ) -> BasicParseError < ' i > {
480
+ pub const fn new_basic_unexpected_token_error ( & self , token : Token < ' i > ) -> BasicParseError < ' i > {
481
481
self . new_basic_error ( BasicParseErrorKind :: UnexpectedToken ( token) )
482
482
}
483
483
484
484
/// Create a new unexpected token ParseError at the current location
485
485
#[ inline]
486
- pub fn new_unexpected_token_error < E > ( & self , token : Token < ' i > ) -> ParseError < ' i , E > {
486
+ pub const fn new_unexpected_token_error < E > ( & self , token : Token < ' i > ) -> ParseError < ' i , E > {
487
487
self . new_error ( BasicParseErrorKind :: UnexpectedToken ( token) )
488
488
}
489
489
0 commit comments