]> git.lizzy.rs Git - rust.git/commitdiff
Add comemnts clarifying logic
authorEsteban Küber <esteban@kuber.com.ar>
Fri, 29 Mar 2019 03:18:50 +0000 (20:18 -0700)
committerEsteban Küber <esteban@kuber.com.ar>
Fri, 29 Mar 2019 03:18:50 +0000 (20:18 -0700)
src/librustc_errors/emitter.rs

index d2c9db2db79cf35a6ed40fef5bb145e8194f408c..98db0097c745734a50eaa82b28ec6a1abc97e94d 100644 (file)
@@ -314,8 +314,13 @@ fn add_annotation_to_file(file_vec: &mut Vec<FileWithAnnotatedLines>,
                 //  | |______foo
                 //  |        baz
                 add_annotation_to_file(&mut output, file.clone(), ann.line_start, ann.as_start());
+                // 4 is the minimum vertical length of a multiline span when presented: two lines
+                // of code and two lines of underline. This is not true for the special case where
+                // the beginning doesn't have an underline, but the current logic seems to be
+                // working correctly.
                 let middle = min(ann.line_start + 4, ann.line_end);
                 for line in ann.line_start + 1..middle {
+                    // Every `|` that joins the beginning of the span (`___^`) to the end (`|__^`).
                     add_annotation_to_file(&mut output, file.clone(), line, ann.as_line());
                 }
                 if middle < ann.line_end - 1 {