1
+ //! `Cargo.toml` / Manifest schema definition
2
+ //!
3
+ //! ## Style
4
+ //!
5
+ //! - Fields duplicated for an alias will have an accessor with the primary field's name
6
+ //! - Keys that exist for bookkeeping but don't correspond to the schema have a `_` prefix
7
+
1
8
use std:: collections:: BTreeMap ;
2
9
use std:: fmt:: { self , Display , Write } ;
3
10
use std:: path:: PathBuf ;
@@ -45,6 +52,10 @@ impl TomlManifest {
45
52
self . profile . is_some ( )
46
53
}
47
54
55
+ pub fn package ( & self ) -> Option < & Box < TomlPackage > > {
56
+ self . package . as_ref ( ) . or ( self . project . as_ref ( ) )
57
+ }
58
+
48
59
pub fn dev_dependencies ( & self ) -> Option < & BTreeMap < String , MaybeWorkspaceDependency > > {
49
60
self . dev_dependencies
50
61
. as_ref ( )
@@ -108,7 +119,7 @@ pub struct InheritableFields {
108
119
// We use skip here since it will never be present when deserializing
109
120
// and we don't want it present when serializing
110
121
#[ serde( skip) ]
111
- pub ws_root : PathBuf ,
122
+ pub _ws_root : PathBuf ,
112
123
}
113
124
114
125
/// Represents the `package`/`project` sections of a `Cargo.toml`.
@@ -430,7 +441,7 @@ impl MaybeWorkspaceDependency {
430
441
pub fn unused_keys ( & self ) -> Vec < String > {
431
442
match self {
432
443
MaybeWorkspaceDependency :: Defined ( d) => d. unused_keys ( ) ,
433
- MaybeWorkspaceDependency :: Workspace ( w) => w. unused_keys . keys ( ) . cloned ( ) . collect ( ) ,
444
+ MaybeWorkspaceDependency :: Workspace ( w) => w. _unused_keys . keys ( ) . cloned ( ) . collect ( ) ,
434
445
}
435
446
}
436
447
}
@@ -471,7 +482,7 @@ pub struct TomlWorkspaceDependency {
471
482
/// This is here to provide a way to see the "unused manifest keys" when deserializing
472
483
#[ serde( skip_serializing) ]
473
484
#[ serde( flatten) ]
474
- pub unused_keys : BTreeMap < String , toml:: Value > ,
485
+ pub _unused_keys : BTreeMap < String , toml:: Value > ,
475
486
}
476
487
477
488
impl TomlWorkspaceDependency {
@@ -510,7 +521,7 @@ impl TomlDependency {
510
521
pub fn unused_keys ( & self ) -> Vec < String > {
511
522
match self {
512
523
TomlDependency :: Simple ( _) => vec ! [ ] ,
513
- TomlDependency :: Detailed ( detailed) => detailed. unused_keys . keys ( ) . cloned ( ) . collect ( ) ,
524
+ TomlDependency :: Detailed ( detailed) => detailed. _unused_keys . keys ( ) . cloned ( ) . collect ( ) ,
514
525
}
515
526
}
516
527
}
@@ -568,7 +579,7 @@ pub struct DetailedTomlDependency<P: Clone = String> {
568
579
/// This is here to provide a way to see the "unused manifest keys" when deserializing
569
580
#[ serde( skip_serializing) ]
570
581
#[ serde( flatten) ]
571
- pub unused_keys : BTreeMap < String , toml:: Value > ,
582
+ pub _unused_keys : BTreeMap < String , toml:: Value > ,
572
583
}
573
584
574
585
impl < P : Clone > DetailedTomlDependency < P > {
@@ -598,7 +609,7 @@ impl<P: Clone> Default for DetailedTomlDependency<P> {
598
609
artifact : Default :: default ( ) ,
599
610
lib : Default :: default ( ) ,
600
611
target : Default :: default ( ) ,
601
- unused_keys : Default :: default ( ) ,
612
+ _unused_keys : Default :: default ( ) ,
602
613
}
603
614
}
604
615
}
@@ -950,10 +961,9 @@ pub struct TomlTarget {
950
961
pub doc : Option < bool > ,
951
962
pub plugin : Option < bool > ,
952
963
pub doc_scrape_examples : Option < bool > ,
953
- #[ serde( rename = "proc-macro" ) ]
954
- pub proc_macro_raw : Option < bool > ,
964
+ pub proc_macro : Option < bool > ,
955
965
#[ serde( rename = "proc_macro" ) ]
956
- pub proc_macro_raw2 : Option < bool > ,
966
+ pub proc_macro2 : Option < bool > ,
957
967
pub harness : Option < bool > ,
958
968
pub required_features : Option < Vec < String > > ,
959
969
pub edition : Option < String > ,
@@ -965,7 +975,7 @@ impl TomlTarget {
965
975
}
966
976
967
977
pub fn proc_macro ( & self ) -> Option < bool > {
968
- self . proc_macro_raw . or ( self . proc_macro_raw2 ) . or_else ( || {
978
+ self . proc_macro . or ( self . proc_macro2 ) . or_else ( || {
969
979
if let Some ( types) = self . crate_types ( ) {
970
980
if types. contains ( & "proc-macro" . to_string ( ) ) {
971
981
return Some ( true ) ;
0 commit comments