Skip to content

Commit

Permalink
[wip | split me up]
Browse files Browse the repository at this point in the history
  • Loading branch information
CohenArthur committed Apr 3, 2024
1 parent d6d4869 commit 98c8abb
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 24 deletions.
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
4 changes: 2 additions & 2 deletions gcc/rust/backend/rust-compile-expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -954,8 +954,8 @@ check_match_scrutinee (HIR::MatchExpr &expr, Context *ctx)
// 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);
rust_assert (adt->is_enum ());
rust_assert (adt->number_of_variants () > 0);
if (adt->is_enum ())
rust_assert (adt->number_of_variants () > 0);
}
else if (scrutinee_kind == TyTy::TypeKind::FLOAT)
{
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 @@ -621,6 +621,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
6 changes: 3 additions & 3 deletions gcc/rust/hir/rust-ast-lower.cc
Original file line number Diff line number Diff line change
Expand Up @@ -534,11 +534,11 @@ ASTLoweringExprWithBlock::visit (AST::ForLoopExpr &expr)
*Analysis::Mappings::get ()};

auto head = std::unique_ptr<Expr> (
ASTLoweringExpr::translate (expr.get_iterator_expr ().get ()));
ASTLoweringExpr::translate (expr.get_iterator_expr ()));
auto pat = std::unique_ptr<Pattern> (
ASTLoweringPattern::translate (expr.get_pattern ().get ()));
ASTLoweringPattern::translate (expr.get_pattern ()));
auto body = std::unique_ptr<Expr> (
ASTLoweringExpr::translate (expr.get_loop_block ().get ()));
ASTLoweringExpr::translate (expr.get_loop_block ()));

rust_assert (head);
rust_assert (pat);
Expand Down
7 changes: 5 additions & 2 deletions gcc/rust/resolve/rust-ast-resolve-type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// <http://www.gnu.org/licenses/>.

#include "rust-ast-resolve-type.h"
#include "rust-ast-dump.h"
#include "rust-ast-resolve-expr.h"

namespace Rust {
Expand Down Expand Up @@ -496,10 +497,12 @@ ResolveTypeToCanonicalPath::visit (AST::TraitObjectTypeOneBound &type)
}

void
ResolveTypeToCanonicalPath::visit (AST::TraitObjectType &)
ResolveTypeToCanonicalPath::visit (AST::TraitObjectType &ty)
{
// FIXME is this actually allowed? dyn A+B
rust_unreachable ();
// FIXME: This is also reached when we have something like a lifetime bound on
// a generic, e.g. Iter<'a, T: 'a> What do we do in that case?
// rust_unreachable ();
}

ResolveTypeToCanonicalPath::ResolveTypeToCanonicalPath ()
Expand Down
3 changes: 3 additions & 0 deletions gcc/rust/typecheck/rust-hir-type-check-base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ TypeCheckBase::check_for_unconstrained (
const TyTy::SubstitutionArgumentMappings &constraint_b,
const TyTy::BaseType *reference)
{
rust_debug ("[ARTHUR] %s ", constraint_a.as_string ().c_str ());
rust_debug ("[ARTHUR] %s ", constraint_b.as_string ().c_str ());

bool check_result = false;
bool check_completed
= context->have_checked_for_unconstrained (reference->get_ref (),
Expand Down
4 changes: 2 additions & 2 deletions gcc/rust/typecheck/rust-hir-type-check-item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -685,8 +685,8 @@ TypeCheckItem::resolve_impl_block_substitutions (HIR::ImplBlock &impl_block,
const TyTy::SubstitutionArgumentMappings impl_constraints
= GetUsedSubstArgs::From (self);

failure_flag = check_for_unconstrained (substitutions, trait_constraints,
impl_constraints, self);
// failure_flag = check_for_unconstrained (substitutions, trait_constraints,
// impl_constraints, self);

return {substitutions, region_constraints};
}
Expand Down
3 changes: 2 additions & 1 deletion gcc/rust/typecheck/rust-hir-type-check-path.cc
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ TypeCheckExpr::resolve_root_path (HIR::PathInExpression &expr, size_t *offset,
}

rust_error_at (seg.get_locus (),
"failed to type resolve root segment");
"failed to type resolve root segment: %s",
expr.as_string ().c_str ());
return new TyTy::ErrorType (expr.get_mappings ().get_hirid ());
}

Expand Down
5 changes: 4 additions & 1 deletion gcc/rust/typecheck/rust-hir-type-check-type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,8 @@ TyTy::BaseType *
TypeCheckType::resolve_root_path (HIR::TypePath &path, size_t *offset,
NodeId *root_resolved_node_id)
{
rust_debug ("[ARTHURl ] %s", path.as_string ().c_str ());

TyTy::BaseType *root_tyty = nullptr;
*offset = 0;
for (size_t i = 0; i < path.get_num_segments (); i++)
Expand Down Expand Up @@ -417,7 +419,8 @@ TypeCheckType::resolve_root_path (HIR::TypePath &path, size_t *offset,
if (is_root)
{
rust_error_at (seg->get_locus (),
"failed to resolve root segment");
"failed to resolve root segment: %s",
seg->as_string ().c_str ());
return new TyTy::ErrorType (path.get_mappings ().get_hirid ());
}
return root_tyty;
Expand Down
3 changes: 3 additions & 0 deletions gcc/rust/typecheck/rust-typecheck-context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -463,18 +463,21 @@ TypeCheckContext::lookup_predicate (HirId id, TyTy::TypeBoundPredicate *result)
void
TypeCheckContext::insert_query (HirId id)
{
rust_debug ("[ARTHUR] INSERTING QUERY: %u", id);
querys_in_progress.insert (id);
}

void
TypeCheckContext::query_completed (HirId id)
{
rust_debug ("[ARTHUR] COMPLETING QUERY: %u", id);
querys_in_progress.erase (id);
}

bool
TypeCheckContext::query_in_progress (HirId id) const
{
rust_debug ("[ARTHUR] CHECKING IF QUERY IN PROGRESS: %u", id);
return querys_in_progress.find (id) != querys_in_progress.end ();
}

Expand Down

0 comments on commit 98c8abb

Please sign in to comment.