16
16
#![ warn( unreachable_pub) ]
17
17
// tidy-alphabetical-end
18
18
19
- use std:: { iter, str, string} ;
20
-
21
19
pub use Alignment :: * ;
22
20
pub use Count :: * ;
23
- pub use Piece :: * ;
24
21
pub use Position :: * ;
25
22
use rustc_lexer:: unescape;
26
23
@@ -86,7 +83,7 @@ impl InnerOffset {
86
83
#[ derive( Clone , Debug , PartialEq ) ]
87
84
pub enum Piece < ' a > {
88
85
/// A literal string which should directly be emitted
89
- String ( & ' a str ) ,
86
+ Lit ( & ' a str ) ,
90
87
/// This describes that formatting should process the next argument (as
91
88
/// specified inside) for emission.
92
89
NextArgument ( Box < Argument < ' a > > ) ,
@@ -205,11 +202,11 @@ pub enum Count<'a> {
205
202
}
206
203
207
204
pub struct ParseError {
208
- pub description : string :: String ,
209
- pub note : Option < string :: String > ,
210
- pub label : string :: String ,
205
+ pub description : String ,
206
+ pub note : Option < String > ,
207
+ pub label : String ,
211
208
pub span : InnerSpan ,
212
- pub secondary_label : Option < ( string :: String , InnerSpan ) > ,
209
+ pub secondary_label : Option < ( String , InnerSpan ) > ,
213
210
pub suggestion : Suggestion ,
214
211
}
215
212
@@ -225,7 +222,7 @@ pub enum Suggestion {
225
222
/// `format!("{foo:?#}")` -> `format!("{foo:#?}")`
226
223
/// `format!("{foo:?x}")` -> `format!("{foo:x?}")`
227
224
/// `format!("{foo:?X}")` -> `format!("{foo:X?}")`
228
- ReorderFormatParameter ( InnerSpan , string :: String ) ,
225
+ ReorderFormatParameter ( InnerSpan , String ) ,
229
226
}
230
227
231
228
/// The parser structure for interpreting the input format string. This is
@@ -237,7 +234,7 @@ pub enum Suggestion {
237
234
pub struct Parser < ' a > {
238
235
mode : ParseMode ,
239
236
input : & ' a str ,
240
- cur : iter:: Peekable < str:: CharIndices < ' a > > ,
237
+ cur : std :: iter:: Peekable < std :: str:: CharIndices < ' a > > ,
241
238
/// Error messages accumulated during parsing
242
239
pub errors : Vec < ParseError > ,
243
240
/// Current position of implicit positional argument pointer
@@ -278,7 +275,7 @@ impl<'a> Iterator for Parser<'a> {
278
275
if self . consume ( '{' ) {
279
276
self . last_opening_brace = curr_last_brace;
280
277
281
- Some ( String ( self . string ( pos + 1 ) ) )
278
+ Some ( Piece :: Lit ( self . string ( pos + 1 ) ) )
282
279
} else {
283
280
let arg = self . argument ( lbrace_end) ;
284
281
if let Some ( rbrace_pos) = self . consume_closing_brace ( & arg) {
@@ -299,13 +296,13 @@ impl<'a> Iterator for Parser<'a> {
299
296
_ => self . suggest_positional_arg_instead_of_captured_arg ( arg) ,
300
297
}
301
298
}
302
- Some ( NextArgument ( Box :: new ( arg) ) )
299
+ Some ( Piece :: NextArgument ( Box :: new ( arg) ) )
303
300
}
304
301
}
305
302
'}' => {
306
303
self . cur . next ( ) ;
307
304
if self . consume ( '}' ) {
308
- Some ( String ( self . string ( pos + 1 ) ) )
305
+ Some ( Piece :: Lit ( self . string ( pos + 1 ) ) )
309
306
} else {
310
307
let err_pos = self . to_span_index ( pos) ;
311
308
self . err_with_note (
@@ -317,7 +314,7 @@ impl<'a> Iterator for Parser<'a> {
317
314
None
318
315
}
319
316
}
320
- _ => Some ( String ( self . string ( pos) ) ) ,
317
+ _ => Some ( Piece :: Lit ( self . string ( pos) ) ) ,
321
318
}
322
319
} else {
323
320
if self . is_source_literal {
@@ -336,7 +333,7 @@ impl<'a> Parser<'a> {
336
333
pub fn new (
337
334
s : & ' a str ,
338
335
style : Option < usize > ,
339
- snippet : Option < string :: String > ,
336
+ snippet : Option < String > ,
340
337
append_newline : bool ,
341
338
mode : ParseMode ,
342
339
) -> Parser < ' a > {
@@ -366,7 +363,7 @@ impl<'a> Parser<'a> {
366
363
/// Notifies of an error. The message doesn't actually need to be of type
367
364
/// String, but I think it does when this eventually uses conditions so it
368
365
/// might as well start using it now.
369
- fn err < S1 : Into < string :: String > , S2 : Into < string :: String > > (
366
+ fn err < S1 : Into < String > , S2 : Into < String > > (
370
367
& mut self ,
371
368
description : S1 ,
372
369
label : S2 ,
@@ -385,11 +382,7 @@ impl<'a> Parser<'a> {
385
382
/// Notifies of an error. The message doesn't actually need to be of type
386
383
/// String, but I think it does when this eventually uses conditions so it
387
384
/// might as well start using it now.
388
- fn err_with_note <
389
- S1 : Into < string:: String > ,
390
- S2 : Into < string:: String > ,
391
- S3 : Into < string:: String > ,
392
- > (
385
+ fn err_with_note < S1 : Into < String > , S2 : Into < String > , S3 : Into < String > > (
393
386
& mut self ,
394
387
description : S1 ,
395
388
label : S2 ,
@@ -968,7 +961,7 @@ impl<'a> Parser<'a> {
968
961
/// in order to properly synthesise the intra-string `Span`s for error diagnostics.
969
962
fn find_width_map_from_snippet (
970
963
input : & str ,
971
- snippet : Option < string :: String > ,
964
+ snippet : Option < String > ,
972
965
str_style : Option < usize > ,
973
966
) -> InputStringKind {
974
967
let snippet = match snippet {
@@ -1083,8 +1076,8 @@ fn find_width_map_from_snippet(
1083
1076
InputStringKind :: Literal { width_mappings }
1084
1077
}
1085
1078
1086
- fn unescape_string ( string : & str ) -> Option < string :: String > {
1087
- let mut buf = string :: String :: new ( ) ;
1079
+ fn unescape_string ( string : & str ) -> Option < String > {
1080
+ let mut buf = String :: new ( ) ;
1088
1081
let mut ok = true ;
1089
1082
unescape:: unescape_unicode ( string, unescape:: Mode :: Str , & mut |_, unescaped_char| {
1090
1083
match unescaped_char {
0 commit comments