summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2019-11-03 11:36:39 +0800
committerJohn Hodge <tpg@mutabah.net>2019-11-03 11:36:39 +0800
commit0a2ea1a773c54c3a4b02edfeb19123aa4224c735 (patch)
treee9b0f49d21b1ded84577461b345f82d97683c666 /src
parentf51e124b2c908aac3f2ae6c03e9fa05034b97b7e (diff)
downloadmrust-0a2ea1a773c54c3a4b02edfeb19123aa4224c735.tar.gz
Codegen C - Fix compilation errors on MSVC (and some warnings on GCC)
Diffstat (limited to 'src')
-rw-r--r--src/trans/codegen_c.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/trans/codegen_c.cpp b/src/trans/codegen_c.cpp
index 631db28b..33e0bbbf 100644
--- a/src/trans/codegen_c.cpp
+++ b/src/trans/codegen_c.cpp
@@ -2191,13 +2191,20 @@ namespace {
MIR_TODO(*m_mir_res, "Handle BorrowData (emit_literal) - " << *e);
),
(String,
- m_of << "{ ";
+ bool is_slice
+ = TU_TEST2(ty.m_data, Borrow, .inner->m_data, Primitive, == HIR::CoreType::Str)
+ || TU_TEST1(ty.m_data, Borrow, .inner->m_data.is_Slice())
+ ;
+ bool is_wrapped = is_slice
+ || ty.m_data.is_Array()
+ ;
+ if( is_wrapped )
+ m_of << "{ ";
this->print_escaped_string(e);
- // TODO: Better type checking?
- if( !ty.m_data.is_Array() ) {
+ if( is_slice )
m_of << ", " << e.size();
- }
- m_of << "}";
+ if( is_wrapped )
+ m_of << "}";
)
)
}