Skip to content

Commit 47a40b2

Browse files
committed
Inline some methods in rustc_span hygiene.rs
Signed-off-by: xizheyin <[email protected]>
1 parent 460259d commit 47a40b2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

compiler/rustc_span/src/hygiene.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ impl ExpnId {
322322

323323
/// `expn_id.outer_expn_is_descendant_of(ctxt)` is equivalent to but faster than
324324
/// `expn_id.is_descendant_of(ctxt.outer_expn())`.
325+
#[inline]
325326
pub fn outer_expn_is_descendant_of(self, ctxt: SyntaxContext) -> bool {
326327
HygieneData::with(|data| data.is_descendant_of(self, data.outer_expn(ctxt)))
327328
}
@@ -437,23 +438,28 @@ impl HygieneData {
437438
}
438439
}
439440

441+
#[inline]
440442
fn normalize_to_macros_2_0(&self, ctxt: SyntaxContext) -> SyntaxContext {
441443
self.syntax_context_data[ctxt.0 as usize].opaque
442444
}
443445

446+
#[inline]
444447
fn normalize_to_macro_rules(&self, ctxt: SyntaxContext) -> SyntaxContext {
445448
self.syntax_context_data[ctxt.0 as usize].opaque_and_semiopaque
446449
}
447450

451+
#[inline]
448452
fn outer_expn(&self, ctxt: SyntaxContext) -> ExpnId {
449453
self.syntax_context_data[ctxt.0 as usize].outer_expn
450454
}
451455

456+
#[inline]
452457
fn outer_mark(&self, ctxt: SyntaxContext) -> (ExpnId, Transparency) {
453458
let data = &self.syntax_context_data[ctxt.0 as usize];
454459
(data.outer_expn, data.outer_transparency)
455460
}
456461

462+
#[inline]
457463
fn parent_ctxt(&self, ctxt: SyntaxContext) -> SyntaxContext {
458464
self.syntax_context_data[ctxt.0 as usize].parent
459465
}
@@ -718,11 +724,13 @@ impl SyntaxContext {
718724
SyntaxContext(raw as u32)
719725
}
720726

727+
#[inline]
721728
fn from_usize(raw: usize) -> SyntaxContext {
722729
SyntaxContext(u32::try_from(raw).unwrap())
723730
}
724731

725732
/// Extend a syntax context with a given expansion and transparency.
733+
#[inline]
726734
pub fn apply_mark(self, expn_id: ExpnId, transparency: Transparency) -> SyntaxContext {
727735
HygieneData::with(|data| data.apply_mark(self, expn_id, transparency))
728736
}
@@ -743,10 +751,12 @@ impl SyntaxContext {
743751
/// of g (call it g1), calling remove_mark will result in the SyntaxContext for the
744752
/// invocation of f that created g1.
745753
/// Returns the mark that was removed.
754+
#[inline]
746755
pub fn remove_mark(&mut self) -> ExpnId {
747756
HygieneData::with(|data| data.remove_mark(self).0)
748757
}
749758

759+
#[inline]
750760
pub fn marks(self) -> Vec<(ExpnId, Transparency)> {
751761
HygieneData::with(|data| data.marks(self))
752762
}
@@ -776,11 +786,13 @@ impl SyntaxContext {
776786
/// ```
777787
/// This returns the expansion whose definition scope we use to privacy check the resolution,
778788
/// or `None` if we privacy check as usual (i.e., not w.r.t. a macro definition scope).
789+
#[inline]
779790
pub fn adjust(&mut self, expn_id: ExpnId) -> Option<ExpnId> {
780791
HygieneData::with(|data| data.adjust(self, expn_id))
781792
}
782793

783794
/// Like `SyntaxContext::adjust`, but also normalizes `self` to macros 2.0.
795+
#[inline]
784796
pub(crate) fn normalize_to_macros_2_0_and_adjust(&mut self, expn_id: ExpnId) -> Option<ExpnId> {
785797
HygieneData::with(|data| {
786798
*self = data.normalize_to_macros_2_0(*self);
@@ -901,10 +913,12 @@ impl SyntaxContext {
901913
HygieneData::with(|data| data.outer_mark(self))
902914
}
903915

916+
#[inline]
904917
pub(crate) fn dollar_crate_name(self) -> Symbol {
905918
HygieneData::with(|data| data.syntax_context_data[self.0 as usize].dollar_crate_name)
906919
}
907920

921+
#[inline]
908922
pub fn edition(self) -> Edition {
909923
HygieneData::with(|data| data.expn_data(data.outer_expn(self)).edition)
910924
}

0 commit comments

Comments
 (0)