Skip to content

Commit ab84521

Browse files
bors[bot]liushuyuphilbertyCohenArthurantego
authored
1162: CI: catch malformed test cases r=philberty a=liushuyu - catch malformed test cases and use GitHub Actions' annotation feature to mark the failures 1167: Fix nullptr when resolving the root of a path expression r=philberty a=philberty When we resolve paths we don't have a _type_, in this scenario there is a bug in our resolution of this generic function so this means the root_tyty is nullptr but the offset is non zero so we return nullptr. Addresses #1132 This test case no longer ICE's but still fails. I have a fix in progress for this ```rust mod mem { extern "rust-intrinsic" { fn transmute<U, V>(_: U) -> V; } } pub trait Hasher { fn write(&mut self, bytes: &[u8]); fn write_u16(&mut self, i: u16) { self.write(&mem::transmute::<_, [u8; 2]>(i)) } } pub struct SipHasher; impl Hasher for SipHasher { #[inline] fn write(&mut self, msg: &[u8]) {} } ``` 1168: ast: resolve: Move ResolveItem into its own source file r=CohenArthur a=CohenArthur Since we need to add new functions to resolve visibilities, we might as well refactor this file before hand :) 1170: Implement macro expansion in `IfExpr`, `IfExprConseqElse`, `IfExprConseqIf`, `IfExprConseqIfLet`. r=CohenArthur a=antego Addresses #1141. Following up on #1161. This change adds support for the macros inside the `if` condition expressions. Things to note: 1. Judging by my research, the `IfExprConseqIfLet` isn't used. The parser treats the syntax `let var = if ...` as a `let` expression followed by `if` expression: ![Screen Shot 2022-04-26 at 9 47 29 am](https://user-images.githubusercontent.com/1451467/165258060-6a42f918-2585-4aef-9da5-9d60d69ca248.png) 2. I didn't add the macro expansion to the `IfLetExpr...` family of expressions because I wasn't able to write a test case reproducing the missing macro expansion. I've tried the following code ```rust fn main() -> i32 { let mut res = 0; enum E { X(u8), Y(u8), Z(u8), } let v = E::Y(12); if let E::Y(n) = v { res = 1; } 0 } ``` which caused the compiler error ``` FAIL: rust/compile/macro43.rs (internal compiler error: in append_reference_for_def, at rust/resolve/rust-name-resolver.h:227) ``` Co-authored-by: liushuyu <liushuyu011@gmail.com> Co-authored-by: Philip Herron <philip.herron@embecosm.com> Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com> Co-authored-by: antego <antego@users.noreply.github.com>
5 parents d7c5bbe + 461bf13 + 1d19dd8 + 3e01b6b + d780b20 commit ab84521

File tree

8 files changed

+1059
-900
lines changed

8 files changed

+1059
-900
lines changed

.github/emit_test_errors.pl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/perl -n
2+
3+
sub analyze_errors() {
4+
/^(FAIL|ERROR|XPASS):\s([^:\s]+):?\s+(.+)/;
5+
6+
my $type = $1;
7+
my $filename = $2;
8+
my $message = $3;
9+
my $line;
10+
11+
if ( !$type ) { return; }
12+
13+
if ( $message =~ /(at line (\d+))?.+(test for \w+, line (\d+))/g ) {
14+
$line = $2 || $4;
15+
}
16+
17+
my $command = "::error file=gcc/testsuite/$filename";
18+
if ($line) {
19+
$command = "$command,line=$line";
20+
}
21+
22+
print "$command,title=Test failure ($type)::$message\n";
23+
}
24+
25+
analyze_errors();

