1
Fork 0

rustc_span: Optimize span parent get/set methods

This commit is contained in:
Vadim Petrochenkov 2024-06-16 00:53:00 +03:00
parent 1aaab8b9f8
commit 4d3b617911
2 changed files with 70 additions and 35 deletions

View file

@ -525,8 +525,9 @@ impl SpanData {
fn with_ctxt(&self, ctxt: SyntaxContext) -> Span {
Span::new(self.lo, self.hi, ctxt, self.parent)
}
/// Avoid if possible, `Span::with_parent` should be preferred.
#[inline]
pub fn with_parent(&self, parent: Option<LocalDefId>) -> Span {
fn with_parent(&self, parent: Option<LocalDefId>) -> Span {
Span::new(self.lo, self.hi, self.ctxt, parent)
}
/// Returns `true` if this is a dummy span with any hygienic context.
@ -580,14 +581,6 @@ impl Span {
pub fn with_ctxt(self, ctxt: SyntaxContext) -> Span {
self.map_ctxt(|_| ctxt)
}
#[inline]
pub fn parent(self) -> Option<LocalDefId> {
self.data().parent
}
#[inline]
pub fn with_parent(self, ctxt: Option<LocalDefId>) -> Span {
self.data().with_parent(ctxt)
}
#[inline]
pub fn is_visible(self, sm: &SourceMap) -> bool {