mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Remove support for compressed dylib metadata from rust-analyzer
This commit is contained in:
parent
7c005ad57a
commit
ad858841e7
4 changed files with 4 additions and 22 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -1364,7 +1364,6 @@ dependencies = [
|
||||||
"proc-macro-api",
|
"proc-macro-api",
|
||||||
"proc-macro-test",
|
"proc-macro-test",
|
||||||
"ra-ap-rustc_lexer",
|
"ra-ap-rustc_lexer",
|
||||||
"snap",
|
|
||||||
"span",
|
"span",
|
||||||
"stdx",
|
"stdx",
|
||||||
"syntax-bridge",
|
"syntax-bridge",
|
||||||
|
@ -1888,12 +1887,6 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "snap"
|
|
||||||
version = "1.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1b6b67fb9a61334225b5b790716f609cd58395f895b3fe8b328786812a40bc3b"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "span"
|
name = "span"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
|
|
|
@ -145,7 +145,6 @@ smallvec = { version = "1.10.0", features = [
|
||||||
"const_generics",
|
"const_generics",
|
||||||
] }
|
] }
|
||||||
smol_str = "0.3.2"
|
smol_str = "0.3.2"
|
||||||
snap = "1.1.0"
|
|
||||||
text-size = "1.1.1"
|
text-size = "1.1.1"
|
||||||
tracing = "0.1.40"
|
tracing = "0.1.40"
|
||||||
tracing-tree = "0.3.0"
|
tracing-tree = "0.3.0"
|
||||||
|
|
|
@ -16,7 +16,6 @@ doctest = false
|
||||||
object.workspace = true
|
object.workspace = true
|
||||||
libloading.workspace = true
|
libloading.workspace = true
|
||||||
memmap2.workspace = true
|
memmap2.workspace = true
|
||||||
snap.workspace = true
|
|
||||||
|
|
||||||
stdx.workspace = true
|
stdx.workspace = true
|
||||||
tt.workspace = true
|
tt.workspace = true
|
||||||
|
|
|
@ -8,7 +8,6 @@ use std::{
|
||||||
use memmap2::Mmap;
|
use memmap2::Mmap;
|
||||||
use object::read::{File as BinaryFile, Object, ObjectSection};
|
use object::read::{File as BinaryFile, Object, ObjectSection};
|
||||||
use paths::AbsPath;
|
use paths::AbsPath;
|
||||||
use snap::read::FrameDecoder as SnapDecoder;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
@ -123,9 +122,8 @@ pub fn read_version(dylib_path: &AbsPath) -> io::Result<String> {
|
||||||
let version = u32::from_be_bytes([dot_rustc[4], dot_rustc[5], dot_rustc[6], dot_rustc[7]]);
|
let version = u32::from_be_bytes([dot_rustc[4], dot_rustc[5], dot_rustc[6], dot_rustc[7]]);
|
||||||
// Last supported version is:
|
// Last supported version is:
|
||||||
// https://github.com/rust-lang/rust/commit/b94cfefc860715fb2adf72a6955423d384c69318
|
// https://github.com/rust-lang/rust/commit/b94cfefc860715fb2adf72a6955423d384c69318
|
||||||
let (snappy_portion, bytes_before_version) = match version {
|
let (mut metadata_portion, bytes_before_version) = match version {
|
||||||
5 | 6 => (&dot_rustc[8..], 13),
|
8 => {
|
||||||
7 | 8 => {
|
|
||||||
let len_bytes = &dot_rustc[8..12];
|
let len_bytes = &dot_rustc[8..12];
|
||||||
let data_len = u32::from_be_bytes(len_bytes.try_into().unwrap()) as usize;
|
let data_len = u32::from_be_bytes(len_bytes.try_into().unwrap()) as usize;
|
||||||
(&dot_rustc[12..data_len + 12], 13)
|
(&dot_rustc[12..data_len + 12], 13)
|
||||||
|
@ -143,13 +141,6 @@ pub fn read_version(dylib_path: &AbsPath) -> io::Result<String> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut uncompressed: Box<dyn Read> = if &snappy_portion[0..4] == b"rust" {
|
|
||||||
// Not compressed.
|
|
||||||
Box::new(snappy_portion)
|
|
||||||
} else {
|
|
||||||
Box::new(SnapDecoder::new(snappy_portion))
|
|
||||||
};
|
|
||||||
|
|
||||||
// We're going to skip over the bytes before the version string, so basically:
|
// We're going to skip over the bytes before the version string, so basically:
|
||||||
// 8 bytes for [b'r',b'u',b's',b't',0,0,0,5]
|
// 8 bytes for [b'r',b'u',b's',b't',0,0,0,5]
|
||||||
// 4 or 8 bytes for [crate root bytes]
|
// 4 or 8 bytes for [crate root bytes]
|
||||||
|
@ -157,11 +148,11 @@ pub fn read_version(dylib_path: &AbsPath) -> io::Result<String> {
|
||||||
// so 13 or 17 bytes in total, and we should check the last of those bytes
|
// so 13 or 17 bytes in total, and we should check the last of those bytes
|
||||||
// to know the length
|
// to know the length
|
||||||
let mut bytes = [0u8; 17];
|
let mut bytes = [0u8; 17];
|
||||||
uncompressed.read_exact(&mut bytes[..bytes_before_version])?;
|
metadata_portion.read_exact(&mut bytes[..bytes_before_version])?;
|
||||||
let length = bytes[bytes_before_version - 1];
|
let length = bytes[bytes_before_version - 1];
|
||||||
|
|
||||||
let mut version_string_utf8 = vec![0u8; length as usize];
|
let mut version_string_utf8 = vec![0u8; length as usize];
|
||||||
uncompressed.read_exact(&mut version_string_utf8)?;
|
metadata_portion.read_exact(&mut version_string_utf8)?;
|
||||||
let version_string = String::from_utf8(version_string_utf8);
|
let version_string = String::from_utf8(version_string_utf8);
|
||||||
version_string.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))
|
version_string.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue