@@ -182,7 +182,7 @@ fn empty_paths_are_noop_if_no_path_was_pushed_before() {
182182 let mut s = Stack :: new ( root. clone ( ) ) ;
183183
184184 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 ( ) ;
186186 assert_eq ! (
187187 s. current_relative( ) . to_string_lossy( ) ,
188188 "" ,
@@ -196,7 +196,7 @@ fn relative_components_are_invalid() {
196196 let mut s = Stack :: new ( root. clone ( ) ) ;
197197
198198 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 ( ) ;
200200 assert_eq ! (
201201 err. to_string( ) ,
202202 format!(
@@ -205,7 +205,7 @@ fn relative_components_are_invalid() {
205205 )
206206 ) ;
207207
208- s. make_relative_path_current ( "a/./b" . as_ref ( ) , & mut r)
208+ s. make_relative_path_current ( p ( "a/./b" ) , & mut r)
209209 . expect ( "dot is ignored" ) ;
210210 assert_eq ! (
211211 r,
@@ -221,7 +221,7 @@ fn relative_components_are_invalid() {
221221 if cfg!( windows) { r".\a\b" } else { "./a/b" } ,
222222 "dot is silently ignored"
223223 ) ;
224- s. make_relative_path_current ( "a//b/" . as_ref ( ) , & mut r)
224+ s. make_relative_path_current ( p ( "a//b/" ) , & mut r)
225225 . expect ( "multiple-slashes are ignored" ) ;
226226 assert_eq ! (
227227 r,
@@ -240,19 +240,19 @@ fn absolute_paths_are_invalid() -> crate::Result {
240240 let mut s = Stack :: new ( root. clone ( ) ) ;
241241
242242 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 ( ) ;
244244 assert_eq ! (
245245 err. to_string( ) ,
246246 r#"Input path "/" contains relative or absolute components"# ,
247247 "a leading slash is always considered absolute"
248248 ) ;
249- s. make_relative_path_current ( "a/" . as_ref ( ) , & mut r) ?;
249+ s. make_relative_path_current ( p ( "a/" ) , & mut r) ?;
250250 assert_eq ! (
251251 s. current( ) ,
252252 p( "./a/" ) ,
253253 "trailing slashes aren't a problem at this stage, as they cannot cause a 'breakout'"
254254 ) ;
255- s. make_relative_path_current ( r"b\" . as_ref ( ) , & mut r) ?;
255+ s. make_relative_path_current ( p ( r"b\" ) , & mut r) ?;
256256 assert_eq ! (
257257 s. current( ) ,
258258 p( r"./b\" ) ,
@@ -261,44 +261,46 @@ fn absolute_paths_are_invalid() -> crate::Result {
261261
262262 #[ cfg( windows) ]
263263 {
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 ( ) ;
265265 assert_eq ! (
266266 err. to_string( ) ,
267267 r#"Input path "\" contains relative or absolute components"# ,
268268 "on Windows, backslashes are considered absolute and replace the base if it is relative, \
269269 hence they are forbidden."
270270 ) ;
271271
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 ( ) ;
273273 assert_eq ! (
274274 err. to_string( ) ,
275275 r#"Input path "c:" contains relative or absolute components"# ,
276276 "on Windows, drive-letters without trailing backslash or slash are also absolute (even though they ought to be relative)"
277277 ) ;
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 ( ) ;
279279 assert_eq ! (
280280 err. to_string( ) ,
281281 r#"Input path "c:\" contains relative or absolute components"# ,
282282 "on Windows, drive-letters are absolute, which is expected"
283283 ) ;
284284
285- s. make_relative_path_current ( "֍:" . as_ref ( ) , & mut r) ?;
285+ s. make_relative_path_current ( Path :: new ( "֍:" ) , & mut r) ?;
286286 assert_eq ! (
287287 s. current( ) . to_string_lossy( ) ,
288288 ".\\ ֍:" ,
289289 "on Windows, almost any unicode character will do as virtual drive-letter actually with `subst`, \
290290 but we just turn it into a presumably invalid path which is fine, i.e. we get a joined path"
291291 ) ;
292292 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)
294294 . unwrap_err ( ) ;
295295 assert_eq ! (
296296 err. to_string( ) ,
297297 r#"Input path "\\localhost\hello" contains relative or absolute components"# ,
298298 "there is UNC paths as well"
299299 ) ;
300300
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 ( ) ;
302304 assert_eq ! (
303305 err. to_string( ) ,
304306 r#"Input path "\\?\C:" contains relative or absolute components"# ,
@@ -314,10 +316,10 @@ fn delegate_calls_are_consistent() -> crate::Result {
314316 let mut s = Stack :: new ( root. clone ( ) ) ;
315317
316318 assert_eq ! ( s. current( ) , root) ;
317- assert_eq ! ( s. current_relative( ) , Path :: new ( "" ) ) ;
319+ assert_eq ! ( s. current_relative( ) , p ( "" ) ) ;
318320
319321 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) ?;
321323 let mut dirs = vec ! [ root. clone( ) , root. join( "a" ) ] ;
322324 assert_eq ! (
323325 r,
@@ -329,7 +331,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
329331 "it pushes the root-directory first, then the intermediate one"
330332 ) ;
331333
332- s. make_relative_path_current ( "a/b2" . as_ref ( ) , & mut r) ?;
334+ s. make_relative_path_current ( "a/b2" , & mut r) ?;
333335 assert_eq ! (
334336 r,
335337 Record {
@@ -340,7 +342,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
340342 "dirs remain the same as b2 is a leaf/file, hence the new `push`"
341343 ) ;
342344
343- s. make_relative_path_current ( "c/d/e" . as_ref ( ) , & mut r) ?;
345+ s. make_relative_path_current ( "c/d/e" , & mut r) ?;
344346 dirs. pop ( ) ;
345347 dirs. extend ( [ root. join ( "c" ) , root. join ( "c" ) . join ( "d" ) ] ) ;
346348 assert_eq ! (
@@ -354,7 +356,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
354356 ) ;
355357
356358 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) ?;
358360 assert_eq ! (
359361 r,
360362 Record {
@@ -366,8 +368,8 @@ fn delegate_calls_are_consistent() -> crate::Result {
366368 ) ;
367369
368370 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" ) ) ;
371373 assert_eq ! (
372374 r,
373375 Record {
@@ -379,7 +381,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
379381 ) ;
380382
381383 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) ?;
383385 assert_eq ! (
384386 r,
385387 Record {
@@ -391,7 +393,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
391393 ) ;
392394
393395 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) ?;
395397 assert_eq ! (
396398 r,
397399 Record {
@@ -404,7 +406,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
404406
405407 dirs. push ( root. join ( "x" ) . join ( "z" ) . join ( "a" ) ) ;
406408 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) ?;
408410 assert_eq ! (
409411 r,
410412 Record {
@@ -416,7 +418,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
416418 ) ;
417419
418420 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) ?;
420422 assert_eq ! (
421423 r,
422424 Record {
@@ -432,15 +434,15 @@ fn delegate_calls_are_consistent() -> crate::Result {
432434 "the stack is state so keeps thinking it's a directory which is consistent. Git does it differently though."
433435 ) ;
434436
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 ( ) ;
436438 assert_eq ! (
437439 err. to_string( ) ,
438440 "empty inputs are not allowed" ,
439441 "this is to protect us from double-counting the root path next time a component is pushed, \
440442 and besides that really shouldn't happen"
441443 ) ;
442444
443- s. make_relative_path_current ( "leaf" . as_ref ( ) , & mut r) ?;
445+ s. make_relative_path_current ( "leaf" , & mut r) ?;
444446 dirs. drain ( 1 ..) . count ( ) ;
445447 assert_eq ! (
446448 r,
@@ -452,7 +454,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
452454 "reset as much as possible, with just a leaf-component and the root directory"
453455 ) ;
454456
455- s. make_relative_path_current ( "a//b" . as_ref ( ) , & mut r) ?;
457+ s. make_relative_path_current ( p ( "a//b" ) , & mut r) ?;
456458 dirs. push ( root. join ( "a" ) ) ;
457459 assert_eq ! (
458460 r,
@@ -466,7 +468,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
466468
467469 #[ cfg( not( windows) ) ]
468470 {
469- s. make_relative_path_current ( r"\/b" . as_ref ( ) , & mut r) ?;
471+ s. make_relative_path_current ( r"\/b" , & mut r) ?;
470472 dirs. pop ( ) ;
471473 dirs. push ( root. join ( r"\" ) ) ;
472474 assert_eq ! (
@@ -479,7 +481,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
479481 "a backslash is a normal character outside of Windows, so it's fine to have it as component"
480482 ) ;
481483
482- s. make_relative_path_current ( r"\" . as_ref ( ) , & mut r) ?;
484+ s. make_relative_path_current ( r"\" , & mut r) ?;
483485 assert_eq ! (
484486 r,
485487 Record {
@@ -494,7 +496,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
494496 r"a backslash can also be a valid leaf component - here we only popped the 'b', leaving the \ 'directory'"
495497 ) ;
496498
497- s. make_relative_path_current ( r"\\" . as_ref ( ) , & mut r) ?;
499+ s. make_relative_path_current ( r"\\" , & mut r) ?;
498500 dirs. pop ( ) ;
499501 assert_eq ! (
500502 r,
@@ -513,7 +515,7 @@ fn delegate_calls_are_consistent() -> crate::Result {
513515
514516 #[ cfg( windows) ]
515517 {
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) ?;
517519 dirs. pop ( ) ;
518520 dirs. push ( root. join ( "c" ) ) ;
519521 assert_eq ! (
0 commit comments