summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-08-24 10:56:22 +0800
committerJohn Hodge <tpg@mutabah.net>2016-08-24 10:56:22 +0800
commitf9763ded502656e173f4c4dc3189142e8254987e (patch)
treea9e002af66db09f44db41c6701023a41e66ca685 /src
parent140a8dd00437f3476096885319a955ef99e1618e (diff)
downloadmrust-f9763ded502656e173f4c4dc3189142e8254987e.tar.gz
MIR Gen - Trait methods in PathValue
Diffstat (limited to 'src')
-rw-r--r--src/mir/from_hir.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/mir/from_hir.cpp b/src/mir/from_hir.cpp
index fd0de5a2..e8b1177b 100644
--- a/src/mir/from_hir.cpp
+++ b/src/mir/from_hir.cpp
@@ -1217,7 +1217,26 @@ namespace {
)
),
(UfcsKnown,
- TODO(sp, "PathValue - UfcsKnown");
+ // Check what item type this is (from the trait)
+ const auto& tr = m_builder.crate().get_trait_by_path(sp, pe.trait.m_path);
+ auto it = tr.m_values.find(pe.item);
+ ASSERT_BUG(sp, it != tr.m_values.end(), "Cannot find trait item for " << node.m_path);
+ TU_MATCHA( (it->second), (e),
+ (None,
+ BUG(sp, "Path " << node.m_path << " points to a None trait item");
+ ),
+ (Constant,
+ TODO(sp, "Associated constants - " << node.m_path);
+ ),
+ (Static,
+ TODO(sp, "Associated statics (non-rustc) - " << node.m_path);
+ ),
+ (Function,
+ auto tmp = m_builder.new_temporary( node.m_res_type.clone() );
+ m_builder.push_stmt_assign( sp, tmp.clone(), ::MIR::Constant::make_ItemAddr(node.m_path.clone()) );
+ m_builder.set_result( sp, mv$(tmp) );
+ )
+ )
),
(UfcsUnknown,
BUG(sp, "PathValue - Encountered UfcsUnknown - " << node.m_path);