1
Fork 0

enable desugaring-sensitive error messages and use them in Try

Maybe I should allow error messages to check the *specific* desugaring?
Thanks @huntiep for the idea!
This commit is contained in:
Ariel Ben-Yehuda 2017-08-31 00:12:34 +03:00
parent 6866aea5af
commit 02b3ae63e2
5 changed files with 74 additions and 9 deletions

View file

@ -205,6 +205,18 @@ impl Span {
}
}
/// Return the compiler desugaring that created this span, or None
/// if this span is not from a desugaring.
pub fn compiler_desugaring_kind(&self) -> Option<CompilerDesugaringKind> {
match self.ctxt().outer().expn_info() {
Some(info) => match info.callee.format {
ExpnFormat::CompilerDesugaring(k) => Some(k),
_ => None
},
None => None
}
}
/// 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]`).