.file(
"src/main.rs",
r#"
+ use std::fs::read_to_string;
+ use std::path::PathBuf;
fn main() {
- let args = std::env::args().collect::<Vec<_>>();
+ // Handle args from `@path` argfile for rustc
+ let args = std::env::args()
+ .flat_map(|p| if let Some(p) = p.strip_prefix("@") {
+ read_to_string(p).unwrap().lines().map(String::from).collect()
+ } else {
+ vec![p]
+ })
+ .collect::<Vec<_>>();
eprintln!("WRAPPER CALLED: {}", args[1..].join(" "));
let status = std::process::Command::new(&args[1])
.args(&args[2..]).status().unwrap();
fn main() {
// Ignore calls to things like --print=file-names and compiling build.rs.
+ // Also compatible for rustc invocations with `@path` argfile.
let is_lib_rs = env::args_os()
.map(PathBuf::from)
+ .flat_map(|p| if let Some(p) = p.to_str().unwrap_or_default().strip_prefix("@") {
+ fs::read_to_string(p).unwrap().lines().map(PathBuf::from).collect()
+ } else {
+ vec![p]
+ })
.any(|l| l == Path::new("src/lib.rs"));
if is_lib_rs {
let path = PathBuf::from(env::var_os("OUT_DIR").unwrap());
use std::process::{self, Command};
fn main() {
+ // Ignore calls to things like --print=file-names and compiling build.rs.
+ // Also compatible for rustc invocations with `@path` argfile.
let is_lib_rs = env::args_os()
.map(PathBuf::from)
+ .flat_map(|p| if let Some(p) = p.to_str().unwrap_or_default().strip_prefix("@") {
+ fs::read_to_string(p).unwrap().lines().map(PathBuf::from).collect()
+ } else {
+ vec![p]
+ })
.any(|l| l == Path::new("src/lib.rs"));
if is_lib_rs {
let path = PathBuf::from(env::var_os("OUT_DIR").unwrap());
const SPACED_VERSION: &str = "a\nb\tc\u{00a0}d";
p.cargo("doc")
+ .env_remove("__CARGO_TEST_FORCE_ARGFILE") // Not applicable for argfile.
.env(
"RUSTDOCFLAGS",
format!("--crate-version {}", SPACED_VERSION),