Skip to content

fix: correct compile_fail doctest example#921

Open
Unique-Usman wants to merge 1 commit intogetfloresta:masterfrom
Unique-Usman:ua/assert_err
Open

fix: correct compile_fail doctest example#921
Unique-Usman wants to merge 1 commit intogetfloresta:masterfrom
Unique-Usman:ua/assert_err

Conversation

@Unique-Usman
Copy link
Copy Markdown

@Unique-Usman Unique-Usman commented Apr 1, 2026

Replace invalid syntax in doctest with Some(42) to properly demonstrate a compile-time error when a non-Result value is passed to assert_err!

Description and Notes

How to verify the changes you have done?

Contributor Checklist

  • I've followed the contribution guidelines
  • I've verified one of the following:
    • Ran just pcc (recommended but slower)
    • Ran just lint-features '-- -D warnings' && cargo test --release
    • Confirmed CI passed on my fork
  • I've linked any related issue(s) in the sections above

Finally, you are encouraged to sign all your commits (it proves authorship and guards against tampering—see How (and why) to sign Git commits and GitHub's guide to signing commits).

@Unique-Usman
Copy link
Copy Markdown
Author

When I ran just test I got this

error: no rules expected `Some`
 --> crates/floresta-common/src/macros.rs:95:28
  |
7 | assert_err!(Ok::<u32, &str>Some(42));
  |                            ^^^^ no rules expected this token in macro call
  |
  = note: while trying to match sequence start

The test was testing for assert_err when Result value is not passed to it.

After this changes it gave this error

error[E0308]: mismatched types
 --> crates/floresta-common/src/macros.rs:65:1
  |
7 | assert_ok!(Some(42));
  | ^^^^^^^^^^^--------^
  | |          |
  | |          this expression has type `Option<{integer}>`
  | expected `Option<{integer}>`, found `Result<_, _>`
  |
  = note: expected enum `Option<{integer}>`
             found enum `Result<_, _>`
  = note: this error originates in the macro `assert_ok` (in Nightly builds, run with -Z macro-backtrace for more info)

rustc 1.93.0 (254b59607 2026-01-19)

Replace invalid syntax in doctest with Some(42) to properly
demonstrate a compile-time error when a non-Result value
is passed to assert_err!

Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
@Unique-Usman Unique-Usman changed the title fix(assert_err): correct compile_fail doctest example fix: correct compile_fail doctest example Apr 1, 2026
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.

1 participant