mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
use doc-comments
This commit is contained in:
parent
cc8c40480a
commit
ad34e79bb9
1 changed files with 22 additions and 21 deletions
|
@ -64,8 +64,8 @@ pub(crate) fn read_info(dylib_path: &Path) -> io::Result<RustCInfo> {
|
||||||
Ok(RustCInfo { version, channel, commit, date })
|
Ok(RustCInfo { version, channel, commit, date })
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is used inside read_version() to locate the ".rustc" section
|
/// This is used inside read_version() to locate the ".rustc" section
|
||||||
// from a proc macro crate's binary file.
|
/// from a proc macro crate's binary file.
|
||||||
fn read_section<'a>(dylib_binary: &'a [u8], section_name: &str) -> io::Result<&'a [u8]> {
|
fn read_section<'a>(dylib_binary: &'a [u8], section_name: &str) -> io::Result<&'a [u8]> {
|
||||||
BinaryFile::parse(dylib_binary)
|
BinaryFile::parse(dylib_binary)
|
||||||
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?
|
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?
|
||||||
|
@ -75,25 +75,26 @@ fn read_section<'a>(dylib_binary: &'a [u8], section_name: &str) -> io::Result<&'
|
||||||
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))
|
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the version of rustc that was used to compile a proc macro crate's
|
/// Check the version of rustc that was used to compile a proc macro crate's
|
||||||
// binary file.
|
///
|
||||||
// A proc macro crate binary's ".rustc" section has following byte layout:
|
/// binary file.
|
||||||
// * [b'r',b'u',b's',b't',0,0,0,5] is the first 8 bytes
|
/// A proc macro crate binary's ".rustc" section has following byte layout:
|
||||||
// * ff060000 734e6150 is followed, it's the snappy format magic bytes,
|
/// * [b'r',b'u',b's',b't',0,0,0,5] is the first 8 bytes
|
||||||
// means bytes from here(including this sequence) are compressed in
|
/// * ff060000 734e6150 is followed, it's the snappy format magic bytes,
|
||||||
// snappy compression format. Version info is inside here, so decompress
|
/// means bytes from here(including this sequence) are compressed in
|
||||||
// this.
|
/// snappy compression format. Version info is inside here, so decompress
|
||||||
// The bytes you get after decompressing the snappy format portion has
|
/// this.
|
||||||
// following layout:
|
/// The bytes you get after decompressing the snappy format portion has
|
||||||
// * [b'r',b'u',b's',b't',0,0,0,5] is the first 8 bytes(again)
|
/// following layout:
|
||||||
// * [crate root bytes] next 4 bytes is to store crate root position,
|
/// * [b'r',b'u',b's',b't',0,0,0,5] is the first 8 bytes(again)
|
||||||
// according to rustc's source code comment
|
/// * [crate root bytes] next 4 bytes is to store crate root position,
|
||||||
// * [length byte] next 1 byte tells us how many bytes we should read next
|
/// according to rustc's source code comment
|
||||||
// for the version string's utf8 bytes
|
/// * [length byte] next 1 byte tells us how many bytes we should read next
|
||||||
// * [version string bytes encoded in utf8] <- GET THIS BOI
|
/// for the version string's utf8 bytes
|
||||||
// * [some more bytes that we don really care but still there] :-)
|
/// * [version string bytes encoded in utf8] <- GET THIS BOI
|
||||||
// Check this issue for more about the bytes layout:
|
/// * [some more bytes that we don really care but still there] :-)
|
||||||
// https://github.com/rust-analyzer/rust-analyzer/issues/6174
|
/// Check this issue for more about the bytes layout:
|
||||||
|
/// https://github.com/rust-analyzer/rust-analyzer/issues/6174
|
||||||
fn read_version(dylib_path: &Path) -> io::Result<String> {
|
fn read_version(dylib_path: &Path) -> io::Result<String> {
|
||||||
let dylib_file = File::open(dylib_path)?;
|
let dylib_file = File::open(dylib_path)?;
|
||||||
let dylib_mmaped = unsafe { Mmap::map(&dylib_file) }?;
|
let dylib_mmaped = unsafe { Mmap::map(&dylib_file) }?;
|
||||||
|
|
Loading…
Reference in a new issue