1616#![ warn( unreachable_pub) ]
1717// tidy-alphabetical-end
1818
19- use std:: { iter, str, string} ;
20-
2119pub use Alignment :: * ;
2220pub use Count :: * ;
23- pub use Piece :: * ;
2421pub use Position :: * ;
2522use rustc_lexer:: unescape;
2623
@@ -86,7 +83,7 @@ impl InnerOffset {
8683#[ derive( Clone , Debug , PartialEq ) ]
8784pub enum Piece < ' a > {
8885 /// A literal string which should directly be emitted
89- String ( & ' a str ) ,
86+ Lit ( & ' a str ) ,
9087 /// This describes that formatting should process the next argument (as
9188 /// specified inside) for emission.
9289 NextArgument ( Box < Argument < ' a > > ) ,
@@ -205,11 +202,11 @@ pub enum Count<'a> {
205202}
206203
207204pub 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 ,
211208 pub span : InnerSpan ,
212- pub secondary_label : Option < ( string :: String , InnerSpan ) > ,
209+ pub secondary_label : Option < ( String , InnerSpan ) > ,
213210 pub suggestion : Suggestion ,
214211}
215212
@@ -225,7 +222,7 @@ pub enum Suggestion {
225222 /// `format!("{foo:?#}")` -> `format!("{foo:#?}")`
226223 /// `format!("{foo:?x}")` -> `format!("{foo:x?}")`
227224 /// `format!("{foo:?X}")` -> `format!("{foo:X?}")`
228- ReorderFormatParameter ( InnerSpan , string :: String ) ,
225+ ReorderFormatParameter ( InnerSpan , String ) ,
229226}
230227
231228/// The parser structure for interpreting the input format string. This is
@@ -237,7 +234,7 @@ pub enum Suggestion {
237234pub struct Parser < ' a > {
238235 mode : ParseMode ,
239236 input : & ' a str ,
240- cur : iter:: Peekable < str:: CharIndices < ' a > > ,
237+ cur : std :: iter:: Peekable < std :: str:: CharIndices < ' a > > ,
241238 /// Error messages accumulated during parsing
242239 pub errors : Vec < ParseError > ,
243240 /// Current position of implicit positional argument pointer
@@ -278,7 +275,7 @@ impl<'a> Iterator for Parser<'a> {
278275 if self . consume ( '{' ) {
279276 self . last_opening_brace = curr_last_brace;
280277
281- Some ( String ( self . string ( pos + 1 ) ) )
278+ Some ( Piece :: Lit ( self . string ( pos + 1 ) ) )
282279 } else {
283280 let arg = self . argument ( lbrace_end) ;
284281 if let Some ( rbrace_pos) = self . consume_closing_brace ( & arg) {
@@ -299,13 +296,13 @@ impl<'a> Iterator for Parser<'a> {
299296 _ => self . suggest_positional_arg_instead_of_captured_arg ( arg) ,
300297 }
301298 }
302- Some ( NextArgument ( Box :: new ( arg) ) )
299+ Some ( Piece :: NextArgument ( Box :: new ( arg) ) )
303300 }
304301 }
305302 '}' => {
306303 self . cur . next ( ) ;
307304 if self . consume ( '}' ) {
308- Some ( String ( self . string ( pos + 1 ) ) )
305+ Some ( Piece :: Lit ( self . string ( pos + 1 ) ) )
309306 } else {
310307 let err_pos = self . to_span_index ( pos) ;
311308 self . err_with_note (
@@ -317,7 +314,7 @@ impl<'a> Iterator for Parser<'a> {
317314 None
318315 }
319316 }
320- _ => Some ( String ( self . string ( pos) ) ) ,
317+ _ => Some ( Piece :: Lit ( self . string ( pos) ) ) ,
321318 }
322319 } else {
323320 if self . is_source_literal {
@@ -336,7 +333,7 @@ impl<'a> Parser<'a> {
336333 pub fn new (
337334 s : & ' a str ,
338335 style : Option < usize > ,
339- snippet : Option < string :: String > ,
336+ snippet : Option < String > ,
340337 append_newline : bool ,
341338 mode : ParseMode ,
342339 ) -> Parser < ' a > {
@@ -366,7 +363,7 @@ impl<'a> Parser<'a> {
366363 /// Notifies of an error. The message doesn't actually need to be of type
367364 /// String, but I think it does when this eventually uses conditions so it
368365 /// 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 > > (
370367 & mut self ,
371368 description : S1 ,
372369 label : S2 ,
@@ -385,11 +382,7 @@ impl<'a> Parser<'a> {
385382 /// Notifies of an error. The message doesn't actually need to be of type
386383 /// String, but I think it does when this eventually uses conditions so it
387384 /// 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 > > (
393386 & mut self ,
394387 description : S1 ,
395388 label : S2 ,
@@ -968,7 +961,7 @@ impl<'a> Parser<'a> {
968961/// in order to properly synthesise the intra-string `Span`s for error diagnostics.
969962fn find_width_map_from_snippet (
970963 input : & str ,
971- snippet : Option < string :: String > ,
964+ snippet : Option < String > ,
972965 str_style : Option < usize > ,
973966) -> InputStringKind {
974967 let snippet = match snippet {
@@ -1083,8 +1076,8 @@ fn find_width_map_from_snippet(
10831076 InputStringKind :: Literal { width_mappings }
10841077}
10851078
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 ( ) ;
10881081 let mut ok = true ;
10891082 unescape:: unescape_unicode ( string, unescape:: Mode :: Str , & mut |_, unescaped_char| {
10901083 match unescaped_char {
0 commit comments