From e77e4fcf898ca4b2aa2041d2cbac200ed0f11b5b Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sun, 27 Feb 2022 16:09:52 +0100 Subject: Only create a single expansion for each inline integration. --- compiler/rustc_span/src/hygiene.rs | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'compiler/rustc_span/src') diff --git a/compiler/rustc_span/src/hygiene.rs b/compiler/rustc_span/src/hygiene.rs index 8265eb23c3d..5fae46d5fd8 100644 --- a/compiler/rustc_span/src/hygiene.rs +++ b/compiler/rustc_span/src/hygiene.rs @@ -874,19 +874,13 @@ impl Span { /// other compiler-generated code to set per-span properties like allowed unstable features. /// The returned span belongs to the created expansion and has the new properties, /// but its location is inherited from the current span. - pub fn fresh_expansion(self, expn_data: ExpnData, ctx: impl HashStableContext) -> Span { - self.fresh_expansion_with_transparency(expn_data, Transparency::Transparent, ctx) - } - - pub fn fresh_expansion_with_transparency( - self, - expn_data: ExpnData, - transparency: Transparency, - ctx: impl HashStableContext, - ) -> Span { - let expn_id = LocalExpnId::fresh(expn_data, ctx).to_expn_id(); + pub fn fresh_expansion(self, expn_id: LocalExpnId) -> Span { HygieneData::with(|data| { - self.with_ctxt(data.apply_mark(SyntaxContext::root(), expn_id, transparency)) + self.with_ctxt(data.apply_mark( + SyntaxContext::root(), + expn_id.to_expn_id(), + Transparency::Transparent, + )) }) } @@ -903,7 +897,8 @@ impl Span { allow_internal_unstable, ..ExpnData::default(ExpnKind::Desugaring(reason), self, edition, None, None) }; - self.fresh_expansion(expn_data, ctx) + let expn_id = LocalExpnId::fresh(expn_data, ctx); + self.fresh_expansion(expn_id) } } -- cgit 1.4.1-3-g733a5