Skip to content

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

@0xllx0

Description

@0xllx0

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 c742973

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions