Rename some things in syntax_pos/hygiene

More consistent with other naming:
ExpnFormat -> ExpnKind
ExpnKind::name -> ExpnKind::descr
DesugaringKind::name -> DesugaringKind::descr

Shorter, no tautology:
CompilerDesugaring -> Desugaring
CompilerDesugaringKind -> DesugaringKind
This commit is contained in:
Vadim Petrochenkov 2019-06-19 01:08:45 +03:00
parent ec376c783e
commit 16918a8e28
25 changed files with 111 additions and 110 deletions

View file

@ -27,7 +27,7 @@ extern crate serialize as rustc_serialize; // used by deriving
pub mod edition;
use edition::Edition;
pub mod hygiene;
pub use hygiene::{Mark, SyntaxContext, ExpnInfo, ExpnFormat, CompilerDesugaringKind};
pub use hygiene::{Mark, SyntaxContext, ExpnInfo, ExpnKind, DesugaringKind};
mod span_encoding;
pub use span_encoding::{Span, DUMMY_SP};
@ -403,10 +403,10 @@ impl Span {
}
/// Checks if this span arises from a compiler desugaring of kind `kind`.
pub fn is_compiler_desugaring(&self, kind: CompilerDesugaringKind) -> bool {
pub fn is_desugaring(&self, kind: DesugaringKind) -> bool {
match self.ctxt().outer_expn_info() {
Some(info) => match info.format {
ExpnFormat::CompilerDesugaring(k) => k == kind,
Some(info) => match info.kind {
ExpnKind::Desugaring(k) => k == kind,
_ => false,
},
None => false,
@ -415,10 +415,10 @@ impl Span {
/// Returns 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> {
pub fn desugaring_kind(&self) -> Option<DesugaringKind> {
match self.ctxt().outer_expn_info() {
Some(info) => match info.format {
ExpnFormat::CompilerDesugaring(k) => Some(k),
Some(info) => match info.kind {
ExpnKind::Desugaring(k) => Some(k),
_ => None
},
None => None
@ -441,14 +441,14 @@ impl Span {
while let Some(info) = self.ctxt().outer_expn_info() {
// Don't print recursive invocations.
if !info.call_site.source_equal(&prev_span) {
let (pre, post) = match info.format {
ExpnFormat::MacroAttribute(..) => ("#[", "]"),
ExpnFormat::MacroBang(..) => ("", "!"),
ExpnFormat::CompilerDesugaring(..) => ("desugaring of `", "`"),
let (pre, post) = match info.kind {
ExpnKind::MacroAttribute(..) => ("#[", "]"),
ExpnKind::MacroBang(..) => ("", "!"),
ExpnKind::Desugaring(..) => ("desugaring of `", "`"),
};
result.push(MacroBacktrace {
call_site: info.call_site,
macro_decl_name: format!("{}{}{}", pre, info.format.name(), post),
macro_decl_name: format!("{}{}{}", pre, info.kind.descr(), post),
def_site_span: info.def_site,
});
}