From b5cb5a870257bd87a377403278f6a0f8853e7d97 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sat, 22 Oct 2016 19:28:45 +0800 Subject: HIR Typecheck Expr - (minor) Comments about possible quirk with Unsize/CoerceUsized handling --- src/hir_typeck/expr_cs.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp index 091a6c56..1ebdd0c0 100644 --- a/src/hir_typeck/expr_cs.cpp +++ b/src/hir_typeck/expr_cs.cpp @@ -4445,6 +4445,8 @@ namespace { // `Unsize for T` means `T -> U` if( v.trait == context.m_crate.get_lang_item_path(sp, "unsize") ) { + // TODO: Detect if this was a compiler-generated bound, or was actually in the code. + ASSERT_BUG(sp, v.params.m_types.size() == 1, "Incorrect number of parameters for Unsize"); const auto& src_ty = context.get_type(v.impl_ty); const auto& dst_ty = context.get_type(v.params.m_types[0]); @@ -4487,6 +4489,8 @@ namespace { } if( v.trait == context.m_crate.get_lang_item_path(sp, "coerce_unsized") ) { + // TODO: Detect if this was a compiler-generated bound, or was actually in the code. + // `CoerceUnsized for T` means when T is found an U is expected, a coerce can happen ASSERT_BUG(sp, v.params.m_types.size() == 1, "Incorrect number of parameters for Unsize"); const auto& src_ty = context.get_type(v.impl_ty); @@ -4592,6 +4596,8 @@ namespace { } else if( v.trait == context.m_crate.get_lang_item_path(sp, "unsize") ) { + // TODO: Detect if this was a compiler-generated bound, or was actually in the code. + ASSERT_BUG(sp, v.params.m_types.size() == 1, "Incorrect number of parameters for Unsize"); const auto& src_ty = context.get_type(v.impl_ty); const auto& dst_ty = context.get_type(v.params.m_types[0]); -- cgit v1.2.3