Skip to content

Commit dc1e09b

Browse files
committed
Auto merge of rust-lang#5897 - matthiaskrgr:no_clone_tts, r=flip1995
write.rs: don't clone TokenStream changelog: none
2 parents 439bae6 + 8a96b9c commit dc1e09b

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

clippy_lints/src/write.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ impl EarlyLintPass for Write {
237237
fn check_mac(&mut self, cx: &EarlyContext<'_>, mac: &MacCall) {
238238
if mac.path == sym!(println) {
239239
span_lint(cx, PRINT_STDOUT, mac.span(), "use of `println!`");
240-
if let (Some(fmt_str), _) = self.check_tts(cx, &mac.args.inner_tokens(), false) {
240+
if let (Some(fmt_str), _) = self.check_tts(cx, mac.args.inner_tokens(), false) {
241241
if fmt_str.symbol == Symbol::intern("") {
242242
span_lint_and_sugg(
243243
cx,
@@ -252,7 +252,7 @@ impl EarlyLintPass for Write {
252252
}
253253
} else if mac.path == sym!(print) {
254254
span_lint(cx, PRINT_STDOUT, mac.span(), "use of `print!`");
255-
if let (Some(fmt_str), _) = self.check_tts(cx, &mac.args.inner_tokens(), false) {
255+
if let (Some(fmt_str), _) = self.check_tts(cx, mac.args.inner_tokens(), false) {
256256
if check_newlines(&fmt_str) {
257257
span_lint_and_then(
258258
cx,
@@ -273,7 +273,7 @@ impl EarlyLintPass for Write {
273273
}
274274
}
275275
} else if mac.path == sym!(write) {
276-
if let (Some(fmt_str), _) = self.check_tts(cx, &mac.args.inner_tokens(), true) {
276+
if let (Some(fmt_str), _) = self.check_tts(cx, mac.args.inner_tokens(), true) {
277277
if check_newlines(&fmt_str) {
278278
span_lint_and_then(
279279
cx,
@@ -294,7 +294,7 @@ impl EarlyLintPass for Write {
294294
}
295295
}
296296
} else if mac.path == sym!(writeln) {
297-
if let (Some(fmt_str), expr) = self.check_tts(cx, &mac.args.inner_tokens(), true) {
297+
if let (Some(fmt_str), expr) = self.check_tts(cx, mac.args.inner_tokens(), true) {
298298
if fmt_str.symbol == Symbol::intern("") {
299299
let mut applicability = Applicability::MachineApplicable;
300300
let suggestion = expr.map_or_else(
@@ -364,17 +364,11 @@ impl Write {
364364
/// (Some("string to write: {}"), Some(buf))
365365
/// ```
366366
#[allow(clippy::too_many_lines)]
367-
fn check_tts<'a>(
368-
&self,
369-
cx: &EarlyContext<'a>,
370-
tts: &TokenStream,
371-
is_write: bool,
372-
) -> (Option<StrLit>, Option<Expr>) {
367+
fn check_tts<'a>(&self, cx: &EarlyContext<'a>, tts: TokenStream, is_write: bool) -> (Option<StrLit>, Option<Expr>) {
373368
use rustc_parse_format::{
374369
AlignUnknown, ArgumentImplicitlyIs, ArgumentIs, ArgumentNamed, CountImplied, FormatSpec, ParseMode, Parser,
375370
Piece,
376371
};
377-
let tts = tts.clone();
378372

379373
let mut parser = parser::Parser::new(&cx.sess.parse_sess, tts, false, None);
380374
let mut expr: Option<Expr> = None;

0 commit comments

Comments
 (0)