From d96bfa25f1d9695e624e7ae393b55ac2ccd6735a Mon Sep 17 00:00:00 2001 From: Nathan Regner Date: Thu, 17 Jun 2021 18:51:07 -0600 Subject: [PATCH] Fix README doctests on latest nightly (#175) (#176) doc(include) was removed in https://github.com/rust-lang/rust/pull/85457. Tests should now run on on both nightly and stable. --- elasticsearch/src/lib.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/elasticsearch/src/lib.rs b/elasticsearch/src/lib.rs index bde412a4..4900fded 100644 --- a/elasticsearch/src/lib.rs +++ b/elasticsearch/src/lib.rs @@ -347,11 +347,19 @@ // TODO: turn on before releasing :) Will require adding documentation within all REST API specs // #![deny(missing_docs)] -// also test examples in README when using rust nightly. -// required as external_doc feature requires nightly -#![cfg_attr(RUSTC_IS_NIGHTLY, feature(external_doc))] -#[cfg_attr(RUSTC_IS_NIGHTLY, doc(include = "../../README.md"), cfg(doctest))] -type _DoctestReadme = (); +// also test examples in README +// source: https://github.com/rust-lang/cargo/issues/383#issuecomment-720873790 +#[cfg(doctest)] +mod readme { + macro_rules! external_doc_test { + ($x:expr) => { + #[doc = $x] + extern "C" {} + }; + } + + external_doc_test!(include_str!("../../README.md")); +} #[macro_use] extern crate dyn_clone;