From 0d33f6dfa94c5e07b7ebcd882ddee0377f2c61c9 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 21 Dec 2021 22:17:17 +0100 Subject: [PATCH] Move pattern matching outside of the loop --- src/librustdoc/html/sources.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/librustdoc/html/sources.rs b/src/librustdoc/html/sources.rs index ba70ed8622a..962a954ff74 100644 --- a/src/librustdoc/html/sources.rs +++ b/src/librustdoc/html/sources.rs @@ -280,13 +280,15 @@ crate fn print_src( tmp /= 10; } line_numbers.write_str("
");
-    for i in 1..=lines {
-        match source_context {
-            SourceContext::Standalone => {
-                writeln!(line_numbers, "{0:1$}", i, cols)
+    match source_context {
+        SourceContext::Standalone => {
+            for line in 1..=lines {
+                writeln!(line_numbers, "{0:1$}", line, cols)
             }
-            SourceContext::Embedded { offset } => {
-                writeln!(line_numbers, "{0:1$}", i + offset, cols)
+        }
+        SourceContext::Embedded { offset } => {
+            for line in 1..=lines {
+                writeln!(line_numbers, "{0:1$}", line + offset, cols)
             }
         }
     }