diff --git a/CHANGELOG.md b/CHANGELOG.md index b3999f0cfa..829f0d9b15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,11 +40,12 @@ Bottom level categories: ## Unreleased -## New Features +### New Features -### Naga +#### Naga - Parse `diagnostic(…)` directives, but don't implement any triggering rules yet. By @ErichDonGubler in [#6456](https://github.com/gfx-rs/wgpu/pull/6456). +- Fix an issue where `naga` CLI would incorrectly skip the first positional argument when `--stdin-file-path` was specified. By @ErichDonGubler in [#6480](https://github.com/gfx-rs/wgpu/pull/6480). ### Changes diff --git a/naga-cli/src/bin/naga.rs b/naga-cli/src/bin/naga.rs index 6523b2102d..e7d007d018 100644 --- a/naga-cli/src/bin/naga.rs +++ b/naga-cli/src/bin/naga.rs @@ -451,13 +451,15 @@ fn run() -> anyhow::Result<()> { return bulk_validate(args, ¶ms); } - let (input_path, input) = if let Some(path) = args.files.first() { - let path = Path::new(path); - (path, fs::read(path)?) - } else if let Some(path) = &args.stdin_file_path { + let mut files = args.files.iter(); + + let (input_path, input) = if let Some(path) = args.stdin_file_path.as_ref() { let mut input = vec![]; std::io::stdin().lock().read_to_end(&mut input)?; (Path::new(path), input) + } else if let Some(path) = files.next() { + let path = Path::new(path); + (path, fs::read(path)?) } else { return Err(CliError("Input file path is not specified").into()); }; @@ -492,12 +494,12 @@ fn run() -> anyhow::Result<()> { } } - let output_paths = args.files.get(1..).unwrap_or(&[]); + let output_paths = files; // Decide which capabilities our output formats can support. let validation_caps = output_paths - .iter() + .clone() .fold(naga::valid::Capabilities::all(), |caps, path| { use naga::valid::Capabilities as C; let missing = match Path::new(path).extension().and_then(|ex| ex.to_str()) { @@ -567,7 +569,7 @@ fn run() -> anyhow::Result<()> { // // If the user asked for output, don't stop: some output formats (".txt", // ".dot", ".bin") can be generated even without a `ModuleInfo`. - if output_paths.is_empty() { + if output_paths.clone().next().is_none() { if info.is_some() { println!("Validation successful"); return Ok(());