diff options
author | John Hodge <tpg@ucc.asn.au> | 2017-06-09 10:58:34 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2017-06-09 10:58:34 +0800 |
commit | 374a42466ee4e9d0a25ef65f73b84e3c870d6f79 (patch) | |
tree | 7c9e1575cdbf8b011d56f65f16a8dcc2431bc66f | |
parent | 9f8d9fa81be1c11b50bc5ced608a3bd18a53de21 (diff) | |
download | mrust-374a42466ee4e9d0a25ef65f73b84e3c870d6f79.tar.gz |
Fix use of hard tabs
-rw-r--r-- | src/ast/path.cpp | 18 | ||||
-rw-r--r-- | src/common.hpp | 4 | ||||
-rw-r--r-- | src/expand/mod.cpp | 38 | ||||
-rw-r--r-- | src/hir/deserialise.cpp | 20 | ||||
-rw-r--r-- | src/hir/dump.cpp | 16 | ||||
-rw-r--r-- | src/hir/from_ast.cpp | 2 | ||||
-rw-r--r-- | src/hir/type.cpp | 2 | ||||
-rw-r--r-- | src/hir/type.hpp | 10 | ||||
-rw-r--r-- | src/hir_expand/erased_types.cpp | 42 | ||||
-rw-r--r-- | src/hir_expand/ufcs_everything.cpp | 6 | ||||
-rw-r--r-- | src/hir_typeck/expr_check.cpp | 4 | ||||
-rw-r--r-- | src/hir_typeck/expr_cs.cpp | 284 | ||||
-rw-r--r-- | src/hir_typeck/helpers.cpp | 4 | ||||
-rw-r--r-- | src/hir_typeck/static.cpp | 116 | ||||
-rw-r--r-- | src/include/debug.hpp | 12 | ||||
-rw-r--r-- | src/include/synext_decorator.hpp | 22 | ||||
-rw-r--r-- | src/include/synext_macro.hpp | 22 | ||||
-rw-r--r-- | src/include/tagged_union.hpp | 18 | ||||
-rw-r--r-- | src/main.cpp | 58 | ||||
-rw-r--r-- | src/mir/check.cpp | 8 | ||||
-rw-r--r-- | src/mir/check_full.cpp | 6 | ||||
-rw-r--r-- | src/parse/lex.cpp | 8 |
22 files changed, 360 insertions, 360 deletions
diff --git a/src/ast/path.cpp b/src/ast/path.cpp index 9976cae5..37428b1a 100644 --- a/src/ast/path.cpp +++ b/src/ast/path.cpp @@ -190,17 +190,17 @@ void Path::bind_variable(unsigned int slot) } void Path::bind_enum_var(const Enum& ent, const ::std::string& name, const ::std::vector<TypeRef>& /*args*/) { - auto it = ::std::find_if(ent.variants().begin(), ent.variants().end(), [&](const auto& x) { return x.m_name == name; }); - if( it == ent.variants().end() ) - { - throw ParseError::Generic("Enum variant not found"); - } - unsigned int idx = it - ent.variants().begin(); + auto it = ::std::find_if(ent.variants().begin(), ent.variants().end(), [&](const auto& x) { return x.m_name == name; }); + if( it == ent.variants().end() ) + { + throw ParseError::Generic("Enum variant not found"); + } + unsigned int idx = it - ent.variants().begin(); DEBUG("Bound to enum variant '" << name << "' (#" << idx << ")"); - ::AST::PathBinding::Data_EnumVar tmp = {}; - tmp.enum_ = &ent; - tmp.idx = idx; + ::AST::PathBinding::Data_EnumVar tmp = {}; + tmp.enum_ = &ent; + tmp.idx = idx; m_binding = PathBinding::make_EnumVar( mv$(tmp) ); } diff --git a/src/common.hpp b/src/common.hpp index 55e0f833..dec40191 100644 --- a/src/common.hpp +++ b/src/common.hpp @@ -12,7 +12,7 @@ #include <memory> #ifdef _MSC_VER -#define __attribute__(x) +#define __attribute__(x) /* no-op */ #endif #define FMT(ss) (dynamic_cast< ::std::stringstream&>(::std::stringstream() << ss).str()) @@ -22,7 +22,7 @@ #define rc_new$(...) ::make_shared_ptr(::std::move(__VA_ARGS__)) #include "include/debug.hpp" -#include "include/rustic.hpp" // slice and option +#include "include/rustic.hpp" // slice and option #include "include/compile_error.hpp" template<typename T> diff --git a/src/expand/mod.cpp b/src/expand/mod.cpp index 01786284..1a534c0b 100644 --- a/src/expand/mod.cpp +++ b/src/expand/mod.cpp @@ -15,8 +15,8 @@ #include <ast/expr.hpp> #include "cfg.hpp" -DecoratorDef* g_decorators_list = nullptr; -MacroDef* g_macros_list = nullptr; +DecoratorDef* g_decorators_list = nullptr; +MacroDef* g_macros_list = nullptr; ::std::map< ::std::string, ::std::unique_ptr<ExpandDecorator> > g_decorators; ::std::map< ::std::string, ::std::unique_ptr<ExpandProcMacro> > g_macros; @@ -26,18 +26,18 @@ void Expand_Expr(::AST::Crate& crate, LList<const AST::Module*> modstack, AST::E void Expand_Expr(::AST::Crate& crate, LList<const AST::Module*> modstack, ::std::shared_ptr<AST::ExprNode>& node); void Register_Synext_Decorator(::std::string name, ::std::unique_ptr<ExpandDecorator> handler) { - g_decorators.insert(::std::make_pair( mv$(name), mv$(handler) )); + g_decorators.insert(::std::make_pair( mv$(name), mv$(handler) )); } void Register_Synext_Macro(::std::string name, ::std::unique_ptr<ExpandProcMacro> handler) { - g_macros.insert(::std::make_pair( mv$(name), mv$(handler) )); + g_macros.insert(::std::make_pair( mv$(name), mv$(handler) )); } void Register_Synext_Decorator_Static(DecoratorDef* def) { - def->prev = g_decorators_list; - g_decorators_list = def; + def->prev = g_decorators_list; + g_decorators_list = def; } void Register_Synext_Macro_Static(MacroDef* def) { - def->prev = g_macros_list; - g_macros_list = def; + def->prev = g_macros_list; + g_macros_list = def; } @@ -1074,17 +1074,17 @@ void Expand_Mod_IndexAnon(::AST::Crate& crate, ::AST::Module& mod) } void Expand(::AST::Crate& crate) { - // Fill macro/decorator map from init list - while(g_decorators_list) - { - g_decorators.insert(::std::make_pair( mv$(g_decorators_list->name), mv$(g_decorators_list->def) )); - g_decorators_list = g_decorators_list->prev; - } - while (g_macros_list) - { - g_macros.insert(::std::make_pair(mv$(g_macros_list->name), mv$(g_macros_list->def))); - g_macros_list = g_macros_list->prev; - } + // Fill macro/decorator map from init list + while(g_decorators_list) + { + g_decorators.insert(::std::make_pair( mv$(g_decorators_list->name), mv$(g_decorators_list->def) )); + g_decorators_list = g_decorators_list->prev; + } + while (g_macros_list) + { + g_macros.insert(::std::make_pair(mv$(g_macros_list->name), mv$(g_macros_list->def))); + g_macros_list = g_macros_list->prev; + } auto modstack = LList<const ::AST::Module*>(nullptr, &crate.m_root_module); diff --git a/src/hir/deserialise.cpp b/src/hir/deserialise.cpp index 0ff4d63b..f4dfdf19 100644 --- a/src/hir/deserialise.cpp +++ b/src/hir/deserialise.cpp @@ -505,10 +505,10 @@ namespace { ::HIR::Linkage deserialise_linkage() { - ::HIR::Linkage l; - l.type = ::HIR::Linkage::Type::Auto; - l.name = m_in.read_string(); - return l; + ::HIR::Linkage l; + l.type = ::HIR::Linkage::Type::Auto; + l.name = m_in.read_string(); + return l; } // - Value items @@ -1004,12 +1004,12 @@ namespace { deserialise_vec< ::std::string>() }); case 3: { - ::MIR::Statement::Data_SetDropFlag sdf; - sdf.idx = static_cast<unsigned int>(m_in.read_count()); - sdf.new_val = m_in.read_bool(); - sdf.other = static_cast<unsigned int>(m_in.read_count()); - return ::MIR::Statement::make_SetDropFlag(sdf); - } + ::MIR::Statement::Data_SetDropFlag sdf; + sdf.idx = static_cast<unsigned int>(m_in.read_count()); + sdf.new_val = m_in.read_bool(); + sdf.other = static_cast<unsigned int>(m_in.read_count()); + return ::MIR::Statement::make_SetDropFlag(sdf); + } case 4: return ::MIR::Statement::make_ScopeEnd({ deserialise_vec<unsigned int>(), diff --git a/src/hir/dump.cpp b/src/hir/dump.cpp index 649116e0..75dde59f 100644 --- a/src/hir/dump.cpp +++ b/src/hir/dump.cpp @@ -262,13 +262,13 @@ namespace { void visit_constant(::HIR::ItemPath p, ::HIR::Constant& item) override { m_os << indent() << "const " << p.get_name() << ": " << item.m_type << " = " << item.m_value_res; - if( item.m_value ) - { - m_os << " /*= "; - item.m_value->visit(*this); - m_os << "*/"; - } - m_os << ";\n"; + if( item.m_value ) + { + m_os << " /*= "; + item.m_value->visit(*this); + m_os << "*/"; + } + m_os << ";\n"; } // - Misc @@ -530,7 +530,7 @@ namespace { m_os << ", "; } m_os << ")"; - m_os << "/* : " << node.m_res_type << " */"; + m_os << "/* : " << node.m_res_type << " */"; } void visit(::HIR::ExprNode_CallValue& node) override { diff --git a/src/hir/from_ast.cpp b/src/hir/from_ast.cpp index c0a3151e..e0429aca 100644 --- a/src/hir/from_ast.cpp +++ b/src/hir/from_ast.cpp @@ -702,7 +702,7 @@ { if( ptr->m_datatype == CORETYPE_UINT || ptr->m_datatype == CORETYPE_ANY ) { - // TODO: Limit check. + // TODO: Limit check. auto size_val = static_cast<unsigned int>( ptr->m_value ); return ::HIR::TypeRef::new_array( mv$(inner), size_val ); } diff --git a/src/hir/type.cpp b/src/hir/type.cpp index 7dd8dc80..c672b3bd 100644 --- a/src/hir/type.cpp +++ b/src/hir/type.cpp @@ -781,7 +781,7 @@ bool ::HIR::TypeRef::match_test_generics(const Span& sp, const ::HIR::TypeRef& x (Enum , return ::HIR::TypeRef::TypePathBinding(e); ) ) assert(!"Fell off end of clone_binding"); - throw ""; + throw ""; } diff --git a/src/hir/type.hpp b/src/hir/type.hpp index a832e8e9..cc0894d2 100644 --- a/src/hir/type.hpp +++ b/src/hir/type.hpp @@ -178,8 +178,8 @@ public: Data m_data; TypeRef(): - m_data(Data::make_Infer({ ~0u, InferClass::None })) - {} + m_data(Data::make_Infer({ ~0u, InferClass::None })) + {} TypeRef(TypeRef&& ) = default; TypeRef(const TypeRef& ) = delete; TypeRef& operator=(TypeRef&& ) = default; @@ -212,9 +212,9 @@ public: static TypeRef new_diverge() { return TypeRef(Data::make_Diverge({})); } - static TypeRef new_infer(unsigned int idx = ~0u, InferClass ty_class = InferClass::None) { - return TypeRef(Data::make_Infer({idx, ty_class})); - } + static TypeRef new_infer(unsigned int idx = ~0u, InferClass ty_class = InferClass::None) { + return TypeRef(Data::make_Infer({idx, ty_class})); + } static TypeRef new_borrow(BorrowType bt, TypeRef inner) { return TypeRef(Data::make_Borrow({bt, box$(mv$(inner))})); } diff --git a/src/hir_expand/erased_types.cpp b/src/hir_expand/erased_types.cpp index f5fbe27a..caf42a79 100644 --- a/src/hir_expand/erased_types.cpp +++ b/src/hir_expand/erased_types.cpp @@ -14,23 +14,23 @@ const ::HIR::Function& HIR_Expand_ErasedType_GetFunction(const Span& sp, const StaticTraitResolve& resolve, const ::HIR::Path& origin_path, t_cb_generic& monomorph_cb, ::HIR::PathParams& impl_params) { const ::HIR::Function* fcn_ptr = nullptr; - switch(origin_path.m_data.tag()) - { + switch(origin_path.m_data.tag()) + { case ::HIR::Path::Data::TAGDEAD: BUG(Span(), "DEAD in ErasedType - " << origin_path); - case ::HIR::Path::Data::TAG_UfcsUnknown: - BUG(Span(), "UfcsUnknown in ErasedType - " << origin_path); - case ::HIR::Path::Data::TAG_Generic: { - const auto& pe = origin_path.m_data.as_Generic(); - monomorph_cb = monomorphise_type_get_cb(sp, nullptr, nullptr, &pe.m_params); - fcn_ptr = &resolve.m_crate.get_function_by_path(sp, pe.m_path); - } break; - case ::HIR::Path::Data::TAG_UfcsKnown: - // NOTE: This isn't possible yet (will it be? or will it expand to an associated type?) - TODO(sp, "Replace ErasedType - " << origin_path << " with source (UfcsKnown)"); - break; - case ::HIR::Path::Data::TAG_UfcsInherent: { - const auto& pe = origin_path.m_data.as_UfcsInherent(); + case ::HIR::Path::Data::TAG_UfcsUnknown: + BUG(Span(), "UfcsUnknown in ErasedType - " << origin_path); + case ::HIR::Path::Data::TAG_Generic: { + const auto& pe = origin_path.m_data.as_Generic(); + monomorph_cb = monomorphise_type_get_cb(sp, nullptr, nullptr, &pe.m_params); + fcn_ptr = &resolve.m_crate.get_function_by_path(sp, pe.m_path); + } break; + case ::HIR::Path::Data::TAG_UfcsKnown: + // NOTE: This isn't possible yet (will it be? or will it expand to an associated type?) + TODO(sp, "Replace ErasedType - " << origin_path << " with source (UfcsKnown)"); + break; + case ::HIR::Path::Data::TAG_UfcsInherent: { + const auto& pe = origin_path.m_data.as_UfcsInherent(); // 1. Find correct impl block for the path const ::HIR::TypeImpl* impl_ptr = nullptr; resolve.m_crate.find_type_impls(*pe.type, [&](const auto& ty)->const auto& { return ty; }, @@ -54,16 +54,16 @@ const ::HIR::Function& HIR_Expand_ErasedType_GetFunction(const Span& sp, const S return ::HIR::Compare::Equal; }); for(const auto& t : impl_params.m_types) - { + { if( t == ::HIR::TypeRef() ) - { + { TODO(sp, "Handle ErasedType where an impl parameter comes from a bound - " << origin_path); - } - } + } + } monomorph_cb = monomorphise_type_get_cb(sp, &*pe.type, &impl_params, &pe.params); - } break; - } + } break; + } assert(fcn_ptr); return *fcn_ptr; } diff --git a/src/hir_expand/ufcs_everything.cpp b/src/hir_expand/ufcs_everything.cpp index 44921105..adae855c 100644 --- a/src/hir_expand/ufcs_everything.cpp +++ b/src/hir_expand/ufcs_everything.cpp @@ -289,7 +289,7 @@ namespace { ASSERT_BUG(sp, ty_slot == ty_val, "Types must equal for non-operator assignment, " << ty_slot << " != " << ty_val); return ; _(Shr): {langitem = "shr_assign"; opname = "shr_assign"; } if(0) - _(Shl): {langitem = "shl_assign"; opname = "shl_assign"; } + _(Shl): {langitem = "shl_assign"; opname = "shl_assign"; } if( is_op_valid_shift(ty_slot, ty_val) ) { return ; } @@ -385,8 +385,8 @@ namespace { auto ty_r_ref = ::HIR::TypeRef::new_borrow( ::HIR::BorrowType::Shared, ty_r.clone() ); ::std::vector< ::HIR::ExprNodeP> args; - auto sp_left = node.m_left ->span(); - auto sp_right = node.m_right->span(); + auto sp_left = node.m_left ->span(); + auto sp_right = node.m_right->span(); args.push_back(NEWNODE(ty_l_ref.clone(), Borrow, sp_left , ::HIR::BorrowType::Shared, mv$(node.m_left ) )); args.push_back(NEWNODE(ty_r_ref.clone(), Borrow, sp_right, ::HIR::BorrowType::Shared, mv$(node.m_right) )); diff --git a/src/hir_typeck/expr_check.cpp b/src/hir_typeck/expr_check.cpp index fe67865f..a5d34186 100644 --- a/src/hir_typeck/expr_check.cpp +++ b/src/hir_typeck/expr_check.cpp @@ -640,7 +640,7 @@ namespace { fcn_ptr = &fcn; - monomorph_cb = monomorphise_type_get_cb(sp, &*e.type, &trait_params, &path_params); + monomorph_cb = monomorphise_type_get_cb(sp, &*e.type, &trait_params, &path_params); ), (UfcsUnknown, TODO(sp, "Hit a UfcsUnknown (" << path << ") - Is this an error?"); @@ -672,7 +672,7 @@ namespace { // Create monomorphise callback const auto& fcn_params = e.params; - monomorph_cb = monomorphise_type_get_cb(sp, &*e.type, &impl_params, &fcn_params); + monomorph_cb = monomorphise_type_get_cb(sp, &*e.type, &impl_params, &fcn_params); ) ) diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp index 9b5e4f5d..de7f05ec 100644 --- a/src/hir_typeck/expr_cs.cpp +++ b/src/hir_typeck/expr_cs.cpp @@ -2366,148 +2366,148 @@ namespace { const auto& ty = *ty_p; DEBUG("- ty = " << ty); - if( const auto* e = ty.m_data.opt_Closure() ) - { - for( const auto& arg : e->m_arg_types ) - node.m_arg_types.push_back(arg.clone()); - node.m_arg_types.push_back(e->m_rettype->clone()); - node.m_trait_used = ::HIR::ExprNode_CallValue::TraitUsed::Unknown; - } - else if( const auto* e = ty.m_data.opt_Function() ) - { - for( const auto& arg : e->m_arg_types ) - node.m_arg_types.push_back(arg.clone()); - node.m_arg_types.push_back(e->m_rettype->clone()); - node.m_trait_used = ::HIR::ExprNode_CallValue::TraitUsed::Fn; - } - else if( ty.m_data.is_Infer() ) - { - // No idea yet - return ; - } - else - { - ::HIR::TypeRef fcn_args_tup; - ::HIR::TypeRef fcn_ret; - - // TODO: Use `find_trait_impls` instead of two different calls - // - This will get the TraitObject impl search too - - // Locate an impl of FnOnce (exists for all other Fn* traits) - unsigned int count = 0; - this->context.m_resolve.find_trait_impls(node.span(), lang_FnOnce, trait_pp, ty, [&](auto impl, auto cmp)->bool { - count++; - - auto tup = impl.get_trait_ty_param(0); - if (!tup.m_data.is_Tuple()) - ERROR(node.span(), E0000, "FnOnce expects a tuple argument, got " << tup); - fcn_args_tup = mv$(tup); - - fcn_ret = impl.get_type("Output"); - DEBUG("[visit:_CallValue] fcn_args_tup=" << fcn_args_tup << ", fcn_ret=" << fcn_ret); - return cmp == ::HIR::Compare::Equal; - }); - DEBUG("Found " << count << " impls of FnOnce"); - if(count > 1) { - return; - } - if(count == 1) - { - - // 3. Locate the most permissive implemented Fn* trait (Fn first, then FnMut, then assume just FnOnce) - // NOTE: Borrowing is added by the expansion to CallPath - if( this->context.m_resolve.find_trait_impls(node.span(), lang_Fn, trait_pp, ty, [&](auto impl, auto cmp) { - // TODO: Take the value of `cmp` into account - fcn_ret = impl.get_type("Output"); - return true; - //return cmp == ::HIR::Compare::Equal; - }) ) - { - DEBUG("-- Using Fn"); - node.m_trait_used = ::HIR::ExprNode_CallValue::TraitUsed::Fn; - - this->context.equate_types_assoc(node.span(), node.m_res_type, lang_Fn, ::make_vec1(fcn_args_tup.clone()), ty, "Output"); - } - else if( this->context.m_resolve.find_trait_impls(node.span(), lang_FnMut, trait_pp, ty, [&](auto impl, auto cmp) { - // TODO: Take the value of `cmp` into account - fcn_ret = impl.get_type("Output"); - return true; - //return cmp == ::HIR::Compare::Equal; - }) ) - { - DEBUG("-- Using FnMut"); - node.m_trait_used = ::HIR::ExprNode_CallValue::TraitUsed::FnMut; - - this->context.equate_types_assoc(node.span(), node.m_res_type, lang_FnMut, ::make_vec1(fcn_args_tup.clone()), ty, "Output"); - } - else - { - DEBUG("-- Using FnOnce (default)"); - node.m_trait_used = ::HIR::ExprNode_CallValue::TraitUsed::FnOnce; - - this->context.equate_types_assoc(node.span(), node.m_res_type, lang_FnOnce, ::make_vec1(fcn_args_tup.clone()), ty, "Output"); - } - - // If the return type wasn't found in the impls, emit it as a UFCS - if(fcn_ret == ::HIR::TypeRef()) - { - fcn_ret = ::HIR::TypeRef(::HIR::Path(::HIR::Path::Data::make_UfcsKnown({ - box$(ty.clone()), - // - Clone argument tuple, as it's stolen into cache below - ::HIR::GenericPath(lang_FnOnce, ::HIR::PathParams(fcn_args_tup.clone())), - "Output", - {} - }))); - } - } - else if( const auto* e = ty.m_data.opt_Borrow() ) - { - deref_count++; - ty_p = &this->context.get_type(*e->inner); - DEBUG("Deref " << ty << " -> " << *ty_p); - keep_looping = true; - continue; - } - else - { - if( !ty.m_data.is_Generic() ) - { - bool found = this->context.m_resolve.find_trait_impls_crate(node.span(), lang_FnOnce, trait_pp, ty, [&](auto impl, auto cmp)->bool { - if (cmp == ::HIR::Compare::Fuzzy) - TODO(node.span(), "Handle fuzzy match - " << impl); - - auto tup = impl.get_trait_ty_param(0); - if (!tup.m_data.is_Tuple()) - ERROR(node.span(), E0000, "FnOnce expects a tuple argument, got " << tup); - fcn_args_tup = mv$(tup); - fcn_ret = impl.get_type("Output"); - ASSERT_BUG(node.span(), fcn_ret != ::HIR::TypeRef(), "Impl didn't have a type for Output - " << impl); - return true; - }); - if (found) { - // Fill cache and leave the TU_MATCH - node.m_arg_types = mv$(fcn_args_tup.m_data.as_Tuple()); - node.m_arg_types.push_back(mv$(fcn_ret)); - node.m_trait_used = ::HIR::ExprNode_CallValue::TraitUsed::Unknown; - break; // leaves TU_MATCH - } - } - if( const auto* next_ty_p = this->context.m_resolve.autoderef(node.span(), ty, tmp_type) ) - { - DEBUG("Deref (autoderef) " << ty << " -> " << *next_ty_p); - deref_count++; - ty_p = next_ty_p; - keep_looping = true; - continue; - } - - // Didn't find anything. Error? - ERROR(node.span(), E0000, "Unable to find an implementation of Fn*" << trait_pp << " for " << this->context.m_ivars.fmt_type(ty)); - } - - node.m_arg_types = mv$(fcn_args_tup.m_data.as_Tuple()); - node.m_arg_types.push_back(mv$(fcn_ret)); - } + if( const auto* e = ty.m_data.opt_Closure() ) + { + for( const auto& arg : e->m_arg_types ) + node.m_arg_types.push_back(arg.clone()); + node.m_arg_types.push_back(e->m_rettype->clone()); + node.m_trait_used = ::HIR::ExprNode_CallValue::TraitUsed::Unknown; + } + else if( const auto* e = ty.m_data.opt_Function() ) + { + for( const auto& arg : e->m_arg_types ) + node.m_arg_types.push_back(arg.clone()); + node.m_arg_types.push_back(e->m_rettype->clone()); + node.m_trait_used = ::HIR::ExprNode_CallValue::TraitUsed::Fn; + } + else if( ty.m_data.is_Infer() ) + { + // No idea yet + return ; + } + else + { + ::HIR::TypeRef fcn_args_tup; + ::HIR::TypeRef fcn_ret; + + // TODO: Use `find_trait_impls` instead of two different calls + // - This will get the TraitObject impl search too + + // Locate an impl of FnOnce (exists for all other Fn* traits) + unsigned int count = 0; + this->context.m_resolve.find_trait_impls(node.span(), lang_FnOnce, trait_pp, ty, [&](auto impl, auto cmp)->bool { + count++; + + auto tup = impl.get_trait_ty_param(0); + if (!tup.m_data.is_Tuple()) + ERROR(node.span(), E0000, "FnOnce expects a tuple argument, got " << tup); + fcn_args_tup = mv$(tup); + + fcn_ret = impl.get_type("Output"); + DEBUG("[visit:_CallValue] fcn_args_tup=" << fcn_args_tup << ", fcn_ret=" << fcn_ret); + return cmp == ::HIR::Compare::Equal; + }); + DEBUG("Found " << count << " impls of FnOnce"); + if(count > 1) { + return; + } + if(count == 1) + { + + // 3. Locate the most permissive implemented Fn* trait (Fn first, then FnMut, then assume just FnOnce) + // NOTE: Borrowing is added by the expansion to CallPath + if( this->context.m_resolve.find_trait_impls(node.span(), lang_Fn, trait_pp, ty, [&](auto impl, auto cmp) { + // TODO: Take the value of `cmp` into account + fcn_ret = impl.get_type("Output"); + return true; + //return cmp == ::HIR::Compare::Equal; + }) ) + { + DEBUG("-- Using Fn"); + node.m_trait_used = ::HIR::ExprNode_CallValue::TraitUsed::Fn; + + this->context.equate_types_assoc(node.span(), node.m_res_type, lang_Fn, ::make_vec1(fcn_args_tup.clone()), ty, "Output"); + } + else if( this->context.m_resolve.find_trait_impls(node.span(), lang_FnMut, trait_pp, ty, [&](auto impl, auto cmp) { + // TODO: Take the value of `cmp` into account + fcn_ret = impl.get_type("Output"); + return true; + //return cmp == ::HIR::Compare::Equal; + }) ) + { + DEBUG("-- Using FnMut"); + node.m_trait_used = ::HIR::ExprNode_CallValue::TraitUsed::FnMut; + + this->context.equate_types_assoc(node.span(), node.m_res_type, lang_FnMut, ::make_vec1(fcn_args_tup.clone()), ty, "Output"); + } + else + { + DEBUG("-- Using FnOnce (default)"); + node.m_trait_used = ::HIR::ExprNode_CallValue::TraitUsed::FnOnce; + + this->context.equate_types_assoc(node.span(), node.m_res_type, lang_FnOnce, ::make_vec1(fcn_args_tup.clone()), ty, "Output"); + } + + // If the return type wasn't found in the impls, emit it as a UFCS + if(fcn_ret == ::HIR::TypeRef()) + { + fcn_ret = ::HIR::TypeRef(::HIR::Path(::HIR::Path::Data::make_UfcsKnown({ + box$(ty.clone()), + // - Clone argument tuple, as it's stolen into cache below + ::HIR::GenericPath(lang_FnOnce, ::HIR::PathParams(fcn_args_tup.clone())), + "Output", + {} + }))); + } + } + else if( const auto* e = ty.m_data.opt_Borrow() ) + { + deref_count++; + ty_p = &this->context.get_type(*e->inner); + DEBUG("Deref " << ty << " -> " << *ty_p); + keep_looping = true; + continue; + } + else + { + if( !ty.m_data.is_Generic() ) + { + bool found = this->context.m_resolve.find_trait_impls_crate(node.span(), lang_FnOnce, trait_pp, ty, [&](auto impl, auto cmp)->bool { + if (cmp == ::HIR::Compare::Fuzzy) + TODO(node.span(), "Handle fuzzy match - " << impl); + + auto tup = impl.get_trait_ty_param(0); + if (!tup.m_data.is_Tuple()) + ERROR(node.span(), E0000, "FnOnce expects a tuple argument, got " << tup); + fcn_args_tup = mv$(tup); + fcn_ret = impl.get_type("Output"); + ASSERT_BUG(node.span(), fcn_ret != ::HIR::TypeRef(), "Impl didn't have a type for Output - " << impl); + return true; + }); + if (found) { + // Fill cache and leave the TU_MATCH + node.m_arg_types = mv$(fcn_args_tup.m_data.as_Tuple()); + node.m_arg_types.push_back(mv$(fcn_ret)); + node.m_trait_used = ::HIR::ExprNode_CallValue::TraitUsed::Unknown; + break; // leaves TU_MATCH + } + } + if( const auto* next_ty_p = this->context.m_resolve.autoderef(node.span(), ty, tmp_type) ) + { + DEBUG("Deref (autoderef) " << ty << " -> " << *next_ty_p); + deref_count++; + ty_p = next_ty_p; + keep_looping = true; + continue; + } + + // Didn't find anything. Error? + ERROR(node.span(), E0000, "Unable to find an implementation of Fn*" << trait_pp << " for " << this->context.m_ivars.fmt_type(ty)); + } + + node.m_arg_types = mv$(fcn_args_tup.m_data.as_Tuple()); + node.m_arg_types.push_back(mv$(fcn_ret)); + } } while( keep_looping ); if( deref_count > 0 ) diff --git a/src/hir_typeck/helpers.cpp b/src/hir_typeck/helpers.cpp index a3fe9b1c..c860c6ce 100644 --- a/src/hir_typeck/helpers.cpp +++ b/src/hir_typeck/helpers.cpp @@ -436,7 +436,7 @@ void HMTypeInferrence::add_ivars(::HIR::TypeRef& type) e.index = this->new_ivar(); this->get_type(type).m_data.as_Infer().ty_class = e.ty_class; this->mark_change(); - DEBUG("New ivar " << type); + DEBUG("New ivar " << type); } ), (Diverge, @@ -2020,7 +2020,7 @@ void TraitResolution::expand_associated_types_inplace__UfcsKnown(const Span& sp, ERROR(sp, E0000, "Couldn't find assocated type " << pe.item << " in " << pe.trait); if( impl.has_magic_params() ) { - } + } // TODO: What if there's multiple impls? DEBUG("Converted UfcsKnown - " << e.path << " = " << ty); diff --git a/src/hir_typeck/static.cpp b/src/hir_typeck/static.cpp index d8b692c9..8a4dba50 100644 --- a/src/hir_typeck/static.cpp +++ b/src/hir_typeck/static.cpp @@ -331,39 +331,39 @@ bool StaticTraitResolve::find_impl( if( m_crate.get_trait_by_path(sp, trait_path).m_is_marker ) { - struct H { - static bool find_impl__auto_trait_check(const StaticTraitResolve& self, - const Span& sp, const ::HIR::SimplePath& trait_path, const ::HIR::PathParams* trait_params, const ::HIR::TypeRef& type, - t_cb_find_impl found_cb, - const ::HIR::MarkerImpl& impl, bool& out_rv - ) - { - DEBUG("- Auto " << (impl.is_positive ? "Pos" : "Neg") - << " impl" << impl.m_params.fmt_args() << " " << trait_path << impl.m_trait_args << " for " << impl.m_type << " " << impl.m_params.fmt_bounds()); - if (impl.is_positive) - { - return self.find_impl__check_crate_raw(sp, trait_path, trait_params, type, impl.m_params, impl.m_trait_args, impl.m_type, - [&](auto impl_params, auto placeholders, auto cmp)->bool { - //rv = found_cb( ImplRef(impl_params, trait_path, impl, mv$(placeholders)), (cmp == ::HIR::Compare::Fuzzy) ); - out_rv = found_cb(ImplRef(&type, trait_params, &null_assoc), cmp == ::HIR::Compare::Fuzzy); - return out_rv; - }); - } - else - { - return self.find_impl__check_crate_raw(sp, trait_path, trait_params, type, impl.m_params, impl.m_trait_args, impl.m_type, - [&](auto impl_params, auto placeholders, auto cmp)->bool { - out_rv = false; - return true; - }); - } - } - }; + struct H { + static bool find_impl__auto_trait_check(const StaticTraitResolve& self, + const Span& sp, const ::HIR::SimplePath& trait_path, const ::HIR::PathParams* trait_params, const ::HIR::TypeRef& type, + t_cb_find_impl found_cb, + const ::HIR::MarkerImpl& impl, bool& out_rv + ) + { + DEBUG("- Auto " << (impl.is_positive ? "Pos" : "Neg") + << " impl" << impl.m_params.fmt_args() << " " << trait_path << impl.m_trait_args << " for " << impl.m_type << " " << impl.m_params.fmt_bounds()); + if (impl.is_positive) + { + return self.find_impl__check_crate_raw(sp, trait_path, trait_params, type, impl.m_params, impl.m_trait_args, impl.m_type, + [&](auto impl_params, auto placeholders, auto cmp)->bool { + //rv = found_cb( ImplRef(impl_params, trait_path, impl, mv$(placeholders)), (cmp == ::HIR::Compare::Fuzzy) ); + out_rv = found_cb(ImplRef(&type, trait_params, &null_assoc), cmp == ::HIR::Compare::Fuzzy); + return out_rv; + }); + } + else + { + return self.find_impl__check_crate_raw(sp, trait_path, trait_params, type, impl.m_params, impl.m_trait_args, impl.m_type, + [&](auto impl_params, auto placeholders, auto cmp)->bool { + out_rv = false; + return true; + }); + } + } + }; // Positive/negative impls bool rv = false; ret = this->m_crate.find_auto_trait_impls(trait_path, type, cb_ident, [&](const auto& impl)->bool { - return H::find_impl__auto_trait_check(*this, sp, trait_path, trait_params, type, found_cb, impl, rv); + return H::find_impl__auto_trait_check(*this, sp, trait_path, trait_params, type, found_cb, impl, rv); }); if(ret) return rv; @@ -592,9 +592,9 @@ bool StaticTraitResolve::find_impl__check_crate_raw( // Bounds for(const auto& bound : impl_params_def.m_bounds) { - if( const auto* ep = bound.opt_TraitBound() ) - { - const auto& e = *ep; + if( const auto* ep = bound.opt_TraitBound() ) + { + const auto& e = *ep; DEBUG("Trait bound " << e.type << " : " << e.trait); auto b_ty_mono = monomorphise_type_with(sp, e.type, cb_monomorph); @@ -665,11 +665,11 @@ bool StaticTraitResolve::find_impl__check_crate_raw( return false; } } - } - else // bound.opt_TraitBound() - { - // Ignore - } + } + else // bound.opt_TraitBound() + { + // Ignore + } } return found_cb( mv$(impl_params), mv$(placeholders), match ); @@ -705,9 +705,9 @@ bool StaticTraitResolve::find_impl__check_crate( }; // - If the type is a path (struct/enum/...), search for impls for all contained types. - if( const auto* ep = type.m_data.opt_Path() ) - { - const auto& e = *ep; + if( const auto* ep = type.m_data.opt_Path() ) + { + const auto& e = *ep; ::HIR::Compare res = ::HIR::Compare::Equal; TU_MATCH( ::HIR::Path::Data, (e.path.m_data), (pe), (Generic, @@ -828,9 +828,9 @@ bool StaticTraitResolve::find_impl__check_crate( ) ) return res; - } - else if( const auto* ep = type.m_data.opt_Tuple() ) - { + } + else if( const auto* ep = type.m_data.opt_Tuple() ) + { ::HIR::Compare res = ::HIR::Compare::Equal; for(const auto& sty : *ep) { @@ -839,11 +839,11 @@ bool StaticTraitResolve::find_impl__check_crate( return ::HIR::Compare::Unequal; } return res; - } + } else if( const auto* e = type.m_data.opt_Array() ) - { + { return type_impls_trait(*e->inner); - } + } // Otherwise, there's no negative so it must be positive else { return ::HIR::Compare::Equal; @@ -986,9 +986,9 @@ void StaticTraitResolve::expand_associated_types__UfcsKnown(const Span& sp, ::HI bool rv; bool assume_opaque = true; rv = this->iterate_bounds([&](const auto& b)->bool { - if( const auto* bep = b.opt_TraitBound() ) - { - const auto& be = *bep; + if( const auto* bep = b.opt_TraitBound() ) + { + const auto& be = *bep; DEBUG("Trait bound - " << be.type << " : " << be.trait); // 1. Check if the type matches // - TODO: This should be a fuzzier match? @@ -1040,20 +1040,20 @@ void StaticTraitResolve::expand_associated_types__UfcsKnown(const Span& sp, ::HI } // - Didn't match - } - else if( const auto* bep = b.opt_TypeEquality() ) - { - const auto& be = *bep; + } + else if( const auto* bep = b.opt_TypeEquality() ) + { + const auto& be = *bep; DEBUG("Equality - " << be.type << " = " << be.other_type); if( input == be.type ) { input = be.other_type.clone(); return true; } - } - else - { - // Nothing. - } + } + else + { + // Nothing. + } return false; }); if( rv ) { diff --git a/src/include/debug.hpp b/src/include/debug.hpp index 2bbecb39..2f593cfb 100644 --- a/src/include/debug.hpp +++ b/src/include/debug.hpp @@ -42,10 +42,10 @@ class NullSink { public: NullSink() - {} + {} - template<typename T> - const NullSink& operator<<(const T&) const { return *this; } + template<typename T> + const NullSink& operator<<(const T&) const { return *this; } }; class TraceLog @@ -62,9 +62,9 @@ public: struct FmtLambda { ::std::function<void(::std::ostream&)> m_cb; - FmtLambda(::std::function<void(::std::ostream&)> cb): - m_cb(cb) - { } + FmtLambda(::std::function<void(::std::ostream&)> cb): + m_cb(cb) + { } friend ::std::ostream& operator<<(::std::ostream& os, const FmtLambda& x) { x.m_cb(os); return os; diff --git a/src/include/synext_decorator.hpp b/src/include/synext_decorator.hpp index 3374fc88..77b55710 100644 --- a/src/include/synext_decorator.hpp +++ b/src/include/synext_decorator.hpp @@ -63,19 +63,19 @@ extern void Register_Synext_Decorator_Static(DecoratorDef* def); struct DecoratorDef { - DecoratorDef* prev; - ::std::string name; - ::std::unique_ptr<ExpandDecorator> def; - DecoratorDef(::std::string name, ::std::unique_ptr<ExpandDecorator> def): - prev(nullptr), - name(::std::move(name)), - def(::std::move(def)) - { - Register_Synext_Decorator_Static(this); - } + DecoratorDef* prev; + ::std::string name; + ::std::unique_ptr<ExpandDecorator> def; + DecoratorDef(::std::string name, ::std::unique_ptr<ExpandDecorator> def): + prev(nullptr), + name(::std::move(name)), + def(::std::move(def)) + { + Register_Synext_Decorator_Static(this); + } }; -#define STATIC_DECORATOR(ident, _handler_class) static DecoratorDef s_register_##_handler_class ( ident, ::std::unique_ptr<ExpandDecorator>(new _handler_class()) ); +#define STATIC_DECORATOR(ident, _handler_class) static DecoratorDef s_register_##_handler_class ( ident, ::std::unique_ptr<ExpandDecorator>(new _handler_class()) ); #endif diff --git a/src/include/synext_macro.hpp b/src/include/synext_macro.hpp index 0abaf0fe..0359d508 100644 --- a/src/include/synext_macro.hpp +++ b/src/include/synext_macro.hpp @@ -31,19 +31,19 @@ extern void Register_Synext_Macro_Static(MacroDef* def); struct MacroDef { - MacroDef* prev; - ::std::string name; - ::std::unique_ptr<ExpandProcMacro> def; - MacroDef(::std::string name, ::std::unique_ptr<ExpandProcMacro> def) : - prev(nullptr), - name(::std::move(name)), - def(::std::move(def)) - { - Register_Synext_Macro_Static(this); - } + MacroDef* prev; + ::std::string name; + ::std::unique_ptr<ExpandProcMacro> def; + MacroDef(::std::string name, ::std::unique_ptr<ExpandProcMacro> def) : + prev(nullptr), + name(::std::move(name)), + def(::std::move(def)) + { + Register_Synext_Macro_Static(this); + } }; -#define STATIC_MACRO(ident, _handler_class) static MacroDef s_register_##_handler_class(ident, ::std::unique_ptr<ExpandProcMacro>(new _handler_class())); +#define STATIC_MACRO(ident, _handler_class) static MacroDef s_register_##_handler_class(ident, ::std::unique_ptr<ExpandProcMacro>(new _handler_class())); #endif diff --git a/src/include/tagged_union.hpp b/src/include/tagged_union.hpp index fbd42a77..f30cb7f2 100644 --- a/src/include/tagged_union.hpp +++ b/src/include/tagged_union.hpp @@ -13,13 +13,13 @@ #include <string> #define TU_FIRST(a, ...) a -#define TU_EXP1(x) x +#define TU_EXP1(x) x #define TU_EXP(...) __VA_ARGS__ -#define TU_CASE_ITEM(src, mod, var, name) mod auto& name = src.as_##var(); (void)&name; -#define TU_CASE_BODY(class,var, ...) case class::var: { __VA_ARGS__ } break; -#define TU_CASE(mod, class, var, name,src, ...) TU_CASE_BODY(mod,class,var, TU_CASE_ITEM(src,mod,var,name) __VA_ARGS__) -#define TU_CASE2(mod, class, var, n1,s1, n2,s2, ...) TU_CASE_BODY(mod,class,var, TU_CASE_ITEM(s1,mod,var,n1) TU_CASE_ITEM(s2,mod,var,n2) __VA_ARGS__) +#define TU_CASE_ITEM(src, mod, var, name) mod auto& name = src.as_##var(); (void)&name; +#define TU_CASE_BODY(class,var, ...) case class::var: { __VA_ARGS__ } break; +#define TU_CASE(mod, class, var, name,src, ...) TU_CASE_BODY(mod,class,var, TU_CASE_ITEM(src,mod,var,name) __VA_ARGS__) +#define TU_CASE2(mod, class, var, n1,s1, n2,s2, ...) TU_CASE_BODY(mod,class,var, TU_CASE_ITEM(s1,mod,var,n1) TU_CASE_ITEM(s2,mod,var,n2) __VA_ARGS__) // Argument iteration @@ -31,7 +31,7 @@ #define TU_DISP5(n, a1,a2,a3, b1,b2 ) TU_DISP3(n, a1,a2,a3) TU_DISP2(n, b1,b2) #define TU_DISP6(n, a1,a2,a3, b1,b2,b3) TU_DISP3(n, a1,a2,a3) TU_DISP3(n, b1,b2,b3) #define TU_DISP7(n, a1,a2,a3,a4, b1,b2,b3 ) TU_DISP4(n, a1,a2,a3,a4) TU_DISP3(n, b1,b2,b3) -#define TU_DISP8(n, a1,a2,a3,a4, b1,b2,b3,b4) TU_DISP4(n, a1,a2,a3,a4) TU_DISP4(n, b1,b2,b3,b4) +#define TU_DISP8(n, a1,a2,a3,a4, b1,b2,b3,b4) TU_DISP4(n, a1,a2,a3,a4) TU_DISP4(n, b1,b2,b3,b4) #define TU_DISP9(n, a1,a2,a3,a4, b1,b2,b3,b4, c1 ) TU_DISP4(n, a1,a2,a3,a4) TU_DISP3(n, b1,b2,b3 ) TU_DISP2(n, b4,c1) #define TU_DISP10(n, a1,a2,a3,a4, b1,b2,b3,b4, c1,c2 ) TU_DISP4(n, a1,a2,a3,a4) TU_DISP4(n, b1,b2,b3,b4) TU_DISP2(n, c1,c2) #define TU_DISP11(n, a1,a2,a3,a4, b1,b2,b3,b4, c1,c2,c3 ) TU_DISP4(n, a1,a2,a3,a4) TU_DISP4(n, b1,b2,b3,b4) TU_DISP3(n, c1,c2,c3) @@ -48,7 +48,7 @@ #define TU_DISPO4(n, v, v2, v3, v4) n(v) n(v2) n(v3) n(v4) #define TU_DISPO5(n, a1,a2,a3, b1,b2 ) TU_DISPO3(n, a1,a2,a3) TU_DISPO2(n, b1,b2) #define TU_DISPO6(n, a1,a2,a3, b1,b2,b3) TU_DISPO3(n, a1,a2,a3) TU_DISPO3(n, b1,b2,b3) -#define TU_DISPO7(n, a1,a2,a3,a4, b1,b2,b3 ) TU_DISPO4(n, a1,a2,a3,a4) TU_DISPO3(n, b1,b2,b3) +#define TU_DISPO7(n, a1,a2,a3,a4, b1,b2,b3 ) TU_DISPO4(n, a1,a2,a3,a4) TU_DISPO3(n, b1,b2,b3) #define TU_DISPO8(n, a1,a2,a3,a4, b1,b2,b3,b4) TU_DISPO4(n, a1,a2,a3,a4) TU_DISPO4(n, b1,b2,b3,b4) #define TU_DISPO9(n, a1,a2,a3,a4, b1,b2,b3,b4, c1) TU_DISPO4(n, a1,a2,a3,a4) TU_DISPO3(n, b1,b2,b3) TU_DISPO2(n, b4,c1) #define TU_DISPO10(n, a1,a2,a3,a4, b1,b2,b3,b4, c1,c2) TU_DISPO4(n, a1,a2,a3,a4) TU_DISPO4(n, b1,b2,b3,b4) TU_DISPO2(n, c1,c2) @@ -61,8 +61,8 @@ #define TU_DISPA(n, a) n a #define TU_DISPA1(n, a, _1) TU_DISPA(n, (TU_EXP a, TU_EXP _1)) -#define TU_DISPA2(n, a, _1, _2) TU_DISPA(n, (TU_EXP a, TU_EXP _1)) TU_DISPA(n, (TU_EXP a, TU_EXP _2)) -#define TU_DISPA3(n, a, _1, _2, _3) TU_DISPA(n, (TU_EXP a, TU_EXP _1)) TU_DISPA(n, (TU_EXP a, TU_EXP _2)) TU_DISPA(n, (TU_EXP a, TU_EXP _3)) +#define TU_DISPA2(n, a, _1, _2) TU_DISPA(n, (TU_EXP a, TU_EXP _1)) TU_DISPA(n, (TU_EXP a, TU_EXP _2)) +#define TU_DISPA3(n, a, _1, _2, _3) TU_DISPA(n, (TU_EXP a, TU_EXP _1)) TU_DISPA(n, (TU_EXP a, TU_EXP _2)) TU_DISPA(n, (TU_EXP a, TU_EXP _3)) #define TU_DISPA4(n, a, a1,a2, b1,b2) TU_DISPA2(n,a, a1,a2) TU_DISPA2(n,a, b1,b2) #define TU_DISPA5(n, a, a1,a2,a3, b1,b2) TU_DISPA3(n,a, a1,a2,a3) TU_DISPA2(n,a, b1,b2) #define TU_DISPA6(n, a, a1,a2,a3, b1,b2,b3) TU_DISPA3(n,a, a1,a2,a3) TU_DISPA3(n,a, b1,b2,b3) diff --git a/src/main.cpp b/src/main.cpp index ec4e9f38..1b09b79b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -258,18 +258,18 @@ int main(int argc, char *argv[]) crate_name = ::std::string(params.infile.begin() + s, params.infile.begin() + e); for(auto& b : crate_name) { - if ('0' <= b && b <= '9') { - } - else if ('A' <= b && b <= 'Z') { - } - else if (b == '_') { - } - else if (b == '-') { - b = '_'; - } - else { - // TODO: Error? - } + if ('0' <= b && b <= '9') { + } + else if ('A' <= b && b <= 'Z') { + } + else if (b == '_') { + } + else if (b == '-') { + b = '_'; + } + else { + // TODO: Error? + } } } crate.m_crate_name = crate_name; @@ -571,14 +571,14 @@ ProgramParams::ProgramParams(int argc, char *argv[]) if( arg[0] != '-' ) { - if (this->infile == "") - { - this->infile = arg; - } - else - { - // TODO: Error - } + if (this->infile == "") + { + this->infile = arg; + } + else + { + // TODO: Error + } } else if( arg[1] != '-' ) { @@ -647,15 +647,15 @@ ProgramParams::ProgramParams(int argc, char *argv[]) } this->crate_path = argv[++i]; } - else if (strcmp(arg, "--out-dir") == 0) { - if (i == argc - 1) { - ::std::cerr << "Flag " << arg << " requires an argument" << ::std::endl; - exit(1); - } - this->output_dir = argv[++i]; - if (this->output_dir == "") { - // TODO: Error? - } + else if (strcmp(arg, "--out-dir") == 0) { + if (i == argc - 1) { + ::std::cerr << "Flag " << arg << " requires an argument" << ::std::endl; + exit(1); + } + this->output_dir = argv[++i]; + if (this->output_dir == "") { + // TODO: Error? + } if( this->output_dir.back() != '/' ) this->output_dir += '/'; } diff --git a/src/mir/check.cpp b/src/mir/check.cpp index 4b9dfd8b..f669623a 100644 --- a/src/mir/check.cpp +++ b/src/mir/check.cpp @@ -689,7 +689,7 @@ void MIR_Validate(const StaticTraitResolve& resolve, const ::HIR::ItemPath& path // TODO: Check suitability of source type (COMPLEX) ), (BinOp, - /* + /* ::HIR::TypeRef tmp_l, tmp_r; const auto& ty_l = state.get_lvalue_type(tmp_l, e.val_l); const auto& ty_r = state.get_lvalue_type(tmp_r, e.val_r); @@ -723,7 +723,7 @@ void MIR_Validate(const StaticTraitResolve& resolve, const ::HIR::ItemPath& path ity_p = &*ty.m_data.as_Pointer().inner; else { MIR_BUG(state, "DstMeta requires a &-ptr as input, got " << ty); - } + } const auto& ity = *ity_p; if( ity.m_data.is_Generic() ) ; @@ -757,7 +757,7 @@ void MIR_Validate(const StaticTraitResolve& resolve, const ::HIR::ItemPath& path ity_p = &*ty.m_data.as_Pointer().inner; else { MIR_BUG(state, "DstPtr requires a &-ptr as input, got " << ty); - } + } const auto& ity = *ity_p; if( ity.m_data.is_Slice() ) ; @@ -785,7 +785,7 @@ void MIR_Validate(const StaticTraitResolve& resolve, const ::HIR::ItemPath& path ity_p = &*te->inner; else { MIR_BUG(state, "DstMeta requires a pointer as output, got " << ty); - } + } assert(ity_p); auto meta = get_metadata_type(state, *ity_p); if( meta == ::HIR::TypeRef() ) diff --git a/src/mir/check_full.cpp b/src/mir/check_full.cpp index cacd9bef..9f32d7ec 100644 --- a/src/mir/check_full.cpp +++ b/src/mir/check_full.cpp @@ -755,9 +755,9 @@ void MIR_Validate_FullValState(::MIR::TypeResolve& mir_res, const ::MIR::Functio TU_MATCHA( (blk.statements[i]), (se), (Assign, if( ENABLE_LEAK_DETECTOR ) - { - // TODO: Check if the target isn't valid. Allow if either invaid, or too complex to know. - } + { + // TODO: Check if the target isn't valid. Allow if either invaid, or too complex to know. + } TU_MATCHA( (se.src), (ve), (Use, state.move_lvalue(mir_res, ve); diff --git a/src/parse/lex.cpp b/src/parse/lex.cpp index 0587e443..9388fca4 100644 --- a/src/parse/lex.cpp +++ b/src/parse/lex.cpp @@ -223,8 +223,8 @@ signed int Lexer::getSymbol() bool issym(Codepoint ch) { - if('0' <= ch.v && ch.v <= '9') - return true; + if('0' <= ch.v && ch.v <= '9') + return true; if( ::std::isalpha(ch.v) ) return true; if( ch == '_' ) @@ -668,7 +668,7 @@ Token Lexer::getTokenInt() { return Token(TOK_EOF); } - throw "Fell off the end of getTokenInt"; + throw "Fell off the end of getTokenInt"; } Token Lexer::getTokenInt_RawString(bool is_byte) @@ -983,7 +983,7 @@ bool Codepoint::isspace() const { case ' ': case 0xC: // ^L case 0x85: - case 0x200E: case 0x200F: // LTR / RTL markers + case 0x200E: case 0x200F: // LTR / RTL markers case 0x2028: // Line Separator case 0x2029: // Paragrah Separator return true; |