summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/hir/from_ast.cpp10
-rw-r--r--src/hir/hir.hpp8
-rw-r--r--src/hir/serialise.cpp9
-rw-r--r--src/hir/type.cpp2
-rw-r--r--src/hir/type.hpp2
-rw-r--r--src/hir/visitor.cpp3
-rw-r--r--src/hir_conv/bind.cpp4
-rw-r--r--src/hir_conv/constant_evaluation.cpp2
-rw-r--r--src/hir_conv/markings.cpp1
-rw-r--r--src/hir_typeck/expr_check.cpp9
-rw-r--r--src/hir_typeck/expr_cs.cpp18
-rw-r--r--src/hir_typeck/helpers.cpp13
-rw-r--r--src/hir_typeck/outer.cpp4
-rw-r--r--src/hir_typeck/static.cpp15
-rw-r--r--src/mir/from_hir.cpp3
-rw-r--r--src/mir/from_hir_match.cpp15
-rw-r--r--src/resolve/absolute.cpp44
-rw-r--r--src/resolve/index.cpp13
-rw-r--r--src/resolve/use.cpp3
-rw-r--r--src/trans/auto_impls.cpp6
-rw-r--r--src/trans/codegen.cpp3
-rw-r--r--src/trans/codegen_c.cpp11
-rw-r--r--src/trans/enumerate.cpp16
23 files changed, 178 insertions, 36 deletions
diff --git a/src/hir/from_ast.cpp b/src/hir/from_ast.cpp
index 768593c4..fb8096f7 100644
--- a/src/hir/from_ast.cpp
+++ b/src/hir/from_ast.cpp
@@ -1187,6 +1187,7 @@ namespace {
::std::vector< ::HIR::TraitPath> trait_bounds;
::std::string lifetime_bound;
auto gps = LowerHIR_GenericParams(i.params(), &is_sized);
+
for(auto& b : gps.m_bounds)
{
TU_MATCH(::HIR::GenericBound, (b), (be),
@@ -1463,6 +1464,15 @@ void _add_mod_val_item(::HIR::Module& mod, ::std::string name, bool is_pub, ::H
_add_mod_ns_item( mod, item.name, item.is_pub, ::HIR::TypeItem::make_Import({ ::HIR::SimplePath(e.name, {}), false, 0} ) );
),
(Type,
+ if( e.type().m_data.is_Any() )
+ {
+ if( !e.params().lft_params().empty() || !e.params().ty_params().empty() || !e.params().bounds().empty() )
+ {
+ ERROR(item.data.span, E0000, "Generics on extern type");
+ }
+ _add_mod_ns_item(mod, item.name, item.is_pub, ::HIR::ExternType {});
+ break;
+ }
_add_mod_ns_item( mod, item.name, item.is_pub, ::HIR::TypeItem::make_TypeAlias( LowerHIR_TypeAlias(e) ) );
),
(Struct,
diff --git a/src/hir/hir.hpp b/src/hir/hir.hpp
index fc4a19e8..48787583 100644
--- a/src/hir/hir.hpp
+++ b/src/hir/hir.hpp
@@ -215,6 +215,13 @@ struct StructMarkings
unsigned int coerce_param = ~0u;
};
+class ExternType
+{
+public:
+ // TODO: do extern types need any associated data?
+ TraitMarkings m_markings;
+};
+
class Enum
{
public:
@@ -367,6 +374,7 @@ TAGGED_UNION(TypeItem, Import,
(Import, struct { ::HIR::SimplePath path; bool is_variant; unsigned int idx; }),
(Module, Module),
(TypeAlias, TypeAlias), // NOTE: These don't introduce new values
+ (ExternType, ExternType),
(Enum, Enum),
(Struct, Struct),
(Union, Union),
diff --git a/src/hir/serialise.cpp b/src/hir/serialise.cpp
index c91cf93f..e5fe8ed5 100644
--- a/src/hir/serialise.cpp
+++ b/src/hir/serialise.cpp
@@ -834,6 +834,10 @@
(Union,
m_out.write_tag(6);
serialise(e);
+ ),
+ (ExternType,
+ m_out.write_tag(7);
+ serialise(e);
)
)
}
@@ -1020,6 +1024,11 @@
serialise(item.m_markings);
}
+ void serialise(const ::HIR::ExternType& item)
+ {
+ TRACE_FUNCTION_F("ExternType");
+ serialise(item.m_markings);
+ }
void serialise(const ::HIR::Trait& item)
{
TRACE_FUNCTION_F("_trait:");
diff --git a/src/hir/type.cpp b/src/hir/type.cpp
index 2c24e3e1..981ed0b3 100644
--- a/src/hir/type.cpp
+++ b/src/hir/type.cpp
@@ -85,6 +85,7 @@ void ::HIR::TypeRef::fmt(::std::ostream& os) const
TU_MATCH(::HIR::TypeRef::TypePathBinding, (e.binding), (be),
(Unbound, os << "/*?*/";),
(Opaque, os << "/*O*/";),
+ (ExternType, os << "/*X*/";),
(Struct, os << "/*S*/";),
(Union, os << "/*U*/";),
(Enum, os << "/*E*/";)
@@ -782,6 +783,7 @@ bool ::HIR::TypeRef::match_test_generics(const Span& sp, const ::HIR::TypeRef& x
TU_MATCH(::HIR::TypeRef::TypePathBinding, (*this), (e),
(Unbound, return ::HIR::TypeRef::TypePathBinding::make_Unbound({}); ),
(Opaque , return ::HIR::TypeRef::TypePathBinding::make_Opaque({}); ),
+ (ExternType, return ::HIR::TypeRef::TypePathBinding(e); ),
(Struct, return ::HIR::TypeRef::TypePathBinding(e); ),
(Union , return ::HIR::TypeRef::TypePathBinding(e); ),
(Enum , return ::HIR::TypeRef::TypePathBinding(e); )
diff --git a/src/hir/type.hpp b/src/hir/type.hpp
index 480b32c4..0c98773f 100644
--- a/src/hir/type.hpp
+++ b/src/hir/type.hpp
@@ -19,6 +19,7 @@
namespace HIR {
+class ExternType;
class Struct;
class Union;
class Enum;
@@ -152,6 +153,7 @@ public:
TAGGED_UNION_EX(TypePathBinding, (), Unbound, (
(Unbound, struct {}), // Not yet bound, either during lowering OR during resolution (when associated and still being resolved)
(Opaque, struct {}), // Opaque, i.e. An associated type of a generic (or Self in a trait)
+ (ExternType, const ::HIR::ExternType*),
(Struct, const ::HIR::Struct*),
(Union, const ::HIR::Union*),
(Enum, const ::HIR::Enum*)
diff --git a/src/hir/visitor.cpp b/src/hir/visitor.cpp
index 5c9c0dfa..f23bae88 100644
--- a/src/hir/visitor.cpp
+++ b/src/hir/visitor.cpp
@@ -47,6 +47,9 @@ void ::HIR::Visitor::visit_module(::HIR::ItemPath p, ::HIR::Module& mod)
DEBUG("type " << name);
this->visit_type_alias(p + name, e);
),
+ (ExternType,
+ DEBUG("extern type " << name);
+ ),
(Enum,
DEBUG("enum " << name);
this->visit_enum(p + name, e);
diff --git a/src/hir_conv/bind.cpp b/src/hir_conv/bind.cpp
index 9b5043f4..b616a64f 100644
--- a/src/hir_conv/bind.cpp
+++ b/src/hir_conv/bind.cpp
@@ -456,6 +456,10 @@ namespace {
(TypeAlias,
BUG(sp, "TypeAlias encountered after `Resolve Type Aliases` - " << ty);
),
+ (ExternType,
+ e.binding = ::HIR::TypeRef::TypePathBinding::make_ExternType(&e3);
+ DEBUG("- " << ty);
+ ),
(Struct,
fix_param_count(sp, pe, e3.m_params, pe.m_params);
e.binding = ::HIR::TypeRef::TypePathBinding::make_Struct(&e3);
diff --git a/src/hir_conv/constant_evaluation.cpp b/src/hir_conv/constant_evaluation.cpp
index 43a64bbb..3d1bf4a5 100644
--- a/src/hir_conv/constant_evaluation.cpp
+++ b/src/hir_conv/constant_evaluation.cpp
@@ -169,6 +169,8 @@ namespace {
),
(Enum,
),
+ (ExternType,
+ ),
(TypeAlias,
)
)
diff --git a/src/hir_conv/markings.cpp b/src/hir_conv/markings.cpp
index df7fbd36..d43db2b5 100644
--- a/src/hir_conv/markings.cpp
+++ b/src/hir_conv/markings.cpp
@@ -333,6 +333,7 @@ public:
TU_MATCHA( (te.binding), (tpb),
(Unbound, ),
(Opaque, ),
+ (ExternType, markings_ptr = &tpb->m_markings; ),
(Struct, markings_ptr = &tpb->m_markings; ),
(Union , markings_ptr = &tpb->m_markings; ),
(Enum , markings_ptr = &tpb->m_markings; )
diff --git a/src/hir_typeck/expr_check.cpp b/src/hir_typeck/expr_check.cpp
index adb3c426..7d5a9c6f 100644
--- a/src/hir_typeck/expr_check.cpp
+++ b/src/hir_typeck/expr_check.cpp
@@ -462,6 +462,9 @@ namespace {
(Union,
BUG(sp, "Union in TupleVariant");
),
+ (ExternType,
+ BUG(sp, "ExternType in TupleVariant");
+ ),
(Struct,
ASSERT_BUG(sp, e->m_data.is_Tuple(), "Pointed struct in TupleVariant (" << node.m_path << ") isn't a Tuple");
fields_ptr = &e->m_data.as_Tuple();
@@ -522,6 +525,9 @@ namespace {
(Union,
TODO(sp, "Union in StructLiteral");
),
+ (ExternType,
+ BUG(sp, "ExternType in StructLiteral");
+ ),
(Struct,
if( e->m_data.is_Unit() )
{
@@ -611,6 +617,9 @@ namespace {
(Union,
BUG(sp, "Union with _UnitVariant");
),
+ (ExternType,
+ BUG(sp, "ExternType with _UnitVariant");
+ ),
(Struct,
assert( e->m_data.is_Unit() );
)
diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp
index 4a53bd4d..291dcd84 100644
--- a/src/hir_typeck/expr_cs.cpp
+++ b/src/hir_typeck/expr_cs.cpp
@@ -1144,6 +1144,9 @@ namespace {
),
(Union,
BUG(sp, "TupleVariant pointing to a union");
+ ),
+ (ExternType,
+ BUG(sp, "TupleVariant pointing to a extern type");
)
)
assert(fields_ptr);
@@ -1216,6 +1219,7 @@ namespace {
TU_MATCH(::HIR::TypeRef::TypePathBinding, (ty.m_data.as_Path().binding), (e),
(Unbound, ),
(Opaque, ),
+ (ExternType, ), // Error?
(Enum,
const auto& var_name = ty_path.m_path.m_components.back();
const auto& enm = *e;
@@ -4900,6 +4904,10 @@ void Context::require_sized(const Span& sp, const ::HIR::TypeRef& ty_)
// Already checked by type_is_sized
params_def = nullptr;
),
+ (ExternType,
+ static ::HIR::GenericParams empty_params;
+ params_def = &empty_params;
+ ),
(Enum,
params_def = &pb->m_params;
),
@@ -5551,6 +5559,13 @@ namespace {
(Opaque,
// Handled above in bounded
),
+ (ExternType,
+ // Must be equal
+ if( sbe == dbe )
+ {
+ return CoerceResult::Equality;
+ }
+ ),
(Enum,
// Must be equal
if( sbe == dbe )
@@ -6474,6 +6489,9 @@ namespace {
// TODO: Check bounds?
return false;
),
+ (ExternType,
+ return false;
+ ),
(Struct,
if(pbe_a != pbe_b) return false;
if( !pbe_a->m_struct_markings.can_unsize )
diff --git a/src/hir_typeck/helpers.cpp b/src/hir_typeck/helpers.cpp
index 1af269ad..5c0696e3 100644
--- a/src/hir_typeck/helpers.cpp
+++ b/src/hir_typeck/helpers.cpp
@@ -2477,6 +2477,9 @@ bool TraitResolution::find_trait_impls_crate(const Span& sp,
),
(Opaque,
),
+ (ExternType,
+ markings = &tpb->m_markings;
+ ),
(Struct,
markings = &tpb->m_markings;
),
@@ -2710,6 +2713,9 @@ bool TraitResolution::find_trait_impls_crate(const Span& sp,
),
(Union,
TODO(sp, "Check auto trait destructure on union " << type);
+ ),
+ (ExternType,
+ TODO(sp, "Check auto trait destructure on extern type " << type);
)
)
DEBUG("- Nothing failed, calling callback");
@@ -3141,6 +3147,10 @@ bool TraitResolution::trait_contains_type(const Span& sp, const ::HIR::GenericPa
(Opaque,
// TODO: Check bounds
),
+ (ExternType,
+ // Is it sized? No.
+ return ::HIR::Compare::Unequal;
+ ),
(Enum,
// HAS to be Sized
),
@@ -4323,6 +4333,9 @@ bool TraitResolution::find_field(const Span& sp, const ::HIR::TypeRef& ty, const
(Enum,
// No fields on enums either
),
+ (ExternType,
+ // No fields on extern types
+ ),
(Union,
const auto& unm = *be;
const auto& params = e.path.m_data.as_Generic().m_params;
diff --git a/src/hir_typeck/outer.cpp b/src/hir_typeck/outer.cpp
index 63e92d8b..6a8e8b35 100644
--- a/src/hir_typeck/outer.cpp
+++ b/src/hir_typeck/outer.cpp
@@ -52,6 +52,10 @@ namespace {
(TypeAlias,
BUG(sp, "Type path pointed to type alias - " << path);
),
+ (ExternType,
+ static ::HIR::GenericParams empty_params;
+ return empty_params;
+ ),
(Module,
BUG(sp, "Type path pointed to module - " << path);
),
diff --git a/src/hir_typeck/static.cpp b/src/hir_typeck/static.cpp
index 457bd44e..ce7faf6c 100644
--- a/src/hir_typeck/static.cpp
+++ b/src/hir_typeck/static.cpp
@@ -851,6 +851,9 @@ bool StaticTraitResolve::find_impl__check_crate(
),
(Union,
TODO(sp, "Check auto trait destructure on union " << type);
+ ),
+ (ExternType,
+ TODO(sp, "Check auto trait destructure on extern type " << type);
)
)
DEBUG("- Nothing failed, calling callback");
@@ -1629,6 +1632,10 @@ bool StaticTraitResolve::type_is_sized(const Span& sp, const ::HIR::TypeRef& ty)
return false;
}
),
+ (ExternType,
+ // Extern types aren't Sized
+ return false;
+ ),
(Enum,
),
(Union,
@@ -1732,6 +1739,10 @@ bool StaticTraitResolve::type_is_impossible(const Span& sp, const ::HIR::TypeRef
(Union,
// TODO: Check all variants? Or just one?
TODO(sp, "type_is_impossible for union " << ty);
+ ),
+ (ExternType,
+ // Extern types are possible, just not usable
+ return false;
)
)
return true;
@@ -2032,6 +2043,10 @@ bool StaticTraitResolve::type_needs_drop_glue(const Span& sp, const ::HIR::TypeR
(Union,
// Unions don't have drop glue unless they impl Drop
return false;
+ ),
+ (ExternType,
+ // Extern types don't have drop glue
+ return false;
)
)
),
diff --git a/src/mir/from_hir.cpp b/src/mir/from_hir.cpp
index 9ce40a74..fb214dda 100644
--- a/src/mir/from_hir.cpp
+++ b/src/mir/from_hir.cpp
@@ -2405,6 +2405,9 @@ namespace {
TU_ARMA(Union, e) {
BUG(node.span(), "_StructLiteral Union isn't valid?");
}
+ TU_ARMA(ExternType, e) {
+ BUG(node.span(), "_StructLiteral ExternType isn't valid?");
+ }
TU_ARMA(Struct, e) {
if(e->m_data.is_Unit()) {
m_builder.set_result( node.span(), ::MIR::RValue::make_Struct({
diff --git a/src/mir/from_hir_match.cpp b/src/mir/from_hir_match.cpp
index 264c74c5..6fb77a3b 100644
--- a/src/mir/from_hir_match.cpp
+++ b/src/mir/from_hir_match.cpp
@@ -802,6 +802,9 @@ void PatternRulesetBuilder::append_from_lit(const Span& sp, const ::HIR::Literal
)
)
),
+ (ExternType,
+ TODO(sp, "Match extern type");
+ ),
(Union,
TODO(sp, "Match union");
),
@@ -1217,6 +1220,9 @@ void PatternRulesetBuilder::append_from(const Span& sp, const ::HIR::Pattern& pa
(Union,
TODO(sp, "Match over union - " << ty);
),
+ (ExternType,
+ TODO(sp, "Match over extern type - " << ty);
+ ),
(Enum,
auto monomorph = [&](const auto& ty) {
auto rv = monomorphise_type(sp, pbe->m_params, e.path.m_data.as_Generic().m_params, ty);
@@ -1738,6 +1744,9 @@ namespace {
(Opaque,
BUG(sp, "Destructuring an opaque type - " << *cur_ty);
),
+ (ExternType,
+ BUG(sp, "Destructuring an extern type - " << *cur_ty);
+ ),
(Struct,
// TODO: Should this do a call to expand_associated_types?
auto monomorph = [&](const auto& ty) {
@@ -2173,6 +2182,9 @@ int MIR_LowerHIR_Match_Simple__GeneratePattern(MirBuilder& builder, const Span&
(Union,
TODO(sp, "Match over Union");
),
+ (ExternType,
+ TODO(sp, "Match over ExternType");
+ ),
(Enum,
auto monomorph = [&](const auto& ty) {
auto rv = monomorphise_type(sp, pbe->m_params, te.path.m_data.as_Generic().m_params, ty);
@@ -2827,6 +2839,9 @@ void MatchGenGrouped::gen_dispatch(const ::std::vector<t_rules_subset>& rules, s
(Union,
TODO(sp, "Match over Union");
),
+ (ExternType,
+ TODO(sp, "Match over ExternType - " << ty);
+ ),
(Enum,
)
)
diff --git a/src/resolve/absolute.cpp b/src/resolve/absolute.cpp
index d2609e9e..75a0857f 100644
--- a/src/resolve/absolute.cpp
+++ b/src/resolve/absolute.cpp
@@ -350,7 +350,7 @@ namespace
auto v = mod.m_value_items.find(name);
if( v != mod.m_value_items.end() ) {
const auto& b = v->second.path.m_bindings.value;
- if( const auto* be = b.opt_EnumVar() ) {
+ if( /*const auto* be =*/ b.opt_EnumVar() ) {
DEBUG("- TY: Enum variant " << v->second.path);
path = ::AST::Path( v->second.path );
return true;
@@ -832,6 +832,9 @@ namespace {
(TypeAlias,
pb.type = ::AST::PathBinding_Type::make_TypeAlias({nullptr/*, &e*/});
),
+ (ExternType,
+ pb.type = ::AST::PathBinding_Type::make_TypeAlias({nullptr/*, &e*/});
+ ),
(Struct,
pb.type = ::AST::PathBinding_Type::make_Struct({nullptr, &e});
),
@@ -880,8 +883,8 @@ namespace {
if( it == hmod->m_mod_items.end() )
ERROR(sp, E0000, "Couldn't find path component '" << n.name() << "' of " << path);
- TU_MATCH(::HIR::TypeItem, (it->second->ent), (e),
- (Import,
+ TU_MATCH_HDRA( (it->second->ent), {)
+ TU_ARMA(Import, e) {
// - Update path then restart
auto newpath = AST::Path(e.path.m_crate_name, {});
for(const auto& n : e.path.m_components)
@@ -892,11 +895,11 @@ namespace {
// TODO: Recursion limit
Resolve_Absolute_Path_BindAbsolute(context, sp, mode, path);
return ;
- ),
- (Module,
+ }
+ TU_ARMA(Module, e) {
hmod = &e;
- ),
- (Trait,
+ }
+ TU_ARMA(Trait, e) {
auto trait_path = ::AST::Path( crate.m_name, {} );
for(unsigned int j = start; j <= i; j ++)
trait_path.nodes().push_back( path_abs.nodes[j].name() );
@@ -940,23 +943,15 @@ namespace {
path = mv$(new_path);
return Resolve_Absolute_Path_BindUFCS(context, sp, mode, path);
- ),
- (TypeAlias,
- path = split_into_crate(sp, mv$(path), start, crate.m_name);
- path = split_into_ufcs_ty(sp, mv$(path), i-start);
- return Resolve_Absolute_Path_BindUFCS(context, sp, mode, path);
- ),
- (Struct,
- path = split_into_crate(sp, mv$(path), start, crate.m_name);
- path = split_into_ufcs_ty(sp, mv$(path), i-start);
- return Resolve_Absolute_Path_BindUFCS(context, sp, mode, path);
- ),
- (Union,
+ }
+ case ::HIR::TypeItem::TAG_ExternType:
+ case ::HIR::TypeItem::TAG_TypeAlias:
+ case ::HIR::TypeItem::TAG_Struct:
+ case ::HIR::TypeItem::TAG_Union:
path = split_into_crate(sp, mv$(path), start, crate.m_name);
path = split_into_ufcs_ty(sp, mv$(path), i-start);
return Resolve_Absolute_Path_BindUFCS(context, sp, mode, path);
- ),
- (Enum,
+ TU_ARMA(Enum, e) {
const auto& last_node = path_abs.nodes.back();
// If this refers to an enum variant, return the full path
auto idx = e.find_variant(last_node.name());
@@ -982,8 +977,8 @@ namespace {
path = split_into_crate(sp, mv$(path), start, crate.m_name);
path = split_into_ufcs_ty(sp, mv$(path), i-start);
return Resolve_Absolute_Path_BindUFCS(context, sp, mode, path);
- )
- )
+ }
+ }
}
const auto& name = path_abs.nodes.back().name();
@@ -1007,6 +1002,9 @@ namespace {
(Module,
path.m_bindings.type = ::AST::PathBinding_Type::make_Module({nullptr, &e});
),
+ (ExternType,
+ path.m_bindings.type = ::AST::PathBinding_Type::make_TypeAlias({nullptr/*, &e*/});
+ ),
(TypeAlias,
path.m_bindings.type = ::AST::PathBinding_Type::make_TypeAlias({nullptr/*, &e*/});
),
diff --git a/src/resolve/index.cpp b/src/resolve/index.cpp
index ec1fcd8d..ddeffa0c 100644
--- a/src/resolve/index.cpp
+++ b/src/resolve/index.cpp
@@ -241,7 +241,15 @@ void Resolve_Index_Module_Base(const AST::Crate& crate, AST::Module& mod)
i.is_pub, i_data.name, mv$(path), e.mac
});
}
- // TODO: Other imports (e.g. derives, which have different naming structures)
+ TU_ARMA(ProcMacro, e) {
+ TODO(sp, "ProcMacro import");
+ }
+ TU_ARMA(ProcMacroAttribute, e) {
+ TODO(sp, "ProcMacroAttribute import");
+ }
+ TU_ARMA(ProcMacroDerive, e) {
+ TODO(sp, "ProcMacroDerive import");
+ }
}}
}
else
@@ -319,6 +327,9 @@ void Resolve_Index_Module_Wildcard__glob_in_hir_mod(const Span& sp, const AST::C
),
(TypeAlias,
p.m_bindings.type = ::AST::PathBinding_Type::make_TypeAlias({nullptr});
+ ),
+ (ExternType,
+ p.m_bindings.type = ::AST::PathBinding_Type::make_TypeAlias({nullptr});
)
)
_add_item_type( sp, dst_mod, it.first, is_pub, mv$(p), false );
diff --git a/src/resolve/use.cpp b/src/resolve/use.cpp
index 8c9266a2..95e6d2c1 100644
--- a/src/resolve/use.cpp
+++ b/src/resolve/use.cpp
@@ -645,6 +645,9 @@ namespace {
(TypeAlias,
rv.type = ::AST::PathBinding_Type::make_TypeAlias({nullptr});
),
+ (ExternType,
+ rv.type = ::AST::PathBinding_Type::make_TypeAlias({nullptr}); // Lazy.
+ ),
(Enum,
rv.type = ::AST::PathBinding_Type::make_Enum({nullptr, &e});
),
diff --git a/src/trans/auto_impls.cpp b/src/trans/auto_impls.cpp
index 418a338b..877659b2 100644
--- a/src/trans/auto_impls.cpp
+++ b/src/trans/auto_impls.cpp
@@ -74,7 +74,7 @@ void Trans_AutoImpl_Clone(State& state, ::HIR::TypeRef ty)
// For each field of the tuple, create a clone (either using Copy if posible, or calling Clone::clone)
for(const auto& subty : te)
{
- auto fld_lvalue = ::MIR::LValue::make_Field({ box$(::MIR::LValue::make_Deref({ box$(::MIR::LValue::make_Argument({ 0 })) })), values.size() });
+ auto fld_lvalue = ::MIR::LValue::make_Field({ box$(::MIR::LValue::make_Deref({ box$(::MIR::LValue::make_Argument({ 0 })) })), static_cast<unsigned>(values.size()) });
if( state.resolve.type_is_copy(sp, subty) )
{
values.push_back( ::std::move(fld_lvalue) );
@@ -94,8 +94,8 @@ void Trans_AutoImpl_Clone(State& state, ::HIR::TypeRef ty)
::MIR::RValue::make_Borrow({ 0, ::HIR::BorrowType::Shared, mv$(fld_lvalue) })
}));
bb.terminator = ::MIR::Terminator::make_Call({
- mir_fcn.blocks.size() + 2, // return block (after the panic block below)
- mir_fcn.blocks.size() + 1, // panic block (next block)
+ static_cast<unsigned>(mir_fcn.blocks.size() + 2), // return block (after the panic block below)
+ static_cast<unsigned>(mir_fcn.blocks.size() + 1), // panic block (next block)
res_lv.clone(),
::MIR::CallTarget( ::HIR::Path(subty.clone(), lang_Clone, "clone") ),
::make_vec1<::MIR::Param>( ::std::move(borrow_lv) )
diff --git a/src/trans/codegen.cpp b/src/trans/codegen.cpp
index 9e93caba..b2b614a9 100644
--- a/src/trans/codegen.cpp
+++ b/src/trans/codegen.cpp
@@ -43,6 +43,9 @@ void Trans_Codegen(const ::std::string& outfile, const TransOptions& opt, const
TU_MATCHA( (te.binding), (tpb),
(Unbound, throw ""; ),
(Opaque, throw ""; ),
+ (ExternType,
+ //codegen->emit_extern_type(sp, te.path.m_data.as_Generic(), *tpb);
+ ),
(Struct,
codegen->emit_struct(sp, te.path.m_data.as_Generic(), *tpb);
),
diff --git a/src/trans/codegen_c.cpp b/src/trans/codegen_c.cpp
index 2c40c991..979da88d 100644
--- a/src/trans/codegen_c.cpp
+++ b/src/trans/codegen_c.cpp
@@ -1013,6 +1013,9 @@ namespace {
(Struct,
m_of << "struct s_" << Trans_Mangle(te.path) << ";\n";
),
+ (ExternType,
+ m_of << "struct x_" << Trans_Mangle(te.path) << ";\n";
+ ),
(Union,
m_of << "union u_" << Trans_Mangle(te.path) << ";\n";
),
@@ -1837,6 +1840,7 @@ namespace {
TU_MATCHA((te.binding), (pbe),
(Unbound, MIR_BUG(*m_mir_res, "Unbound type path " << ty); ),
(Opaque, MIR_BUG(*m_mir_res, "Opaque type path " << ty); ),
+ (ExternType, MIR_BUG(*m_mir_res, "Extern type literal " << ty); ),
(Struct,
TU_MATCHA( (pbe->m_data), (se),
(Unit,
@@ -5351,6 +5355,9 @@ namespace {
TU_MATCHA((te.binding), (pbe),
(Unbound, MIR_BUG(*m_mir_res, "Unbound type path " << ty); ),
(Opaque, MIR_BUG(*m_mir_res, "Opaque type path " << ty); ),
+ (ExternType,
+ MIR_BUG(*m_mir_res, "Extern type literal");
+ ),
(Struct,
TU_MATCHA( (pbe->m_data), (se),
(Unit,
@@ -5835,6 +5842,10 @@ namespace {
(Enum,
m_of << "struct e_" << Trans_Mangle(te.path);
),
+ (ExternType,
+ m_of << "struct x_" << Trans_Mangle(te.path);
+ //return ;
+ ),
(Unbound,
MIR_BUG(*m_mir_res, "Unbound type path in trans - " << ty);
),
diff --git a/src/trans/enumerate.cpp b/src/trans/enumerate.cpp
index 6aeb3485..c326d125 100644
--- a/src/trans/enumerate.cpp
+++ b/src/trans/enumerate.cpp
@@ -570,6 +570,9 @@ namespace {
(Opaque,
BUG(Span(), "Opaque type hit in enumeration - " << ty);
),
+ (ExternType,
+ // No innards to visit
+ ),
(Struct,
visit_struct(te.path.m_data.as_Generic(), *tpb);
),
@@ -1064,15 +1067,10 @@ void Trans_Enumerate_Types(EnumState& state)
TU_MATCHA( (te.binding), (tpb),
(Unbound, ),
(Opaque, ),
- (Struct,
- markings_ptr = &tpb->m_markings;
- ),
- (Union,
- markings_ptr = &tpb->m_markings;
- ),
- (Enum,
- markings_ptr = &tpb->m_markings;
- )
+ (ExternType, markings_ptr = &tpb->m_markings; ),
+ (Struct, markings_ptr = &tpb->m_markings; ),
+ (Union, markings_ptr = &tpb->m_markings; ),
+ (Enum, markings_ptr = &tpb->m_markings; )
)
ASSERT_BUG(Span(), markings_ptr, "Path binding not set correctly - " << ty);