Skip to content

Commit a969411

Browse files
committed
Remove support for compressed dylib metadata from rust-analyzer
1 parent 87b9c09 commit a969411

File tree

4 files changed

+4
-21
lines changed

4 files changed

+4
-21
lines changed

src/tools/rust-analyzer/Cargo.lock

-7
Original file line numberDiff line numberDiff line change
@@ -1364,7 +1364,6 @@ dependencies = [
13641364
"proc-macro-api",
13651365
"proc-macro-test",
13661366
"ra-ap-rustc_lexer",
1367-
"snap",
13681367
"span",
13691368
"stdx",
13701369
"syntax-bridge",
@@ -1888,12 +1887,6 @@ dependencies = [
18881887
"serde",
18891888
]
18901889

1891-
[[package]]
1892-
name = "snap"
1893-
version = "1.1.1"
1894-
source = "registry+https://github.com/rust-lang/crates.io-index"
1895-
checksum = "1b6b67fb9a61334225b5b790716f609cd58395f895b3fe8b328786812a40bc3b"
1896-
18971890
[[package]]
18981891
name = "span"
18991892
version = "0.0.0"

src/tools/rust-analyzer/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ smallvec = { version = "1.10.0", features = [
145145
"const_generics",
146146
] }
147147
smol_str = "0.3.2"
148-
snap = "1.1.0"
149148
text-size = "1.1.1"
150149
tracing = "0.1.40"
151150
tracing-tree = "0.3.0"

src/tools/rust-analyzer/crates/proc-macro-srv/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ doctest = false
1616
object.workspace = true
1717
libloading.workspace = true
1818
memmap2.workspace = true
19-
snap.workspace = true
2019

2120
stdx.workspace = true
2221
tt.workspace = true

src/tools/rust-analyzer/crates/proc-macro-srv/src/dylib/version.rs

+4-12
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,8 @@ pub fn read_version(dylib_path: &AbsPath) -> io::Result<String> {
123123
let version = u32::from_be_bytes([dot_rustc[4], dot_rustc[5], dot_rustc[6], dot_rustc[7]]);
124124
// Last supported version is:
125125
// https://github.com/rust-lang/rust/commit/b94cfefc860715fb2adf72a6955423d384c69318
126-
let (snappy_portion, bytes_before_version) = match version {
127-
5 | 6 => (&dot_rustc[8..], 13),
128-
7 | 8 => {
126+
let (mut metadata_portion, bytes_before_version) = match version {
127+
8 => {
129128
let len_bytes = &dot_rustc[8..12];
130129
let data_len = u32::from_be_bytes(len_bytes.try_into().unwrap()) as usize;
131130
(&dot_rustc[12..data_len + 12], 13)
@@ -143,25 +142,18 @@ pub fn read_version(dylib_path: &AbsPath) -> io::Result<String> {
143142
}
144143
};
145144

146-
let mut uncompressed: Box<dyn Read> = if &snappy_portion[0..4] == b"rust" {
147-
// Not compressed.
148-
Box::new(snappy_portion)
149-
} else {
150-
Box::new(SnapDecoder::new(snappy_portion))
151-
};
152-
153145
// We're going to skip over the bytes before the version string, so basically:
154146
// 8 bytes for [b'r',b'u',b's',b't',0,0,0,5]
155147
// 4 or 8 bytes for [crate root bytes]
156148
// 1 byte for length of version string
157149
// so 13 or 17 bytes in total, and we should check the last of those bytes
158150
// to know the length
159151
let mut bytes = [0u8; 17];
160-
uncompressed.read_exact(&mut bytes[..bytes_before_version])?;
152+
metadata_portion.read_exact(&mut bytes[..bytes_before_version])?;
161153
let length = bytes[bytes_before_version - 1];
162154

163155
let mut version_string_utf8 = vec![0u8; length as usize];
164-
uncompressed.read_exact(&mut version_string_utf8)?;
156+
metadata_portion.read_exact(&mut version_string_utf8)?;
165157
let version_string = String::from_utf8(version_string_utf8);
166158
version_string.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))
167159
}

0 commit comments

Comments
 (0)