diff options
-rw-r--r-- | src/expand/lang_item.cpp | 2 | ||||
-rw-r--r-- | src/expand/mod.cpp | 3 | ||||
-rw-r--r-- | src/include/target_version.hpp | 12 | ||||
-rw-r--r-- | src/main.cpp | 2 |
4 files changed, 15 insertions, 4 deletions
diff --git a/src/expand/lang_item.cpp b/src/expand/lang_item.cpp index 0bdd37e5..f59d81c3 100644 --- a/src/expand/lang_item.cpp +++ b/src/expand/lang_item.cpp @@ -68,7 +68,7 @@ void handle_lang_item(const Span& sp, AST::Crate& crate, const AST::Path& path, else if( name == "fn_once" ) { DEBUG("Bind '"<<name<<"' to " << path); } else if( name == "eq" ) { DEBUG("Bind '"<<name<<"' to " << path); } - else if( TARGETVER_1_19 && name == "ord" ) { DEBUG("Bind '"<<name<<"' to " << path); } + else if( name == "ord" ) { DEBUG("Bind '"<<name<<"' to " << path); } // In 1.29 this is Ord, before it was PartialOrd else if( TARGETVER_1_29 && name == "partial_ord" ) { DEBUG("Bind '"<<name<<"' to " << path); } // New name for v1.29 else if( name == "unsize" ) { DEBUG("Bind '"<<name<<"' to " << path); } else if( name == "coerce_unsized" ) { DEBUG("Bind '"<<name<<"' to " << path); } diff --git a/src/expand/mod.cpp b/src/expand/mod.cpp index 66a7308a..34c47455 100644 --- a/src/expand/mod.cpp +++ b/src/expand/mod.cpp @@ -781,7 +781,8 @@ struct CExpandExpr: ::AST::ExprNode_StructLiteral::t_values values; values.push_back({ {}, "start", mv$(node.m_left) }); values.push_back({ {}, "end" , mv$(node.m_right) }); - values.push_back({ {}, "is_empty", ::AST::ExprNodeP(new ::AST::ExprNode_NamedValue(mv$(path_None))) }); + if( TARGETVER_1_29 ) + values.push_back({ {}, "is_empty", ::AST::ExprNodeP(new ::AST::ExprNode_NamedValue(mv$(path_None))) }); replacement.reset( new ::AST::ExprNode_StructLiteral(mv$(path_RangeInclusive_NonEmpty), nullptr, mv$(values)) ); } else diff --git a/src/include/target_version.hpp b/src/include/target_version.hpp index dddf69e4..07528276 100644 --- a/src/include/target_version.hpp +++ b/src/include/target_version.hpp @@ -7,5 +7,13 @@ */ #pragma once -#define TARGETVER_1_19 true -#define TARGETVER_1_29 true +enum class TargetVersion { + Rustc1_19, + Rustc1_29, +}; + +// Defined in main.cpp +extern TargetVersion gTargetVersion; + +#define TARGETVER_1_19 (gTargetVersion == TargetVersion::Rustc1_19) +#define TARGETVER_1_29 (gTargetVersion == TargetVersion::Rustc1_29) diff --git a/src/main.cpp b/src/main.cpp index 7130cf1c..5db6d811 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -34,6 +34,8 @@ bool g_debug_enabled = true; ::std::string g_cur_phase; ::std::set< ::std::string> g_debug_disable_map; +TargetVersion gTargetVersion = TargetVersion::Rustc1_19; + void init_debug_list() { g_debug_disable_map.insert( "Parse" ); |