Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove proc-macro2-diagnostics dependency #138

Merged
merged 1 commit into from Nov 17, 2023

Conversation

dtolnay
Copy link
Contributor

@dtolnay dtolnay commented Nov 17, 2023

The code using proc-macro2-diagnostics produces worse/spurious diagnostics on both stable and nightly compilers. Example:

use test_case::test_case;

#[test_case(1 => is not not eq 1 ; "repro")]
fn id(input: i32) -> i32 {
    input
}

Before:

$ cargo +nightly test

error: multiple negations on single item are forbidden
 --> src/main.rs:3:1
  |
3 | #[test_case(1 => is not not eq 1 ; "repro")]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: this error originates in the attribute macro `test_case` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
 --> src/main.rs:3:45
  |
3 | #[test_case(1 => is not not eq 1 ; "repro")]
  | --------------------------------------------^ expected `bool`, found `()`
  | |
  | implicitly returns `()` as its body has no tail or `return` expression
  |
  = note: this error originates in the attribute macro `test_case` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0308`.
$ cargo +stable test

error: multiple negations on single item are forbidden
 --> src/main.rs:3:1
  |
3 | #[test_case(1 => is not not eq 1 ; "repro")]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: this error originates in the attribute macro `test_case` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
 --> src/main.rs:3:1
  |
3 | #[test_case(1 => is not not eq 1 ; "repro")]
  | ^-------------------------------------------
  | |
  | expected `bool`, found `()`
  | implicitly returns `()` as its body has no tail or `return` expression
  |
  = note: this error originates in the attribute macro `test_case` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0308`.

After:

$ cargo test  # (same on both)

error: multiple negations on single item are forbidden
 --> src/main.rs:3:1
  |
3 | #[test_case(1 => is not not eq 1 ; "repro")]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: this error originates in the attribute macro `test_case` (in Nightly builds, run with -Z macro-backtrace for more info)

@luke-biel
Copy link
Collaborator

An oversight on our side. Tested this locally and it checks out. Thanks for contrib.

@luke-biel luke-biel merged commit 3cfb534 into frondeus:master Nov 17, 2023
8 checks passed
@dtolnay dtolnay deleted the diag branch November 17, 2023 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants