diff options
Diffstat (limited to 'src/ast/ast.cpp')
-rw-r--r-- | src/ast/ast.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp index aadade4f..b6bc74a2 100644 --- a/src/ast/ast.cpp +++ b/src/ast/ast.cpp @@ -221,6 +221,16 @@ const Module& Crate::get_root_module(const ::std::string& name) const { throw ParseError::Generic("crate name unknown");
}
+bool Crate::is_trait_implicit(const Path& trait) const
+{
+ // 1. Handle lang_item traits (e.g. FhantomFn)
+ if( m_lang_item_PhantomFn.is_valid() && trait.equal_no_generic( m_lang_item_PhantomFn ) >= 0 )
+ {
+ return true;
+ }
+ return false;
+}
+
/**
* \brief Checks if a type implements the provided wildcard trait
* \param trait Trait path
@@ -267,6 +277,12 @@ bool Crate::find_impl(const Path& trait, const TypeRef& type, Impl** out_impl) if(out_impl) *out_impl = nullptr;
+ if( is_trait_implicit(trait) )
+ {
+ if(out_impl) throw CompileError::BugCheck("find_impl - Asking for concrete impl of PhantomFn");
+ return true;
+ }
+
// 0. Handle generic bounds
// TODO: Handle more complex bounds like "[T]: Trait"
if( type.is_type_param() )
|