Skip to content

Commit be56dc0

Browse files
authored
Rollup merge of #106190 - estebank:multiline-start-tweak, r=jackh726
Account for multiple multiline spans with empty padding Instead of ``` LL | fn oom( | __^ | | _| | || LL | || ) { | ||_- LL | | } | |__^ ``` emit ``` LL | // fn oom( LL | || ) { | ||_- LL | | } | |__^ ```
2 parents 10374d3 + af74ca0 commit be56dc0

9 files changed

+30
-47
lines changed

compiler/rustc_errors/src/emitter.rs

+19-3
Original file line numberDiff line numberDiff line change
@@ -845,18 +845,34 @@ impl EmitterWriter {
845845
// 3 | |
846846
// 4 | | }
847847
// | |_^ test
848-
if let [ann] = &line.annotations[..] {
848+
let mut buffer_ops = vec![];
849+
let mut annotations = vec![];
850+
let mut short_start = true;
851+
for ann in &line.annotations {
849852
if let AnnotationType::MultilineStart(depth) = ann.annotation_type {
850853
if source_string.chars().take(ann.start_col).all(|c| c.is_whitespace()) {
851854
let style = if ann.is_primary {
852855
Style::UnderlinePrimary
853856
} else {
854857
Style::UnderlineSecondary
855858
};
856-
buffer.putc(line_offset, width_offset + depth - 1, '/', style);
857-
return vec![(depth, style)];
859+
annotations.push((depth, style));
860+
buffer_ops.push((line_offset, width_offset + depth - 1, '/', style));
861+
} else {
862+
short_start = false;
863+
break;
858864
}
865+
} else if let AnnotationType::MultilineLine(_) = ann.annotation_type {
866+
} else {
867+
short_start = false;
868+
break;
869+
}
870+
}
871+
if short_start {
872+
for (y, x, c, s) in buffer_ops {
873+
buffer.putc(y, x, c, s);
859874
}
875+
return annotations;
860876
}
861877

862878
// We want to display like this:

src/test/ui/alloc-error/alloc-error-handler-bad-signature-1.stderr

+2-8
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ error[E0308]: mismatched types
33
|
44
LL | #[alloc_error_handler]
55
| ---------------------- in this procedural macro expansion
6-
LL | fn oom(
7-
| __^
8-
| | _|
9-
| ||
6+
LL | // fn oom(
107
LL | || info: &Layout,
118
LL | || ) -> ()
129
| ||_______- arguments to this function are incorrect
@@ -29,10 +26,7 @@ error[E0308]: mismatched types
2926
|
3027
LL | #[alloc_error_handler]
3128
| ---------------------- in this procedural macro expansion
32-
LL | fn oom(
33-
| __^
34-
| | _|
35-
| ||
29+
LL | // fn oom(
3630
LL | || info: &Layout,
3731
LL | || ) -> ()
3832
| ||_______^ expected `!`, found `()`

src/test/ui/alloc-error/alloc-error-handler-bad-signature-2.stderr

+2-8
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ error[E0308]: mismatched types
33
|
44
LL | #[alloc_error_handler]
55
| ---------------------- in this procedural macro expansion
6-
LL | fn oom(
7-
| __^
8-
| | _|
9-
| ||
6+
LL | // fn oom(
107
LL | || info: Layout,
118
LL | || ) {
129
| ||_- arguments to this function are incorrect
@@ -36,10 +33,7 @@ error[E0308]: mismatched types
3633
|
3734
LL | #[alloc_error_handler]
3835
| ---------------------- in this procedural macro expansion
39-
LL | fn oom(
40-
| __^
41-
| | _|
42-
| ||
36+
LL | // fn oom(
4337
LL | || info: Layout,
4438
LL | || ) {
4539
| ||_^ expected `!`, found `()`

src/test/ui/asm/aarch64/interpolated-idents.stderr

+1-6
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,7 @@ error: asm outputs are not allowed with the `noreturn` option
3030
LL | asm!("", $in(x) x, $out(x) x, $lateout(x) x, $inout(x) x, $inlateout(x) x,
3131
| ^^^^^^^^^ ^^^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^^^^^
3232
...
33-
LL | m!(in out lateout inout inlateout const sym
34-
| _____-
35-
| |_____|
36-
| |_____|
37-
| |_____|
38-
| |
33+
LL | / m!(in out lateout inout inlateout const sym
3934
LL | | pure nomem readonly preserves_flags
4035
LL | | noreturn nostack options);
4136
| | -

src/test/ui/asm/x86_64/interpolated-idents.stderr

+1-6
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,7 @@ error: asm outputs are not allowed with the `noreturn` option
3030
LL | asm!("", $in(x) x, $out(x) x, $lateout(x) x, $inout(x) x, $inlateout(x) x,
3131
| ^^^^^^^^^ ^^^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^^^^^
3232
...
33-
LL | m!(in out lateout inout inlateout const sym
34-
| _____-
35-
| |_____|
36-
| |_____|
37-
| |_____|
38-
| |
33+
LL | / m!(in out lateout inout inlateout const sym
3934
LL | | pure nomem readonly preserves_flags
4035
LL | | noreturn nostack att_syntax options);
4136
| | -

src/test/ui/issues/issue-13497-2.stderr

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
error[E0515]: cannot return value referencing local variable `rawLines`
22
--> $DIR/issue-13497-2.rs:3:5
33
|
4-
LL | rawLines
5-
| ______^
6-
| | _____|
7-
| ||
4+
LL | // rawLines
85
LL | || .iter().map(|l| l.trim()).collect()
96
| ||_______________-___________________________^ returns a value referencing data owned by the current function
107
| |_______________|

src/test/ui/suggestions/issue-99240-2.stderr

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ error[E0618]: expected function, found enum variant `Alias::Unit`
44
LL | Unit,
55
| ---- enum variant `Alias::Unit` defined here
66
...
7-
LL | Alias::
8-
| ______^
9-
| | _____|
10-
| ||
7+
LL | // Alias::
118
LL | || Unit();
129
| ||________^_- call expression requires function
1310
| |________|

src/tools/clippy/tests/ui/async_yields_async.stderr

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ error: an async construct yields a type which is itself awaitable
33
|
44
LL | let _h = async {
55
| _____________________-
6-
LL | | async {
7-
| | _________^
6+
LL | |/ async {
87
LL | || 3
98
LL | || }
109
| ||_________^ awaitable value not awaited
@@ -37,8 +36,7 @@ error: an async construct yields a type which is itself awaitable
3736
|
3837
LL | let _j = async || {
3938
| ________________________-
40-
LL | | async {
41-
| | _________^
39+
LL | |/ async {
4240
LL | || 3
4341
LL | || }
4442
| ||_________^ awaitable value not awaited

src/tools/clippy/tests/ui/result_map_unit_fn_unfixable.stderr

+1-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ LL | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value)
1919
error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()`
2020
--> $DIR/result_map_unit_fn_unfixable.rs:29:5
2121
|
22-
LL | x.field.map(|value| {
23-
| ______^
24-
| | _____|
25-
| ||
22+
LL | // x.field.map(|value| {
2623
LL | || do_nothing(value);
2724
LL | || do_nothing(value)
2825
LL | || });

0 commit comments

Comments
 (0)