Skip to content

Commit 0124b07

Browse files
committed
parse_format optimize import use
1 parent 3e074fd commit 0124b07

File tree

1 file changed

+12
-18
lines changed
  • compiler/rustc_parse_format/src

1 file changed

+12
-18
lines changed

compiler/rustc_parse_format/src/lib.rs

+12-18
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
#![warn(unreachable_pub)]
1717
// tidy-alphabetical-end
1818

19-
use std::{iter, str, string};
20-
2119
pub use Alignment::*;
2220
pub use Count::*;
2321
pub use Piece::*;
@@ -205,11 +203,11 @@ pub enum Count<'a> {
205203
}
206204

207205
pub struct ParseError {
208-
pub description: string::String,
209-
pub note: Option<string::String>,
210-
pub label: string::String,
206+
pub description: String,
207+
pub note: Option<String>,
208+
pub label: String,
211209
pub span: InnerSpan,
212-
pub secondary_label: Option<(string::String, InnerSpan)>,
210+
pub secondary_label: Option<(String, InnerSpan)>,
213211
pub suggestion: Suggestion,
214212
}
215213

@@ -225,7 +223,7 @@ pub enum Suggestion {
225223
/// `format!("{foo:?#}")` -> `format!("{foo:#?}")`
226224
/// `format!("{foo:?x}")` -> `format!("{foo:x?}")`
227225
/// `format!("{foo:?X}")` -> `format!("{foo:X?}")`
228-
ReorderFormatParameter(InnerSpan, string::String),
226+
ReorderFormatParameter(InnerSpan, String),
229227
}
230228

231229
/// The parser structure for interpreting the input format string. This is
@@ -237,7 +235,7 @@ pub enum Suggestion {
237235
pub struct Parser<'a> {
238236
mode: ParseMode,
239237
input: &'a str,
240-
cur: iter::Peekable<str::CharIndices<'a>>,
238+
cur: std::iter::Peekable<std::str::CharIndices<'a>>,
241239
/// Error messages accumulated during parsing
242240
pub errors: Vec<ParseError>,
243241
/// Current position of implicit positional argument pointer
@@ -336,7 +334,7 @@ impl<'a> Parser<'a> {
336334
pub fn new(
337335
s: &'a str,
338336
style: Option<usize>,
339-
snippet: Option<string::String>,
337+
snippet: Option<String>,
340338
append_newline: bool,
341339
mode: ParseMode,
342340
) -> Parser<'a> {
@@ -366,7 +364,7 @@ impl<'a> Parser<'a> {
366364
/// Notifies of an error. The message doesn't actually need to be of type
367365
/// String, but I think it does when this eventually uses conditions so it
368366
/// might as well start using it now.
369-
fn err<S1: Into<string::String>, S2: Into<string::String>>(
367+
fn err<S1: Into<String>, S2: Into<String>>(
370368
&mut self,
371369
description: S1,
372370
label: S2,
@@ -385,11 +383,7 @@ impl<'a> Parser<'a> {
385383
/// Notifies of an error. The message doesn't actually need to be of type
386384
/// String, but I think it does when this eventually uses conditions so it
387385
/// 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-
>(
386+
fn err_with_note<S1: Into<String>, S2: Into<String>, S3: Into<String>>(
393387
&mut self,
394388
description: S1,
395389
label: S2,
@@ -974,7 +968,7 @@ impl<'a> Parser<'a> {
974968
/// in order to properly synthesise the intra-string `Span`s for error diagnostics.
975969
fn find_width_map_from_snippet(
976970
input: &str,
977-
snippet: Option<string::String>,
971+
snippet: Option<String>,
978972
str_style: Option<usize>,
979973
) -> InputStringKind {
980974
let snippet = match snippet {
@@ -1089,8 +1083,8 @@ fn find_width_map_from_snippet(
10891083
InputStringKind::Literal { width_mappings }
10901084
}
10911085

1092-
fn unescape_string(string: &str) -> Option<string::String> {
1093-
let mut buf = string::String::new();
1086+
fn unescape_string(string: &str) -> Option<String> {
1087+
let mut buf = String::new();
10941088
let mut ok = true;
10951089
unescape::unescape_unicode(string, unescape::Mode::Str, &mut |_, unescaped_char| {
10961090
match unescaped_char {

0 commit comments

Comments
 (0)