tikv / fail-rs

Fail points for rust
Apache License 2.0
338 stars 40 forks source link

Cannot use `fail_point!` 3 arguments macro without importing it #64

Closed slinkydeveloper closed 2 years ago

slinkydeveloper commented 2 years ago

Describe the bug Cannot use full name qualification for fail_point! macro in the 3 arguments case

To Reproduce Just try to compile:

fail::fail_point!("fail-point-3", enable, |_| {});

And you'll get:

error: cannot find macro `fail_point` in this scope
   --> my_code.rs:10
    |
10 |                     fail::fail_point!("fail-point-3", enable, |_| {});
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: consider importing this macro:
            fail::fail_point
    = note: this error originates in the macro `fail::fail_point` (in Nightly builds, run with -Z macro-backtrace for more info)

Expected behavior You should be able to use the macro without importing it with use

Additional context Looks like the issue is here: https://github.com/tikv/fail-rs/blob/6645f1767b4d0adbe454a07c25e30224b1b08dbd/src/lib.rs#L841

The recursive macro invocation should look like this:

$crate::fail_point!($name, $e);
BusyJay commented 2 years ago

Good catch! Would you like to send a PR to fix it?

slinkydeveloper commented 2 years ago

Hi @BusyJay, here is the PR: https://github.com/tikv/fail-rs/pull/66

slinkydeveloper commented 2 years ago

Hi @BusyJay, is there any plan to release a new version of this crate? There's a bunch of fixes since the last release :)

slinkydeveloper commented 2 years ago

Thank you @BusyJay for the release!