about summary refs log tree commit diff
path: root/src/libsyntax_pos
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2019-06-19 01:08:45 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2019-07-11 00:12:07 +0300
commit16918a8e28d4e7a476f31ff3d3c1e2d998c086af (patch)
treedfb8cbb1c6f60085551a0dd32c57fda7b56c8396 /src/libsyntax_pos
parentec376c783e3a64445c4b55fb5980ae922319a916 (diff)
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
Diffstat (limited to 'src/libsyntax_pos')
-rw-r--r--src/libsyntax_pos/hygiene.rs44
-rw-r--r--src/libsyntax_pos/lib.rs24
2 files changed, 34 insertions, 34 deletions
diff --git a/src/libsyntax_pos/hygiene.rs b/src/libsyntax_pos/hygiene.rs
index 6a2aba17a79..f36a4d5816e 100644
--- a/src/libsyntax_pos/hygiene.rs
+++ b/src/libsyntax_pos/hygiene.rs
@@ -162,7 +162,7 @@ impl Mark {
         HygieneData::with(|data| {
             if data.default_transparency(self) == Transparency::Opaque {
                 if let Some(expn_info) = &data.marks[self.0 as usize].expn_info {
-                    if let ExpnFormat::MacroAttribute(name) = expn_info.format {
+                    if let ExpnKind::MacroAttribute(name) = expn_info.kind {
                         if name.as_str().starts_with("derive(") {
                             return true;
                         }
@@ -654,7 +654,7 @@ pub struct ExpnInfo {
     /// pointing to the `foo!` invocation.
     pub call_site: Span,
     /// The format with which the macro was invoked.
-    pub format: ExpnFormat,
+    pub kind: ExpnKind,
 
     // --- The part specific to the macro/desugaring definition.
     // --- FIXME: Share it between expansions with the same definition.
@@ -681,10 +681,10 @@ pub struct ExpnInfo {
 
 impl ExpnInfo {
     /// Constructs an expansion info with default properties.
-    pub fn default(format: ExpnFormat, call_site: Span, edition: Edition) -> ExpnInfo {
+    pub fn default(kind: ExpnKind, call_site: Span, edition: Edition) -> ExpnInfo {
         ExpnInfo {
             call_site,
-            format,
+            kind,
             def_site: None,
             default_transparency: Transparency::SemiTransparent,
             allow_internal_unstable: None,
@@ -694,31 +694,31 @@ impl ExpnInfo {
         }
     }
 
-    pub fn with_unstable(format: ExpnFormat, call_site: Span, edition: Edition,
+    pub fn with_unstable(kind: ExpnKind, call_site: Span, edition: Edition,
                          allow_internal_unstable: &[Symbol]) -> ExpnInfo {
         ExpnInfo {
             allow_internal_unstable: Some(allow_internal_unstable.into()),
-            ..ExpnInfo::default(format, call_site, edition)
+            ..ExpnInfo::default(kind, call_site, edition)
         }
     }
 }
 
 /// The source of expansion.
 #[derive(Clone, Hash, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable)]
-pub enum ExpnFormat {
+pub enum ExpnKind {
     /// e.g., #[derive(...)] <item>
     MacroAttribute(Symbol),
     /// e.g., `format!()`
     MacroBang(Symbol),
     /// Desugaring done by the compiler during HIR lowering.
-    CompilerDesugaring(CompilerDesugaringKind)
+    Desugaring(DesugaringKind)
 }
 
-impl ExpnFormat {
-    pub fn name(&self) -> Symbol {
+impl ExpnKind {
+    pub fn descr(&self) -> Symbol {
         match *self {
-            ExpnFormat::MacroBang(name) | ExpnFormat::MacroAttribute(name) => name,
-            ExpnFormat::CompilerDesugaring(kind) => kind.name(),
+            ExpnKind::MacroBang(name) | ExpnKind::MacroAttribute(name) => name,
+            ExpnKind::Desugaring(kind) => kind.descr(),
         }
     }
 }
@@ -753,7 +753,7 @@ impl MacroKind {
 
 /// The kind of compiler desugaring.
 #[derive(Clone, Copy, Hash, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable)]
-pub enum CompilerDesugaringKind {
+pub enum DesugaringKind {
     /// We desugar `if c { i } else { e }` to `match $ExprKind::Use(c) { true => i, _ => e }`.
     /// However, we do not want to blame `c` for unreachability but rather say that `i`
     /// is unreachable. This desugaring kind allows us to avoid blaming `c`.
@@ -770,16 +770,16 @@ pub enum CompilerDesugaringKind {
     ForLoop,
 }
 
-impl CompilerDesugaringKind {
-    pub fn name(self) -> Symbol {
+impl DesugaringKind {
+    pub fn descr(self) -> Symbol {
         Symbol::intern(match self {
-            CompilerDesugaringKind::CondTemporary => "if and while condition",
-            CompilerDesugaringKind::Async => "async",
-            CompilerDesugaringKind::Await => "await",
-            CompilerDesugaringKind::QuestionMark => "?",
-            CompilerDesugaringKind::TryBlock => "try block",
-            CompilerDesugaringKind::ExistentialType => "existential type",
-            CompilerDesugaringKind::ForLoop => "for loop",
+            DesugaringKind::CondTemporary => "if and while condition",
+            DesugaringKind::Async => "async",
+            DesugaringKind::Await => "await",
+            DesugaringKind::QuestionMark => "?",
+            DesugaringKind::TryBlock => "try block",
+            DesugaringKind::ExistentialType => "existential type",
+            DesugaringKind::ForLoop => "for loop",
         })
     }
 }
diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs
index 07b9f609320..d4c1958f7e2 100644
--- a/src/libsyntax_pos/lib.rs
+++ b/src/libsyntax_pos/lib.rs
@@ -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,
                 });
             }