Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account for multiple multiline spans with empty padding #106190

Merged
merged 1 commit into from
Dec 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -845,18 +845,34 @@ impl EmitterWriter {
// 3 | |
// 4 | | }
// | |_^ test
if let [ann] = &line.annotations[..] {
let mut buffer_ops = vec![];
let mut annotations = vec![];
let mut short_start = true;
for ann in &line.annotations {
if let AnnotationType::MultilineStart(depth) = ann.annotation_type {
if source_string.chars().take(ann.start_col).all(|c| c.is_whitespace()) {
let style = if ann.is_primary {
Style::UnderlinePrimary
} else {
Style::UnderlineSecondary
};
buffer.putc(line_offset, width_offset + depth - 1, '/', style);
return vec![(depth, style)];
annotations.push((depth, style));
buffer_ops.push((line_offset, width_offset + depth - 1, '/', style));
} else {
short_start = false;
break;
}
} else if let AnnotationType::MultilineLine(_) = ann.annotation_type {
} else {
short_start = false;
break;
}
}
if short_start {
for (y, x, c, s) in buffer_ops {
buffer.putc(y, x, c, s);
}
return annotations;
}

// We want to display like this:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ error[E0308]: mismatched types
|
LL | #[alloc_error_handler]
| ---------------------- in this procedural macro expansion
LL | fn oom(
| __^
| | _|
| ||
LL | // fn oom(
LL | || info: &Layout,
LL | || ) -> ()
| ||_______- arguments to this function are incorrect
Expand All @@ -29,10 +26,7 @@ error[E0308]: mismatched types
|
LL | #[alloc_error_handler]
| ---------------------- in this procedural macro expansion
LL | fn oom(
| __^
| | _|
| ||
LL | // fn oom(
LL | || info: &Layout,
LL | || ) -> ()
| ||_______^ expected `!`, found `()`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ error[E0308]: mismatched types
|
LL | #[alloc_error_handler]
| ---------------------- in this procedural macro expansion
LL | fn oom(
| __^
| | _|
| ||
LL | // fn oom(
LL | || info: Layout,
LL | || ) {
| ||_- arguments to this function are incorrect
Expand Down Expand Up @@ -36,10 +33,7 @@ error[E0308]: mismatched types
|
LL | #[alloc_error_handler]
| ---------------------- in this procedural macro expansion
LL | fn oom(
| __^
| | _|
| ||
LL | // fn oom(
LL | || info: Layout,
LL | || ) {
| ||_^ expected `!`, found `()`
Expand Down
7 changes: 1 addition & 6 deletions src/test/ui/asm/aarch64/interpolated-idents.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,7 @@ error: asm outputs are not allowed with the `noreturn` option
LL | asm!("", $in(x) x, $out(x) x, $lateout(x) x, $inout(x) x, $inlateout(x) x,
| ^^^^^^^^^ ^^^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^^^^^
...
LL | m!(in out lateout inout inlateout const sym
| _____-
| |_____|
| |_____|
| |_____|
| |
LL | / m!(in out lateout inout inlateout const sym
LL | | pure nomem readonly preserves_flags
LL | | noreturn nostack options);
| | -
Expand Down
7 changes: 1 addition & 6 deletions src/test/ui/asm/x86_64/interpolated-idents.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,7 @@ error: asm outputs are not allowed with the `noreturn` option
LL | asm!("", $in(x) x, $out(x) x, $lateout(x) x, $inout(x) x, $inlateout(x) x,
| ^^^^^^^^^ ^^^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^^^^^
...
LL | m!(in out lateout inout inlateout const sym
| _____-
| |_____|
| |_____|
| |_____|
| |
LL | / m!(in out lateout inout inlateout const sym
LL | | pure nomem readonly preserves_flags
LL | | noreturn nostack att_syntax options);
| | -
Expand Down
5 changes: 1 addition & 4 deletions src/test/ui/issues/issue-13497-2.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
error[E0515]: cannot return value referencing local variable `rawLines`
--> $DIR/issue-13497-2.rs:3:5
|
LL | rawLines
| ______^
| | _____|
| ||
LL | // rawLines
LL | || .iter().map(|l| l.trim()).collect()
| ||_______________-___________________________^ returns a value referencing data owned by the current function
| |_______________|
Comment on lines 1 to 7
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be nice to tweak the layout algorithm here to avoid the first unnecessary overlap, but it might be tricky to get right.

Screen Shot 2022-12-27 at 11 06 45 AM

Expand Down
5 changes: 1 addition & 4 deletions src/test/ui/suggestions/issue-99240-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ error[E0618]: expected function, found enum variant `Alias::Unit`
LL | Unit,
| ---- enum variant `Alias::Unit` defined here
...
LL | Alias::
| ______^
| | _____|
| ||
LL | // Alias::
LL | || Unit();
| ||________^_- call expression requires function
| |________|
Expand Down
6 changes: 2 additions & 4 deletions src/tools/clippy/tests/ui/async_yields_async.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ error: an async construct yields a type which is itself awaitable
|
LL | let _h = async {
| _____________________-
LL | | async {
| | _________^
LL | |/ async {
LL | || 3
LL | || }
| ||_________^ awaitable value not awaited
Expand Down Expand Up @@ -37,8 +36,7 @@ error: an async construct yields a type which is itself awaitable
|
LL | let _j = async || {
| ________________________-
LL | | async {
| | _________^
LL | |/ async {
LL | || 3
LL | || }
| ||_________^ awaitable value not awaited
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ LL | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value)
error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()`
--> $DIR/result_map_unit_fn_unfixable.rs:29:5
|
LL | x.field.map(|value| {
| ______^
| | _____|
| ||
LL | // x.field.map(|value| {
LL | || do_nothing(value);
LL | || do_nothing(value)
LL | || });
Expand Down