Implement CompilerDesugaringKind enum
This commit is contained in:
parent
045ca8b43b
commit
4acfef8f63
3 changed files with 49 additions and 5 deletions
|
@ -47,7 +47,7 @@ extern crate serialize;
|
|||
extern crate serialize as rustc_serialize; // used by deriving
|
||||
|
||||
pub mod hygiene;
|
||||
pub use hygiene::{SyntaxContext, ExpnInfo, ExpnFormat, NameAndSpan};
|
||||
pub use hygiene::{SyntaxContext, ExpnInfo, ExpnFormat, NameAndSpan, CompilerDesugaringKind};
|
||||
|
||||
pub mod symbol;
|
||||
|
||||
|
@ -153,6 +153,17 @@ impl Span {
|
|||
}
|
||||
}
|
||||
|
||||
/// Check if this span arises from a compiler desugaring of kind `kind`.
|
||||
pub fn is_compiler_desugaring(&self, kind: CompilerDesugaringKind) -> bool {
|
||||
match self.ctxt.outer().expn_info() {
|
||||
Some(info) => match info.callee.format {
|
||||
ExpnFormat::CompilerDesugaring(k) => k == kind,
|
||||
_ => false,
|
||||
},
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Check if a span is "internal" to a macro in which `unsafe`
|
||||
/// can be used without triggering the `unsafe_code` lint
|
||||
// (that is, a macro marked with `#[allow_internal_unsafe]`).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue