diff options
author | John Hodge <tpg@mutabah.net> | 2016-07-07 19:10:28 +1000 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-07-07 19:10:28 +1000 |
commit | 54a2382a5d6ba587f565f290404f4405035533da (patch) | |
tree | 0980e32f4b4591a2041eaf5c001e421c827b5633 /src | |
parent | 01855eb0d44ca9b30f8a4a9604dadfa9eb55e218 (diff) | |
download | mrust-54a2382a5d6ba587f565f290404f4405035533da.tar.gz |
HIR Typecheck CS - Sized trait
Diffstat (limited to 'src')
-rw-r--r-- | src/hir_typeck/helpers.cpp | 22 |
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"); |