@@ -182,7 +182,7 @@ fn empty_paths_are_noop_if_no_path_was_pushed_before() {
182
182
let mut s = Stack :: new ( root. clone ( ) ) ;
183
183
184
184
let mut r = Record :: default ( ) ;
185
- s. make_relative_path_current ( "" . as_ref ( ) , & mut r) . unwrap ( ) ;
185
+ s. make_relative_path_current ( "" , & mut r) . unwrap ( ) ;
186
186
assert_eq ! (
187
187
s. current_relative( ) . to_string_lossy( ) ,
188
188
"" ,
@@ -196,7 +196,7 @@ fn relative_components_are_invalid() {
196
196
let mut s = Stack :: new ( root. clone ( ) ) ;
197
197
198
198
let mut r = Record :: default ( ) ;
199
- let err = s. make_relative_path_current ( "a/.." . as_ref ( ) , & mut r) . unwrap_err ( ) ;
199
+ let err = s. make_relative_path_current ( p ( "a/.." ) , & mut r) . unwrap_err ( ) ;
200
200
assert_eq ! (
201
201
err. to_string( ) ,
202
202
format!(
@@ -205,7 +205,7 @@ fn relative_components_are_invalid() {
205
205
)
206
206
) ;
207
207
208
- s. make_relative_path_current ( "a/./b" . as_ref ( ) , & mut r)
208
+ s. make_relative_path_current ( p ( "a/./b" ) , & mut r)
209
209
. expect ( "dot is ignored" ) ;
210
210
assert_eq ! (
211
211
r,
@@ -221,7 +221,7 @@ fn relative_components_are_invalid() {
221
221
if cfg!( windows) { r".\a\b" } else { "./a/b" } ,
222
222
"dot is silently ignored"
223
223
) ;
224
- s. make_relative_path_current ( "a//b/" . as_ref ( ) , & mut r)
224
+ s. make_relative_path_current ( p ( "a//b/" ) , & mut r)
225
225
. expect ( "multiple-slashes are ignored" ) ;
226
226
assert_eq ! (
227
227
r,
@@ -240,19 +240,19 @@ fn absolute_paths_are_invalid() -> crate::Result {
240
240
let mut s = Stack :: new ( root. clone ( ) ) ;
241
241
242
242
let mut r = Record :: default ( ) ;
243
- let err = s. make_relative_path_current ( "/" . as_ref ( ) , & mut r) . unwrap_err ( ) ;
243
+ let err = s. make_relative_path_current ( p ( "/" ) , & mut r) . unwrap_err ( ) ;
244
244
assert_eq ! (
245
245
err. to_string( ) ,
246
246
r#"Input path "/" contains relative or absolute components"# ,
247
247
"a leading slash is always considered absolute"
248
248
) ;
249
- s. make_relative_path_current ( "a/" . as_ref ( ) , & mut r) ?;
249
+ s. make_relative_path_current ( p ( "a/" ) , & mut r) ?;
250
250
assert_eq ! (
251
251
s. current( ) ,
252
252
p( "./a/" ) ,
253
253
"trailing slashes aren't a problem at this stage, as they cannot cause a 'breakout'"
254
254
) ;
255
- s. make_relative_path_current ( r"b\" . as_ref ( ) , & mut r) ?;
255
+ s. make_relative_path_current ( p ( r"b\" ) , & mut r) ?;
256
256
assert_eq ! (
257
257
s. current( ) ,
258
258
p( r"./b\" ) ,
@@ -314,10 +314,10 @@ fn delegate_calls_are_consistent() -> crate::Result {
314
314
let mut s = Stack :: new ( root. clone ( ) ) ;
315
315
316
316
assert_eq ! ( s. current( ) , root) ;
317
- assert_eq ! ( s. current_relative( ) , Path :: new ( "" ) ) ;
317
+ assert_eq ! ( s. current_relative( ) , p ( "" ) ) ;
318
318
319
319
let mut r = Record :: default ( ) ;
320
- s. make_relative_path_current ( "a/b" . as_ref ( ) , & mut r) ?;
320
+ s. make_relative_path_current ( "a/b" , & mut r) ?;
321
321
let mut dirs = vec ! [ root. clone( ) , root. join( "a" ) ] ;
322
322
assert_eq ! (
323
323
r,
@@ -329,7 +329,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
329
329
"it pushes the root-directory first, then the intermediate one"
330
330
) ;
331
331
332
- s. make_relative_path_current ( "a/b2" . as_ref ( ) , & mut r) ?;
332
+ s. make_relative_path_current ( "a/b2" , & mut r) ?;
333
333
assert_eq ! (
334
334
r,
335
335
Record {
@@ -340,7 +340,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
340
340
"dirs remain the same as b2 is a leaf/file, hence the new `push`"
341
341
) ;
342
342
343
- s. make_relative_path_current ( "c/d/e" . as_ref ( ) , & mut r) ?;
343
+ s. make_relative_path_current ( "c/d/e" , & mut r) ?;
344
344
dirs. pop ( ) ;
345
345
dirs. extend ( [ root. join ( "c" ) , root. join ( "c" ) . join ( "d" ) ] ) ;
346
346
assert_eq ! (
@@ -354,7 +354,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
354
354
) ;
355
355
356
356
dirs. push ( root. join ( "c" ) . join ( "d" ) . join ( "x" ) ) ;
357
- s. make_relative_path_current ( "c/d/x/z" . as_ref ( ) , & mut r) ?;
357
+ s. make_relative_path_current ( "c/d/x/z" , & mut r) ?;
358
358
assert_eq ! (
359
359
r,
360
360
Record {
@@ -366,8 +366,8 @@ fn delegate_calls_are_consistent() -> crate::Result {
366
366
) ;
367
367
368
368
dirs. drain ( 1 ..) . count ( ) ;
369
- s. make_relative_path_current ( "f" . as_ref ( ) , & mut r) ?;
370
- assert_eq ! ( s. current_relative( ) , Path :: new ( "f" ) ) ;
369
+ s. make_relative_path_current ( "f" , & mut r) ?;
370
+ assert_eq ! ( s. current_relative( ) , p ( "f" ) ) ;
371
371
assert_eq ! (
372
372
r,
373
373
Record {
@@ -379,7 +379,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
379
379
) ;
380
380
381
381
dirs. push ( root. join ( "x" ) ) ;
382
- s. make_relative_path_current ( "x/z" . as_ref ( ) , & mut r) ?;
382
+ s. make_relative_path_current ( "x/z" , & mut r) ?;
383
383
assert_eq ! (
384
384
r,
385
385
Record {
@@ -391,7 +391,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
391
391
) ;
392
392
393
393
dirs. push ( root. join ( "x" ) . join ( "z" ) ) ;
394
- s. make_relative_path_current ( "x/z/a" . as_ref ( ) , & mut r) ?;
394
+ s. make_relative_path_current ( "x/z/a" , & mut r) ?;
395
395
assert_eq ! (
396
396
r,
397
397
Record {
@@ -404,7 +404,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
404
404
405
405
dirs. push ( root. join ( "x" ) . join ( "z" ) . join ( "a" ) ) ;
406
406
dirs. push ( root. join ( "x" ) . join ( "z" ) . join ( "a" ) . join ( "b" ) ) ;
407
- s. make_relative_path_current ( "x/z/a/b/c" . as_ref ( ) , & mut r) ?;
407
+ s. make_relative_path_current ( "x/z/a/b/c" , & mut r) ?;
408
408
assert_eq ! (
409
409
r,
410
410
Record {
@@ -416,7 +416,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
416
416
) ;
417
417
418
418
dirs. drain ( 1 /*root*/ + 1 /*x*/ + 1 /*x/z*/ ..) . count ( ) ;
419
- s. make_relative_path_current ( "x/z" . as_ref ( ) , & mut r) ?;
419
+ s. make_relative_path_current ( "x/z" , & mut r) ?;
420
420
assert_eq ! (
421
421
r,
422
422
Record {
@@ -432,15 +432,15 @@ fn delegate_calls_are_consistent() -> crate::Result {
432
432
"the stack is state so keeps thinking it's a directory which is consistent. Git does it differently though."
433
433
) ;
434
434
435
- let err = s. make_relative_path_current ( "" . as_ref ( ) , & mut r) . unwrap_err ( ) ;
435
+ let err = s. make_relative_path_current ( p ( "" ) , & mut r) . unwrap_err ( ) ;
436
436
assert_eq ! (
437
437
err. to_string( ) ,
438
438
"empty inputs are not allowed" ,
439
439
"this is to protect us from double-counting the root path next time a component is pushed, \
440
440
and besides that really shouldn't happen"
441
441
) ;
442
442
443
- s. make_relative_path_current ( "leaf" . as_ref ( ) , & mut r) ?;
443
+ s. make_relative_path_current ( "leaf" , & mut r) ?;
444
444
dirs. drain ( 1 ..) . count ( ) ;
445
445
assert_eq ! (
446
446
r,
@@ -452,7 +452,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
452
452
"reset as much as possible, with just a leaf-component and the root directory"
453
453
) ;
454
454
455
- s. make_relative_path_current ( "a//b" . as_ref ( ) , & mut r) ?;
455
+ s. make_relative_path_current ( p ( "a//b" ) , & mut r) ?;
456
456
dirs. push ( root. join ( "a" ) ) ;
457
457
assert_eq ! (
458
458
r,
@@ -466,7 +466,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
466
466
467
467
#[ cfg( not( windows) ) ]
468
468
{
469
- s. make_relative_path_current ( r"\/b" . as_ref ( ) , & mut r) ?;
469
+ s. make_relative_path_current ( r"\/b" , & mut r) ?;
470
470
dirs. pop ( ) ;
471
471
dirs. push ( root. join ( r"\" ) ) ;
472
472
assert_eq ! (
@@ -479,7 +479,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
479
479
"a backslash is a normal character outside of Windows, so it's fine to have it as component"
480
480
) ;
481
481
482
- s. make_relative_path_current ( r"\" . as_ref ( ) , & mut r) ?;
482
+ s. make_relative_path_current ( r"\" , & mut r) ?;
483
483
assert_eq ! (
484
484
r,
485
485
Record {
@@ -494,7 +494,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
494
494
r"a backslash can also be a valid leaf component - here we only popped the 'b', leaving the \ 'directory'"
495
495
) ;
496
496
497
- s. make_relative_path_current ( r"\\" . as_ref ( ) , & mut r) ?;
497
+ s. make_relative_path_current ( r"\\" , & mut r) ?;
498
498
dirs. pop ( ) ;
499
499
assert_eq ! (
500
500
r,
0 commit comments