diff options
author | John Hodge <tpg@ucc.asn.au> | 2017-09-10 18:11:20 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2017-09-10 18:11:20 +0800 |
commit | 22ce602788b285b303854a095a0c340274a76b06 (patch) | |
tree | 5e5b1562c69bfca32ab0ddfa21953eb7cb768cb0 /src/trans/enumerate.cpp | |
parent | 24fe34bfd1fa06d4aacba07e752134d5774884be (diff) | |
download | mrust-22ce602788b285b303854a095a0c340274a76b06.tar.gz |
Consteval - Litle tweaks
Diffstat (limited to 'src/trans/enumerate.cpp')
-rw-r--r-- | src/trans/enumerate.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
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); |