@@ -94,13 +94,13 @@ pub fn find_closest_pnp_manifest_path(path: &Path) -> Option<PathBuf> {
9494 None
9595}
9696
97- pub fn load_pnp_manifest < P : AsRef < Path > > ( p : P ) -> Result < Manifest , Error > {
98- let manifest_content = std:: fs:: read_to_string ( p. as_ref ( ) ) . map_err ( |err| {
97+ pub fn load_pnp_manifest ( p : & Path ) -> Result < Manifest , Error > {
98+ let manifest_content = std:: fs:: read_to_string ( p) . map_err ( |err| {
9999 Error :: FailedManifestHydration ( Box :: new ( FailedManifestHydration {
100100 message : format ! (
101101 "We failed to read the content of the manifest.\n \n Original error: {err}"
102102 ) ,
103- manifest_path : p. as_ref ( ) . to_path_buf ( ) ,
103+ manifest_path : p. to_path_buf ( ) ,
104104 } ) )
105105 } ) ?;
106106
@@ -117,7 +117,7 @@ pub fn load_pnp_manifest<P: AsRef<Path>>(p: P) -> Result<Manifest, Error> {
117117 . unwrap_or_default ( )
118118 . ok_or_else ( || Error :: FailedManifestHydration ( Box :: new ( FailedManifestHydration {
119119 message : String :: from ( "We failed to locate the PnP data payload inside its manifest file. Did you manually edit the file?" ) ,
120- manifest_path : p. as_ref ( ) . to_path_buf ( ) ,
120+ manifest_path : p. to_path_buf ( ) ,
121121 } ) ) ) ?;
122122
123123 let iter = manifest_content. chars ( ) . skip ( manifest_match. end ( ) ) ;
@@ -142,18 +142,18 @@ pub fn load_pnp_manifest<P: AsRef<Path>>(p: P) -> Result<Manifest, Error> {
142142 let mut manifest: Manifest = serde_json:: from_str ( & json_string. to_owned ( ) )
143143 . map_err ( |err| Error :: FailedManifestHydration ( Box :: new ( FailedManifestHydration {
144144 message : format ! ( "We failed to parse the PnP data payload as proper JSON; Did you manually edit the file?\n \n Original error: {err}" ) ,
145- manifest_path : p. as_ref ( ) . to_path_buf ( ) ,
145+ manifest_path : p. to_path_buf ( ) ,
146146 } ) ) ) ?;
147147
148- init_pnp_manifest ( & mut manifest, p. as_ref ( ) ) ;
148+ init_pnp_manifest ( & mut manifest, p) ;
149149
150150 Ok ( manifest)
151151}
152152
153- pub fn init_pnp_manifest < P : AsRef < Path > > ( manifest : & mut Manifest , p : P ) {
154- manifest. manifest_path = p. as_ref ( ) . to_path_buf ( ) ;
153+ pub fn init_pnp_manifest ( manifest : & mut Manifest , p : & Path ) {
154+ manifest. manifest_path = p. to_path_buf ( ) ;
155155
156- manifest. manifest_dir = p. as_ref ( ) . parent ( ) . expect ( "Should have a parent directory" ) . to_owned ( ) ;
156+ manifest. manifest_dir = p. parent ( ) . expect ( "Should have a parent directory" ) . to_owned ( ) ;
157157
158158 for ( name, ranges) in manifest. package_registry_data . iter_mut ( ) {
159159 for ( reference, info) in ranges. iter_mut ( ) {
@@ -187,17 +187,14 @@ pub fn init_pnp_manifest<P: AsRef<Path>>(manifest: &mut Manifest, p: P) {
187187}
188188
189189pub fn find_pnp_manifest ( parent : & Path ) -> Result < Option < Manifest > , Error > {
190- find_closest_pnp_manifest_path ( parent) . map_or ( Ok ( None ) , |p| Ok ( Some ( load_pnp_manifest ( p) ?) ) )
190+ find_closest_pnp_manifest_path ( parent) . map_or ( Ok ( None ) , |p| Ok ( Some ( load_pnp_manifest ( & p) ?) ) )
191191}
192192
193193pub fn is_dependency_tree_root < ' a > ( manifest : & ' a Manifest , locator : & ' a PackageLocator ) -> bool {
194194 manifest. dependency_tree_roots . contains ( locator)
195195}
196196
197- pub fn find_locator < ' a , P : AsRef < Path > > (
198- manifest : & ' a Manifest ,
199- path : & P ,
200- ) -> Option < & ' a PackageLocator > {
197+ pub fn find_locator < ' a > ( manifest : & ' a Manifest , path : & Path ) -> Option < & ' a PackageLocator > {
201198 let rel_path = pathdiff:: diff_paths ( path, & manifest. manifest_dir )
202199 . expect ( "Assertion failed: Provided path should be absolute" ) ;
203200
@@ -240,14 +237,14 @@ pub fn find_broken_peer_dependencies(
240237 [ ] . to_vec ( )
241238}
242239
243- pub fn resolve_to_unqualified_via_manifest < P : AsRef < Path > > (
240+ pub fn resolve_to_unqualified_via_manifest (
244241 manifest : & Manifest ,
245242 specifier : & str ,
246- parent : P ,
243+ parent : & Path ,
247244) -> Result < Resolution , Error > {
248245 let ( ident, module_path) = parse_bare_identifier ( specifier) ?;
249246
250- if let Some ( parent_locator) = find_locator ( manifest, & parent) {
247+ if let Some ( parent_locator) = find_locator ( manifest, parent) {
251248 let parent_pkg = get_package ( manifest, parent_locator) ?;
252249
253250 let mut reference_or_alias: Option < PackageDependency > = None ;
@@ -281,7 +278,7 @@ pub fn resolve_to_unqualified_via_manifest<P: AsRef<Path>>(
281278 } else {
282279 String :: from( "" )
283280 } ,
284- issuer_path = parent. as_ref ( ) . to_string_lossy( ) ,
281+ issuer_path = parent. to_string_lossy( ) ,
285282 )
286283 } else {
287284 format ! (
@@ -293,7 +290,7 @@ pub fn resolve_to_unqualified_via_manifest<P: AsRef<Path>>(
293290 } else {
294291 String :: from( "" )
295292 } ,
296- issuer_path = parent. as_ref ( ) . to_string_lossy( ) ,
293+ issuer_path = parent. to_string_lossy( ) ,
297294 )
298295 }
299296 } else if is_dependency_tree_root ( manifest, parent_locator) {
@@ -305,7 +302,7 @@ pub fn resolve_to_unqualified_via_manifest<P: AsRef<Path>>(
305302 } else {
306303 String :: from( "" )
307304 } ,
308- issuer_path = parent. as_ref ( ) . to_string_lossy( ) ,
305+ issuer_path = parent. to_string_lossy( ) ,
309306 )
310307 } else {
311308 format ! (
@@ -318,7 +315,7 @@ pub fn resolve_to_unqualified_via_manifest<P: AsRef<Path>>(
318315 } else {
319316 String :: from( "" )
320317 } ,
321- issuer_path = parent. as_ref ( ) . to_string_lossy( ) ,
318+ issuer_path = parent. to_string_lossy( ) ,
322319 )
323320 } ;
324321
@@ -327,7 +324,7 @@ pub fn resolve_to_unqualified_via_manifest<P: AsRef<Path>>(
327324 request : specifier. to_string ( ) ,
328325 dependency_name : ident,
329326 issuer_locator : parent_locator. clone ( ) ,
330- issuer_path : parent. as_ref ( ) . to_path_buf ( ) ,
327+ issuer_path : parent. to_path_buf ( ) ,
331328 } ) ) ) ;
332329 }
333330
@@ -354,7 +351,7 @@ pub fn resolve_to_unqualified_via_manifest<P: AsRef<Path>>(
354351 } else {
355352 String :: from( "" )
356353 } ,
357- issuer_path = parent. as_ref ( ) . to_string_lossy( ) ,
354+ issuer_path = parent. to_string_lossy( ) ,
358355 )
359356 } else if !broken_ancestors. is_empty ( )
360357 && broken_ancestors. iter ( ) . all ( |locator| is_dependency_tree_root ( manifest, locator) )
@@ -369,7 +366,7 @@ pub fn resolve_to_unqualified_via_manifest<P: AsRef<Path>>(
369366 } else {
370367 String :: from( "" )
371368 } ,
372- issuer_path = parent. as_ref ( ) . to_string_lossy( ) ,
369+ issuer_path = parent. to_string_lossy( ) ,
373370 )
374371 } else {
375372 format ! (
@@ -382,7 +379,7 @@ pub fn resolve_to_unqualified_via_manifest<P: AsRef<Path>>(
382379 } else {
383380 String :: from( "" )
384381 } ,
385- issuer_path = parent. as_ref ( ) . to_string_lossy( ) ,
382+ issuer_path = parent. to_string_lossy( ) ,
386383 )
387384 } ;
388385
@@ -391,7 +388,7 @@ pub fn resolve_to_unqualified_via_manifest<P: AsRef<Path>>(
391388 request : specifier. to_string ( ) ,
392389 dependency_name : ident,
393390 issuer_locator : parent_locator. clone ( ) ,
394- issuer_path : parent. as_ref ( ) . to_path_buf ( ) ,
391+ issuer_path : parent. to_path_buf ( ) ,
395392 broken_ancestors : [ ] . to_vec ( ) ,
396393 } ) ) )
397394 }
@@ -400,13 +397,13 @@ pub fn resolve_to_unqualified_via_manifest<P: AsRef<Path>>(
400397 }
401398}
402399
403- pub fn resolve_to_unqualified < P : AsRef < Path > > (
400+ pub fn resolve_to_unqualified (
404401 specifier : & str ,
405- parent : P ,
402+ parent : & Path ,
406403 config : & ResolutionConfig ,
407404) -> Result < Resolution , Error > {
408- if let Some ( manifest) = ( config. host . find_pnp_manifest ) ( parent. as_ref ( ) ) ? {
409- resolve_to_unqualified_via_manifest ( & manifest, specifier, & parent)
405+ if let Some ( manifest) = ( config. host . find_pnp_manifest ) ( parent) ? {
406+ resolve_to_unqualified_via_manifest ( & manifest, specifier, parent)
410407 } else {
411408 Ok ( Resolution :: Skipped )
412409 }
0 commit comments