Skip to content

Commit 01cbfd6

Browse files
committed
Fix new rustc #[macro_export] warning in doctests
rustc now warns any time a `#[macro_export]` is used inside a function as it generates surprising results. Because doctests are run inside implicit test functions this means any use of `#[macro_export]` inside a doctest will now warn. We do this in `lightning-custom-message` to demonstrated how to use the crate, which now fails to compile. Here we fix this by adding an `fn main() {}` to the doctest, which causes doctests to be compiled as freestanding code rather than inside a test function. Note that while discussing this upstream it came up that rustc is also planning on changing the way doctests are compiled to compile an entire crate's doctests in one go rather than in separate crates, causing doctests to have a shared namespace which may generate future surprising outcomes.
1 parent 2b14cc4 commit 01cbfd6

File tree

1 file changed

+1
-0
lines changed
  • lightning-custom-message/src

1 file changed

+1
-0
lines changed

lightning-custom-message/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
//! `Foo` and `Bar` messages, and further composing it with a handler for `Baz` messages.
1313
//!
1414
//!```
15+
//! # fn main() {} // Avoid #[macro_export] generating an in-function warning
1516
//! # extern crate bitcoin;
1617
//! extern crate lightning;
1718
//! #[macro_use]

0 commit comments

Comments
 (0)