forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Why deprecate doc(include)? This nightly feature is a strictly less general version of `extended_key_value_attributes`, which looks like this: ``` #[doc = include_str!("docs.md")] ``` In particular, that feature allows manipulating the filename and included docs in a way that `doc(include)` cannot, due to eager evaluation: ``` #[doc = concat!( "These are my docs: ", include_str!(concat!(env!("OUT_DIR"), "generated_docs.md")) )] ``` For more about eager evaluation and how it impacts macro parsing, see petrochenkov's excellent writeup: https://internals.rust-lang.org/t/macro-expansion-points-in-attributes/11455 Given that `#[doc(include)]` offers no features that `extended_key_value_attributes` cannot, it makes no sense for the language and rustdoc to maintain it indefinitely. This deprecates `doc(include)` and adds a structured suggestion to switch to switch to `doc = include_str!` instead. ## Implementation Notably, this changes attribute cleaning to pass in whether an item is local or not. This is necessary to avoid warning about `doc(include)` in dependencies (see rust-lang#82284 for the sort of trouble that can cause).
- Loading branch information
Showing
8 changed files
with
96 additions
and
20 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
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
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
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
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,5 @@ | ||
#![crate_name = "inner"] | ||
#![feature(external_doc)] | ||
#[doc(include = "docs.md")] | ||
pub struct HasDocInclude {} | ||
pub struct NoDocs {} |
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 @@ | ||
Here have some docs |
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,14 @@ | ||
// aux-build:doc-include-deprecated.rs | ||
// check-pass | ||
#![feature(external_doc)] | ||
#![doc(include = "auxiliary/docs.md")] //~ WARNING deprecated | ||
|
||
extern crate inner; | ||
|
||
pub use inner::HasDocInclude; | ||
|
||
#[doc(include = "auxiliary/docs.md")] //~ WARNING deprecated | ||
pub use inner::HasDocInclude as _; | ||
|
||
#[doc(include = "auxiliary/docs.md")] //~ WARNING deprecated | ||
pub use inner::NoDocs; |
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,35 @@ | ||
warning: `doc(include)` is deprecated | ||
--> $DIR/doc-include-deprecated.rs:10:1 | ||
| | ||
LL | #[doc(include = "auxiliary/docs.md")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
help: use `#![feature(extended_key_value_attributes)]` instead | ||
| | ||
LL | #[doc = include_str!("auxiliary/docs.md")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
warning: `doc(include)` is deprecated | ||
--> $DIR/doc-include-deprecated.rs:13:1 | ||
| | ||
LL | #[doc(include = "auxiliary/docs.md")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
help: use `#![feature(extended_key_value_attributes)]` instead | ||
| | ||
LL | #[doc = include_str!("auxiliary/docs.md")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
warning: `doc(include)` is deprecated | ||
--> $DIR/doc-include-deprecated.rs:4:1 | ||
| | ||
LL | #![doc(include = "auxiliary/docs.md")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
help: use `#![feature(extended_key_value_attributes)]` instead | ||
| | ||
LL | #![doc = include_str!("auxiliary/docs.md")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
warning: 3 warnings emitted | ||
|