Skip to content

Commit 949ab27

Browse files
committed
Only run analyses when we are going to use their results
Currently, there are various analyses related to deriving various traits that we unconditionally run. However, if we aren't going to derive those traits in codegen, then computing whether or not we can derive the traits is wasteful.
1 parent 5ca0569 commit 949ab27

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/ir/context.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -1790,7 +1790,9 @@ impl<'ctx> BindgenContext<'ctx> {
17901790
/// Compute whether we can derive debug.
17911791
fn compute_cannot_derive_debug(&mut self) {
17921792
assert!(self.cannot_derive_debug.is_none());
1793-
self.cannot_derive_debug = Some(analyze::<CannotDeriveDebug>(self));
1793+
if self.options.derive_debug {
1794+
self.cannot_derive_debug = Some(analyze::<CannotDeriveDebug>(self));
1795+
}
17941796
}
17951797

17961798
/// Look up whether the item with `id` can
@@ -1807,7 +1809,9 @@ impl<'ctx> BindgenContext<'ctx> {
18071809
/// Compute whether we can derive default.
18081810
fn compute_cannot_derive_default(&mut self) {
18091811
assert!(self.cannot_derive_default.is_none());
1810-
self.cannot_derive_default = Some(analyze::<CannotDeriveDefault>(self));
1812+
if self.options.derive_default {
1813+
self.cannot_derive_default = Some(analyze::<CannotDeriveDefault>(self));
1814+
}
18111815
}
18121816

18131817
/// Look up whether the item with `id` can
@@ -1830,7 +1834,9 @@ impl<'ctx> BindgenContext<'ctx> {
18301834
/// Compute whether we can derive hash.
18311835
fn compute_cannot_derive_hash(&mut self) {
18321836
assert!(self.cannot_derive_hash.is_none());
1833-
self.cannot_derive_hash = Some(analyze::<CannotDeriveHash>(self));
1837+
if self.options.derive_hash {
1838+
self.cannot_derive_hash = Some(analyze::<CannotDeriveHash>(self));
1839+
}
18341840
}
18351841

18361842
/// Look up whether the item with `id` can

0 commit comments

Comments
 (0)