Mercurial > crates > nonstick
comparison libpam-sys/libpam-sys-test/build.rs @ 151:3a7cf05d2b5f
Fix libpam-sys-test from panicking over `mod aliases`.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Mon, 07 Jul 2025 19:04:52 -0400 |
parents | 4b3a5095f68c |
children |
comparison
equal
deleted
inserted
replaced
150:036eb312baea | 151:3a7cf05d2b5f |
---|---|
157 | 157 |
158 test.generate(&deconsted_file, "ctest.rs"); | 158 test.generate(&deconsted_file, "ctest.rs"); |
159 } | 159 } |
160 | 160 |
161 fn remove_consts(file_contents: &str, out_file: impl AsRef<Path>) { | 161 fn remove_consts(file_contents: &str, out_file: impl AsRef<Path>) { |
162 let lines: Vec<_> = file_contents | |
163 .lines() | |
164 .filter(|&l| !l.starts_with("pub mod")) | |
165 .collect(); | |
166 let file_contents = lines.join("\n"); | |
162 let deconstified = deconstify( | 167 let deconstified = deconstify( |
163 TokenStream::from_str(file_contents).unwrap(), | 168 TokenStream::from_str(&file_contents).unwrap(), |
164 &format_ident!("mut"), | 169 &format_ident!("mut"), |
165 ) | 170 ) |
166 .to_string(); | 171 .to_string(); |
167 let out_file = out_file.as_ref(); | 172 let out_file = out_file.as_ref(); |
168 fs::write(out_file, deconstified).unwrap(); | 173 fs::write(out_file, deconstified).unwrap(); |
189 other => other.into_token_stream(), | 194 other => other.into_token_stream(), |
190 } | 195 } |
191 })) | 196 })) |
192 } | 197 } |
193 | 198 |
194 enum ItemOr {} | |
195 | |
196 fn test_file(name: impl AsRef<str>) -> String { | 199 fn test_file(name: impl AsRef<str>) -> String { |
197 format!("{}/{}", env::var("OUT_DIR").unwrap(), name.as_ref()) | 200 format!("{}/{}", env::var("OUT_DIR").unwrap(), name.as_ref()) |
198 } | 201 } |
199 | 202 |
200 #[derive(Default)] | 203 #[derive(Default)] |