| 249 | |
| 250 | #[track_caller] |
| 251 | fn missing_cargo_bin(name: &str) -> ! { |
| 252 | let possible_names: Vec<_> = env::vars_os() |
| 253 | .filter_map(|(k, _)| k.into_string().ok()) |
| 254 | .filter_map(|k| k.strip_prefix(CARGO_BIN_EXE_).map(|s| s.to_owned())) |
| 255 | .collect(); |
| 256 | if possible_names.is_empty() { |
| 257 | panic!("`CARGO_BIN_EXE_{name}` is unset |
| 258 | help: if this is running within a unit test, move it to an integration test to gain access to `CARGO_BIN_EXE_{name}`") |
| 259 | } else { |
| 260 | let mut names = String::new(); |
| 261 | for (i, name) in possible_names.iter().enumerate() { |
| 262 | use std::fmt::Write as _; |
| 263 | if i != 0 { |
| 264 | let _ = write!(&mut names, ", "); |
| 265 | } |
| 266 | let _ = write!(&mut names, "\"{name}\""); |
| 267 | } |
| 268 | panic!( |
| 269 | "`CARGO_BIN_EXE_{name}` is unset |
| 270 | help: available binary names are {names}" |
| 271 | ) |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | fn legacy_cargo_bin(name: &str) -> Option<path::PathBuf> { |
| 276 | let target_dir = target_dir()?; |