File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
compiler/rustc_session/src Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -2129,6 +2129,12 @@ fn collect_print_requests(
21292129 ( "deployment-target" , PrintKind :: DeploymentTarget ) ,
21302130 ] ;
21312131
2132+ // We disallow reusing the same path in multiple prints, such as `--print
2133+ // cfg=output.txt --print link-args=output.txt`, because outputs are printed
2134+ // by disparate pieces of the compiler, and keeping track of which files
2135+ // need to be overwritten vs appended to is annoying.
2136+ let mut printed_paths = FxHashSet :: default ( ) ;
2137+
21322138 prints. extend ( matches. opt_strs ( "print" ) . into_iter ( ) . map ( |req| {
21332139 let ( req, out) = split_out_file_name ( & req) ;
21342140
@@ -2165,6 +2171,15 @@ fn collect_print_requests(
21652171 } ;
21662172
21672173 let out = out. unwrap_or ( OutFileName :: Stdout ) ;
2174+ if let OutFileName :: Real ( path) = & out {
2175+ if !printed_paths. insert ( path. clone ( ) ) {
2176+ handler. early_error ( format ! (
2177+ "cannot print multiple outputs to the same path: {}" ,
2178+ path. display( ) ,
2179+ ) ) ;
2180+ }
2181+ }
2182+
21682183 PrintRequest { kind, out }
21692184 } ) ) ;
21702185
You can’t perform that action at this time.
0 commit comments