diff options
| author | David Tolnay <dtolnay@gmail.com> | 2023-07-16 19:06:04 -0700 |
|---|---|---|
| committer | David Tolnay <dtolnay@gmail.com> | 2023-07-20 11:04:30 -0700 |
| commit | 32cac2e0024aa4d02661859f9bfc69d33e6e8ba9 (patch) | |
| tree | 33754e61bf87a50cfa7604704e720b1655d058de /compiler/rustc_session/src | |
| parent | f72bdb150180f3fb9ccd6447f13e9e37b3e33e79 (diff) | |
| download | rust-32cac2e0024aa4d02661859f9bfc69d33e6e8ba9.tar.gz rust-32cac2e0024aa4d02661859f9bfc69d33e6e8ba9.zip | |
Disallow overlapping prints to the same location
Diffstat (limited to 'compiler/rustc_session/src')
| -rw-r--r-- | compiler/rustc_session/src/config.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 738625485c4..ee871dc8005 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -2129,6 +2129,12 @@ fn collect_print_requests( ("deployment-target", PrintKind::DeploymentTarget), ]; + // We disallow reusing the same path in multiple prints, such as `--print + // cfg=output.txt --print link-args=output.txt`, because outputs are printed + // by disparate pieces of the compiler, and keeping track of which files + // need to be overwritten vs appended to is annoying. + let mut printed_paths = FxHashSet::default(); + prints.extend(matches.opt_strs("print").into_iter().map(|req| { let (req, out) = split_out_file_name(&req); @@ -2165,6 +2171,15 @@ fn collect_print_requests( }; let out = out.unwrap_or(OutFileName::Stdout); + if let OutFileName::Real(path) = &out { + if !printed_paths.insert(path.clone()) { + handler.early_error(format!( + "cannot print multiple outputs to the same path: {}", + path.display(), + )); + } + } + PrintRequest { kind, out } })); |
