summaryrefslogtreecommitdiff
path: root/src/trans/enumerate.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2018-08-04 15:35:46 +0800
committerJohn Hodge <tpg@mutabah.net>2018-08-04 15:36:26 +0800
commitcd56b774f425b0c842556c3ddeeba708b0fe309f (patch)
tree2000d80c60c67e4f2d4f0d1906a8e0793e478ec5 /src/trans/enumerate.cpp
parent5ad533aca561e3daaaf5c7e492ccc5b6a3c99d1b (diff)
downloadmrust-cd56b774f425b0c842556c3ddeeba708b0fe309f.tar.gz
Trans - Add auto-generated Clone impls (only for Copy types currently)
Diffstat (limited to 'src/trans/enumerate.cpp')
-rw-r--r--src/trans/enumerate.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/trans/enumerate.cpp b/src/trans/enumerate.cpp
index 4e04ddf9..e16f9dcf 100644
--- a/src/trans/enumerate.cpp
+++ b/src/trans/enumerate.cpp
@@ -1209,7 +1209,7 @@ namespace {
DEBUG("[get_ent_fullpath] Found " << impl_ref);
//ASSERT_BUG(sp, !is_fuzz, "Fuzzy match not allowed here");
if( ! impl_ref.m_data.is_TraitImpl() ) {
- DEBUG("Trans impl search found an invalid impl type");
+ DEBUG("Trans impl search found an invalid impl type - " << impl_ref.m_data.tag_str());
is_dynamic = true;
// TODO: This can only really happen if it's a trait object magic impl, which should become a vtable lookup.
return true;
@@ -1380,6 +1380,14 @@ void Trans_Enumerate_FillFrom_Path(EnumState& state, const ::HIR::Path& path, co
{
// Must have been a dynamic dispatch request, just leave as-is
}
+ // <* as Clone>::clone
+ else if( TARGETVER_1_29 && path_mono.m_data.is_UfcsKnown() && path_mono.m_data.as_UfcsKnown().trait == state.crate.get_lang_item_path_opt("clone") )
+ {
+ const auto& pe = path_mono.m_data.as_UfcsKnown();
+ ASSERT_BUG(sp, pe.item == "clone", "");
+ // Add this type to a list of types that will have the impl auto-generated
+ state.rv.auto_clone_impls.insert( pe.type->clone() );
+ }
else
{
BUG(sp, "AutoGenerate returned for unknown path type - " << path_mono);
@@ -1692,4 +1700,3 @@ void Trans_Enumerate_FillFrom(EnumState& state, const ::HIR::Static& item, Trans
out_stat.ptr = &item;
out_stat.pp = mv$(pp);
}
-