summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/hir_typeck/static.cpp12
-rw-r--r--src/mir/from_hir.cpp23
-rw-r--r--src/trans/codegen_c.cpp3
-rw-r--r--src/trans/enumerate.cpp4
4 files changed, 28 insertions, 14 deletions
diff --git a/src/hir_typeck/static.cpp b/src/hir_typeck/static.cpp
index 5fec2477..135c778c 100644
--- a/src/hir_typeck/static.cpp
+++ b/src/hir_typeck/static.cpp
@@ -548,7 +548,7 @@ bool StaticTraitResolve::find_impl__check_crate_raw(
(
),
(TraitBound,
- DEBUG("[find_impl] Trait bound " << e.type << " : " << e.trait);
+ DEBUG("Trait bound " << e.type << " : " << e.trait);
auto b_ty_mono = monomorphise_type_with(sp, e.type, cb_monomorph);
this->expand_associated_types(sp, b_ty_mono);
auto b_tp_mono = monomorphise_traitpath_with(sp, e.trait, cb_monomorph, false);
@@ -559,14 +559,15 @@ bool StaticTraitResolve::find_impl__check_crate_raw(
// TODO: These should be tagged with the source trait and that source trait used for expansion.
this->expand_associated_types(sp, assoc_bound.second);
}
- DEBUG("[find_impl] - b_ty_mono = " << b_ty_mono << ", b_tp_mono = " << b_tp_mono);
+ DEBUG("- b_ty_mono = " << b_ty_mono << ", b_tp_mono = " << b_tp_mono);
// HACK: If the type is '_', assume the bound passes
if( b_ty_mono.m_data.is_Infer() ) {
continue ;
}
// TODO: This is extrememly inefficient (looks up the trait impl 1+N times)
- if( b_tp_mono.m_type_bounds.size() > 0 ) {
+ if( b_tp_mono.m_type_bounds.size() > 0 )
+ {
//
for(const auto& assoc_bound : b_tp_mono.m_type_bounds) {
const auto& aty_name = assoc_bound.first;
@@ -597,10 +598,13 @@ bool StaticTraitResolve::find_impl__check_crate_raw(
}
}
}
- else
+
+ // TODO: Detect if the associated type bound above is from directly the bounded trait, and skip this if it's the case
+ //else
{
bool rv = false;
if( b_ty_mono.m_data.is_Generic() && (b_ty_mono.m_data.as_Generic().binding >> 8) == 2 ) {
+ DEBUG("- Placeholder param " << b_ty_mono << ", magic success");
rv = true;
}
else {
diff --git a/src/mir/from_hir.cpp b/src/mir/from_hir.cpp
index 722e3aa1..4b9b6f5e 100644
--- a/src/mir/from_hir.cpp
+++ b/src/mir/from_hir.cpp
@@ -1524,20 +1524,29 @@ namespace {
for(auto& arg : args)
{
this->visit_node_ptr(arg);
-
- if( args.size() == 1 )
+ if( !m_builder.block_active() )
+ {
+ auto tmp = m_builder.new_temporary(arg->m_res_type);
+ values.push_back( mv$(tmp) );
+ }
+ else if( args.size() == 1 )
{
values.push_back( m_builder.get_result_in_param(arg->span(), arg->m_res_type, /*allow_missing_value=*/true) );
}
else
{
- // NOTE: Have to allocate a new temporary because ordering matters
- auto tmp = m_builder.new_temporary(arg->m_res_type);
- if( m_builder.block_active() )
+ auto res = m_builder.get_result(arg->span());
+ if( auto* e = res.opt_Constant() )
{
- m_builder.push_stmt_assign( arg->span(), tmp.clone(), m_builder.get_result(arg->span()) );
+ values.push_back( mv$(*e) );
+ }
+ else
+ {
+ // NOTE: Have to allocate a new temporary because ordering matters
+ auto tmp = m_builder.new_temporary(arg->m_res_type);
+ m_builder.push_stmt_assign( arg->span(), tmp.clone(), mv$(res) );
+ values.push_back( mv$(tmp) );
}
- values.push_back( mv$(tmp) );
}
if(const auto* e = values.back().opt_LValue() )
diff --git a/src/trans/codegen_c.cpp b/src/trans/codegen_c.cpp
index f44c9980..5c56e4d1 100644
--- a/src/trans/codegen_c.cpp
+++ b/src/trans/codegen_c.cpp
@@ -1498,9 +1498,8 @@ namespace {
(BinOp,
emit_lvalue(e.dst);
m_of << " = ";
- MIR_ASSERT(mir_res, ve.val_l.is_LValue() || ve.val_r.is_LValue(), "");
::HIR::TypeRef tmp;
- const auto& ty = mir_res.get_lvalue_type(tmp, ve.val_l.is_LValue() ? ve.val_l.as_LValue() : ve.val_r.as_LValue());
+ const auto& ty = ve.val_l.is_LValue() ? mir_res.get_lvalue_type(tmp, ve.val_l.as_LValue()) : tmp = mir_res.get_const_type(ve.val_l.as_Constant());
if( ty.m_data.is_Borrow() ) {
m_of << "(slice_cmp("; emit_param(ve.val_l); m_of << ", "; emit_param(ve.val_r); m_of << ")";
switch(ve.op)
diff --git a/src/trans/enumerate.cpp b/src/trans/enumerate.cpp
index 89846344..e4560ffa 100644
--- a/src/trans/enumerate.cpp
+++ b/src/trans/enumerate.cpp
@@ -1150,7 +1150,7 @@ namespace {
::std::vector<::HIR::TypeRef> best_impl_params;
const ::HIR::TraitImpl* best_impl = nullptr;
resolve.find_impl(sp, e.trait.m_path, e.trait.m_params, *e.type, [&](auto impl_ref, auto is_fuzz) {
- DEBUG("Found " << impl_ref);
+ 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");
@@ -1201,6 +1201,8 @@ namespace {
else
BUG(sp, "Parameter " << i << " unset");
}
+ if( is_spec )
+ DEBUG("- Specialisable");
return !is_spec;
}
return false;