@@ -55,7 +55,14 @@ pub fn read_manifest(
55
55
let toml = deserialize_toml ( & document)
56
56
. map_err ( |e| emit_diagnostic ( e. into ( ) , & contents, path, gctx) ) ?;
57
57
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| {
59
66
ManifestError :: new (
60
67
err. context ( format ! ( "failed to parse manifest at `{}`" , path. display( ) ) ) ,
61
68
path. into ( ) ,
@@ -160,30 +167,6 @@ fn emit_diagnostic(
160
167
return AlreadyPrintedError :: new ( e. into ( ) ) . into ( ) ;
161
168
}
162
169
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
-
187
170
fn stringify ( dst : & mut String , path : & serde_ignored:: Path < ' _ > ) {
188
171
use serde_ignored:: Path ;
189
172
0 commit comments