Skip to content

Commit

Permalink
Auto merge of #112366 - lukas-code:test, r=Nilstrieb
Browse files Browse the repository at this point in the history
`#[test]` function signature verification improvements

This PR contains two improvements to the expansion of the `#[test]` macro.

The first one fixes rust-lang/rust#112360 by correctly recovering item statements if the signature verification fails.

The second one forbids non-lifetime generics on `#[test]` functions. These were previously allowed if the function returned `()`, but always caused an inference error:

before:
```text
error[E0282]: type annotations needed
 --> src/lib.rs:2:1
  |
1 | #[test]
  | ------- in this procedural macro expansion
2 | fn foo<T>() {}
  | ^^^^^^^^^^^^^^ cannot infer type
```

after:
```text
error: functions used as tests can not have any non-lifetime generic parameters
 --> src/lib.rs:2:1
  |
2 | fn foo<T>() {}
  | ^^^^^^^^^^^^^^
```

Also includes some basic tests for test function signature verification, because I couldn't find any (???) in the test suite.
  • Loading branch information
bors committed Jun 19, 2023
2 parents bc6a866 + ad1c789 commit c10d257
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit c10d257

Please sign in to comment.