diff --git a/compiler/rustc_driver_impl/src/args.rs b/compiler/rustc_driver_impl/src/args.rs index 654d7636da200..8ac28d052a34b 100644 --- a/compiler/rustc_driver_impl/src/args.rs +++ b/compiler/rustc_driver_impl/src/args.rs @@ -14,7 +14,11 @@ fn arg_expand(arg: String) -> Result, Error> { } Err(err) => return Err(Error::IOError(path.to_string(), err)), }; - Ok(file.lines().map(ToString::to_string).collect()) + Ok(file + .lines() + .map(str::trim) + .filter_map(|s| (!s.is_empty()).then(|| s.to_string())) + .collect()) } else { Ok(vec![arg]) } diff --git a/tests/ui/empty/response-file b/tests/ui/empty/response-file new file mode 100644 index 0000000000000..002ddd717f5b3 --- /dev/null +++ b/tests/ui/empty/response-file @@ -0,0 +1,4 @@ + + + -v + diff --git a/tests/ui/empty/response-file-ignores-spaces.rs b/tests/ui/empty/response-file-ignores-spaces.rs new file mode 100644 index 0000000000000..860961421ebdb --- /dev/null +++ b/tests/ui/empty/response-file-ignores-spaces.rs @@ -0,0 +1,6 @@ +// check-pass +// compile-flags: @{{src-base}}/empty/response-file + +// Check that blank lines as well as leading and trailing whitespace in response +// files are ignored +#![crate_type = "lib"]