Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Desugar AST::ForLoopExprs as part of HIR lowering #2903

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
8 changes: 8 additions & 0 deletions gcc/rust/ast/rust-collect-lang-items.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,13 @@ CollectLangItems::visit (AST::TraitItemType &item)
DefaultASTVisitor::visit (item);
}

void
CollectLangItems::visit (AST::Function &item)
{
maybe_add_lang_item (item);

DefaultASTVisitor::visit (item);
}

} // namespace AST
} // namespace Rust
1 change: 1 addition & 0 deletions gcc/rust/ast/rust-collect-lang-items.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class CollectLangItems : public DefaultASTVisitor

void visit (AST::Trait &item) override;
void visit (AST::TraitItemType &item) override;
void visit (AST::Function &item) override;

private:
template <typename T> void maybe_add_lang_item (const T &item);
Expand Down
27 changes: 14 additions & 13 deletions gcc/rust/ast/rust-macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,8 @@ class MacroRulesDefinition : public VisItem
DeclMacro,
};

MacroRulesDefinition (const MacroRulesDefinition &other) = default;

private:
std::vector<Attribute> outer_attrs;
Identifier rule_name;
Expand Down Expand Up @@ -602,6 +604,18 @@ class MacroInvocation : public TypeNoBounds,
public ExprWithoutBlock
{
public:
MacroInvocation (const MacroInvocation &other)
: TraitItem (other.locus), outer_attrs (other.outer_attrs),
locus (other.locus), node_id (other.node_id),
invoc_data (other.invoc_data), is_semi_coloned (other.is_semi_coloned),
kind (other.kind), builtin_kind (other.builtin_kind)
{
if (other.kind == InvocKind::Builtin)
for (auto &pending : other.pending_eager_invocs)
pending_eager_invocs.emplace_back (
pending->clone_macro_invocation_impl ());
}

enum class InvocKind
{
Regular,
Expand Down Expand Up @@ -726,19 +740,6 @@ class MacroInvocation : public TypeNoBounds,
pending_eager_invocs (std::move (pending_eager_invocs))
{}

MacroInvocation (const MacroInvocation &other)
: TraitItem (other.locus), ExternalItem (other.node_id),
outer_attrs (other.outer_attrs), locus (other.locus),
node_id (other.node_id), invoc_data (other.invoc_data),
is_semi_coloned (other.is_semi_coloned), kind (other.kind),
builtin_kind (other.builtin_kind)
{
if (other.kind == InvocKind::Builtin)
for (auto &pending : other.pending_eager_invocs)
pending_eager_invocs.emplace_back (
pending->clone_macro_invocation_impl ());
}

std::vector<Attribute> outer_attrs;
location_t locus;
NodeId node_id;
Expand Down
10 changes: 9 additions & 1 deletion gcc/rust/backend/rust-compile-expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,15 @@ check_match_scrutinee (HIR::MatchExpr &expr, Context *ctx)
|| scrutinee_kind == TyTy::TypeKind::TUPLE
|| scrutinee_kind == TyTy::TypeKind::REF);

if (scrutinee_kind == TyTy::TypeKind::FLOAT)
if (scrutinee_kind == TyTy::TypeKind::ADT)
{
// this will need to change but for now the first pass implementation,
// lets assert this is the case
TyTy::ADTType *adt = static_cast<TyTy::ADTType *> (scrutinee_expr_tyty);
if (adt->is_enum ())
rust_assert (adt->number_of_variants () > 0);
}
else if (scrutinee_kind == TyTy::TypeKind::FLOAT)
{
// FIXME: CASE_LABEL_EXPR does not support floating point types.
// Find another way to compile these.
Expand Down
1 change: 1 addition & 0 deletions gcc/rust/hir/rust-ast-lower-base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ ASTLoweringBase::lower_generic_args (AST::GenericArgs &args)

for (auto &arg : args.get_generic_args ())
{
rust_debug ("[ARTHUR ] %s", arg.as_string ().c_str ());
switch (arg.get_kind ())
{
case AST::GenericArg::Kind::Type: {
Expand Down
Loading
Loading