Audit uses of apply_mark
in built-in macros
Replace them with equivalents of `Span::{def_site,call_site}` from proc macro API. The new API is much less error prone and doesn't rely on macros having default transparency.
This commit is contained in:
parent
760226733e
commit
0fb01d219c
19 changed files with 56 additions and 41 deletions
|
@ -22,6 +22,7 @@ pub mod edition;
|
|||
use edition::Edition;
|
||||
pub mod hygiene;
|
||||
pub use hygiene::{ExpnId, SyntaxContext, ExpnData, ExpnKind, MacroKind, DesugaringKind};
|
||||
use hygiene::Transparency;
|
||||
|
||||
mod span_encoding;
|
||||
pub use span_encoding::{Span, DUMMY_SP};
|
||||
|
@ -512,6 +513,13 @@ impl Span {
|
|||
span.ctxt)
|
||||
}
|
||||
|
||||
/// Produces a span with the same location as `self` and context produced by a macro with the
|
||||
/// given ID and transparency, assuming that macro was defined directly and not produced by
|
||||
/// some other macro (which is the case for built-in and procedural macros).
|
||||
pub fn with_ctxt_from_mark(self, expn_id: ExpnId, transparency: Transparency) -> Span {
|
||||
self.with_ctxt(SyntaxContext::root().apply_mark_with_transparency(expn_id, transparency))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn apply_mark(self, mark: ExpnId) -> Span {
|
||||
let span = self.data();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue