Skip to content

Commit 492714c

Browse files
author
bors-servo
authored
Auto merge of rust-lang#912 - fitzgen:only-run-analyses-if-needed, r=emilio
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. r? @emilio
2 parents 7e84c43 + 949ab27 commit 492714c

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
@@ -1804,7 +1804,9 @@ impl<'ctx> BindgenContext<'ctx> {
18041804
/// Compute whether we can derive debug.
18051805
fn compute_cannot_derive_debug(&mut self) {
18061806
assert!(self.cannot_derive_debug.is_none());
1807-
self.cannot_derive_debug = Some(analyze::<CannotDeriveDebug>(self));
1807+
if self.options.derive_debug {
1808+
self.cannot_derive_debug = Some(analyze::<CannotDeriveDebug>(self));
1809+
}
18081810
}
18091811

18101812
/// Look up whether the item with `id` can
@@ -1821,7 +1823,9 @@ impl<'ctx> BindgenContext<'ctx> {
18211823
/// Compute whether we can derive default.
18221824
fn compute_cannot_derive_default(&mut self) {
18231825
assert!(self.cannot_derive_default.is_none());
1824-
self.cannot_derive_default = Some(analyze::<CannotDeriveDefault>(self));
1826+
if self.options.derive_default {
1827+
self.cannot_derive_default = Some(analyze::<CannotDeriveDefault>(self));
1828+
}
18251829
}
18261830

18271831
/// Look up whether the item with `id` can
@@ -1844,7 +1848,9 @@ impl<'ctx> BindgenContext<'ctx> {
18441848
/// Compute whether we can derive hash.
18451849
fn compute_cannot_derive_hash(&mut self) {
18461850
assert!(self.cannot_derive_hash.is_none());
1847-
self.cannot_derive_hash = Some(analyze::<CannotDeriveHash>(self));
1851+
if self.options.derive_hash {
1852+
self.cannot_derive_hash = Some(analyze::<CannotDeriveHash>(self));
1853+
}
18481854
}
18491855

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

0 commit comments

Comments
 (0)