-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add regression test for
doc_include_without_cfg
lint
- Loading branch information
1 parent
ffbed4d
commit 43466bb
Showing
4 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#![warn(clippy::doc_include_without_cfg)] | ||
// Should not lint. | ||
#![doc(html_playground_url = "https://playground.example.com/")] | ||
#![cfg_attr(doc, doc = include_str!("../approx_const.rs"))] //~ doc_include_without_cfg | ||
// Should not lint. | ||
#![cfg_attr(feature = "whatever", doc = include_str!("../approx_const.rs"))] | ||
#![cfg_attr(doc, doc = include_str!("../approx_const.rs"))] | ||
#![doc = "some doc"] | ||
//! more doc | ||
|
||
#[cfg_attr(doc, doc = include_str!("../approx_const.rs"))] //~ doc_include_without_cfg | ||
// Should not lint. | ||
#[cfg_attr(feature = "whatever", doc = include_str!("../approx_const.rs"))] | ||
#[cfg_attr(doc, doc = include_str!("../approx_const.rs"))] | ||
#[doc = "some doc"] | ||
/// more doc | ||
fn main() { | ||
// test code goes here | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#![warn(clippy::doc_include_without_cfg)] | ||
// Should not lint. | ||
#![doc(html_playground_url = "https://playground.example.com/")] | ||
#![doc = include_str!("../approx_const.rs")] //~ doc_include_without_cfg | ||
// Should not lint. | ||
#![cfg_attr(feature = "whatever", doc = include_str!("../approx_const.rs"))] | ||
#![cfg_attr(doc, doc = include_str!("../approx_const.rs"))] | ||
#![doc = "some doc"] | ||
//! more doc | ||
|
||
#[doc = include_str!("../approx_const.rs")] //~ doc_include_without_cfg | ||
// Should not lint. | ||
#[cfg_attr(feature = "whatever", doc = include_str!("../approx_const.rs"))] | ||
#[cfg_attr(doc, doc = include_str!("../approx_const.rs"))] | ||
#[doc = "some doc"] | ||
/// more doc | ||
fn main() { | ||
// test code goes here | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
error: included a file in documentation unconditionally | ||
--> tests/ui/doc/doc_include_without_cfg.rs:4:1 | ||
| | ||
LL | #![doc = include_str!("../approx_const.rs")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `cfg_attr(doc, doc = "...")`: `#![cfg_attr(doc, doc = include_str!("../approx_const.rs"))]` | ||
| | ||
= note: `-D clippy::doc-include-without-cfg` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::doc_include_without_cfg)]` | ||
|
||
error: included a file in documentation unconditionally | ||
--> tests/ui/doc/doc_include_without_cfg.rs:11:1 | ||
| | ||
LL | #[doc = include_str!("../approx_const.rs")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `cfg_attr(doc, doc = "...")`: `#[cfg_attr(doc, doc = include_str!("../approx_const.rs"))]` | ||
|
||
error: aborting due to 2 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#![warn(clippy::missing_docs_in_private_items)] | ||
#![allow(clippy::doc_include_without_cfg)] | ||
#![doc = include_str!("../../README.md")] | ||
|
||
fn main() {} |