Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Removing duplicate Slice origins and surrounding empty lines #9

Closed
Assignees
phansch
@phansch

Description

@phansch

I'm currently trying to move the suggestions of the following diagnostic over from Rust to annotate-snippet:

error[E0382]: use of moved value: `x`  --> /code/rust/src/test/ui/annotate-snippet/suggestion.rs:4:5   | 4 |     let x = vec![1];   |         - move occurs because `x` has type `std::vec::Vec<i32>`, which does not implement the `Copy` trait 7 |     let y = x;   |             - value moved here 9 |     x; //~ ERROR use of moved value   |     ^ value used here after move

In short, from Rust I can only get aVec that contains the three lines with the annotations. ThisVec containsonly the lines with annotations and no other lines around it. Something similar to this:

[  Line {      line_index: 4,      annotations: [          Annotation {              start_col: 8,              end_col: 9,              label: "move occurs because ...",          },      ],  },  Line {      line_index: 7,      annotations: [          Annotation {              start_col: 11,              end_col: 12,              label: "value moved here",          },      ],  },  // etc..]

I'm currently mapping this to annotate-snippets by turning eachLine into aSlice and then callingDisplayList::from(snippet) at the end.

The problem is that eachSlice has theorigin at the top:

error[E0382]: use of moved value: `x`  --> /code/rust/src/test/ui/annotate-snippet/suggestion.rs:4:8   | 4 |     let x = vec![1];   |         ^ move occurs because `x` has type `std::vec::Vec<i32>`, which does not implement the `Copy` trait   |  ::: /code/rust/src/test/ui/annotate-snippet/suggestion.rs:7:12   | 7 |     let y = x;   |             ^ value moved here   |  ::: /code/rust/src/test/ui/annotate-snippet/suggestion.rs:9:4   | 9 |     x; //~ ERROR use of moved value   |     ^ value used here after move

If I set the origin of consecutive slices toNone there will still be extra empty padding lines:

error[E0382]: use of moved value: `x`  --> /code/rust/src/test/ui/annotate-snippet/suggestion.rs:5:8                                                                |LL |     let x = vec![1];   |         ^ move occurs because `x` has type `std::vec::Vec<i32>`, which does not implement the `Copy` trait   |   |LL |     let y = x;   |             ^ value moved here   |   |LL |     x; //~ ERROR use of moved value   |     ^ value used here after move   |

I'm not sure what the original idea for aSlice was, but it seems like the best approach for those rustc annotations?

I can see three ways to solve this currently:

  1. annotate-snippets doesn't add empty padding lines if theorigin isNone
  2. annotate-snippets removes the origin and empty padding lines of consecutive Slices that have the same origin. This means annotate-snippet would have to compare theorigin of each Slice to origin of the previous Slice.
  3. We implementFrom<Snippet> for DisplayList by ourselves in rustc.

I would love to hear your thoughts on this before I continue with the annotations =)

ccrust-lang/rust#61809

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp