Skip to content

Commit

Permalink
Merge branch 'master' into test-v0
Browse files Browse the repository at this point in the history
  • Loading branch information
CohenArthur authored Oct 16, 2023
2 parents 88be622 + 7292e71 commit 9c7bb67
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 22 deletions.
4 changes: 2 additions & 2 deletions gcc/rust/ast/rust-expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -4594,14 +4594,14 @@ struct InlineAsmTemplatePiece

struct TupleClobber
{
// as gccrs still doesen't contain a symbol class I have put them as strings
// as gccrs still doesn't contain a symbol class I have put them as strings
std::string symbol;
location_t loc;
};

struct TupleTemplateStr
{
// as gccrs still doesen't contain a symbol class I have put them as strings
// as gccrs still doesn't contain a symbol class I have put them as strings
std::string symbol;
std::string optional_symbol;
location_t loc;
Expand Down
12 changes: 4 additions & 8 deletions gcc/rust/backend/rust-compile-expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ CompileExpr::visit (HIR::StructExprStructFields &struct_expr)
else
{
// this assumes all fields are in order from type resolution and if a
// base struct was specified those fields are filed via accesors
// base struct was specified those fields are filed via accessors
for (size_t i = 0; i < struct_expr.get_fields ().size (); i++)
{
// assignments are coercion sites so lets convert the rvalue if
Expand Down Expand Up @@ -1552,7 +1552,7 @@ CompileExpr::visit (HIR::CallExpr &expr)
}

// this assumes all fields are in order from type resolution and if a
// base struct was specified those fields are filed via accesors
// base struct was specified those fields are filed via accessors
std::vector<tree> arguments;
for (size_t i = 0; i < expr.get_arguments ().size (); i++)
{
Expand Down Expand Up @@ -1635,17 +1635,13 @@ CompileExpr::visit (HIR::CallExpr &expr)
return;

bool is_variadic = false;
if (tyty->get_kind () == TyTy::TypeKind::FNDEF)
{
const TyTy::FnType *fn = static_cast<const TyTy::FnType *> (tyty);
is_variadic = fn->is_variadic ();
}

size_t required_num_args = expr.get_arguments ().size ();

if (tyty->get_kind () == TyTy::TypeKind::FNDEF)
{
const TyTy::FnType *fn = static_cast<const TyTy::FnType *> (tyty);
required_num_args = fn->num_params ();
is_variadic = fn->is_variadic ();
}
else if (tyty->get_kind () == TyTy::TypeKind::FNPTR)
{
Expand Down
6 changes: 2 additions & 4 deletions gcc/rust/backend/rust-compile-extern.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,8 @@ class CompileExternItem : public HIRCompileBase,
}

if (fntype->has_substitutions_defined ())
{
// override the Hir Lookups for the substituions in this context
fntype->override_context ();
}
// override the HIR lookups for the substitutions in this context
fntype->override_context ();

if (fntype->get_abi () == ABI::INTRINSIC)
{
Expand Down
2 changes: 1 addition & 1 deletion gcc/rust/backend/rust-compile-implitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
namespace Rust {
namespace Compile {

// this is a proxy for HIR::ImplItem's back to use the normel HIR::Item path
// this is a proxy for HIR::ImplItem's back to use the normal HIR::Item path
class CompileInherentImplItem : public CompileItem
{
public:
Expand Down
4 changes: 2 additions & 2 deletions gcc/rust/backend/rust-compile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ HIRCompileBase::coercion_site1 (tree rvalue, TyTy::BaseType *rval,
if (!valid_coercion)
return error_mark_node;

const TyTy::ReferenceType *exp
= static_cast<const TyTy::ReferenceType *> (expected);
const TyTy::PointerType *exp
= static_cast<const TyTy::PointerType *> (expected);

TyTy::BaseType *actual_base = nullptr;
if (actual->get_kind () == TyTy::TypeKind::REF)
Expand Down
2 changes: 1 addition & 1 deletion gcc/rust/backend/rust-constexpr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ struct GTY ((for_user)) rust_constexpr_call
/* Result of the call.
NULL means the call is being evaluated.
error_mark_node means that the evaluation was erroneous;
otherwise, the actuall value of the call. */
otherwise, the actual value of the call. */
tree result;
/* The hash of this call; we remember it here to avoid having to
recalculate it when expanding the hash table. */
Expand Down
4 changes: 0 additions & 4 deletions gcc/rust/expand/rust-macro-builtins.cc
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,6 @@ MacroBuiltin::include_str_handler (location_t invoc_locus,
auto node = AST::SingleASTNode (make_string (invoc_locus, str));
auto str_tok = make_token (Token::make_string (invoc_locus, std::move (str)));

// FIXME: Do not return an empty token vector here
return AST::Fragment ({node}, std::move (str_tok));
}

Expand Down Expand Up @@ -785,7 +784,6 @@ MacroBuiltin::env_handler (location_t invoc_locus, AST::MacroInvocData &invoc)
auto tok
= make_token (Token::make_string (invoc_locus, std::move (env_value)));

// FIXME: Do not return an empty token vector here
return AST::Fragment ({node}, std::move (tok));
}

Expand Down Expand Up @@ -824,7 +822,6 @@ MacroBuiltin::cfg_handler (location_t invoc_locus, AST::MacroInvocData &invoc)
auto tok = make_token (
Token::make (result ? TRUE_LITERAL : FALSE_LITERAL, invoc_locus));

// FIXME: Do not return an empty token vector here
return AST::Fragment ({literal_exp}, std::move (tok));
}

Expand Down Expand Up @@ -912,7 +909,6 @@ MacroBuiltin::line_handler (location_t invoc_locus, AST::MacroInvocData &)
auto tok
= make_token (Token::make_int (invoc_locus, std::to_string (current_line)));

// FIXME: Do not return an empty token vector here
return AST::Fragment ({line_no}, std::move (tok));
}

Expand Down
2 changes: 2 additions & 0 deletions gcc/rust/parse/rust-parse-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -11452,6 +11452,8 @@ Parser<ManagedTokenSource>::parse_struct_pattern_field_partial (
std::string index_str = t->get_str ();
int index = atoi (index_str.c_str ());

lexer.skip_token ();

if (!skip_token (COLON))
{
return nullptr;
Expand Down
3 changes: 3 additions & 0 deletions gcc/rust/rust-session-manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,9 @@ Session::expansion (AST::Crate &crate)
while (!fixed_point_reached && iterations < cfg.recursion_limit)
{
CfgStrip ().go (crate);
// Errors might happen during cfg strip pass
if (saw_errors ())
break;

auto ctx = Resolver2_0::NameResolutionContext ();

Expand Down
4 changes: 4 additions & 0 deletions gcc/testsuite/rust/compile/issue-2645.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// { dg-additional-options "-frust-compile-until=ast" }
pub fn struct_tuple(A { 0: a, 1: ref b }: A) -> i32 {
a
}

0 comments on commit 9c7bb67

Please sign in to comment.