Skip to content

Commit

Permalink
Fix ... in multline code-skips in suggestions
Browse files Browse the repository at this point in the history
When we have long code skips, we write `...` in the line number gutter.

For suggestions, we were "centering" the `...` with the line, but that was consistent with what we do in every other case.
  • Loading branch information
estebank committed Jun 20, 2024
1 parent 3d5d7a2 commit 9fd7784
Show file tree
Hide file tree
Showing 18 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1905,7 +1905,7 @@ impl HumanEmitter {
//
// LL | this line was highlighted
// LL | this line is just for context
// ...
// ...
// LL | this line is just for context
// LL | this line was highlighted
_ => {
Expand All @@ -1926,7 +1926,7 @@ impl HumanEmitter {
)
}

buffer.puts(row_num, max_line_num_len - 1, "...", Style::LineNumber);
buffer.puts(row_num, 0, "...", Style::LineNumber);
row_num += 1;

if let Some((p, l)) = last_line {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ LL | }
LL | match s.len() {
LL ~ 10 => 2,
LL | 20 => {
...
...
LL | if foo() {
LL ~ return 20;
LL | }
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/tests/ui/needless_collect_indirect.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ help: check if the original Iterator contains an element instead of collecting t
|
LL ~
LL |
...
...
LL | // Do lint
LL ~ vec.iter().map(|k| k * k).any(|x| x == n);
|
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/tests/ui/needless_late_init.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ help: move the declaration `x` here
|
LL ~
LL | // types that should be considered insignificant
...
...
LL | let y = Box::new(4);
LL ~ let x = SignificantDrop;
|
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/tests/ui/needless_return.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ help: remove `return`
|
LL ~ 10
LL | },
...
...
LL | },
LL ~ }
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ help: add a dummy let to cause `fptr` to be fully captured
|
LL ~ thread::spawn(move || { let _ = &fptr; unsafe {
LL |
...
...
LL |
LL ~ } }).join().unwrap();
|
Expand All @@ -39,7 +39,7 @@ help: add a dummy let to cause `fptr` to be fully captured
|
LL ~ thread::spawn(move || { let _ = &fptr; unsafe {
LL |
...
...
LL |
LL ~ } }).join().unwrap();
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ help: add a dummy let to cause `fptr1`, `fptr2` to be fully captured
|
LL ~ thread::spawn(move || { let _ = (&fptr1, &fptr2); unsafe {
LL |
...
...
LL |
LL ~ } }).join().unwrap();
|
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/imports/issue-59764.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ help: a macro with this name exists at the root of the crate
|
LL ~ issue_59764::{makro as foobar,
LL |
...
...
LL |
LL ~ foo::{baz}
|
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/issues/issue-22644.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ help: try comparing the cast value
|
LL ~ println!("{}", (a
LL |
...
...
LL |
LL ~ usize)
|
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/issues/issue-57271.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
|
LL ~ Array(Box<TypeSignature>),
LL | TypeVariable(()),
...
...
LL | Base(BaseType),
LL ~ Object(Box<ObjectType>),
|
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/let-else/let-else-if.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ help: try placing this code inside a block
|
LL ~ let Some(_) = Some(()) else { if true {
LL |
...
...
LL | return;
LL ~ } };
|
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/loops/loop-else-break-with-value.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ help: you might want to use `if let` to ignore the variant that isn't matched
|
LL ~ if let Some(1) = loop {
LL |
...
...
LL | return;
LL ~ } { todo!() };
|
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/moves/nested-loop-moved-value-wrong-continue.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ help: consider moving the expression out of the loop so it is only moved once
LL ~ for foo in foos { let mut value = baz.push(foo);
LL ~ for bar in &bars { if foo == *bar {
LL |
...
...
LL |
LL ~ value;
|
Expand Down Expand Up @@ -69,7 +69,7 @@ help: consider moving the expression out of the loop so it is only moved once
LL ~ let mut value = baz.push(foo);
LL ~ for bar in &bars {
LL |
...
...
LL | if foo == *bar {
LL ~ value;
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ help: consider enclosing expression in a block
|
LL ~ let _i = 'label: { match x {
LL | 0 => 42,
...
...
LL | _ => 1,
LL ~ } };
|
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/span/recursive-type-field.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
|
LL ~ bar: Box<Bar<'a>>,
LL | b: Rc<Bar<'a>>,
...
...
LL | struct Bar<'a> {
LL ~ y: (Box<Foo<'a>>, Box<Foo<'a>>),
|
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/suggestions/issue-68049-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ help: consider changing this to be a mutable reference in the `impl` method and
|
LL ~ fn example(&mut self, input: &i32);
LL | }
...
...
LL | impl Hello for Test2 {
LL ~ fn example(&mut self, input: &i32) {
|
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/try-trait/try-operator-on-main.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ help: consider adding return type
|
LL ~ fn main() -> Result<(), Box<dyn std::error::Error>> {
LL | // error for a `Try` type on a non-`Try` fn
...
...
LL | try_trait_generic::<()>();
LL +
LL + Ok(())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ help: consider introducing a named lifetime parameter
|
LL ~ fn main<'a>() {
LL | eq::< dyn for<'a> Foo<(&'a isize,), Output=&'a isize>,
...
...
LL |
LL ~ let _: dyn Foo(&'a isize, &'a usize) -> &'a usize;
|
Expand Down

0 comments on commit 9fd7784

Please sign in to comment.