@@ -19,7 +19,6 @@ use cargo_util_schemas::manifest::{RustVersion, StringOrBool};
1919use itertools:: Itertools ;
2020use lazycell:: LazyCell ;
2121use pathdiff:: diff_paths;
22- use toml_edit:: Document ;
2322use url:: Url ;
2423
2524use crate :: core:: compiler:: { CompileKind , CompileTarget } ;
@@ -166,16 +165,28 @@ fn read_toml_string(path: &Path, is_embedded: bool, gctx: &GlobalContext) -> Car
166165}
167166
168167#[ tracing:: instrument( skip_all) ]
169- fn parse_document ( contents : & str ) -> Result < toml_edit:: Document < String > , toml_edit:: de:: Error > {
170- toml_edit:: Document :: parse ( contents. to_owned ( ) ) . map_err ( Into :: into)
168+ fn parse_document (
169+ contents : & str ,
170+ ) -> Result < toml:: Spanned < toml:: de:: DeTable < ' static > > , toml:: de:: Error > {
171+ let mut table = toml:: de:: DeTable :: parse ( contents) ?;
172+ table. get_mut ( ) . make_owned ( ) ;
173+ // SAFETY: `DeTable::make_owned` ensures no borrows remain and the lifetime does not affect
174+ // layout
175+ let table = unsafe {
176+ std:: mem:: transmute :: <
177+ toml:: Spanned < toml:: de:: DeTable < ' _ > > ,
178+ toml:: Spanned < toml:: de:: DeTable < ' static > > ,
179+ > ( table)
180+ } ;
181+ Ok ( table)
171182}
172183
173184#[ tracing:: instrument( skip_all) ]
174185fn deserialize_toml (
175- document : & toml_edit :: Document < String > ,
176- ) -> Result < manifest:: TomlManifest , toml_edit :: de:: Error > {
186+ document : & toml :: Spanned < toml :: de :: DeTable < ' static > > ,
187+ ) -> Result < manifest:: TomlManifest , toml :: de:: Error > {
177188 let mut unused = BTreeSet :: new ( ) ;
178- let deserializer = toml_edit :: de:: Deserializer :: from ( document. clone ( ) ) ;
189+ let deserializer = toml :: de:: Deserializer :: from ( document. clone ( ) ) ;
179190 let mut document: manifest:: TomlManifest = serde_ignored:: deserialize ( deserializer, |path| {
180191 let mut key = String :: new ( ) ;
181192 stringify ( & mut key, & path) ;
@@ -1256,7 +1267,7 @@ fn deprecated_ws_default_features(
12561267#[ tracing:: instrument( skip_all) ]
12571268pub fn to_real_manifest (
12581269 contents : String ,
1259- document : toml_edit :: Document < String > ,
1270+ document : toml :: Spanned < toml :: de :: DeTable < ' static > > ,
12601271 original_toml : manifest:: TomlManifest ,
12611272 normalized_toml : manifest:: TomlManifest ,
12621273 features : Features ,
@@ -1843,7 +1854,7 @@ pub fn to_real_manifest(
18431854fn missing_dep_diagnostic (
18441855 missing_dep : & MissingDependencyError ,
18451856 orig_toml : & TomlManifest ,
1846- document : & Document < String > ,
1857+ document : & toml :: Spanned < toml :: de :: DeTable < ' static > > ,
18471858 contents : & str ,
18481859 manifest_file : & Path ,
18491860 gctx : & GlobalContext ,
@@ -1921,7 +1932,7 @@ fn missing_dep_diagnostic(
19211932
19221933fn to_virtual_manifest (
19231934 contents : String ,
1924- document : toml_edit :: Document < String > ,
1935+ document : toml :: Spanned < toml :: de :: DeTable < ' static > > ,
19251936 original_toml : manifest:: TomlManifest ,
19261937 normalized_toml : manifest:: TomlManifest ,
19271938 features : Features ,
@@ -2761,7 +2772,7 @@ fn lints_to_rustflags(lints: &manifest::TomlLints) -> CargoResult<Vec<String>> {
27612772}
27622773
27632774fn emit_diagnostic (
2764- e : toml_edit :: de:: Error ,
2775+ e : toml :: de:: Error ,
27652776 contents : & str ,
27662777 manifest_file : & Path ,
27672778 gctx : & GlobalContext ,
0 commit comments