Skip to content

Commit 6946cc1

Browse files
committed
Remove SmallVec
1 parent a7fa2a6 commit 6946cc1

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

clippy_lints/src/write.rs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use rustc_parse::parser;
1414
use rustc_session::{declare_tool_lint, impl_lint_pass};
1515
use rustc_span::symbol::{kw, Symbol};
1616
use rustc_span::{sym, BytePos, Span, DUMMY_SP};
17-
use smallvec::SmallVec;
1817

1918
declare_clippy_lint! {
2019
/// **What it does:** This lint warns when you use `println!("")` to
@@ -359,8 +358,8 @@ fn newline_span(fmtstr: &StrLit) -> Span {
359358
/// empty format string.
360359
#[derive(Default)]
361360
struct SimpleFormatArgs {
362-
unnamed: Vec<SmallVec<[Span; 1]>>,
363-
named: Vec<(Symbol, SmallVec<[Span; 1]>)>,
361+
unnamed: Vec<Vec<Span>>,
362+
named: Vec<(Symbol, Vec<Span>)>,
364363
}
365364
impl SimpleFormatArgs {
366365
fn get_unnamed(&self) -> impl Iterator<Item = &[Span]> {
@@ -396,11 +395,11 @@ impl SimpleFormatArgs {
396395
ArgumentIs(n) | ArgumentImplicitlyIs(n) => {
397396
if self.unnamed.len() <= n {
398397
// Use a dummy span to mark all unseen arguments.
399-
self.unnamed.resize_with(n, || SmallVec::from([DUMMY_SP]));
398+
self.unnamed.resize_with(n, || vec![DUMMY_SP]);
400399
if arg.format == SIMPLE {
401-
self.unnamed.push(SmallVec::from([span]));
400+
self.unnamed.push(vec![span]);
402401
} else {
403-
self.unnamed.push(SmallVec::new());
402+
self.unnamed.push(Vec::new());
404403
}
405404
} else {
406405
let args = &mut self.unnamed[n];
@@ -410,7 +409,7 @@ impl SimpleFormatArgs {
410409
// Replace the dummy span, if it exists.
411410
([dummy @ DUMMY_SP], true) => *dummy = span,
412411
([_, ..], true) => args.push(span),
413-
([_, ..], false) => *args = SmallVec::new(),
412+
([_, ..], false) => *args = Vec::new(),
414413
}
415414
}
416415
},
@@ -420,12 +419,12 @@ impl SimpleFormatArgs {
420419
// A non-empty format string has been seen already.
421420
[] => (),
422421
[_, ..] if arg.format == SIMPLE => x.1.push(span),
423-
[_, ..] => x.1 = SmallVec::new(),
422+
[_, ..] => x.1 = Vec::new(),
424423
}
425424
} else if arg.format == SIMPLE {
426-
self.named.push((n, SmallVec::from([span])));
425+
self.named.push((n, vec![span]));
427426
} else {
428-
self.named.push((n, SmallVec::new()));
427+
self.named.push((n, Vec::new()));
429428
}
430429
},
431430
};
@@ -436,24 +435,27 @@ impl Write {
436435
/// Parses a format string into a collection of spans for each argument. This only keeps track
437436
/// of empty format arguments. Will also lint usages of debug format strings outside of debug
438437
/// impls.
439-
fn parse_fmt_string(&self, cx: &EarlyContext<'_>, str: &StrLit) -> Option<SimpleFormatArgs> {
438+
fn parse_fmt_string(&self, cx: &EarlyContext<'_>, str_lit: &StrLit) -> Option<SimpleFormatArgs> {
440439
use rustc_parse_format::{ParseMode, Parser, Piece};
441440

442-
let str_sym = str.symbol_unescaped.as_str();
443-
let style = match str.style {
441+
let str_sym = str_lit.symbol_unescaped.as_str();
442+
let style = match str_lit.style {
444443
StrStyle::Cooked => None,
445444
StrStyle::Raw(n) => Some(n as usize),
446445
};
447446

448-
let mut parser = Parser::new(&str_sym, style, snippet_opt(cx, str.span), false, ParseMode::Format);
447+
let mut parser = Parser::new(&str_sym, style, snippet_opt(cx, str_lit.span), false, ParseMode::Format);
449448
let mut args = SimpleFormatArgs::default();
450449

451450
while let Some(arg) = parser.next() {
452451
let arg = match arg {
453452
Piece::String(_) => continue,
454453
Piece::NextArgument(arg) => arg,
455454
};
456-
let span = parser.arg_places.last().map_or(DUMMY_SP, |&x| str.span.from_inner(x));
455+
let span = parser
456+
.arg_places
457+
.last()
458+
.map_or(DUMMY_SP, |&x| str_lit.span.from_inner(x));
457459

458460
if !self.in_debug_impl && arg.format.ty == "?" {
459461
// FIXME: modify rustc's fmt string parser to give us the current span

0 commit comments

Comments
 (0)