@@ -78,8 +78,15 @@ fn release_profile_default_to_object() {
7878
7979 p. cargo ( "build --release --verbose -Ztrim-paths" )
8080 . masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
81- . with_stderr_does_not_contain ( "[..]-Zremap-path-scope=[..]" )
82- . with_stderr_does_not_contain ( "[..]--remap-path-prefix=[..]" )
81+ . with_stderr (
82+ "\
83+ [COMPILING] foo v0.0.1 ([CWD])
84+ [RUNNING] `rustc [..]\
85+ -Zremap-path-scope=object \
86+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
87+ --remap-path-prefix=[CWD]= [..]
88+ [FINISHED] release [..]" ,
89+ )
8390 . run ( ) ;
8491}
8592
@@ -109,8 +116,15 @@ fn one_option() {
109116 for option in [ "macro" , "diagnostics" , "object" , "all" ] {
110117 build ( option)
111118 . masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
112- . with_stderr_does_not_contain ( "[..]-Zremap-path-scope=[..]" )
113- . with_stderr_does_not_contain ( "[..]--remap-path-prefix=[..]" )
119+ . with_stderr ( & format ! (
120+ "\
121+ [COMPILING] foo v0.0.1 ([CWD])
122+ [RUNNING] `rustc [..]\
123+ -Zremap-path-scope={option} \
124+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
125+ --remap-path-prefix=[CWD]= [..]
126+ [FINISHED] dev [..]" ,
127+ ) )
114128 . run ( ) ;
115129 }
116130 build ( "none" )
@@ -139,32 +153,15 @@ fn multiple_options() {
139153
140154 p. cargo ( "build --verbose -Ztrim-paths" )
141155 . masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
142- . with_stderr_does_not_contain ( "[..]-Zremap-path-scope=[..]" )
143- . with_stderr_does_not_contain ( "[..]--remap-path-prefix=[..]" )
144- . run ( ) ;
145- }
146-
147- #[ cargo_test( nightly, reason = "-Zremap-path-scope is unstable" ) ]
148- fn multiple_options_with_none ( ) {
149- let p = project ( )
150- . file (
151- "Cargo.toml" ,
152- r#"
153- [package]
154- name = "foo"
155- version = "0.0.1"
156-
157- [profile.dev]
158- trim-paths = ["diagnostics", "macro", "object", "all", "none"]
159- "# ,
156+ . with_stderr (
157+ "\
158+ [COMPILING] foo v0.0.1 ([CWD])
159+ [RUNNING] `rustc [..]\
160+ -Zremap-path-scope=diagnostics,macro,object \
161+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
162+ --remap-path-prefix=[CWD]= [..]
163+ [FINISHED] dev [..]" ,
160164 )
161- . file ( "src/lib.rs" , "" )
162- . build ( ) ;
163-
164- p. cargo ( "build --verbose -Ztrim-paths" )
165- . masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
166- . with_stderr_does_not_contain ( "[..]-Zremap-path-scope=[..]" )
167- . with_stderr_does_not_contain ( "[..]--remap-path-prefix=[..]" )
168165 . run ( ) ;
169166}
170167
@@ -193,13 +190,29 @@ fn registry_dependency() {
193190 . build ( ) ;
194191
195192 let registry_src = paths:: home ( ) . join ( ".cargo/registry/src" ) ;
196- let registry_src = registry_src. display ( ) ;
193+ let pkg_remap = format ! ( "{}/[..]/bar-0.0.1=bar-0.0.1" , registry_src. display( ) ) ;
197194
198195 p. cargo ( "run --verbose -Ztrim-paths" )
199196 . masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
200- . with_stdout ( format ! ( "{registry_src}/[..]/bar-0.0.1/src/lib.rs" ) )
201- . with_stderr_does_not_contain ( "[..]-Zremap-path-scope=[..]" )
202- . with_stderr_does_not_contain ( "[..]--remap-path-prefix=[..]" )
197+ . with_stdout ( "bar-0.0.1/src/lib.rs" )
198+ . with_stderr ( & format ! (
199+ "\
200+ [UPDATING] [..]
201+ [DOWNLOADING] crates ...
202+ [DOWNLOADED] bar v0.0.1 ([..])
203+ [COMPILING] bar v0.0.1
204+ [RUNNING] `rustc [..]\
205+ -Zremap-path-scope=object \
206+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
207+ --remap-path-prefix={pkg_remap} [..]
208+ [COMPILING] foo v0.0.1 ([CWD])
209+ [RUNNING] `rustc [..]\
210+ -Zremap-path-scope=object \
211+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
212+ --remap-path-prefix=[CWD]= [..]
213+ [FINISHED] dev [..]
214+ [RUNNING] `target/debug/foo[EXE]`"
215+ ) )
203216 . run ( ) ;
204217}
205218
@@ -233,13 +246,27 @@ fn git_dependency() {
233246 . build ( ) ;
234247
235248 let git_checkouts_src = paths:: home ( ) . join ( ".cargo/git/checkouts" ) ;
236- let git_checkouts_src = git_checkouts_src. display ( ) ;
249+ let pkg_remap = format ! ( "{}/bar-[..]/[..]=bar-0.0.1" , git_checkouts_src. display( ) ) ;
237250
238251 p. cargo ( "run --verbose -Ztrim-paths" )
239252 . masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
240- . with_stdout ( format ! ( "{git_checkouts_src}/bar-[..]/[..]/src/lib.rs" ) )
241- . with_stderr_does_not_contain ( "[..]-Zremap-path-scope=[..]" )
242- . with_stderr_does_not_contain ( "[..]--remap-path-prefix=[..]" )
253+ . with_stdout ( "bar-0.0.1/src/lib.rs" )
254+ . with_stderr ( & format ! (
255+ "\
256+ [UPDATING] git repository `{url}`
257+ [COMPILING] bar v0.0.1 ({url}[..])
258+ [RUNNING] `rustc [..]\
259+ -Zremap-path-scope=object \
260+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
261+ --remap-path-prefix={pkg_remap} [..]
262+ [COMPILING] foo v0.0.1 ([CWD])
263+ [RUNNING] `rustc [..]\
264+ -Zremap-path-scope=object \
265+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
266+ --remap-path-prefix=[CWD]= [..]
267+ [FINISHED] dev [..]
268+ [RUNNING] `target/debug/foo[EXE]`"
269+ ) )
243270 . run ( ) ;
244271}
245272
@@ -271,8 +298,21 @@ fn path_dependency() {
271298 p. cargo ( "run --verbose -Ztrim-paths" )
272299 . masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
273300 . with_stdout ( "cocktail-bar/src/lib.rs" )
274- . with_stderr_does_not_contain ( "[..]-Zremap-path-scope=[..]" )
275- . with_stderr_does_not_contain ( "[..]--remap-path-prefix=[..]" )
301+ . with_stderr ( & format ! (
302+ "\
303+ [COMPILING] bar v0.0.1 ([..]/cocktail-bar)
304+ [RUNNING] `rustc [..]\
305+ -Zremap-path-scope=object \
306+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
307+ --remap-path-prefix=[CWD]= [..]
308+ [COMPILING] foo v0.0.1 ([CWD])
309+ [RUNNING] `rustc [..]\
310+ -Zremap-path-scope=object \
311+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
312+ --remap-path-prefix=[CWD]= [..]
313+ [FINISHED] dev [..]
314+ [RUNNING] `target/debug/foo[EXE]`"
315+ ) )
276316 . run ( ) ;
277317}
278318
@@ -306,9 +346,22 @@ fn path_dependency_outside_workspace() {
306346
307347 p. cargo ( "run --verbose -Ztrim-paths" )
308348 . masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
309- . with_stdout ( format ! ( "{bar_path}/src/lib.rs" ) )
310- . with_stderr_does_not_contain ( "[..]-Zremap-path-scope=[..]" )
311- . with_stderr_does_not_contain ( "[..]--remap-path-prefix=[..]" )
349+ . with_stdout ( "bar-0.0.1/src/lib.rs" )
350+ . with_stderr ( & format ! (
351+ "\
352+ [COMPILING] bar v0.0.1 ([..]/bar)
353+ [RUNNING] `rustc [..]\
354+ -Zremap-path-scope=object \
355+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
356+ --remap-path-prefix={bar_path}=bar-0.0.1 [..]
357+ [COMPILING] foo v0.0.1 ([CWD])
358+ [RUNNING] `rustc [..]\
359+ -Zremap-path-scope=object \
360+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
361+ --remap-path-prefix=[CWD]= [..]
362+ [FINISHED] dev [..]
363+ [RUNNING] `target/debug/foo[EXE]`"
364+ ) )
312365 . run ( ) ;
313366}
314367
@@ -337,22 +390,34 @@ fn diagnostics_works() {
337390 . build ( ) ;
338391
339392 let registry_src = paths:: home ( ) . join ( ".cargo/registry/src" ) ;
340- let registry_src = registry_src. display ( ) ;
393+ let pkg_remap = format ! ( "{}/[..]/bar-0.0.1=bar-0.0.1" , registry_src. display( ) ) ;
341394
342395 p. cargo ( "build -vv -Ztrim-paths" )
343396 . masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
344- . with_stderr_contains ( format ! (
397+ . with_stderr_contains (
345398 "\
346399 warning: unused variable: `unused`
347- --> {registry_src}/[..]/ bar-0.0.1/src/lib.rs:1:18
400+ --> bar-0.0.1/src/lib.rs:1:18
348401 |
349- 1 | pub fn f() {{ let unused = 0; } }
402+ 1 | pub fn f() { let unused = 0; }
350403 | ^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused`
351404 |
352405 = note: `#[warn(unused_variables)]` on by default" ,
406+ )
407+ . with_stderr_contains ( & format ! (
408+ "\
409+ [RUNNING] [..]rustc [..]\
410+ -Zremap-path-scope=diagnostics \
411+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
412+ --remap-path-prefix={pkg_remap} [..]",
353413 ) )
354- . with_stderr_does_not_contain ( "[..]-Zremap-path-scope=[..]" )
355- . with_stderr_does_not_contain ( "[..]--remap-path-prefix=[..]" )
414+ . with_stderr_contains (
415+ "\
416+ [RUNNING] [..]rustc [..]\
417+ -Zremap-path-scope=diagnostics \
418+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
419+ --remap-path-prefix=[CWD]= [..]",
420+ )
356421 . run ( ) ;
357422}
358423
@@ -370,6 +435,8 @@ fn object_works() {
370435 } ;
371436
372437 let registry_src = paths:: home ( ) . join ( ".cargo/registry/src" ) ;
438+ let pkg_remap = format ! ( "{}/[..]/bar-0.0.1=bar-0.0.1" , registry_src. display( ) ) ;
439+ let rust_src = "/lib/rustc/src/rust" . as_bytes ( ) ;
373440 let registry_src_bytes = registry_src. as_os_str ( ) . as_bytes ( ) ;
374441
375442 Package :: new ( "bar" , "0.0.1" )
@@ -425,16 +492,26 @@ fn object_works() {
425492
426493 p. cargo ( "build --verbose -Ztrim-paths" )
427494 . masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
428- . with_stderr_does_not_contain ( "[..]-Zremap-path-scope=[..]" )
429- . with_stderr_does_not_contain ( "[..]--remap-path-prefix=[..]" )
495+ . with_stderr ( & format ! (
496+ "\
497+ [COMPILING] bar v0.0.1
498+ [RUNNING] `rustc [..]\
499+ -Zremap-path-scope=object \
500+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
501+ --remap-path-prefix={pkg_remap} [..]
502+ [COMPILING] foo v0.0.1 ([CWD])
503+ [RUNNING] `rustc [..]\
504+ -Zremap-path-scope=object \
505+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
506+ --remap-path-prefix=[CWD]= [..]
507+ [FINISHED] dev [..]" ,
508+ ) )
430509 . run ( ) ;
431510
432511 let bin_path = p. bin ( "foo" ) ;
433512 assert ! ( bin_path. is_file( ) ) ;
434513 let stdout = run_readelf ( bin_path) . stdout ;
435- // TODO: re-enable this check when rustc bootstrap disables remapping
436- // <https://github.com/rust-lang/cargo/pull/12625#discussion_r1371714791>
437- // assert!(memchr::memmem::find(&stdout, rust_src).is_some());
438- assert ! ( memchr:: memmem:: find( & stdout, registry_src_bytes) . is_some( ) ) ;
439- assert ! ( memchr:: memmem:: find( & stdout, pkg_root) . is_some( ) ) ;
514+ assert ! ( memchr:: memmem:: find( & stdout, rust_src) . is_none( ) ) ;
515+ assert ! ( memchr:: memmem:: find( & stdout, registry_src_bytes) . is_none( ) ) ;
516+ assert ! ( memchr:: memmem:: find( & stdout, pkg_root) . is_none( ) ) ;
440517}
0 commit comments