Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c5850c0
gccrs: nr: Add better error to unresolved attribute macro
CohenArthur Sep 16, 2025
b206ae3
gccrs: remove match arm pattern vector to single pattern
lucasly-ba Nov 20, 2025
f097d1f
gccrs: Fix rogue macro error during lowering on expansion failure
Harishankar14 Jan 1, 2026
9de3825
gccrs: Move old parser error classes to error header
P-E-P Dec 10, 2025
bdcb59a
gccrs: Use error collector in the parser
P-E-P Dec 10, 2025
7897a8c
gccrs: Use tl::expected for parse_block_expr results
P-E-P Dec 10, 2025
753933b
gccrs: Remove redundant error types
P-E-P Dec 12, 2025
85977b0
gccrs: Use error wrapper when required instead of nullptr
P-E-P Dec 26, 2025
5ec7640
gccrs: Explicitely specify templates for GCC5
P-E-P Jan 5, 2026
3b10d0f
gccrs: forever-stack: Display depth in debug string
CohenArthur Dec 31, 2025
357b641
gccrs: nr: Add prelude field to NRCtx, and fill it upon encountering …
CohenArthur Sep 10, 2025
db31b2d
gccrs: forever-stack: Add extra path resolution from a known NodeId.
CohenArthur Sep 10, 2025
09ede54
gccrs: nr: Do prelude resolution for Identifiers
CohenArthur Sep 12, 2025
14d8e02
gccrs: nr: Ignore errors when doing prelude resolution
CohenArthur Oct 1, 2025
a584b2c
gccrs: util/attributes: error on malformed #[link_name] input
Pasta-coder Jan 3, 2026
ee5d194
gccrs: add redudant semicolon lint
lucasly-ba Jan 6, 2026
15f50be
gccrs: util/attributes: error on malformed #[target_feature] input
Pasta-coder Jan 6, 2026
5903185
gccrs: util/attributes: error on malformed #[no_mangle] input
Pasta-coder Jan 6, 2026
21abcd2
gccrs: add unused label lint
lucasly-ba Jan 7, 2026
c7a2b03
gccrs: handle outer attributes in expression parsing
Villosse Jan 6, 2026
cb9a019
gccrs: Adds and fixes tests for outer attributes in expression
Villosse Jan 6, 2026
2688e65
gccrs: Fix empty struct constructors causing ICE during type checking
Polygonalr Dec 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions gcc/rust/ast/rust-ast-builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,7 @@ Builder::match (std::unique_ptr<Expr> &&scrutinee,
MatchArm
Builder::match_arm (std::unique_ptr<Pattern> &&pattern)
{
auto patterns = std::vector<std::unique_ptr<Pattern>> ();
patterns.emplace_back (std::move (pattern));

return MatchArm (std::move (patterns), loc);
return MatchArm (std::move (pattern), loc);
}

MatchCase
Expand Down
18 changes: 4 additions & 14 deletions gcc/rust/ast/rust-ast-collector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1477,7 +1477,7 @@ TokenCollector::visit (BreakExpr &expr)
if (expr.has_label ())
visit (expr.get_label_unchecked ());
if (expr.has_break_expr ())
visit (expr.get_break_expr ());
visit (expr.get_break_expr_unchecked ());
});
}

