gccrs icon indicating copy to clipboard operation
gccrs copied to clipboard

tests: `make check-rust` fails to catch a parsing error

Open 0xllx0 opened this issue 3 months ago • 3 comments

Summary

When trying to add a reproducer / regression test for #2886, the test case should fail with a parsing error, similar to what is found in https://godbolt.org/z/WorW4oqG4.

Reproducer

I tried this code (in gcc/testsuite/rust/compile/parens.rs):

pub fn ret_parens(x: i32) -> i32 {
    ((x+1))
}

pub fn arg_ret_parens((x): (i32)) -> (i32) {
    ((x+1))
}

pub fn ret_rpit_parens2(x: i32) -> (i32) {
    ((x+1))
}

pub fn ret_parens3(x: i32) -> i32 {
    ((x+1))
}

Related: #2886

Does the code make use of any (1.49) nightly feature ?

  • [ ] Nightly

Godbolt link

https://godbolt.org/z/WorW4oqG4

Actual behavior

The test passes, which it should only after a proper fix.

Expected behavior

The test should fail to compile with the following errors:

<source>:7:21: error: Failed to resolve trait by looking up hir node
    7 | fn increment1((x): (i32)) -> i32{
      |                     ^~~
<source>:8:7: error: cannot apply operator '+' to types dyn [] and <integer>
    8 |     ((x+1))
      |       ^
<source>:11:27: error: Failed to resolve trait by looking up hir node
   11 | fn increment2(x: i32) -> (i32) {
      |                           ^~~
Compiler returned: 1

GCC Version

GCC 15.2.1, GCCRS c742973c23448e321fba4d9ff98a9092dc0df7ba

0xllx0 avatar Sep 10 '25 23:09 0xllx0

@0xllx0 This is not a parsing error with rustc 1.49 https://godbolt.org/z/Mr61sz5Tf

P-E-P avatar Sep 18 '25 16:09 P-E-P

@0xllx0 This is not a parsing error with rustc 1.49 https://godbolt.org/z/Mr61sz5Tf

Right, which is part of why it is a parsing error in gccrs. We should be getting warning messages similar to upstream rustc, instead we get parsing errors related to attempts at trait parsing.

This issue is related to make check-rust needing to catch the current parsing error, which is probably because the relevant test needs the proper dg-error decorator comments.

0xllx0 avatar Sep 18 '25 16:09 0xllx0

Right, which is part of why it is a parsing error in gccrs. We should be getting warning messages similar to upstream rustc, instead we get parsing errors related to attempts at trait parsing.

This issue is related to make check-rust needing to catch the current parsing error, which is probably because the relevant test needs the proper dg-error decorator comments.

True indeed, I got it backward, thank you for correcting me.

P-E-P avatar Sep 18 '25 17:09 P-E-P