-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
libsyntax: librustdoc: ignore utf-8 BOM in .rs files #12976
Conversation
@@ -463,6 +463,14 @@ impl<'a> SourceCollector<'a> { | |||
}; | |||
let contents = str::from_utf8_owned(contents).unwrap(); | |||
|
|||
// Remove the utf-8 BOM bytes if any | |||
let contents = if contents.len() > 2 && contents[0] == 0xefu8 && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better written as contents.starts_with("\ufeff")
(or contents.as_bytes().starts_with([0xEF, 0xBB, 0xBF])
).
This needs a rebase. |
@huonw Comments addressed, and rebased. |
let mut files = self.files.borrow_mut(); | ||
let start_pos = match files.get().last() { | ||
None => 0, | ||
Some(last) => last.deref().start_pos.to_uint() + last.deref().src.len(), | ||
}; | ||
|
||
// Remove utf-8 BOM if any. | ||
// FIXME: I haven't found an efficient way to remove it from ~vec/~str, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better written as FIXME #12884: no efficient/safe way to remove from the start of a string and reuse the allocation
.
@huonw Updated. r? |
feat: emit SCIP from rust-analyzer hi rust-analyzer team I'm one of the engineers at Sourcegraph (and have done a few small changes related to the LSIF work done in rust-analyzer). Recently, we've moved to a new protocol as the primary way to interact with Sourcegraph (LSIF is still possible to upload, so existing jobs will not stop working any time soon). This new protocol is SCIP (I linked a blog post below with more information). I've implemented SCIP support (based largely on the existing LSIF support). In addition to supporting the existing features that `rust-analyzer`'s LSIF support does, this PR adds the ability to move between crates on sourcegraph.com. So if both your project and a dependency are indexed, you would be able to hop to the particular version and view the source code. I'd be happy to record a demo of that on my local instance if you're interested. There are a few TODO's left in the code (some that you might have insights on) which I'm happy to fix in this PR, but I just wanted to open this up for discussion first. Thanks for your time :) TJ - [announcing scip](https://about.sourcegraph.com/blog/announcing-scip)
…ednet Fix some false-positive cases of `explicit_auto_deref` changelog: [`explicit_auto_deref`] Fix some false-positive cases Fix part of rust-lang#9841 Fix rust-lang#12969 r? xFrednet
Closes #12974