@@ -34,35 +34,35 @@ pub enum ParseMode {
3434/// A piece is a portion of the format string which represents the next part
3535/// to emit. These are emitted as a stream by the `Parser` class.
3636#[ derive( Clone , Debug , PartialEq ) ]
37- pub enum Piece < ' a > {
37+ pub enum Piece < ' input > {
3838 /// A literal string which should directly be emitted
39- Lit ( & ' a str ) ,
39+ Lit ( & ' input str ) ,
4040 /// This describes that formatting should process the next argument (as
4141 /// specified inside) for emission.
42- NextArgument ( Box < Argument < ' a > > ) ,
42+ NextArgument ( Box < Argument < ' input > > ) ,
4343}
4444
4545/// Representation of an argument specification.
4646#[ derive( Clone , Debug , PartialEq ) ]
47- pub struct Argument < ' a > {
47+ pub struct Argument < ' input > {
4848 /// Where to find this argument
49- pub position : Position < ' a > ,
49+ pub position : Position < ' input > ,
5050 /// The span of the position indicator. Includes any whitespace in implicit
5151 /// positions (`{ }`).
5252 pub position_span : Range < usize > ,
5353 /// How to format the argument
54- pub format : FormatSpec < ' a > ,
54+ pub format : FormatSpec < ' input > ,
5555}
5656
57- impl < ' a > Argument < ' a > {
57+ impl < ' input > Argument < ' input > {
5858 pub fn is_identifier ( & self ) -> bool {
5959 matches ! ( self . position, Position :: ArgumentNamed ( _) ) && self . format == FormatSpec :: default ( )
6060 }
6161}
6262
6363/// Specification for the formatting of an argument in the format string.
6464#[ derive( Clone , Debug , PartialEq , Default ) ]
65- pub struct FormatSpec < ' a > {
65+ pub struct FormatSpec < ' input > {
6666 /// Optionally specified character to fill alignment with.
6767 pub fill : Option < char > ,
6868 /// Span of the optionally specified fill character.
@@ -78,30 +78,30 @@ pub struct FormatSpec<'a> {
7878 /// The `x` or `X` flag. (Only for `Debug`.)
7979 pub debug_hex : Option < DebugHex > ,
8080 /// The integer precision to use.
81- pub precision : Count < ' a > ,
81+ pub precision : Count < ' input > ,
8282 /// The span of the precision formatting flag (for diagnostics).
8383 pub precision_span : Option < Range < usize > > ,
8484 /// The string width requested for the resulting format.
85- pub width : Count < ' a > ,
85+ pub width : Count < ' input > ,
8686 /// The span of the width formatting flag (for diagnostics).
8787 pub width_span : Option < Range < usize > > ,
8888 /// The descriptor string representing the name of the format desired for
8989 /// this argument, this can be empty or any number of characters, although
9090 /// it is required to be one word.
91- pub ty : & ' a str ,
91+ pub ty : & ' input str ,
9292 /// The span of the descriptor string (for diagnostics).
9393 pub ty_span : Option < Range < usize > > ,
9494}
9595
9696/// Enum describing where an argument for a format can be located.
9797#[ derive( Clone , Debug , PartialEq ) ]
98- pub enum Position < ' a > {
98+ pub enum Position < ' input > {
9999 /// The argument is implied to be located at an index
100100 ArgumentImplicitlyIs ( usize ) ,
101101 /// The argument is located at a specific index given in the format,
102102 ArgumentIs ( usize ) ,
103103 /// The argument has a name.
104- ArgumentNamed ( & ' a str ) ,
104+ ArgumentNamed ( & ' input str ) ,
105105}
106106
107107impl Position < ' _ > {
@@ -148,11 +148,11 @@ pub enum DebugHex {
148148/// A count is used for the precision and width parameters of an integer, and
149149/// can reference either an argument or a literal integer.
150150#[ derive( Clone , Debug , PartialEq , Default ) ]
151- pub enum Count < ' a > {
151+ pub enum Count < ' input > {
152152 /// The count is specified explicitly.
153153 CountIs ( u16 ) ,
154154 /// The count is specified by the argument with the given name.
155- CountIsName ( & ' a str , Range < usize > ) ,
155+ CountIsName ( & ' input str , Range < usize > ) ,
156156 /// The count is specified by the argument at the given index.
157157 CountIsParam ( usize ) ,
158158 /// The count is specified by a star (like in `{:.*}`) that refers to the argument at the given index.
@@ -192,10 +192,10 @@ pub enum Suggestion {
192192///
193193/// This is a recursive-descent parser for the sake of simplicity, and if
194194/// necessary there's probably lots of room for improvement performance-wise.
195- pub struct Parser < ' a > {
195+ pub struct Parser < ' input > {
196196 mode : ParseMode ,
197197 /// Input to be parsed
198- input : & ' a str ,
198+ input : & ' input str ,
199199 /// Tuples of the span in the code snippet (input as written before being unescaped), the pos in input, and the char in input
200200 input_vec : Vec < ( Range < usize > , usize , char ) > ,
201201 /// Index into input_vec
@@ -221,10 +221,10 @@ pub struct Parser<'a> {
221221 pub line_spans : Vec < Range < usize > > ,
222222}
223223
224- impl < ' a > Iterator for Parser < ' a > {
225- type Item = Piece < ' a > ;
224+ impl < ' input > Iterator for Parser < ' input > {
225+ type Item = Piece < ' input > ;
226226
227- fn next ( & mut self ) -> Option < Piece < ' a > > {
227+ fn next ( & mut self ) -> Option < Piece < ' input > > {
228228 if let Some ( ( Range { start, end } , idx, ch) ) = self . peek ( ) {
229229 match ch {
230230 '{' => {
@@ -287,14 +287,14 @@ impl<'a> Iterator for Parser<'a> {
287287 }
288288}
289289
290- impl < ' a > Parser < ' a > {
290+ impl < ' input > Parser < ' input > {
291291 /// Creates a new parser for the given unescaped input string and
292292 /// optional code snippet (the input as written before being unescaped),
293293 /// where `style` is `Some(nr_hashes)` when the snippet is a raw string with that many hashes.
294294 /// If the input comes via `println` or `panic`, then it has a newline already appended,
295295 /// which is reflected in the `appended_newline` parameter.
296296 pub fn new (
297- input : & ' a str ,
297+ input : & ' input str ,
298298 style : Option < usize > ,
299299 snippet : Option < String > ,
300300 appended_newline : bool ,
@@ -471,7 +471,7 @@ impl<'a> Parser<'a> {
471471
472472 /// Parses all of a string which is to be considered a "raw literal" in a
473473 /// format string. This is everything outside of the braces.
474- fn string ( & mut self , start : usize ) -> & ' a str {
474+ fn string ( & mut self , start : usize ) -> & ' input str {
475475 while let Some ( ( r, i, c) ) = self . peek ( ) {
476476 match c {
477477 '{' | '}' => {
@@ -495,7 +495,7 @@ impl<'a> Parser<'a> {
495495 }
496496
497497 /// Parses an `Argument` structure, or what's contained within braces inside the format string.
498- fn argument ( & mut self ) -> Argument < ' a > {
498+ fn argument ( & mut self ) -> Argument < ' input > {
499499 let start_idx = self . input_vec_index ;
500500
501501 let position = self . position ( ) ;
@@ -524,7 +524,7 @@ impl<'a> Parser<'a> {
524524 /// integer index of an argument, a named argument, or a blank string.
525525 /// Returns `Some(parsed_position)` if the position is not implicitly
526526 /// consuming a macro argument, `None` if it's the case.
527- fn position ( & mut self ) -> Option < Position < ' a > > {
527+ fn position ( & mut self ) -> Option < Position < ' input > > {
528528 if let Some ( i) = self . integer ( ) {
529529 Some ( ArgumentIs ( i. into ( ) ) )
530530 } else {
@@ -579,7 +579,7 @@ impl<'a> Parser<'a> {
579579
580580 /// Parses a format specifier at the current position, returning all of the
581581 /// relevant information in the `FormatSpec` struct.
582- fn format ( & mut self ) -> FormatSpec < ' a > {
582+ fn format ( & mut self ) -> FormatSpec < ' input > {
583583 let mut spec = FormatSpec :: default ( ) ;
584584
585585 if !self . consume ( ':' ) {
@@ -697,7 +697,7 @@ impl<'a> Parser<'a> {
697697
698698 /// Parses an inline assembly template modifier at the current position, returning the modifier
699699 /// in the `ty` field of the `FormatSpec` struct.
700- fn inline_asm ( & mut self ) -> FormatSpec < ' a > {
700+ fn inline_asm ( & mut self ) -> FormatSpec < ' input > {
701701 let mut spec = FormatSpec :: default ( ) ;
702702
703703 if !self . consume ( ':' ) {
@@ -718,7 +718,7 @@ impl<'a> Parser<'a> {
718718 /// Parses a `Count` parameter at the current position. This does not check
719719 /// for 'CountIsNextParam' because that is only used in precision, not
720720 /// width.
721- fn count ( & mut self ) -> Count < ' a > {
721+ fn count ( & mut self ) -> Count < ' input > {
722722 if let Some ( i) = self . integer ( ) {
723723 if self . consume ( '$' ) { CountIsParam ( i. into ( ) ) } else { CountIs ( i) }
724724 } else {
@@ -737,7 +737,7 @@ impl<'a> Parser<'a> {
737737
738738 /// Parses a word starting at the current position. A word is the same as a
739739 /// Rust identifier, except that it can't start with `_` character.
740- fn word ( & mut self ) -> & ' a str {
740+ fn word ( & mut self ) -> & ' input str {
741741 let index = self . input_vec_index ;
742742 match self . peek ( ) {
743743 Some ( ( ref r, i, c) ) if rustc_lexer:: is_id_start ( c) => {
0 commit comments