Expand Down Expand Up @@ -1617,11 +1617,7 @@ TokenCollector::visit (WhileLetLoopExpr &expr)
visit_loop_common (expr);
push (Rust::Token::make (WHILE, expr.get_locus ()));
push (Rust::Token::make (LET, UNDEF_LOCATION));
// TODO: The reference mention only one Pattern
for (auto &item : expr.get_patterns ())
{
visit (item);
}
visit (expr.get_pattern ());
push (Rust::Token::make (EQUAL, UNDEF_LOCATION));
visit (expr.get_scrutinee_expr ());
visit (expr.get_loop_block ());
Expand Down Expand Up @@ -1669,10 +1665,7 @@ TokenCollector::visit (IfLetExpr &expr)
describe_node (std::string ("IfLetExpr"), [this, &expr] () {
push (Rust::Token::make (IF, expr.get_locus ()));
push (Rust::Token::make (LET, UNDEF_LOCATION));
for (auto &pattern : expr.get_patterns ())
{
visit (pattern);
}
visit (expr.get_pattern ());
push (Rust::Token::make (EQUAL, UNDEF_LOCATION));
visit (expr.get_value_expr ());
visit (expr.get_if_block ());
Expand All @@ -1695,10 +1688,7 @@ TokenCollector::visit (MatchArm &arm)
{
describe_node (std::string ("MatchArm"), [this, &arm] () {
visit_items_as_lines (arm.get_outer_attrs ());
for (auto &pattern : arm.get_patterns ())
{
visit (pattern);
}
visit (arm.get_pattern ());
if (arm.has_match_arm_guard ())
{
push (Rust::Token::make (IF, UNDEF_LOCATION));
Expand Down
11 changes: 4 additions & 7 deletions gcc/rust/ast/rust-ast-pointer-visitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ PointerVisitor::visit (AST::BreakExpr &expr)
visit (expr.get_label_unchecked ());

if (expr.has_break_expr ())
reseat (expr.get_break_expr_ptr ());
reseat (expr.get_break_expr_ptr_unchecked ());
}

void
Expand Down Expand Up @@ -587,8 +587,7 @@ void
PointerVisitor::visit (AST::WhileLetLoopExpr &expr)
{
visit_outer_attrs (expr);
for (auto &pattern : expr.get_patterns ())
reseat (pattern);
reseat (expr.get_pattern ());

if (expr.has_loop_label ())
visit (expr.get_loop_label ());
Expand Down Expand Up @@ -627,8 +626,7 @@ void
PointerVisitor::visit (AST::IfLetExpr &expr)
{
visit_outer_attrs (expr);
for (auto &pattern : expr.get_patterns ())
reseat (pattern);
reseat (expr.get_pattern ());
reseat (expr.get_value_expr_ptr ());
visit (expr.get_if_block ());
}
Expand All @@ -644,8 +642,7 @@ void
PointerVisitor::visit (AST::MatchArm &arm)
{
visit_outer_attrs (arm);
for (auto &pattern : arm.get_patterns ())
reseat (pattern);
reseat (arm.get_pattern ());
if (arm.has_match_arm_guard ())
reseat (arm.get_guard_expr_ptr ());
}
Expand Down
11 changes: 4 additions & 7 deletions gcc/rust/ast/rust-ast-visitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ DefaultASTVisitor::visit (AST::BreakExpr &expr)
visit (expr.get_label_unchecked ());

if (expr.has_break_expr ())
visit (expr.get_break_expr ());
visit (expr.get_break_expr_unchecked ());
}

void
Expand Down Expand Up @@ -607,8 +607,7 @@ void
DefaultASTVisitor::visit (AST::WhileLetLoopExpr &expr)
{
visit_outer_attrs (expr);
for (auto &pattern : expr.get_patterns ())
visit (pattern);
visit (expr.get_pattern ());

if (expr.has_loop_label ())
visit (expr.get_loop_label ());
Expand Down Expand Up @@ -647,8 +646,7 @@ void
DefaultASTVisitor::visit (AST::IfLetExpr &expr)
{
visit_outer_attrs (expr);
for (auto &pattern : expr.get_patterns ())
visit (pattern);
visit (expr.get_pattern ());
visit (expr.get_value_expr ());
visit (expr.get_if_block ());
}
Expand All @@ -664,8 +662,7 @@ void
DefaultASTVisitor::visit (AST::MatchArm &arm)
{
visit_outer_attrs (arm);
for (auto &pattern : arm.get_patterns ())
visit (pattern);
visit (arm.get_pattern ());
if (arm.has_match_arm_guard ())
visit (arm.get_guard_expr ());
}
Expand Down
28 changes: 13 additions & 15 deletions gcc/rust/ast/rust-ast.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1649,7 +1649,7 @@ ReturnExpr::as_string () const
std::string str ("return ");

if (has_returned_expr ())
str += return_expr->as_string ();
str += get_returned_expr ().as_string ();

return str;
}
Expand Down Expand Up @@ -1943,14 +1943,13 @@ IfLetExpr::as_string () const
str += append_attributes (outer_attrs, OUTER);

str += "\n Condition match arm patterns: ";
if (match_arm_patterns.empty ())
if (match_arm_pattern == nullptr)
{
str += "none";
}
else
{
for (const auto &pattern : match_arm_patterns)
str += "\n " + pattern->as_string ();
str += "\n " + match_arm_pattern->as_string ();
}

str += "\n Scrutinee expr: " + value->as_string ();
Expand Down Expand Up @@ -2167,14 +2166,13 @@ WhileLetLoopExpr::as_string () const
str += get_loop_label ().as_string ();

str += "\n Match arm patterns: ";
if (match_arm_patterns.empty ())
if (match_arm_pattern == nullptr)
{
str += "none";
}
else
{
for (const auto &pattern : match_arm_patterns)
str += "\n " + pattern->as_string ();
str += "\n " + match_arm_pattern->as_string ();
}

str += "\n Scrutinee expr: " + scrutinee->as_string ();
Expand Down Expand Up @@ -2235,7 +2233,7 @@ BreakExpr::as_string () const
str += get_label_unchecked ().as_string () + " ";

if (has_break_expr ())
str += break_expr->as_string ();
str += get_break_expr_unchecked ().as_string ();

return str;
}
Expand All @@ -2253,14 +2251,13 @@ MatchArm::as_string () const
std::string str = append_attributes (outer_attrs, OUTER);

str += "\nPatterns: ";
if (match_arm_patterns.empty ())
if (match_arm_pattern == nullptr)
{
str += "none";
}
else
{
for (const auto &pattern : match_arm_patterns)
str += "\n " + pattern->as_string ();
str += "\n " + match_arm_pattern->as_string ();
}

str += "\nGuard expr: ";
Expand Down Expand Up @@ -3729,15 +3726,16 @@ AttributeParser::parse_path_meta_item ()
{
lexer->skip_token ();

std::unique_ptr<Expr> expr = parser->parse_expr ();
auto expr = parser->parse_expr ();

// handle error
// parse_expr should already emit an error and return nullptr
if (!expr)
return nullptr;

return std::unique_ptr<MetaItemPathExpr> (
new MetaItemPathExpr (std::move (path.value ()), std::move (expr)));
new MetaItemPathExpr (std::move (path.value ()),
std::move (expr.value ())));
}
case COMMA:
// just simple path
Expand Down Expand Up @@ -3816,7 +3814,7 @@ DelimTokenTree::to_token_stream () const
std::unique_ptr<MetaItemLitExpr>
AttributeParser::parse_meta_item_lit ()
{
std::unique_ptr<LiteralExpr> lit_expr = parser->parse_literal_expr ({});
auto lit_expr = parser->parse_literal_expr ({});

// TODO: return nullptr instead?
if (!lit_expr)
Expand All @@ -3825,7 +3823,7 @@ AttributeParser::parse_meta_item_lit ()
lexer->peek_token ()->get_locus ()));

return std::unique_ptr<MetaItemLitExpr> (
new MetaItemLitExpr (std::move (*lit_expr)));
new MetaItemLitExpr (std::move (*lit_expr.value ())));
}

