From 5ad533aca561e3daaaf5c7e492ccc5b6a3c99d1b Mon Sep 17 00:00:00 2001 From: John Hodge Date: Fri, 3 Aug 2018 23:25:55 +0800 Subject: HIR Typecheck - Handle UfcsUnknown in fuzzy matching --- src/hir_expand/ufcs_everything.cpp | 8 ++++---- src/hir_typeck/expr_check.cpp | 8 ++++---- src/hir_typeck/helpers.cpp | 4 ++++ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/hir_expand/ufcs_everything.cpp b/src/hir_expand/ufcs_everything.cpp index 629dd284..97947f4a 100644 --- a/src/hir_expand/ufcs_everything.cpp +++ b/src/hir_expand/ufcs_everything.cpp @@ -353,10 +353,10 @@ namespace { { case ::HIR::ExprNode_BinOp::Op::CmpEqu: { langitem = "eq"; method = "eq"; } if(0) case ::HIR::ExprNode_BinOp::Op::CmpNEqu:{ langitem = "eq"; method = "ne"; } if(0) - case ::HIR::ExprNode_BinOp::Op::CmpLt: { langitem = "ord"; method = "lt"; } if(0) - case ::HIR::ExprNode_BinOp::Op::CmpLtE: { langitem = "ord"; method = "le"; } if(0) - case ::HIR::ExprNode_BinOp::Op::CmpGt: { langitem = "ord"; method = "gt"; } if(0) - case ::HIR::ExprNode_BinOp::Op::CmpGtE: { langitem = "ord"; method = "ge"; } + case ::HIR::ExprNode_BinOp::Op::CmpLt: { langitem = TARGETVER_1_29 ? "partial_ord" : "ord"; method = "lt"; } if(0) + case ::HIR::ExprNode_BinOp::Op::CmpLtE: { langitem = TARGETVER_1_29 ? "partial_ord" : "ord"; method = "le"; } if(0) + case ::HIR::ExprNode_BinOp::Op::CmpGt: { langitem = TARGETVER_1_29 ? "partial_ord" : "ord"; method = "gt"; } if(0) + case ::HIR::ExprNode_BinOp::Op::CmpGtE: { langitem = TARGETVER_1_29 ? "partial_ord" : "ord"; method = "ge"; } { // 1. Check if the types are valid for primitive comparison if( ty_l == ty_r ) { diff --git a/src/hir_typeck/expr_check.cpp b/src/hir_typeck/expr_check.cpp index 985fe15f..8a199557 100644 --- a/src/hir_typeck/expr_check.cpp +++ b/src/hir_typeck/expr_check.cpp @@ -208,10 +208,10 @@ namespace { { case ::HIR::ExprNode_BinOp::Op::CmpEqu: item_name = "eq"; break; case ::HIR::ExprNode_BinOp::Op::CmpNEqu: item_name = "eq"; break; - case ::HIR::ExprNode_BinOp::Op::CmpLt: item_name = "ord"; break; - case ::HIR::ExprNode_BinOp::Op::CmpLtE: item_name = "ord"; break; - case ::HIR::ExprNode_BinOp::Op::CmpGt: item_name = "ord"; break; - case ::HIR::ExprNode_BinOp::Op::CmpGtE: item_name = "ord"; break; + case ::HIR::ExprNode_BinOp::Op::CmpLt: item_name = TARGETVER_1_29 ? "partial_ord" : "ord"; break; + case ::HIR::ExprNode_BinOp::Op::CmpLtE: item_name = TARGETVER_1_29 ? "partial_ord" : "ord"; break; + case ::HIR::ExprNode_BinOp::Op::CmpGt: item_name = TARGETVER_1_29 ? "partial_ord" : "ord"; break; + case ::HIR::ExprNode_BinOp::Op::CmpGtE: item_name = TARGETVER_1_29 ? "partial_ord" : "ord"; break; default: break; } assert(item_name); diff --git a/src/hir_typeck/helpers.cpp b/src/hir_typeck/helpers.cpp index 0e839219..1383300f 100644 --- a/src/hir_typeck/helpers.cpp +++ b/src/hir_typeck/helpers.cpp @@ -2812,6 +2812,10 @@ bool TraitResolution::find_trait_impls_crate(const Span& sp, if( ty.m_data.is_Infer() && !ty.m_data.as_Infer().is_lit() ) { return ::HIR::Compare::Fuzzy; } + // If the RHS is an unbound UfcsKnown, also fuzzy + if( ty.m_data.is_Path() && ty.m_data.as_Path().binding.is_Unbound() ) { + return ::HIR::Compare::Fuzzy; + } return ::HIR::Compare::Unequal; } }; -- cgit v1.2.3