Debian Codegraph @

src/lib.rs

raw symbols SCIP
1 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#;
2 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::processrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/::Commandrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/Command#;
3 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/;
4
5 /// This macro creates the version string during compilation from the
6 /// current environment
7 #[macro_export]
8 macro_rules! get_version_inforust-analyzer cargo rustc_tools_util 0.4.2 get_version_info! {
9 () => {{
10 let major = std::env!("CARGO_PKG_VERSION_MAJOR").parse::<u8>().unwrap();
11 let minor = std::env!("CARGO_PKG_VERSION_MINOR").parse::<u8>().unwrap();
12 let patch = std::env!("CARGO_PKG_VERSION_PATCH").parse::<u16>().unwrap();
13 let crate_name = String::from(std::env!("CARGO_PKG_NAME"));
14
15 let host_compiler = std::option_env!("RUSTC_RELEASE_CHANNEL").map(str::to_string);
16 let commit_hash = std::option_env!("GIT_HASH").map(str::to_string);
17 let commit_date = std::option_env!("COMMIT_DATE").map(str::to_string);
18
19 $crate::VersionInfo {
20 major,
21 minor,
22 patch,
23 host_compiler,
24 commit_hash,
25 commit_date,
26 crate_name,
27 }
28 }};
29 }
30
31 /// This macro can be used in `build.rs` to automatically set the needed environment values, namely
32 /// `GIT_HASH`, `COMMIT_DATE` and `RUSTC_RELEASE_CHANNEL`
33 #[macro_export]
34 macro_rules! setup_version_inforust-analyzer cargo rustc_tools_util 0.4.2 setup_version_info! {
35 () => {{
36 let _ = $crate::rerun_if_git_changes();
37 println!(
38 "cargo:rustc-env=GIT_HASH={}",
39 $crate::get_commit_hash().unwrap_or_default()
40 );
41 println!(
42 "cargo:rustc-env=COMMIT_DATE={}",
43 $crate::get_commit_date().unwrap_or_default()
44 );
45 let compiler_version = $crate::get_compiler_version();
46 println!(
47 "cargo:rustc-env=RUSTC_RELEASE_CHANNEL={}",
48 $crate::get_channel(compiler_version)
49 );
50 }};
51 }
52
53 // some code taken and adapted from RLS and cargo
54 pub struct VersionInforust-analyzer cargo rustc_tools_util 0.4.2 VersionInfo# {
55 pub majorrust-analyzer cargo rustc_tools_util 0.4.2 VersionInfo#major.: u8,
56 pub minorrust-analyzer cargo rustc_tools_util 0.4.2 VersionInfo#minor.: u8,
57 pub patchrust-analyzer cargo rustc_tools_util 0.4.2 VersionInfo#patch.: u16,
58 pub host_compilerrust-analyzer cargo rustc_tools_util 0.4.2 VersionInfo#host_compiler.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>,
59 pub commit_hashrust-analyzer cargo rustc_tools_util 0.4.2 VersionInfo#commit_hash.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>,
60 pub commit_daterust-analyzer cargo rustc_tools_util 0.4.2 VersionInfo#commit_date.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>,
61 pub crate_namerust-analyzer cargo rustc_tools_util 0.4.2 VersionInfo#crate_name.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
62 }
63
64 impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for VersionInforust-analyzer cargo rustc_tools_util 0.4.2 VersionInfo# {
65 fn fmtrust-analyzer cargo rustc_tools_util 0.4.2 impl#[VersionInfo][Display]fmt().(&self, f: &mut stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
66 let hash = self.commit_hashrust-analyzer cargo rustc_tools_util 0.4.2 VersionInfo#commit_hash..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().().unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().();
67 let hash_trimmed = hash.trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().();
68
69 let date = self.commit_daterust-analyzer cargo rustc_tools_util 0.4.2 VersionInfo#commit_date..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().().unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().();
70 let date_trimmed = date.trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().();
71
72 if (hash_trimmed.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().date_trimmed.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().()) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().0 {
73 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(
74 f,
75 "{} {}.{}.{} ({hash_trimmed} {date_trimmed})",
76 self.crate_namerust-analyzer cargo rustc_tools_util 0.4.2 VersionInfo#crate_name., self.majorrust-analyzer cargo rustc_tools_util 0.4.2 VersionInfo#major., self.minorrust-analyzer cargo rustc_tools_util 0.4.2 VersionInfo#minor., self.patchrust-analyzer cargo rustc_tools_util 0.4.2 VersionInfo#patch.,
77 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
78 } else {
79 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{} {}.{}.{}", self.crate_namerust-analyzer cargo rustc_tools_util 0.4.2 VersionInfo#crate_name., self.majorrust-analyzer cargo rustc_tools_util 0.4.2 VersionInfo#major., self.minorrust-analyzer cargo rustc_tools_util 0.4.2 VersionInfo#minor., self.patchrust-analyzer cargo rustc_tools_util 0.4.2 VersionInfo#patch.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
80 }
81
82 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
83 }
84 }
85
86 impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for VersionInforust-analyzer cargo rustc_tools_util 0.4.2 VersionInfo# {
87 fn fmtrust-analyzer cargo rustc_tools_util 0.4.2 impl#[VersionInfo][Debug]fmt().(&self, f: &mut stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
88 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(
89 f,
90 "VersionInfo {{ crate_name: \"{}\", major: {}, minor: {}, patch: {}",
91 self.crate_namerust-analyzer cargo rustc_tools_util 0.4.2 VersionInfo#crate_name., self.majorrust-analyzer cargo rustc_tools_util 0.4.2 VersionInfo#major., self.minorrust-analyzer cargo rustc_tools_util 0.4.2 VersionInfo#minor., self.patchrust-analyzer cargo rustc_tools_util 0.4.2 VersionInfo#patch.,
92 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
93 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ref commit_hash) = self.commit_hashrust-analyzer cargo rustc_tools_util 0.4.2 VersionInfo#commit_hash. {
94 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, ", commit_hash: \"{}\"", commit_hash.trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().(),)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
95 }
96 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ref commit_date) = self.commit_daterust-analyzer cargo rustc_tools_util 0.4.2 VersionInfo#commit_date. {
97 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, ", commit_date: \"{}\"", commit_date.trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
98 }
99 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ref host_compiler) = self.host_compilerrust-analyzer cargo rustc_tools_util 0.4.2 VersionInfo#host_compiler. {
100 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, ", host_compiler: \"{}\"", host_compiler.trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
101 }
102
103 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, " }}")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
104
105 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
106 }
107 }
108
109 #[must_use]
110 fn get_outputrust-analyzer cargo rustc_tools_util 0.4.2 get_output().(cmd: &str, args: &[&str]) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
111 let output = Commandrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/Command#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/impl#[Command]new().(cmd).argsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/impl#[Command]args().(args).outputrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/impl#[Command]output().().okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().;
112 let mut stdout = output.statusrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/Output#status..successrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/impl#[ExitStatus]success().().then_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then_some().(output.stdoutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/Output#stdout.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().;
113 // Remove trailing newlines.
114 while stdout.lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last().().copiedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<&T>`]copied().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(b'\n') {
115 stdout.poprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]pop().();
116 }
117 Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::from_utf8rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]from_utf8().(stdout).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().()
118 }
119
120 #[must_use]
121 pub fn rerun_if_git_changesrust-analyzer cargo rustc_tools_util 0.4.2 rerun_if_git_changes().() -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<()> {
122 // Make sure we get rerun when the git commit changes.
123 // We want to watch two files: HEAD, which tracks which branch we are on,
124 // and the file for that branch that tracks which commit is is on.
125
126 // First, find the `HEAD` file. This should work even with worktrees.
127 let git_head_file = PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<String>`]from().(get_outputrust-analyzer cargo rustc_tools_util 0.4.2 get_output().("git", &["rev-parse", "--git-path", "HEAD"])?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().);
128 if git_head_file.existsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]exists().() {
129 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("cargo::rerun-if-changed={}", git_head_file.displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().());
130 }
131
132 // Determine the name of the current ref.
133 // This will quit if HEAD is detached.
134 let git_head_ref = get_outputrust-analyzer cargo rustc_tools_util 0.4.2 get_output().("git", &["symbolic-ref", "-q", "HEAD"])?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().;
135 // Ask git where this ref is stored.
136 let git_head_ref_file = PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<String>`]from().(get_outputrust-analyzer cargo rustc_tools_util 0.4.2 get_output().("git", &["rev-parse", "--git-path", &git_head_ref])?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().);
137 // If this ref is packed, the file does not exist. However, the checked-out branch is never (?)
138 // packed, so we should always be able to find this file.
139 if git_head_ref_file.existsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]exists().() {
140 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("cargo::rerun-if-changed={}", git_head_ref_file.displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().());
141 }
142
143 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(())
144 }
145
146 #[must_use]
147 pub fn get_commit_hashrust-analyzer cargo rustc_tools_util 0.4.2 get_commit_hash().() -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
148 let mut stdout = get_outputrust-analyzer cargo rustc_tools_util 0.4.2 get_output().("git", &["rev-parse", "HEAD"])?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().;
149 stdout.truncaterust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]truncate().(10);
150 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(stdout)
151 }
152
153 #[must_use]
154 pub fn get_commit_daterust-analyzer cargo rustc_tools_util 0.4.2 get_commit_date().() -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
155 get_outputrust-analyzer cargo rustc_tools_util 0.4.2 get_output().("git", &["log", "-1", "--date=short", "--pretty=format:%cd"])
156 }
157
158 #[must_use]
159 pub fn get_compiler_versionrust-analyzer cargo rustc_tools_util 0.4.2 get_compiler_version().() -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
160 get_outputrust-analyzer cargo rustc_tools_util 0.4.2 get_output().("rustc", &["-V"])
161 }
162
163 #[must_use]
164 pub fn get_channelrust-analyzer cargo rustc_tools_util 0.4.2 get_channel().(compiler_version: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
165 if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(channel) = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::varrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/var().("CFG_RELEASE_CHANNEL") {
166 return channel;
167 }
168
169 // if that failed, try to ask rustc -V, do some parsing and find out
170 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(rustc_output) = compiler_version {
171 if rustc_output.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("beta") {
172 return Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("beta");
173 } else if rustc_output.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("nightly") {
174 return Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("nightly");
175 }
176 }
177
178 // default to stable
179 Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("stable")
180 }
181
182 #[cfg(test)]
183 mod testrust-analyzer cargo rustc_tools_util 0.4.2 test/ {
184 use superrust-analyzer cargo rustc_tools_util 0.4.2 crate/::*;
185
186 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
187 fn test_struct_localrust-analyzer cargo rustc_tools_util 0.4.2 test/test_struct_local().() {
188 let vi = get_version_inforust-analyzer cargo rustc_tools_util 0.4.2 get_version_info!!();
189 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(vi.majorrust-analyzer cargo rustc_tools_util 0.4.2 VersionInfo#major., 0);
190 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(vi.minorrust-analyzer cargo rustc_tools_util 0.4.2 VersionInfo#minor., 4);
191 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(vi.patchrust-analyzer cargo rustc_tools_util 0.4.2 VersionInfo#patch., 2);
192 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(vi.crate_namerust-analyzer cargo rustc_tools_util 0.4.2 VersionInfo#crate_name., "rustc_tools_util");
193 // hard to make positive tests for these since they will always change
194 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(vi.commit_hashrust-analyzer cargo rustc_tools_util 0.4.2 VersionInfo#commit_hash..is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().());
195 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(vi.commit_daterust-analyzer cargo rustc_tools_util 0.4.2 VersionInfo#commit_date..is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().());
196
197 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(vi.host_compilerrust-analyzer cargo rustc_tools_util 0.4.2 VersionInfo#host_compiler..is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().());
198 }
199
200 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
201 fn test_display_localrust-analyzer cargo rustc_tools_util 0.4.2 test/test_display_local().() {
202 let vi = get_version_inforust-analyzer cargo rustc_tools_util 0.4.2 get_version_info!!();
203 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(vi.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "rustc_tools_util 0.4.2");
204 }
205
206 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
207 fn test_debug_localrust-analyzer cargo rustc_tools_util 0.4.2 test/test_debug_local().() {
208 let vi = get_version_inforust-analyzer cargo rustc_tools_util 0.4.2 get_version_info!!();
209 let s = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{vi:?}");
210 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
211 s,
212 "VersionInfo { crate_name: \"rustc_tools_util\", major: 0, minor: 4, patch: 2 }"
213 );
214 }
215 }