summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--src/expand/test.cpp27
2 files changed, 28 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 6774279b..39f6ab22 100644
--- a/Makefile
+++ b/Makefile
@@ -71,6 +71,7 @@ OBJ += expand/derive.o expand/lang_item.o
OBJ += expand/std_prelude.o expand/crate_tags.o
OBJ += expand/include.o
OBJ += expand/env.o
+OBJ += expand/test.o
OBJ += expand/rustc_diagnostics.o
OBJ += macro_rules/mod.o macro_rules/eval.o macro_rules/parse.o
OBJ += resolve/use.o resolve/index.o resolve/absolute.o
diff --git a/src/expand/test.cpp b/src/expand/test.cpp
new file mode 100644
index 00000000..ba18fd24
--- /dev/null
+++ b/src/expand/test.cpp
@@ -0,0 +1,27 @@
+/*
+ * MRustC - Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * expand/test.cpp
+ * - #[test] handling
+ */
+#include <synext_decorator.hpp>
+#include <ast/ast.hpp>
+
+class CTestHandler:
+ public ExpandDecorator
+{
+ AttrStage stage() const override { return AttrStage::Pre; }
+
+ void handle(const Span& sp, const AST::MetaItem& mi, ::AST::Crate& crate, const AST::Path& path, AST::Module& mod, AST::Item&i) const override {
+ if( ! i.is_Function() ) {
+ ERROR(sp, E0000, "#[test] can only be put on functions - found on " << i.tag_str());
+ }
+
+ // TODO: Proper #[test] support, for now just remove them
+ i = AST::Item::make_None({});
+ }
+};
+
+STATIC_DECORATOR("test", CTestHandler);
+