Skip to content

Commit 52aba28

Browse files
Remove doc_cfg, doc_auto_cfg and doc_cfg_hide features
1 parent 380aefd commit 52aba28

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+41
-235
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

-2
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
165165

166166
gate_doc!(
167167
"experimental" {
168-
cfg => doc_cfg
169-
cfg_hide => doc_cfg_hide
170168
masked => doc_masked
171169
notable_trait => doc_notable_trait
172170
}

compiler/rustc_feature/src/unstable.rs

-6
Original file line numberDiff line numberDiff line change
@@ -462,12 +462,6 @@ declare_features! (
462462
(unstable, deprecated_suggestion, "1.61.0", Some(94785)),
463463
/// Allows deref patterns.
464464
(incomplete, deref_patterns, "1.79.0", Some(87121)),
465-
/// Tells rustdoc to automatically generate `#[doc(cfg(...))]`.
466-
(unstable, doc_auto_cfg, "1.58.0", Some(43781)),
467-
/// Allows `#[doc(cfg(...))]`.
468-
(unstable, doc_cfg, "1.21.0", Some(43781)),
469-
/// Allows `#[doc(cfg_hide(...))]`.
470-
(unstable, doc_cfg_hide, "1.57.0", Some(43781)),
471465
/// Allows `#[doc(masked)]`.
472466
(unstable, doc_masked, "1.21.0", Some(44027)),
473467
/// Allows `dyn* Trait` objects.

compiler/rustc_passes/src/check_attr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1283,14 +1283,14 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
12831283
self.tcx.emit_node_span_lint(
12841284
INVALID_DOC_ATTRIBUTES,
12851285
hir_id,
1286-
meta.span,
1286+
item.span(),
12871287
errors::DocAutoCfgExpectsHideOrShow,
12881288
);
12891289
} else if item.meta_item_list().is_none() {
12901290
self.tcx.emit_node_span_lint(
12911291
INVALID_DOC_ATTRIBUTES,
12921292
hir_id,
1293-
meta.span,
1293+
item.span(),
12941294
errors::DocAutoCfgHideShowExpectsList { attr_name: attr_name.as_str() },
12951295
);
12961296
}

compiler/rustc_span/src/symbol.rs

-3
Original file line numberDiff line numberDiff line change
@@ -824,9 +824,6 @@ symbols! {
824824
do_not_recommend,
825825
doc,
826826
doc_alias,
827-
doc_auto_cfg,
828-
doc_cfg,
829-
doc_cfg_hide,
830827
doc_keyword,
831828
doc_masked,
832829
doc_notable_trait,

library/alloc/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@
204204
// tidy-alphabetical-end
205205
//
206206
// Rustdoc features:
207-
#![feature(doc_cfg)]
208-
#![feature(doc_cfg_hide)]
207+
#![cfg_attr(bootstrap, feature(doc_cfg))]
208+
#![cfg_attr(bootstrap, feature(doc_cfg_hide))]
209209
// Technically, this is a bug in rustdoc: rustdoc sees the documentation on `#[lang = slice_alloc]`
210210
// blocks is for `&[T]`, which also has documentation using this feature in `core`, and gets mad
211211
// that the feature-gate isn't enabled. Ideally, it wouldn't check for the feature gate for docs

library/core/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@
159159
//
160160
// Language features:
161161
// tidy-alphabetical-start
162+
#![cfg_attr(bootstrap, feature(doc_cfg))]
163+
#![cfg_attr(bootstrap, feature(doc_cfg_hide))]
162164
#![feature(abi_unadjusted)]
163165
#![feature(adt_const_params)]
164166
#![feature(allow_internal_unsafe)]
@@ -172,8 +174,6 @@
172174
#![feature(const_trait_impl)]
173175
#![feature(decl_macro)]
174176
#![feature(deprecated_suggestion)]
175-
#![feature(doc_cfg)]
176-
#![feature(doc_cfg_hide)]
177177
#![feature(doc_notable_trait)]
178178
#![feature(extern_types)]
179179
#![feature(f128)]

library/std/src/lib.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,8 @@
286286
//
287287
// Language features:
288288
// tidy-alphabetical-start
289-
289+
#![cfg_attr(bootstrap, feature(doc_cfg))]
290+
#![cfg_attr(bootstrap, feature(doc_cfg_hide))]
290291
// stabilization was reverted after it hit beta
291292
#![feature(alloc_error_handler)]
292293
#![feature(allocator_internals)]
@@ -301,8 +302,6 @@
301302
#![feature(concat_idents)]
302303
#![feature(decl_macro)]
303304
#![feature(deprecated_suggestion)]
304-
#![feature(doc_cfg)]
305-
#![feature(doc_cfg_hide)]
306305
#![feature(doc_masked)]
307306
#![feature(doc_notable_trait)]
308307
#![feature(dropck_eyepatch)]

src/doc/unstable-book/src/language-features/doc-cfg.md

-46
This file was deleted.

src/librustdoc/clean/types.rs

+11-60
Original file line numberDiff line numberDiff line change
@@ -1030,34 +1030,20 @@ impl Default for CfgInfo {
10301030
}
10311031
}
10321032

1033-
fn handle_auto_cfg_hide_show(
1034-
tcx: TyCtxt<'_>,
1035-
cfg_info: &mut CfgInfo,
1036-
sub_attr: &MetaItemInner,
1037-
is_show: bool,
1038-
) {
1033+
fn handle_auto_cfg_hide_show(cfg_info: &mut CfgInfo, sub_attr: &MetaItemInner, is_show: bool) {
10391034
if let MetaItemInner::MetaItem(item) = sub_attr
10401035
&& let MetaItemKind::List(items) = &item.kind
10411036
{
10421037
for item in items {
1043-
match Cfg::parse(item) {
1044-
Ok(cfg) => {
1045-
if is_show {
1046-
cfg_info.hidden_cfg.remove(&cfg);
1047-
} else {
1048-
cfg_info.hidden_cfg.insert(cfg);
1049-
}
1050-
}
1051-
Err(_) => {
1052-
tcx.sess
1053-
.dcx()
1054-
.struct_span_err(sub_attr.span(), "unexpected `auto_cfg` value")
1055-
.emit();
1038+
// Errors should already have been reported in `rustc_passes::check_attr`.
1039+
if let Ok(cfg) = Cfg::parse(item) {
1040+
if is_show {
1041+
cfg_info.hidden_cfg.remove(&cfg);
1042+
} else {
1043+
cfg_info.hidden_cfg.insert(cfg);
10561044
}
10571045
}
10581046
}
1059-
} else {
1060-
tcx.sess.dcx().struct_span_err(sub_attr.span(), "unexpected `auto_cfg` value kind").emit();
10611047
}
10621048
}
10631049

@@ -1143,14 +1129,7 @@ pub(crate) fn extract_cfg_from_attrs<'a, I: Iterator<Item = &'a hir::Attribute>
11431129
sym::doc if let Some(attrs) = attr.meta_item_list() => {
11441130
for attr in attrs.iter().filter(|attr| attr.has_name(sym::auto_cfg)) {
11451131
let MetaItemInner::MetaItem(attr) = attr else {
1146-
tcx.sess
1147-
.dcx()
1148-
.struct_span_err(
1149-
attr.span(),
1150-
"unexpected value in `auto_cfg` attribute",
1151-
)
1152-
.emit();
1153-
break 'main;
1132+
continue;
11541133
};
11551134
match &attr.kind {
11561135
MetaItemKind::Word => {
@@ -1175,14 +1154,6 @@ pub(crate) fn extract_cfg_from_attrs<'a, I: Iterator<Item = &'a hir::Attribute>
11751154
changed_auto_active_status = Some(attr.span);
11761155
}
11771156
cfg_info.doc_auto_cfg_active = value;
1178-
} else {
1179-
tcx.sess
1180-
.dcx()
1181-
.struct_span_err(
1182-
attr.span,
1183-
"unexpected value for `auto_cfg` attribute",
1184-
)
1185-
.emit();
11861157
}
11871158
}
11881159
MetaItemKind::List(sub_attrs) => {
@@ -1197,34 +1168,14 @@ pub(crate) fn extract_cfg_from_attrs<'a, I: Iterator<Item = &'a hir::Attribute>
11971168
// Whatever happens next, the feature is enabled again.
11981169
cfg_info.doc_auto_cfg_active = true;
11991170
for sub_attr in sub_attrs.iter() {
1200-
let Some(ident) = sub_attr.ident() else {
1201-
tcx.sess
1202-
.dcx()
1203-
.struct_span_err(
1204-
attr.span,
1205-
"unexpected value for `auto_cfg` attribute",
1206-
)
1207-
.emit();
1208-
continue;
1209-
};
1210-
if ident.name == sym::show || ident.name == sym::hide {
1171+
if let Some(ident) = sub_attr.ident()
1172+
&& (ident.name == sym::show || ident.name == sym::hide)
1173+
{
12111174
handle_auto_cfg_hide_show(
1212-
tcx,
12131175
cfg_info,
12141176
&sub_attr,
12151177
ident.name == sym::show,
12161178
);
1217-
} else {
1218-
tcx.sess
1219-
.dcx()
1220-
.struct_span_err(
1221-
attr.span,
1222-
format!(
1223-
"unknown value `{}` for `auto_cfg` attribute",
1224-
ident.name
1225-
),
1226-
)
1227-
.emit();
12281179
}
12291180
}
12301181
}

tests/rustdoc-gui/src/lib2/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
// ignore-tidy-linelength
22

3-
#![feature(doc_cfg)]
4-
#![feature(doc_auto_cfg)]
5-
63
pub mod another_folder;
74
pub mod another_mod;
85

tests/rustdoc-gui/src/test_docs/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#![crate_name = "test_docs"]
66
#![allow(internal_features)]
77
#![feature(rustdoc_internals)]
8-
#![feature(doc_cfg)]
98
#![feature(associated_type_defaults)]
109

1110
/*!

tests/rustdoc-ui/cfg-boolean-literal.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//@ check-pass
22

33
#![feature(cfg_boolean_literals)]
4-
#![feature(doc_cfg)]
54

65
#[doc(cfg(false))]
76
pub fn foo() {}

tests/rustdoc-ui/doc-cfg-check-cfg.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Ensure that `doc(cfg())` respects `check-cfg`
22
// Currently not properly working
3-
#![feature(doc_cfg)]
43
#![deny(unexpected_cfgs)]
54

65
//@revisions: no_check cfg_empty cfg_foo

tests/rustdoc-ui/doc-cfg-unstable.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// #138113: rustdoc didn't gate unstable predicates inside `doc(cfg(..))`
2-
#![feature(doc_cfg)]
3-
41
// `cfg_boolean_literals`
52
#[doc(cfg(false))] //~ ERROR `cfg(false)` is experimental and subject to change
63
pub fn cfg_boolean_literals() {}

tests/rustdoc-ui/doc-cfg-unstable.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0658]: `cfg(false)` is experimental and subject to change
2-
--> $DIR/doc-cfg-unstable.rs:5:11
2+
--> $DIR/doc-cfg-unstable.rs:2:11
33
|
44
LL | #[doc(cfg(false))]
55
| ^^^^^
@@ -9,7 +9,7 @@ LL | #[doc(cfg(false))]
99
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
1010

1111
error[E0658]: `cfg(sanitize)` is experimental and subject to change
12-
--> $DIR/doc-cfg-unstable.rs:9:11
12+
--> $DIR/doc-cfg-unstable.rs:6:11
1313
|
1414
LL | #[doc(cfg(sanitize = "thread"))]
1515
| ^^^^^^^^^^^^^^^^^^^

tests/rustdoc-ui/doc-cfg.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(doc_cfg)]
2-
31
#[doc(cfg(), cfg(foo, bar))]
42
//~^ ERROR
53
//~^^ ERROR

tests/rustdoc-ui/doc-cfg.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
error: `cfg` predicate is not specified
2-
--> $DIR/doc-cfg.rs:3:7
2+
--> $DIR/doc-cfg.rs:1:7
33
|
44
LL | #[doc(cfg(), cfg(foo, bar))]
55
| ^^^^^ help: expected syntax is: `cfg(/* predicate */)`
66

77
error: multiple `cfg` predicates are specified
8-
--> $DIR/doc-cfg.rs:3:23
8+
--> $DIR/doc-cfg.rs:1:23
99
|
1010
LL | #[doc(cfg(), cfg(foo, bar))]
1111
| ^^^
1212

1313
error: `cfg` predicate is not specified
14-
--> $DIR/doc-cfg.rs:7:7
14+
--> $DIR/doc-cfg.rs:5:7
1515
|
1616
LL | #[doc(cfg())]
1717
| ^^^^^ help: expected syntax is: `cfg(/* predicate */)`
1818

1919
error: multiple `cfg` predicates are specified
20-
--> $DIR/doc-cfg.rs:8:16
20+
--> $DIR/doc-cfg.rs:6:16
2121
|
2222
LL | #[doc(cfg(foo, bar))]
2323
| ^^^

tests/rustdoc-ui/doctest/doc-test-rustdoc-feature.rs

-15
This file was deleted.

tests/rustdoc-ui/doctest/doc-test-rustdoc-feature.stdout

-6
This file was deleted.

tests/rustdoc-ui/feature-gate-doc_cfg_hide.rs

-7
This file was deleted.

tests/rustdoc-ui/feature-gate-doc_cfg_hide.stderr

-13
This file was deleted.

tests/rustdoc-ui/invalid-cfg.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(doc_cfg)]
21
#[doc(cfg = "x")] //~ ERROR not followed by parentheses
32
#[doc(cfg(x, y))] //~ ERROR multiple `cfg` predicates
43
struct S {}

0 commit comments

Comments
 (0)