Skip to content

Commit 89b9940

Browse files
committed
Auto merge of #14153 - CraftSpider:v7-metadata, r=CraftSpider
Add v7 metadata support to rust-analyzer Paired to #101550
2 parents 37608f3 + 853f047 commit 89b9940

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

crates/proc-macro-api/src/version.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,20 @@ pub fn read_version(dylib_path: &AbsPath) -> io::Result<String> {
120120
let version = u32::from_be_bytes([dot_rustc[4], dot_rustc[5], dot_rustc[6], dot_rustc[7]]);
121121
// Last supported version is:
122122
// https://github.com/rust-lang/rust/commit/0696e79f2740ad89309269b460579e548a5cd632
123-
match version {
124-
5 | 6 => {}
123+
let snappy_portion = match version {
124+
5 | 6 => &dot_rustc[8..],
125+
7 => {
126+
let len_bytes = &dot_rustc[8..12];
127+
let data_len = u32::from_be_bytes(len_bytes.try_into().unwrap()) as usize;
128+
&dot_rustc[12..data_len + 12]
129+
}
125130
_ => {
126131
return Err(io::Error::new(
127132
io::ErrorKind::InvalidData,
128133
format!("unsupported metadata version {version}"),
129134
));
130135
}
131-
}
132-
133-
let snappy_portion = &dot_rustc[8..];
136+
};
134137

135138
let mut snappy_decoder = SnapDecoder::new(snappy_portion);
136139

0 commit comments

Comments
 (0)