Skip to content

Commit 2c10688

Browse files
committedJun 5, 2021
Auto merge of #85457 - jyn514:remove-doc-include, r=GuillaumeGomez
Remove `doc(include)` This nightly feature is redundant now that `extended_key_value_attributes` is stable (#83366). `@rust-lang/rustdoc` not sure if you think this needs FCP; there was already an FCP in #82539, but technically it was for deprecating, not removing the feature altogether. This should not be merged before #83366. cc `@petrochenkov`
·
1.88.01.54.0
2 parents 9e6f0e8 + 15fec1f commit 2c10688

File tree

28 files changed

+79
-449
lines changed

28 files changed

+79
-449
lines changed
 

‎compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
318318
}}
319319

320320
gate_doc!(
321-
include => external_doc
322321
cfg => doc_cfg
323322
masked => doc_masked
324323
notable_trait => doc_notable_trait

‎compiler/rustc_expand/src/base.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,11 +1068,11 @@ impl<'a> ExtCtxt<'a> {
10681068
self.resolver.check_unused_macros();
10691069
}
10701070

1071-
/// Resolves a path mentioned inside Rust code.
1071+
/// Resolves a `path` mentioned inside Rust code, returning an absolute path.
10721072
///
1073-
/// This unifies the logic used for resolving `include_X!`, and `#[doc(include)]` file paths.
1073+
/// This unifies the logic used for resolving `include_X!`.
10741074
///
1075-
/// Returns an absolute path to the file that `path` refers to.
1075+
/// FIXME: move this to `rustc_builtin_macros` and make it private.
10761076
pub fn resolve_path(
10771077
&self,
10781078
path: impl Into<PathBuf>,

‎compiler/rustc_expand/src/expand.rs

Lines changed: 5 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ use rustc_ast::ptr::P;
1212
use rustc_ast::token;
1313
use rustc_ast::tokenstream::TokenStream;
1414
use rustc_ast::visit::{self, AssocCtxt, Visitor};
15-
use rustc_ast::{AstLike, AttrItem, Block, Inline, ItemKind, LitKind, MacArgs};
15+
use rustc_ast::{AstLike, Block, Inline, ItemKind, MacArgs};
1616
use rustc_ast::{MacCallStmt, MacStmtStyle, MetaItemKind, ModKind, NestedMetaItem};
1717
use rustc_ast::{NodeId, PatKind, Path, StmtKind, Unsafe};
1818
use rustc_ast_pretty::pprust;
19-
use rustc_attr::{self as attr, is_builtin_attr};
19+
use rustc_attr::is_builtin_attr;
2020
use rustc_data_structures::map_in_place::MapInPlace;
2121
use rustc_data_structures::stack::ensure_sufficient_stack;
2222
use rustc_data_structures::sync::Lrc;
@@ -28,15 +28,14 @@ use rustc_session::lint::builtin::UNUSED_DOC_COMMENTS;
2828
use rustc_session::lint::BuiltinLintDiagnostics;
2929
use rustc_session::parse::{feature_err, ParseSess};
3030
use rustc_session::Limit;
31-
use rustc_span::symbol::{sym, Ident, Symbol};
32-
use rustc_span::{ExpnId, FileName, Span, DUMMY_SP};
31+
use rustc_span::symbol::{sym, Ident};
32+
use rustc_span::{ExpnId, FileName, Span};
3333

3434
use smallvec::{smallvec, SmallVec};
35-
use std::io::ErrorKind;
3635
use std::ops::DerefMut;
3736
use std::path::PathBuf;
3837
use std::rc::Rc;
39-
use std::{iter, mem, slice};
38+
use std::{iter, mem};
4039

4140
macro_rules! ast_fragments {
4241
(
@@ -1524,139 +1523,6 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
15241523
noop_flat_map_generic_param(param, self)
15251524
}
15261525

1527-
fn visit_attribute(&mut self, at: &mut ast::Attribute) {
1528-
// turn `#[doc(include="filename")]` attributes into `#[doc(include(file="filename",
1529-
// contents="file contents")]` attributes
1530-
if !self.cx.sess.check_name(at, sym::doc) {
1531-
return noop_visit_attribute(at, self);
1532-
}
1533-
1534-
if let Some(list) = at.meta_item_list() {
1535-
if !list.iter().any(|it| it.has_name(sym::include)) {
1536-
return noop_visit_attribute(at, self);
1537-
}
1538-
1539-
let mut items = vec![];
1540-
1541-
for mut it in list {
1542-
if !it.has_name(sym::include) {
1543-
items.push({
1544-
noop_visit_meta_list_item(&mut it, self);
1545-
it
1546-
});
1547-
continue;
1548-
}
1549-
1550-
if let Some(file) = it.value_str() {
1551-
let err_count = self.cx.sess.parse_sess.span_diagnostic.err_count();
1552-
self.check_attributes(slice::from_ref(at));
1553-
if self.cx.sess.parse_sess.span_diagnostic.err_count() > err_count {
1554-
// avoid loading the file if they haven't enabled the feature
1555-
return noop_visit_attribute(at, self);
1556-
}
1557-
1558-
let filename = match self.cx.resolve_path(&*file.as_str(), it.span()) {
1559-
Ok(filename) => filename,
1560-
Err(mut err) => {
1561-
err.emit();
1562-
continue;
1563-
}
1564-
};
1565-
1566-
match self.cx.source_map().load_file(&filename) {
1567-
Ok(source_file) => {
1568-
let src = source_file
1569-
.src
1570-
.as_ref()
1571-
.expect("freshly loaded file should have a source");
1572-
let src_interned = Symbol::intern(src.as_str());
1573-
1574-
let include_info = vec![
1575-
ast::NestedMetaItem::MetaItem(attr::mk_name_value_item_str(
1576-
Ident::with_dummy_span(sym::file),
1577-
file,
1578-
DUMMY_SP,
1579-
)),
1580-
ast::NestedMetaItem::MetaItem(attr::mk_name_value_item_str(
1581-
Ident::with_dummy_span(sym::contents),
1582-
src_interned,
1583-
DUMMY_SP,
1584-
)),
1585-
];
1586-
1587-
let include_ident = Ident::with_dummy_span(sym::include);
1588-
let item = attr::mk_list_item(include_ident, include_info);
1589-
items.push(ast::NestedMetaItem::MetaItem(item));
1590-
}
1591-
Err(e) => {
1592-
let lit_span = it.name_value_literal_span().unwrap();
1593-
1594-
if e.kind() == ErrorKind::InvalidData {
1595-
self.cx
1596-
.struct_span_err(
1597-
lit_span,
1598-
&format!("{} wasn't a utf-8 file", filename.display()),
1599-
)
1600-
.span_label(lit_span, "contains invalid utf-8")
1601-
.emit();
1602-
} else {
1603-
let mut err = self.cx.struct_span_err(
1604-
lit_span,
1605-
&format!("couldn't read {}: {}", filename.display(), e),
1606-
);
1607-
err.span_label(lit_span, "couldn't read file");
1608-
1609-
err.emit();
1610-
}
1611-
}
1612-
}
1613-
} else {
1614-
let mut err = self
1615-
.cx
1616-
.struct_span_err(it.span(), "expected path to external documentation");
1617-
1618-
// Check if the user erroneously used `doc(include(...))` syntax.
1619-
let literal = it.meta_item_list().and_then(|list| {
1620-
if list.len() == 1 {
1621-
list[0].literal().map(|literal| &literal.kind)
1622-
} else {
1623-
None
1624-
}
1625-
});
1626-
1627-
let (path, applicability) = match &literal {
1628-
Some(LitKind::Str(path, ..)) => {
1629-
(path.to_string(), Applicability::MachineApplicable)
1630-
}
1631-
_ => (String::from("<path>"), Applicability::HasPlaceholders),
1632-
};
1633-
1634-
err.span_suggestion(
1635-
it.span(),
1636-
"provide a file path with `=`",
1637-
format!("include = \"{}\"", path),
1638-
applicability,
1639-
);
1640-
1641-
err.emit();
1642-
}
1643-
}
1644-
1645-
let meta = attr::mk_list_item(Ident::with_dummy_span(sym::doc), items);
1646-
*at = ast::Attribute {
1647-
kind: ast::AttrKind::Normal(
1648-
AttrItem { path: meta.path, args: meta.kind.mac_args(meta.span), tokens: None },
1649-
None,
1650-
),
1651-
span: at.span,
1652-
id: at.id,
1653-
style: at.style,
1654-
};
1655-
} else {
1656-
noop_visit_attribute(at, self)
1657-
}
1658-
}
1659-
16601526
fn visit_id(&mut self, id: &mut ast::NodeId) {
16611527
if self.monotonic {
16621528
debug_assert_eq!(*id, ast::DUMMY_NODE_ID);

‎compiler/rustc_feature/src/active.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,6 @@ declare_features! (
370370
/// Allows `#[doc(masked)]`.
371371
(active, doc_masked, "1.21.0", Some(44027), None),
372372

373-
/// Allows `#[doc(include = "some-file")]`.
374-
(active, external_doc, "1.22.0", Some(44732), None),
375-
376373
/// Allows using `crate` as visibility modifier, synonymous with `pub(crate)`.
377374
(active, crate_visibility_modifier, "1.23.0", Some(53120), None),
378375

‎compiler/rustc_feature/src/removed.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ declare_features! (
140140
(removed, const_fn, "1.54.0", Some(57563), None,
141141
Some("split into finer-grained feature gates")),
142142

143+
/// Allows `#[doc(include = "some-file")]`.
144+
(removed, external_doc, "1.54.0", Some(44732), None,
145+
Some("use #[doc = include_str!(\"filename\")] instead, which handles macro invocations")),
146+
143147
// -------------------------------------------------------------------------
144148
// feature-group-end: removed features
145149
// -------------------------------------------------------------------------

‎compiler/rustc_lint/src/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ fn has_doc(sess: &Session, attr: &ast::Attribute) -> bool {
489489

490490
if let Some(list) = attr.meta_item_list() {
491491
for meta in list {
492-
if meta.has_name(sym::include) || meta.has_name(sym::hidden) {
492+
if meta.has_name(sym::hidden) {
493493
return true;
494494
}
495495
}

‎compiler/rustc_passes/src/check_attr.rs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ impl CheckAttrVisitor<'tcx> {
705705
let mut is_valid = true;
706706

707707
if let Some(list) = attr.meta().and_then(|mi| mi.meta_item_list().map(|l| l.to_vec())) {
708-
for meta in list {
708+
for meta in &list {
709709
if let Some(i_meta) = meta.meta_item() {
710710
match i_meta.name_or_empty() {
711711
sym::alias
@@ -757,7 +757,6 @@ impl CheckAttrVisitor<'tcx> {
757757
| sym::html_no_source
758758
| sym::html_playground_url
759759
| sym::html_root_url
760-
| sym::include
761760
| sym::inline
762761
| sym::issue_tracker_base_url
763762
| sym::keyword
@@ -792,6 +791,30 @@ impl CheckAttrVisitor<'tcx> {
792791
);
793792
diag.note("`doc(spotlight)` is now a no-op");
794793
}
794+
if i_meta.has_name(sym::include) {
795+
if let Some(value) = i_meta.value_str() {
796+
// if there are multiple attributes, the suggestion would suggest deleting all of them, which is incorrect
797+
let applicability = if list.len() == 1 {
798+
Applicability::MachineApplicable
799+
} else {
800+
Applicability::MaybeIncorrect
801+
};
802+
let inner = if attr.style == AttrStyle::Inner {
803+
"!"
804+
} else {
805+
""
806+
};
807+
diag.span_suggestion(
808+
attr.meta().unwrap().span,
809+
"use `doc = include_str!` instead",
810+
format!(
811+
"#{}[doc = include_str!(\"{}\")]",
812+
inner, value
813+
),
814+
applicability,
815+
);
816+
}
817+
}
795818
diag.emit();
796819
},
797820
);

‎compiler/rustc_save_analysis/src/lib.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -826,20 +826,6 @@ impl<'tcx> SaveContext<'tcx> {
826826
// FIXME: Should save-analysis beautify doc strings itself or leave it to users?
827827
result.push_str(&beautify_doc_string(val).as_str());
828828
result.push('\n');
829-
} else if self.tcx.sess.check_name(attr, sym::doc) {
830-
if let Some(meta_list) = attr.meta_item_list() {
831-
meta_list
832-
.into_iter()
833-
.filter(|it| it.has_name(sym::include))
834-
.filter_map(|it| it.meta_item_list().map(|l| l.to_owned()))
835-
.flat_map(|it| it)
836-
.filter(|meta| meta.has_name(sym::contents))
837-
.filter_map(|meta| meta.value_str())
838-
.for_each(|val| {
839-
result.push_str(&val.as_str());
840-
result.push('\n');
841-
});
842-
}
843829
}
844830
}
845831

‎library/core/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@
159159
#![feature(const_fn_transmute)]
160160
#![feature(abi_unadjusted)]
161161
#![feature(adx_target_feature)]
162-
#![feature(external_doc)]
163162
#![feature(associated_type_bounds)]
164163
#![feature(const_caller_location)]
165164
#![feature(slice_ptr_get)]

‎src/doc/rustdoc/src/documentation-tests.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,7 @@ without including it in your main documentation. For example, you could write th
424424
`lib.rs` to test your README as part of your doctests:
425425

426426
```rust,no_run
427-
#![feature(external_doc)]
428-
429-
#[doc(include = "../README.md")]
427+
#[doc = include_str!("../README.md")]
430428
#[cfg(doctest)]
431429
pub struct ReadmeDoctests;
432430
```

‎src/doc/rustdoc/src/unstable-features.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -131,22 +131,6 @@ Book][unstable-masked] and [its tracking issue][issue-masked].
131131
[unstable-masked]: ../unstable-book/language-features/doc-masked.html
132132
[issue-masked]: https://github.com/rust-lang/rust/issues/44027
133133

134-
### Include external files as API documentation
135-
136-
As designed in [RFC 1990], Rustdoc can read an external file to use as a type's documentation. This
137-
is useful if certain documentation is so long that it would break the flow of reading the source.
138-
Instead of writing it all inline, writing `#[doc(include = "sometype.md")]` will ask Rustdoc to
139-
instead read that file and use it as if it were written inline.
140-
141-
[RFC 1990]: https://github.com/rust-lang/rfcs/pull/1990
142-
143-
`#[doc(include = "...")]` currently requires the `#![feature(external_doc)]` feature gate. For more
144-
information, see [its chapter in the Unstable Book][unstable-include] and [its tracking
145-
issue][issue-include].
146-
147-
[unstable-include]: ../unstable-book/language-features/external-doc.html
148-
[issue-include]: https://github.com/rust-lang/rust/issues/44732
149-
150134
## Unstable command-line arguments
151135

152136
These features are enabled by passing a command-line flag to Rustdoc, but the flags in question are

‎src/doc/unstable-book/src/language-features/external-doc.md

Lines changed: 0 additions & 40 deletions
This file was deleted.

‎src/librustdoc/clean/types.rs

Lines changed: 5 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ impl AttributesExt for [ast::Attribute] {
809809
// #[doc(...)]
810810
if let Some(list) = attr.meta().as_ref().and_then(|mi| mi.meta_item_list()) {
811811
for item in list {
812-
// #[doc(include)]
812+
// #[doc(hidden)]
813813
if !item.has_name(sym::cfg) {
814814
continue;
815815
}
@@ -894,9 +894,6 @@ crate enum DocFragmentKind {
894894
SugaredDoc,
895895
/// A doc fragment created from a "raw" `#[doc=""]` attribute.
896896
RawDoc,
897-
/// A doc fragment created from a `#[doc(include="filename")]` attribute. Contains both the
898-
/// given filename and the file contents.
899-
Include { filename: Symbol },
900897
}
901898

902899
// The goal of this function is to apply the `DocFragment` transformations that are required when
@@ -930,18 +927,8 @@ impl<'a> FromIterator<&'a DocFragment> for String {
930927
where
931928
T: IntoIterator<Item = &'a DocFragment>,
932929
{
933-
let mut prev_kind: Option<DocFragmentKind> = None;
934930
iter.into_iter().fold(String::new(), |mut acc, frag| {
935-
if !acc.is_empty()
936-
&& prev_kind
937-
.take()
938-
.map(|p| matches!(p, DocFragmentKind::Include { .. }) && p != frag.kind)
939-
.unwrap_or(false)
940-
{
941-
acc.push('\n');
942-
}
943931
add_doc_fragment(&mut acc, &frag);
944-
prev_kind = Some(frag.kind);
945932
acc
946933
})
947934
}
@@ -988,45 +975,6 @@ impl Attributes {
988975
self.other_attrs.lists(name)
989976
}
990977

991-
/// Reads a `MetaItem` from within an attribute, looks for whether it is a
992-
/// `#[doc(include="file")]`, and returns the filename and contents of the file as loaded from
993-
/// its expansion.
994-
crate fn extract_include(mi: &ast::MetaItem) -> Option<(Symbol, Symbol)> {
995-
mi.meta_item_list().and_then(|list| {
996-
for meta in list {
997-
if meta.has_name(sym::include) {
998-
// the actual compiled `#[doc(include="filename")]` gets expanded to
999-
// `#[doc(include(file="filename", contents="file contents")]` so we need to
1000-
// look for that instead
1001-
return meta.meta_item_list().and_then(|list| {
1002-
let mut filename: Option<Symbol> = None;
1003-
let mut contents: Option<Symbol> = None;
1004-
1005-
for it in list {
1006-
if it.has_name(sym::file) {
1007-
if let Some(name) = it.value_str() {
1008-
filename = Some(name);
1009-
}
1010-
} else if it.has_name(sym::contents) {
1011-
if let Some(docs) = it.value_str() {
1012-
contents = Some(docs);
1013-
}
1014-
}
1015-
}
1016-
1017-
if let (Some(filename), Some(contents)) = (filename, contents) {
1018-
Some((filename, contents))
1019-
} else {
1020-
None
1021-
}
1022-
});
1023-
}
1024-
}
1025-
1026-
None
1027-
})
1028-
}
1029-
1030978
crate fn has_doc_flag(&self, flag: Symbol) -> bool {
1031979
for attr in &self.other_attrs {
1032980
if !attr.has_name(sym::doc) {
@@ -1050,18 +998,9 @@ impl Attributes {
1050998
let mut doc_strings: Vec<DocFragment> = vec![];
1051999
let mut doc_line = 0;
10521000

1053-
fn update_need_backline(doc_strings: &mut Vec<DocFragment>, frag: &DocFragment) {
1001+
fn update_need_backline(doc_strings: &mut Vec<DocFragment>) {
10541002
if let Some(prev) = doc_strings.last_mut() {
1055-
if matches!(prev.kind, DocFragmentKind::Include { .. })
1056-
|| prev.kind != frag.kind
1057-
|| prev.parent_module != frag.parent_module
1058-
{
1059-
// add a newline for extra padding between segments
1060-
prev.need_backline = prev.kind == DocFragmentKind::SugaredDoc
1061-
|| prev.kind == DocFragmentKind::RawDoc
1062-
} else {
1063-
prev.need_backline = true;
1064-
}
1003+
prev.need_backline = true;
10651004
}
10661005
}
10671006

@@ -1087,31 +1026,12 @@ impl Attributes {
10871026
indent: 0,
10881027
};
10891028

1090-
update_need_backline(&mut doc_strings, &frag);
1029+
update_need_backline(&mut doc_strings);
10911030

10921031
doc_strings.push(frag);
10931032

10941033
None
10951034
} else {
1096-
if attr.has_name(sym::doc) {
1097-
if let Some(mi) = attr.meta() {
1098-
if let Some((filename, contents)) = Attributes::extract_include(&mi) {
1099-
let line = doc_line;
1100-
doc_line += contents.as_str().lines().count();
1101-
let frag = DocFragment {
1102-
line,
1103-
span: attr.span,
1104-
doc: contents,
1105-
kind: DocFragmentKind::Include { filename },
1106-
parent_module,
1107-
need_backline: false,
1108-
indent: 0,
1109-
};
1110-
update_need_backline(&mut doc_strings, &frag);
1111-
doc_strings.push(frag);
1112-
}
1113-
}
1114-
}
11151035
Some(attr.clone())
11161036
}
11171037
};
@@ -1137,10 +1057,7 @@ impl Attributes {
11371057
let mut out = String::new();
11381058
add_doc_fragment(&mut out, &ori);
11391059
while let Some(new_frag) = iter.next() {
1140-
if matches!(ori.kind, DocFragmentKind::Include { .. })
1141-
|| new_frag.kind != ori.kind
1142-
|| new_frag.parent_module != ori.parent_module
1143-
{
1060+
if new_frag.kind != ori.kind || new_frag.parent_module != ori.parent_module {
11441061
break;
11451062
}
11461063
add_doc_fragment(&mut out, &new_frag);

‎src/test/run-make-fulldeps/include_bytes_deps/main.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#![feature(external_doc)]
2-
3-
#[doc(include="input.md")]
1+
#[doc = include_str!("input.md")]
42
pub struct SomeStruct;
53

64
pub fn main() {

‎src/test/run-make-fulldeps/save-analysis/foo.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#![feature(box_syntax)]
33
#![feature(rustc_private)]
44
#![feature(associated_type_defaults)]
5-
#![feature(external_doc)]
65

76
extern crate rustc_graphviz;
87
// A simple rust project
@@ -454,9 +453,9 @@ impl Iterator for SilenceGenerator {
454453
}
455454
}
456455

456+
#[doc = include_str!("extra-docs.md")]
457+
struct StructWithDocs;
458+
457459
trait Foo {
458460
type Bar = FrameBuffer;
459461
}
460-
461-
#[doc(include = "extra-docs.md")]
462-
struct StructWithDocs;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// check-pass
2+
3+
#[doc(include = "external-cross-doc.md")]
4+
//~^ WARNING unknown `doc` attribute `include`
5+
//~| HELP use `doc = include_str!` instead
6+
// FIXME(#85497): make this a deny instead so it's more clear what's happening
7+
//~| NOTE on by default
8+
//~| WARNING previously accepted
9+
//~| NOTE see issue #82730
10+
pub struct NeedMoreDocs;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
warning: unknown `doc` attribute `include`
2+
--> $DIR/doc-include-suggestion.rs:3:7
3+
|
4+
LL | #[doc(include = "external-cross-doc.md")]
5+
| ------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-- help: use `doc = include_str!` instead: `#[doc = include_str!("external-cross-doc.md")]`
6+
|
7+
= note: `#[warn(invalid_doc_attributes)]` on by default
8+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
9+
= note: for more information, see issue #82730 <https://github.com/rust-lang/rust/issues/82730>
10+
11+
warning: 1 warning emitted
12+
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Cross-crate imported docs
22

3-
This file is to make sure `#[doc(include="file.md")]` works when you re-export an item with included
3+
This file is to make sure `#[doc = include_str!("file.md")]` works when you re-export an item with included
44
docs.
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(external_doc)]
2-
#![deny(missing_doc)]
3-
4-
#[doc(include="external-cross-doc.md")]
1+
#[deny(missing_docs)]
2+
#[doc = include_str!("external-cross-doc.md")]
53
pub struct NeedMoreDocs;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# External Docs
22

3-
This file is here to test the `#[doc(include="file")]` attribute.
3+
This file is here to test the `#[doc = include_str!("file")]` attribute.

‎src/test/rustdoc/external-doc.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
#![feature(external_doc)]
2-
3-
// @has external_doc/struct.CanHasDocs.html
4-
// @has - '//h1' 'External Docs'
5-
// @has - '//h2' 'Inline Docs'
6-
#[doc(include = "auxiliary/external-doc.md")]
7-
/// ## Inline Docs
8-
pub struct CanHasDocs;
9-
101
// @has external_doc/struct.IncludeStrDocs.html
112
// @has - '//h1' 'External Docs'
123
// @has - '//h2' 'Inline Docs'

‎src/test/rustdoc/unindent.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(external_doc)]
2-
31
#![crate_name = "foo"]
42

53
// @has foo/struct.Example.html
@@ -51,7 +49,7 @@ pub struct I;
5149
// @matches - '//div[@class="docblock"]/p' '(?m)a\nno whitespace\nJust some text.\Z'
5250
///a
5351
///no whitespace
54-
#[doc(include = "unindent.md")]
52+
#[doc = include_str!("unindent.md")]
5553
pub struct J;
5654

5755
// @has foo/struct.K.html
@@ -60,5 +58,5 @@ pub struct J;
6058
///
6159
/// 4 whitespaces!
6260
///
63-
#[doc(include = "unindent.md")]
61+
#[doc = include_str!("unindent.md")]
6462
pub struct K;

‎src/test/ui/extern/external-doc-error.rs

Lines changed: 0 additions & 31 deletions
This file was deleted.

‎src/test/ui/extern/external-doc-error.stderr

Lines changed: 0 additions & 38 deletions
This file was deleted.

‎src/test/ui/feature-gates/feature-gate-external_doc.rs

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎src/test/ui/feature-gates/feature-gate-external_doc.stderr

Lines changed: 0 additions & 21 deletions
This file was deleted.

‎src/tools/clippy/clippy_lints/src/missing_doc.rs

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
use clippy_utils::attrs::is_doc_hidden;
99
use clippy_utils::diagnostics::span_lint;
10-
use if_chain::if_chain;
11-
use rustc_ast::ast::{self, MetaItem, MetaItemKind};
10+
use rustc_ast::ast;
1211
use rustc_hir as hir;
1312
use rustc_lint::{LateContext, LateLintPass, LintContext};
1413
use rustc_middle::ty;
@@ -56,20 +55,6 @@ impl MissingDoc {
5655
*self.doc_hidden_stack.last().expect("empty doc_hidden_stack")
5756
}
5857

59-
fn has_include(meta: Option<MetaItem>) -> bool {
60-
if_chain! {
61-
if let Some(meta) = meta;
62-
if let MetaItemKind::List(list) = meta.kind;
63-
if let Some(meta) = list.get(0);
64-
if let Some(name) = meta.ident();
65-
then {
66-
name.name == sym::include
67-
} else {
68-
false
69-
}
70-
}
71-
}
72-
7358
fn check_missing_docs_attrs(
7459
&self,
7560
cx: &LateContext<'_>,
@@ -95,7 +80,7 @@ impl MissingDoc {
9580

9681
let has_doc = attrs
9782
.iter()
98-
.any(|a| a.doc_str().is_some() || Self::has_include(a.meta()));
83+
.any(|a| a.doc_str().is_some());
9984
if !has_doc {
10085
span_lint(
10186
cx,
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![warn(clippy::missing_docs_in_private_items)]
2-
#![feature(external_doc)]
3-
#![doc(include = "../../README.md")]
2+
#![doc = include_str!("../../README.md")]
43

54
fn main() {}

0 commit comments

Comments
 (0)
Please sign in to comment.