summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-07-07 19:10:28 +1000
committerJohn Hodge <tpg@mutabah.net>2016-07-07 19:10:28 +1000
commit54a2382a5d6ba587f565f290404f4405035533da (patch)
tree0980e32f4b4591a2041eaf5c001e421c827b5633 /src
parent01855eb0d44ca9b30f8a4a9604dadfa9eb55e218 (diff)
downloadmrust-54a2382a5d6ba587f565f290404f4405035533da.tar.gz
HIR Typecheck CS - Sized trait
Diffstat (limited to 'src')
-rw-r--r--src/hir_typeck/helpers.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/hir_typeck/helpers.cpp b/src/hir_typeck/helpers.cpp
index bcc2fbde..9646b239 100644
--- a/src/hir_typeck/helpers.cpp
+++ b/src/hir_typeck/helpers.cpp
@@ -909,6 +909,28 @@ bool TraitResolution::find_trait_impls(const Span& sp,
const auto& type = this->m_ivars.get_type(ty);
TRACE_FUNCTION_F("trait = " << trait << ", type = " << type);
+ if( trait == this->m_crate.get_lang_item_path(sp, "sized") ) {
+ TU_MATCH_DEF(::HIR::TypeRef::Data, (type.m_data), (e),
+ (
+ // Any unknown - it's sized
+ ),
+ (Primitive,
+ if( e == ::HIR::CoreType::Str )
+ return false;
+ ),
+ (Slice,
+ return false;
+ ),
+ (Path,
+ // ... TODO (Search the innards or bounds)
+ ),
+ (TraitObject,
+ return false;
+ )
+ )
+ return callback( type, ::HIR::PathParams(), {} );
+ }
+
// Closures are magical. They're unnamable and all trait impls come from within the compiler
TU_IFLET(::HIR::TypeRef::Data, type.m_data, Closure, e,
const auto trait_fn = this->m_crate.get_lang_item_path(sp, "fn");