bool
Expand Down
2 changes: 1 addition & 1 deletion gcc/rust/ast/rust-desugar-for-loops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ DesugarForLoops::DesugarCtx::make_break_arm ()
builder.path_in_expression (LangItem::Kind::OPTION_NONE))));

auto break_expr
= std::unique_ptr<Expr> (new BreakExpr (tl::nullopt, nullptr, {}, loc));
= std::unique_ptr<Expr> (new BreakExpr (tl::nullopt, tl::nullopt, {}, loc));

return MatchCase (std::move (arm), std::move (break_expr));
}
Expand Down
6 changes: 1 addition & 5 deletions gcc/rust/ast/rust-desugar-question-mark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ MatchArm
make_match_arm (std::unique_ptr<Pattern> &&pattern)
{
auto loc = pattern->get_locus ();

auto patterns = std::vector<std::unique_ptr<Pattern>> ();
patterns.emplace_back (std::move (pattern));

return MatchArm (std::move (patterns), loc);
return MatchArm (std::move (pattern), loc);
}

MatchCase
Expand Down
6 changes: 3 additions & 3 deletions gcc/rust/ast/rust-desugar-while-let.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ DesugarWhileLet::DesugarCtx::make_break_arm ()
auto arm = builder.match_arm (builder.wildcard ());

auto break_expr
= std::unique_ptr<Expr> (new BreakExpr (tl::nullopt, nullptr, {}, loc));
= std::unique_ptr<Expr> (new BreakExpr (tl::nullopt, tl::nullopt, {}, loc));

return MatchCase (std::move (arm), std::move (break_expr));
}
Expand All @@ -53,9 +53,9 @@ DesugarWhileLet::DesugarCtx::make_continue_arm (
std::unique_ptr<Expr>
DesugarWhileLet::desugar (WhileLetLoopExpr &expr)
{
rust_assert (expr.get_patterns ().size () == 1);
rust_assert (expr.get_pattern () != nullptr);

auto pattern = expr.get_patterns ()[0]->clone_pattern ();
auto pattern = expr.get_pattern ()->clone_pattern ();
auto body = expr.get_loop_block ().clone_block_expr ();
auto scrutinee = expr.get_scrutinee_expr ().clone_expr ();

Expand Down
Loading