@@ -64,8 +64,8 @@ pub(crate) fn read_info(dylib_path: &Path) -> io::Result<RustCInfo> {
64
64
Ok ( RustCInfo { version, channel, commit, date } )
65
65
}
66
66
67
- // This is used inside read_version() to locate the ".rustc" section
68
- // from a proc macro crate's binary file.
67
+ /// This is used inside read_version() to locate the ".rustc" section
68
+ /// from a proc macro crate's binary file.
69
69
fn read_section < ' a > ( dylib_binary : & ' a [ u8 ] , section_name : & str ) -> io:: Result < & ' a [ u8 ] > {
70
70
BinaryFile :: parse ( dylib_binary)
71
71
. 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<&'
75
75
. map_err ( |e| io:: Error :: new ( io:: ErrorKind :: InvalidData , e) )
76
76
}
77
77
78
- // Check the version of rustc that was used to compile a proc macro crate's
79
- // binary file.
80
- // A proc macro crate binary's ".rustc" section has following byte layout:
81
- // * [b'r',b'u',b's',b't',0,0,0,5] is the first 8 bytes
82
- // * ff060000 734e6150 is followed, it's the snappy format magic bytes,
83
- // means bytes from here(including this sequence) are compressed in
84
- // snappy compression format. Version info is inside here, so decompress
85
- // this.
86
- // The bytes you get after decompressing the snappy format portion has
87
- // following layout:
88
- // * [b'r',b'u',b's',b't',0,0,0,5] is the first 8 bytes(again)
89
- // * [crate root bytes] next 4 bytes is to store crate root position,
90
- // according to rustc's source code comment
91
- // * [length byte] next 1 byte tells us how many bytes we should read next
92
- // for the version string's utf8 bytes
93
- // * [version string bytes encoded in utf8] <- GET THIS BOI
94
- // * [some more bytes that we don really care but still there] :-)
95
- // Check this issue for more about the bytes layout:
96
- // https://github.com/rust-analyzer/rust-analyzer/issues/6174
78
+ /// Check the version of rustc that was used to compile a proc macro crate's
79
+ ///
80
+ /// binary file.
81
+ /// A proc macro crate binary's ".rustc" section has following byte layout:
82
+ /// * [b'r',b'u',b's',b't',0,0,0,5] is the first 8 bytes
83
+ /// * ff060000 734e6150 is followed, it's the snappy format magic bytes,
84
+ /// means bytes from here(including this sequence) are compressed in
85
+ /// snappy compression format. Version info is inside here, so decompress
86
+ /// this.
87
+ /// The bytes you get after decompressing the snappy format portion has
88
+ /// following layout:
89
+ /// * [b'r',b'u',b's',b't',0,0,0,5] is the first 8 bytes(again)
90
+ /// * [crate root bytes] next 4 bytes is to store crate root position,
91
+ /// according to rustc's source code comment
92
+ /// * [length byte] next 1 byte tells us how many bytes we should read next
93
+ /// for the version string's utf8 bytes
94
+ /// * [version string bytes encoded in utf8] <- GET THIS BOI
95
+ /// * [some more bytes that we don really care but still there] :-)
96
+ /// Check this issue for more about the bytes layout:
97
+ /// https://github.com/rust-analyzer/rust-analyzer/issues/6174
97
98
fn read_version ( dylib_path : & Path ) -> io:: Result < String > {
98
99
let dylib_file = File :: open ( dylib_path) ?;
99
100
let dylib_mmaped = unsafe { Mmap :: map ( & dylib_file) } ?;
0 commit comments