@@ -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\" ) ,
@@ -261,44 +261,46 @@ fn absolute_paths_are_invalid() -> crate::Result {
261
261
262
262
#[ cfg( windows) ]
263
263
{
264
- let err = s. make_relative_path_current ( r"\" . as_ref ( ) , & mut r) . unwrap_err ( ) ;
264
+ let err = s. make_relative_path_current ( Path :: new ( r"\" ) , & mut r) . unwrap_err ( ) ;
265
265
assert_eq ! (
266
266
err. to_string( ) ,
267
267
r#"Input path "\" contains relative or absolute components"# ,
268
268
"on Windows, backslashes are considered absolute and replace the base if it is relative, \
269
269
hence they are forbidden."
270
270
) ;
271
271
272
- let err = s. make_relative_path_current ( "c:" . as_ref ( ) , & mut r) . unwrap_err ( ) ;
272
+ let err = s. make_relative_path_current ( Path :: new ( "c:" ) , & mut r) . unwrap_err ( ) ;
273
273
assert_eq ! (
274
274
err. to_string( ) ,
275
275
r#"Input path "c:" contains relative or absolute components"# ,
276
276
"on Windows, drive-letters without trailing backslash or slash are also absolute (even though they ought to be relative)"
277
277
) ;
278
- let err = s. make_relative_path_current ( r"c:\" . as_ref ( ) , & mut r) . unwrap_err ( ) ;
278
+ let err = s. make_relative_path_current ( Path :: new ( r"c:\" ) , & mut r) . unwrap_err ( ) ;
279
279
assert_eq ! (
280
280
err. to_string( ) ,
281
281
r#"Input path "c:\" contains relative or absolute components"# ,
282
282
"on Windows, drive-letters are absolute, which is expected"
283
283
) ;
284
284
285
- s. make_relative_path_current ( "֍:" . as_ref ( ) , & mut r) ?;
285
+ s. make_relative_path_current ( Path :: new ( "֍:" ) , & mut r) ?;
286
286
assert_eq ! (
287
287
s. current( ) . to_string_lossy( ) ,
288
288
".\\ ֍:" ,
289
289
"on Windows, almost any unicode character will do as virtual drive-letter actually with `subst`, \
290
290
but we just turn it into a presumably invalid path which is fine, i.e. we get a joined path"
291
291
) ;
292
292
let err = s
293
- . make_relative_path_current ( r"\\localhost\hello" . as_ref ( ) , & mut r)
293
+ . make_relative_path_current ( Path :: new ( r"\\localhost\hello" ) , & mut r)
294
294
. unwrap_err ( ) ;
295
295
assert_eq ! (
296
296
err. to_string( ) ,
297
297
r#"Input path "\\localhost\hello" contains relative or absolute components"# ,
298
298
"there is UNC paths as well"
299
299
) ;
300
300
301
- let err = s. make_relative_path_current ( r#"\\?\C:"# . as_ref ( ) , & mut r) . unwrap_err ( ) ;
301
+ let err = s
302
+ . make_relative_path_current ( Path :: new ( r#"\\?\C:"# ) , & mut r)
303
+ . unwrap_err ( ) ;
302
304
assert_eq ! (
303
305
err. to_string( ) ,
304
306
r#"Input path "\\?\C:" contains relative or absolute components"# ,
@@ -314,10 +316,10 @@ fn delegate_calls_are_consistent() -> crate::Result {
314
316
let mut s = Stack :: new ( root. clone ( ) ) ;
315
317
316
318
assert_eq ! ( s. current( ) , root) ;
317
- assert_eq ! ( s. current_relative( ) , Path :: new ( "" ) ) ;
319
+ assert_eq ! ( s. current_relative( ) , p ( "" ) ) ;
318
320
319
321
let mut r = Record :: default ( ) ;
320
- s. make_relative_path_current ( "a/b" . as_ref ( ) , & mut r) ?;
322
+ s. make_relative_path_current ( "a/b" , & mut r) ?;
321
323
let mut dirs = vec ! [ root. clone( ) , root. join( "a" ) ] ;
322
324
assert_eq ! (
323
325
r,
@@ -329,7 +331,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
329
331
"it pushes the root-directory first, then the intermediate one"
330
332
) ;
331
333
332
- s. make_relative_path_current ( "a/b2" . as_ref ( ) , & mut r) ?;
334
+ s. make_relative_path_current ( "a/b2" , & mut r) ?;
333
335
assert_eq ! (
334
336
r,
335
337
Record {
@@ -340,7 +342,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
340
342
"dirs remain the same as b2 is a leaf/file, hence the new `push`"
341
343
) ;
342
344
343
- s. make_relative_path_current ( "c/d/e" . as_ref ( ) , & mut r) ?;
345
+ s. make_relative_path_current ( "c/d/e" , & mut r) ?;
344
346
dirs. pop ( ) ;
345
347
dirs. extend ( [ root. join ( "c" ) , root. join ( "c" ) . join ( "d" ) ] ) ;
346
348
assert_eq ! (
@@ -354,7 +356,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
354
356
) ;
355
357
356
358
dirs. push ( root. join ( "c" ) . join ( "d" ) . join ( "x" ) ) ;
357
- s. make_relative_path_current ( "c/d/x/z" . as_ref ( ) , & mut r) ?;
359
+ s. make_relative_path_current ( "c/d/x/z" , & mut r) ?;
358
360
assert_eq ! (
359
361
r,
360
362
Record {
@@ -366,8 +368,8 @@ fn delegate_calls_are_consistent() -> crate::Result {
366
368
) ;
367
369
368
370
dirs. drain ( 1 ..) . count ( ) ;
369
- s. make_relative_path_current ( "f" . as_ref ( ) , & mut r) ?;
370
- assert_eq ! ( s. current_relative( ) , Path :: new ( "f" ) ) ;
371
+ s. make_relative_path_current ( "f" , & mut r) ?;
372
+ assert_eq ! ( s. current_relative( ) , p ( "f" ) ) ;
371
373
assert_eq ! (
372
374
r,
373
375
Record {
@@ -379,7 +381,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
379
381
) ;
380
382
381
383
dirs. push ( root. join ( "x" ) ) ;
382
- s. make_relative_path_current ( "x/z" . as_ref ( ) , & mut r) ?;
384
+ s. make_relative_path_current ( "x/z" , & mut r) ?;
383
385
assert_eq ! (
384
386
r,
385
387
Record {
@@ -391,7 +393,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
391
393
) ;
392
394
393
395
dirs. push ( root. join ( "x" ) . join ( "z" ) ) ;
394
- s. make_relative_path_current ( "x/z/a" . as_ref ( ) , & mut r) ?;
396
+ s. make_relative_path_current ( "x/z/a" , & mut r) ?;
395
397
assert_eq ! (
396
398
r,
397
399
Record {
@@ -404,7 +406,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
404
406
405
407
dirs. push ( root. join ( "x" ) . join ( "z" ) . join ( "a" ) ) ;
406
408
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) ?;
409
+ s. make_relative_path_current ( "x/z/a/b/c" , & mut r) ?;
408
410
assert_eq ! (
409
411
r,
410
412
Record {
@@ -416,7 +418,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
416
418
) ;
417
419
418
420
dirs. drain ( 1 /*root*/ + 1 /*x*/ + 1 /*x/z*/ ..) . count ( ) ;
419
- s. make_relative_path_current ( "x/z" . as_ref ( ) , & mut r) ?;
421
+ s. make_relative_path_current ( "x/z" , & mut r) ?;
420
422
assert_eq ! (
421
423
r,
422
424
Record {
@@ -432,15 +434,15 @@ fn delegate_calls_are_consistent() -> crate::Result {
432
434
"the stack is state so keeps thinking it's a directory which is consistent. Git does it differently though."
433
435
) ;
434
436
435
- let err = s. make_relative_path_current ( "" . as_ref ( ) , & mut r) . unwrap_err ( ) ;
437
+ let err = s. make_relative_path_current ( p ( "" ) , & mut r) . unwrap_err ( ) ;
436
438
assert_eq ! (
437
439
err. to_string( ) ,
438
440
"empty inputs are not allowed" ,
439
441
"this is to protect us from double-counting the root path next time a component is pushed, \
440
442
and besides that really shouldn't happen"
441
443
) ;
442
444
443
- s. make_relative_path_current ( "leaf" . as_ref ( ) , & mut r) ?;
445
+ s. make_relative_path_current ( "leaf" , & mut r) ?;
444
446
dirs. drain ( 1 ..) . count ( ) ;
445
447
assert_eq ! (
446
448
r,
@@ -452,7 +454,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
452
454
"reset as much as possible, with just a leaf-component and the root directory"
453
455
) ;
454
456
455
- s. make_relative_path_current ( "a//b" . as_ref ( ) , & mut r) ?;
457
+ s. make_relative_path_current ( p ( "a//b" ) , & mut r) ?;
456
458
dirs. push ( root. join ( "a" ) ) ;
457
459
assert_eq ! (
458
460
r,
@@ -466,7 +468,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
466
468
467
469
#[ cfg( not( windows) ) ]
468
470
{
469
- s. make_relative_path_current ( r"\/b" . as_ref ( ) , & mut r) ?;
471
+ s. make_relative_path_current ( r"\/b" , & mut r) ?;
470
472
dirs. pop ( ) ;
471
473
dirs. push ( root. join ( r"\" ) ) ;
472
474
assert_eq ! (
@@ -479,7 +481,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
479
481
"a backslash is a normal character outside of Windows, so it's fine to have it as component"
480
482
) ;
481
483
482
- s. make_relative_path_current ( r"\" . as_ref ( ) , & mut r) ?;
484
+ s. make_relative_path_current ( r"\" , & mut r) ?;
483
485
assert_eq ! (
484
486
r,
485
487
Record {
@@ -494,7 +496,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
494
496
r"a backslash can also be a valid leaf component - here we only popped the 'b', leaving the \ 'directory'"
495
497
) ;
496
498
497
- s. make_relative_path_current ( r"\\" . as_ref ( ) , & mut r) ?;
499
+ s. make_relative_path_current ( r"\\" , & mut r) ?;
498
500
dirs. pop ( ) ;
499
501
assert_eq ! (
500
502
r,
@@ -513,7 +515,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
513
515
514
516
#[ cfg( windows) ]
515
517
{
516
- s. make_relative_path_current ( r"c\/d" . as_ref ( ) , & mut r) ?;
518
+ s. make_relative_path_current ( Path :: new ( r"c\/d" ) , & mut r) ?;
517
519
dirs. pop ( ) ;
518
520
dirs. push ( root. join ( "c" ) ) ;
519
521
assert_eq ! (
0 commit comments