-
Notifications
You must be signed in to change notification settings - Fork 37
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
Removing duplicate Slice origins and surrounding empty lines #9
Comments
The idea behind In your case, you're trying to something different - you want to fold the lines that don't have annotation in the Slice. Unfortunately, the data provided by rustc seems to be misaligned with that model, so we'll have to find a way to merge them. I see two options:
I think I prefer the latter, because it feels (<-- bias, intuition, take with a grain of salt) that this is more generic approach that other use cases may want. I assume there's some way to extract the whole slice from the start of the first annotation line to the end of the last annotation line, but if there isn't or you don't want to use it, we can also fake it, and we could have a helper function in rustc bindings that produces sth like: let x = vec![1];
let y = x;
x; //~ ERROR use of moved value So, basically fill the missing lines with empty lines. Now, this mocked slice, can be fed to our API with annotations in the right positions. The last thing we need is some param that would tell the API that if the line has no annotation, skip it. Would that make sense? |
Thanks for your input! I will try to go with option 2 for now and see if I can make it work.
I think that shouldn't be too big of a problem in the end. I was just hoping there was an existing way to work around that (hence the issue) :)
I may be missing a piece of the picture here, but isn't that what the |
Yes! I'm just not sure if it does exactly what you need (and what rustc one does). We can fine tune it tho :) |
Short update as I'm back working on this. I think I was trying to hard to work with what rustc currently uses for the old emitter. |
I'm currently trying to move the suggestions of the following diagnostic over from Rust to annotate-snippet:
In short, from Rust I can only get a
Vec
that contains the three lines with the annotations. ThisVec
contains only the lines with annotations and no other lines around it. Something similar to this:I'm currently mapping this to annotate-snippets by turning each
Line
into aSlice
and then callingDisplayList::from(snippet)
at the end.The problem is that each
Slice
has theorigin
at the top:If I set the origin of consecutive slices to
None
there will still be extra empty padding lines:I'm not sure what the original idea for a
Slice
was, but it seems like the best approach for those rustc annotations?I can see three ways to solve this currently:
origin
isNone
origin
of each Slice to origin of the previous Slice.From<Snippet> for DisplayList
by ourselves in rustc.I would love to hear your thoughts on this before I continue with the annotations =)
cc rust-lang/rust#61809
The text was updated successfully, but these errors were encountered: