@@ -55,7 +55,14 @@ pub fn read_manifest(
5555    let  toml = deserialize_toml ( & document) 
5656        . map_err ( |e| emit_diagnostic ( e. into ( ) ,  & contents,  path,  gctx) ) ?; 
5757
58-     convert_toml ( toml,  path,  source_id,  gctx) . map_err ( |err| { 
58+     ( || { 
59+         if  toml. package ( ) . is_some ( )  { 
60+             to_real_manifest ( toml,  source_id,  path,  gctx) . map ( EitherManifest :: Real ) 
61+         }  else  { 
62+             to_virtual_manifest ( toml,  source_id,  path,  gctx) . map ( EitherManifest :: Virtual ) 
63+         } 
64+     } ) ( ) 
65+     . map_err ( |err| { 
5966        ManifestError :: new ( 
6067            err. context ( format ! ( "failed to parse manifest at `{}`" ,  path. display( ) ) ) , 
6168            path. into ( ) , 
@@ -160,30 +167,6 @@ fn emit_diagnostic(
160167    return  AlreadyPrintedError :: new ( e. into ( ) ) . into ( ) ; 
161168} 
162169
163- /// Parse an already-loaded `Cargo.toml` as a Cargo manifest. 
164- /// 
165- /// This could result in a real or virtual manifest being returned. 
166- /// 
167- /// A list of nested paths is also returned, one for each path dependency 
168- /// within the manifest. For virtual manifests, these paths can only 
169- /// come from patched or replaced dependencies. These paths are not 
170- /// canonicalized. 
171- #[ tracing:: instrument( skip_all) ]  
172- fn  convert_toml ( 
173-     manifest :  manifest:: TomlManifest , 
174-     manifest_file :  & Path , 
175-     source_id :  SourceId , 
176-     gctx :  & GlobalContext , 
177- )  -> CargoResult < EitherManifest >  { 
178-     return  if  manifest. package ( ) . is_some ( )  { 
179-         let  manifest = to_real_manifest ( manifest,  source_id,  manifest_file,  gctx) ?; 
180-         Ok ( EitherManifest :: Real ( manifest) ) 
181-     }  else  { 
182-         let  manifest = to_virtual_manifest ( manifest,  source_id,  manifest_file,  gctx) ?; 
183-         Ok ( EitherManifest :: Virtual ( manifest) ) 
184-     } ; 
185- } 
186- 
187170fn  stringify ( dst :  & mut  String ,  path :  & serde_ignored:: Path < ' _ > )  { 
188171    use  serde_ignored:: Path ; 
189172
0 commit comments