Skip to content

Commit ec376c7

Browse files
committed
Move MacroKind into libsyntax_pos
So it can be eventually used in `ExpnInfo`
1 parent 4863522 commit ec376c7

File tree

2 files changed

+29
-28
lines changed

2 files changed

+29
-28
lines changed

src/libsyntax/ext/base.rs

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use std::path::PathBuf;
2424
use std::rc::Rc;
2525
use std::default::Default;
2626

27+
pub use syntax_pos::hygiene::MacroKind;
2728

2829
#[derive(Debug,Clone)]
2930
pub enum Annotatable {
@@ -518,34 +519,6 @@ impl MacResult for DummyResult {
518519
}
519520
}
520521

521-
/// Represents different kinds of macro invocations that can be resolved.
522-
#[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
523-
pub enum MacroKind {
524-
/// A bang macro - foo!()
525-
Bang,
526-
/// An attribute macro - #[foo]
527-
Attr,
528-
/// A derive attribute macro - #[derive(Foo)]
529-
Derive,
530-
}
531-
532-
impl MacroKind {
533-
pub fn descr(self) -> &'static str {
534-
match self {
535-
MacroKind::Bang => "macro",
536-
MacroKind::Attr => "attribute macro",
537-
MacroKind::Derive => "derive macro",
538-
}
539-
}
540-
541-
pub fn article(self) -> &'static str {
542-
match self {
543-
MacroKind::Attr => "an",
544-
_ => "a",
545-
}
546-
}
547-
}
548-
549522
/// A syntax extension kind.
550523
pub enum SyntaxExtensionKind {
551524
/// A token-based function-like macro.

src/libsyntax_pos/hygiene.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,34 @@ impl ExpnFormat {
723723
}
724724
}
725725

726+
/// The kind of macro invocation or definition.
727+
#[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
728+
pub enum MacroKind {
729+
/// A bang macro `foo!()`.
730+
Bang,
731+
/// An attribute macro `#[foo]`.
732+
Attr,
733+
/// A derive macro `#[derive(Foo)]`
734+
Derive,
735+
}
736+
737+
impl MacroKind {
738+
pub fn descr(self) -> &'static str {
739+
match self {
740+
MacroKind::Bang => "macro",
741+
MacroKind::Attr => "attribute macro",
742+
MacroKind::Derive => "derive macro",
743+
}
744+
}
745+
746+
pub fn article(self) -> &'static str {
747+
match self {
748+
MacroKind::Attr => "an",
749+
_ => "a",
750+
}
751+
}
752+
}
753+
726754
/// The kind of compiler desugaring.
727755
#[derive(Clone, Copy, Hash, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable)]
728756
pub enum CompilerDesugaringKind {

0 commit comments

Comments
 (0)