@@ -847,14 +847,19 @@ where
847
847
}
848
848
}
849
849
850
+ pub struct LintedBuildSpec {
851
+ build_spec : BuildSpec ,
852
+ lints : Vec < Lint > ,
853
+ }
854
+
850
855
#[ derive( FieldNamesAsArray ) ]
851
856
struct SpecVisitor < B , T > {
852
857
pkg : Option < Ident < B , T > > ,
853
858
meta : Option < LintedItem < Meta > > ,
854
859
compat : Option < Compat > ,
855
860
deprecated : Option < bool > ,
856
861
sources : Option < Vec < LintedItem < SourceSpec > > > ,
857
- build : Option < LintedItem < UncheckedBuildSpec > > ,
862
+ build : Option < LintedBuildSpec > ,
858
863
tests : Option < Vec < LintedItem < TestSpec > > > ,
859
864
install : Option < LintedItem < InstallSpec > > ,
860
865
#[ field_names_as_array( skip) ]
@@ -902,14 +907,7 @@ where
902
907
. collect_vec ( )
903
908
} ,
904
909
build : match value. build . take ( ) {
905
- Some ( build_spec) if !value. check_build_spec => {
906
- // Safety: see the SpecVisitor::package constructor
907
- unsafe { build_spec. item . into_inner ( ) }
908
- }
909
- Some ( build_spec) => match build_spec. item . try_into ( ) {
910
- Ok ( b) => b,
911
- Err ( _) => BuildSpec :: default ( ) ,
912
- } ,
910
+ Some ( build) => build. build_spec ,
913
911
None => Default :: default ( ) ,
914
912
} ,
915
913
tests : value
@@ -995,7 +993,20 @@ where
995
993
"compat" => self . compat = Some ( map. next_value :: < Compat > ( ) ?) ,
996
994
"deprecated" => self . deprecated = Some ( map. next_value :: < bool > ( ) ?) ,
997
995
"sources" => self . sources = Some ( map. next_value :: < Vec < LintedItem < SourceSpec > > > ( ) ?) ,
998
- "build" => self . build = Some ( map. next_value :: < LintedItem < UncheckedBuildSpec > > ( ) ?) ,
996
+ "build" => {
997
+ self . build = {
998
+ let build = map. next_value :: < LintedItem < UncheckedBuildSpec > > ( ) ?;
999
+ let lints = build. lints . clone ( ) ;
1000
+ let build_spec = if !self . check_build_spec {
1001
+ // Safety: see the SpecVisitor::package constructor
1002
+ unsafe { build. item . into_inner ( ) }
1003
+ } else {
1004
+ build. item . try_into ( ) . map_err ( serde:: de:: Error :: custom) ?
1005
+ } ;
1006
+
1007
+ Some ( LintedBuildSpec { build_spec, lints } )
1008
+ }
1009
+ }
999
1010
"tests" => self . tests = Some ( map. next_value :: < Vec < LintedItem < TestSpec > > > ( ) ?) ,
1000
1011
"install" => self . install = Some ( map. next_value :: < LintedItem < InstallSpec > > ( ) ?) ,
1001
1012
"api" => {
@@ -1015,12 +1026,6 @@ where
1015
1026
. as_ref ( )
1016
1027
. ok_or_else ( || serde:: de:: Error :: missing_field ( "pkg" ) ) ?;
1017
1028
1018
- if self . check_build_spec {
1019
- if let Some ( build_spec) = self . build . as_ref ( ) {
1020
- TryInto :: < BuildSpec > :: try_into ( build_spec. item ) . map_err ( serde:: de:: Error :: custom) ?;
1021
- }
1022
- }
1023
-
1024
1029
Ok ( self )
1025
1030
}
1026
1031
}
0 commit comments