.github/workflows/ccpp.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,10 @@ jobs:
7777
- name: Check regressions
7878
run: |
7979
cd gccrs-build; \
80-
if grep -e "unexpected" -e "unresolved" gcc/testsuite/rust/rust.sum;\
80+
if grep -e "unexpected" -e "unresolved" -e "ERROR:" gcc/testsuite/rust/rust.sum;\
8181
then \
82-
echo "some tests are not correct"; \
82+
echo "::error title=Regression test failed::some tests are not correct"; \
83+
perl -n ../.github/emit_test_errors.pl < gcc/testsuite/rust/rust.sum; \
8384
exit 1; \
8485
else \
8586
exit 0; \
@@ -142,9 +143,9 @@ jobs:
142143
- name: Check regressions
143144
run: |
144145
cd gccrs-build; \
145-
if grep -e "unexpected" -e "unresolved" gcc/testsuite/rust/rust.sum;\
146+
if grep -e "unexpected" -e "unresolved" -e "ERROR:" gcc/testsuite/rust/rust.sum;\
146147
then \
147-
echo "some tests are not correct"; \
148+
echo "::error title=Regression test failed::some tests are not correct"; \
148149
exit 1; \
149150
else \
150151
exit 0; \
@@ -196,9 +197,9 @@ jobs:
196197
- name: Check regressions
197198
run: |
198199
cd gccrs-build; \
199-
if grep -e "unexpected" -e "unresolved" gcc/testsuite/rust/rust.sum;\
200+
if grep -e "unexpected" -e "unresolved" -e "ERROR:" gcc/testsuite/rust/rust.sum;\
200201
then \
201-
echo "some tests are not correct"; \
202+
echo "::error title=Regression test failed::some tests are not correct"; \
202203
exit 1; \
203204
else \
204205
exit 0; \

gcc/rust/Make-lang.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ GRS_OBJS = \
8787
rust/rust-ast-lower-pattern.o \
8888
rust/rust-name-resolver.o \
8989
rust/rust-ast-resolve.o \
90+
rust/rust-ast-resolve-item.o \
9091
rust/rust-ast-resolve-pattern.o \
9192
rust/rust-ast-resolve-expr.o \
9293
rust/rust-ast-resolve-type.o \

gcc/rust/expand/rust-attribute-visitor.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,6 +1630,9 @@ AttrVisitor::visit (AST::IfExpr &expr)
16301630
// can't strip condition expr itself, but can strip sub-expressions
16311631
auto &condition_expr = expr.get_condition_expr ();
16321632
condition_expr->accept_vis (*this);
1633+
auto cond_fragment = expander.take_expanded_fragment (*this);
1634+
if (cond_fragment.should_expand ())
1635+
condition_expr = cond_fragment.take_expression_fragment ();
16331636
if (condition_expr->is_marked_for_strip ())
16341637
rust_error_at (condition_expr->get_locus (),
16351638
"cannot strip expression in this position - outer "
@@ -1657,6 +1660,9 @@ AttrVisitor::visit (AST::IfExprConseqElse &expr)
16571660
// can't strip condition expr itself, but can strip sub-expressions
16581661
auto &condition_expr = expr.get_condition_expr ();
16591662
condition_expr->accept_vis (*this);
1663+
auto cond_fragment = expander.take_expanded_fragment (*this);
1664+
if (cond_fragment.should_expand ())
1665+
condition_expr = cond_fragment.take_expression_fragment ();
16601666
if (condition_expr->is_marked_for_strip ())
16611667
rust_error_at (condition_expr->get_locus (),
16621668
"cannot strip expression in this position - outer "
@@ -1692,6 +1698,9 @@ AttrVisitor::visit (AST::IfExprConseqIf &expr)
16921698
// can't strip condition expr itself, but can strip sub-expressions
16931699
auto &condition_expr = expr.get_condition_expr ();
16941700
condition_expr->accept_vis (*this);
1701+
auto cond_fragment = expander.take_expanded_fragment (*this);
1702+
if (cond_fragment.should_expand ())
1703+
condition_expr = cond_fragment.take_expression_fragment ();
16951704
if (condition_expr->is_marked_for_strip ())
16961705
rust_error_at (condition_expr->get_locus (),
16971706
"cannot strip expression in this position - outer "
@@ -1727,6 +1736,9 @@ AttrVisitor::visit (AST::IfExprConseqIfLet &expr)
17271736
// can't strip condition expr itself, but can strip sub-expressions
17281737
auto &condition_expr = expr.get_condition_expr ();
17291738
condition_expr->accept_vis (*this);
1739+
auto cond_fragment = expander.take_expanded_fragment (*this);
1740+
if (cond_fragment.should_expand ())
1741+
condition_expr = cond_fragment.take_expression_fragment ();
17301742
if (condition_expr->is_marked_for_strip ())
17311743
rust_error_at (condition_expr->get_locus (),
17321744
"cannot strip expression in this position - outer "

0 commit comments

Comments
 (0)