Skip to content

Commit b130ce0

Browse files
committed
Remove SmallVec
1 parent a15f9ee commit b130ce0

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

clippy_lints/src/write.rs

+17-15
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use rustc_parse::parser;
1313
use rustc_session::{declare_tool_lint, impl_lint_pass};
1414
use rustc_span::symbol::{kw, Symbol};
1515
use rustc_span::{sym, BytePos, Span, DUMMY_SP};
16-
use smallvec::SmallVec;
1716

1817
declare_clippy_lint! {
1918
/// **What it does:** This lint warns when you use `println!("")` to
@@ -358,8 +357,8 @@ fn newline_span(fmtstr: &StrLit) -> Span {
358357
/// empty format string.
359358
#[derive(Default)]
360359
struct SimpleFormatArgs {
361-
unnamed: Vec<SmallVec<[Span; 1]>>,
362-
named: Vec<(Symbol, SmallVec<[Span; 1]>)>,
360+
unnamed: Vec<Vec<Span>>,
361+
named: Vec<(Symbol, Vec<Span>)>,
363362
}
364363
impl SimpleFormatArgs {
365364
fn get_unnamed(&self) -> impl Iterator<Item = &[Span]> {
@@ -395,11 +394,11 @@ impl SimpleFormatArgs {
395394
ArgumentIs(n) | ArgumentImplicitlyIs(n) => {
396395
if self.unnamed.len() <= n {
397396
// Use a dummy span to mark all unseen arguments.
398-
self.unnamed.resize_with(n, || SmallVec::from([DUMMY_SP]));
397+
self.unnamed.resize_with(n, || vec![DUMMY_SP]);
399398
if arg.format == SIMPLE {
400-
self.unnamed.push(SmallVec::from([span]));
399+
self.unnamed.push(vec![span]);
401400
} else {
402-
self.unnamed.push(SmallVec::new());
401+
self.unnamed.push(Vec::new());
403402
}
404403
} else {
405404
let args = &mut self.unnamed[n];
@@ -409,7 +408,7 @@ impl SimpleFormatArgs {
409408
// Replace the dummy span, if it exists.
410409
([dummy @ DUMMY_SP], true) => *dummy = span,
411410
([_, ..], true) => args.push(span),
412-
([_, ..], false) => *args = SmallVec::new(),
411+
([_, ..], false) => *args = Vec::new(),
413412
}
414413
}
415414
},
@@ -419,12 +418,12 @@ impl SimpleFormatArgs {
419418
// A non-empty format string has been seen already.
420419
[] => (),
421420
[_, ..] if arg.format == SIMPLE => x.1.push(span),
422-
[_, ..] => x.1 = SmallVec::new(),
421+
[_, ..] => x.1 = Vec::new(),
423422
}
424423
} else if arg.format == SIMPLE {
425-
self.named.push((n, SmallVec::from([span])));
424+
self.named.push((n, vec![span]));
426425
} else {
427-
self.named.push((n, SmallVec::new()));
426+
self.named.push((n, Vec::new()));
428427
}
429428
},
430429
};
@@ -435,24 +434,27 @@ impl Write {
435434
/// Parses a format string into a collection of spans for each argument. This only keeps track
436435
/// of empty format arguments. Will also lint usages of debug format strings outside of debug
437436
/// impls.
438-
fn parse_fmt_string(&self, cx: &EarlyContext<'_>, str: &StrLit) -> Option<SimpleFormatArgs> {
437+
fn parse_fmt_string(&self, cx: &EarlyContext<'_>, str_lit: &StrLit) -> Option<SimpleFormatArgs> {
439438
use rustc_parse_format::{ParseMode, Parser, Piece};
440439

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

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

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

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

0 commit comments

Comments
 (0)