@@ -299,7 +299,7 @@ pub fn prepare_target<'a, 'cfg>(
299
299
// here. See documentation on `build_script_local_fingerprints`
300
300
// below for more information. Despite this just try to proceed and
301
301
// hobble along if it happens to return `Some`.
302
- if let Some ( new_local) = gen_local. call_box ( & deps, None ) ? {
302
+ if let Some ( new_local) = ( gen_local) ( & deps, None ) ? {
303
303
* fingerprint. local . lock ( ) . unwrap ( ) = new_local;
304
304
* fingerprint. memoized_hash . lock ( ) . unwrap ( ) = None ;
305
305
}
@@ -1121,9 +1121,7 @@ fn calculate_run_custom_build<'a, 'cfg>(
1121
1121
// the whole crate.
1122
1122
let ( gen_local, overridden) = build_script_local_fingerprints ( cx, unit) ;
1123
1123
let deps = & cx. build_explicit_deps [ unit] ;
1124
- let local = gen_local
1125
- . call_box ( deps, Some ( & || pkg_fingerprint ( cx. bcx , unit. pkg ) ) ) ?
1126
- . unwrap ( ) ;
1124
+ let local = ( gen_local) ( deps, Some ( & || pkg_fingerprint ( cx. bcx , unit. pkg ) ) ) ?. unwrap ( ) ;
1127
1125
let output = deps. build_script_output . clone ( ) ;
1128
1126
1129
1127
// Include any dependencies of our execution, which is typically just the
@@ -1167,11 +1165,10 @@ fn calculate_run_custom_build<'a, 'cfg>(
1167
1165
/// scripts). That deduplication is the rationale for the closure at least.
1168
1166
///
1169
1167
/// The arguments to the closure are a bit weirder, though, and I'll apologize
1170
- /// in advance for the weirdness too. The first argument to the closure (see
1171
- /// `MyFnOnce` below) is a `&BuildDeps`. This is the parsed version of a build
1172
- /// script, and when Cargo starts up this is cached from previous runs of a
1173
- /// build script. After a build script executes the output file is reparsed and
1174
- /// passed in here.
1168
+ /// in advance for the weirdness too. The first argument to the closure is a
1169
+ /// `&BuildDeps`. This is the parsed version of a build script, and when Cargo
1170
+ /// starts up this is cached from previous runs of a build script. After a
1171
+ /// build script executes the output file is reparsed and passed in here.
1175
1172
///
1176
1173
/// The second argument is the weirdest, it's *optionally* a closure to
1177
1174
/// call `pkg_fingerprint` below. The `pkg_fingerprint` below requires access
@@ -1191,7 +1188,16 @@ fn calculate_run_custom_build<'a, 'cfg>(
1191
1188
fn build_script_local_fingerprints < ' a , ' cfg > (
1192
1189
cx : & mut Context < ' a , ' cfg > ,
1193
1190
unit : & Unit < ' a > ,
1194
- ) -> ( Box < dyn MyFnOnce + Send > , bool ) {
1191
+ ) -> (
1192
+ Box <
1193
+ dyn FnOnce (
1194
+ & BuildDeps ,
1195
+ Option < & dyn Fn ( ) -> CargoResult < String > > ,
1196
+ ) -> CargoResult < Option < Vec < LocalFingerprint > > >
1197
+ + Send ,
1198
+ > ,
1199
+ bool ,
1200
+ ) {
1195
1201
// First up, if this build script is entirely overridden, then we just
1196
1202
// return the hash of what we overrode it with. This is the easy case!
1197
1203
if let Some ( fingerprint) = build_script_override_fingerprint ( cx, unit) {
@@ -1603,30 +1609,3 @@ pub fn parse_rustc_dep_info(rustc_dep_info: &Path) -> CargoResult<Vec<(String, V
1603
1609
} )
1604
1610
. collect ( )
1605
1611
}
1606
-
1607
- // This trait solely exists for the `build_script_local_fingerprints` function
1608
- // above, see documentation there for more information. If we had `Box<dyn
1609
- // FnOnce>` we wouldn't need this.
1610
- trait MyFnOnce {
1611
- fn call_box (
1612
- self : Box < Self > ,
1613
- f : & BuildDeps ,
1614
- pkg_fingerprint : Option < & dyn Fn ( ) -> CargoResult < String > > ,
1615
- ) -> CargoResult < Option < Vec < LocalFingerprint > > > ;
1616
- }
1617
-
1618
- impl < F > MyFnOnce for F
1619
- where
1620
- F : FnOnce (
1621
- & BuildDeps ,
1622
- Option < & dyn Fn ( ) -> CargoResult < String > > ,
1623
- ) -> CargoResult < Option < Vec < LocalFingerprint > > > ,
1624
- {
1625
- fn call_box (
1626
- self : Box < Self > ,
1627
- f : & BuildDeps ,
1628
- pkg_fingerprint : Option < & dyn Fn ( ) -> CargoResult < String > > ,
1629
- ) -> CargoResult < Option < Vec < LocalFingerprint > > > {
1630
- ( * self ) ( f, pkg_fingerprint)
1631
- }
1632
- }
0 commit comments