From 7d373c9c11a63714a1dd9ce79d38a088a435723d Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Tue, 13 Jul 2021 10:57:10 -0400 Subject: [PATCH] Avoid cloning ExpnData to access Span edition ExpnData is a fairly hefty structure to clone; cloning it may not be cheap. In some cases this may get optimized out, but it's not clear that will always be the case. Try to avoid that cost. --- compiler/rustc_span/src/hygiene.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_span/src/hygiene.rs b/compiler/rustc_span/src/hygiene.rs index 78b181aa3300a..3dc178afe9584 100644 --- a/compiler/rustc_span/src/hygiene.rs +++ b/compiler/rustc_span/src/hygiene.rs @@ -644,7 +644,7 @@ impl SyntaxContext { } pub fn edition(self) -> Edition { - self.outer_expn_data().edition + HygieneData::with(|data| data.expn_data(data.outer_expn(self)).edition) } }