summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/hir_conv/constant_evaluation.cpp2
-rw-r--r--src/hir_expand/const_eval_full.cpp10
-rw-r--r--src/trans/enumerate.cpp16
3 files changed, 23 insertions, 5 deletions
diff --git a/src/hir_conv/constant_evaluation.cpp b/src/hir_conv/constant_evaluation.cpp
index e8138169..4686139d 100644
--- a/src/hir_conv/constant_evaluation.cpp
+++ b/src/hir_conv/constant_evaluation.cpp
@@ -447,7 +447,7 @@ namespace {
TU_MATCH_DEF( ::HIR::TypeRef::Data, (m_exp_type.m_data), (te),
(
- ERROR(node.span(), E0000, "Invalid expected type for a &-ptr - " << m_exp_type);
+ //ERROR(node.span(), E0000, "Invalid expected type for a &-ptr - " << m_exp_type);
),
(Infer,
),
diff --git a/src/hir_expand/const_eval_full.cpp b/src/hir_expand/const_eval_full.cpp
index 04575a6e..39bbce02 100644
--- a/src/hir_expand/const_eval_full.cpp
+++ b/src/hir_expand/const_eval_full.cpp
@@ -468,10 +468,14 @@ namespace {
if( e.type != ::HIR::BorrowType::Shared ) {
MIR_BUG(state, "Only shared borrows are allowed in constants");
}
-
- if( e.val.is_Static() ) {
+ if( const auto* p = e.val.opt_Deref() ) {
+ if( p->val->is_Deref() )
+ MIR_TODO(state, "Undo nested deref coercion - " << *p->val);
+ val = read_lval(*p->val);
+ }
+ else if( const auto* p = e.val.opt_Static() ) {
// Borrow of a static, emit BorrowOf with the same path
- val = ::HIR::Literal::make_BorrowOf( e.val.as_Static().clone() );
+ val = ::HIR::Literal::make_BorrowOf( p->clone() );
}
else {
auto inner_val = read_lval(e.val);
diff --git a/src/trans/enumerate.cpp b/src/trans/enumerate.cpp
index adc9575a..b62b21e8 100644
--- a/src/trans/enumerate.cpp
+++ b/src/trans/enumerate.cpp
@@ -93,11 +93,16 @@ TransList Trans_Enumerate_Main(const ::HIR::Crate& crate)
namespace {
void Trans_Enumerate_Public_Mod(EnumState& state, ::HIR::Module& mod, ::HIR::SimplePath mod_path, bool is_visible)
{
+ // TODO: Make this configurable, and debug cases where it breaks
+ // (needs to be `true` currently)
+ // - Errors likely caused by re-exports making items visible that
+ // aren't otherwise.
const bool EMIT_ALL = true;
for(auto& vi : mod.m_value_items)
{
TU_MATCHA( (vi.second->ent), (e),
(Import,
+ // TODO: If visible, ensure that target is visited.
),
(StructConstant,
),
@@ -108,6 +113,11 @@ namespace {
(Static,
if( EMIT_ALL || (is_visible && vi.second->is_public) )
{
+ // HACK: Refuse to emit unused generated statics
+ // - Needed because all items are visited (regardless of
+ // visibility)
+ if(e.m_type.m_data.is_Infer())
+ continue ;
//state.enum_static(mod_path + vi.first, *e);
auto* ptr = state.rv.add_static(mod_path + vi.first);
if(ptr)
@@ -1621,10 +1631,14 @@ void Trans_Enumerate_FillFrom(EnumState& state, const ::HIR::Function& function,
void Trans_Enumerate_FillFrom(EnumState& state, const ::HIR::Static& item, TransList_Static& out_stat, Trans_Params pp)
{
TRACE_FUNCTION;
- if( item.m_value.m_mir )
+ /*if( item.m_value.m_mir )
{
Trans_Enumerate_FillFrom_MIR(state, *item.m_value.m_mir, pp);
}
+ else*/ if( item.m_type.m_data.is_Infer() )
+ {
+ BUG(Span(), "Enumerating static with no assigned type (unused elevated literal)");
+ }
else if( ! item.m_value_res.is_Invalid() )
{
Trans_Enumerate_FillFrom_Literal(state, item.m_value_res, pp);