Skip to content

Commit 9f29d6c

Browse files
Remove doc_cfg, doc_auto_cfg and doc_cfg_hide features
1 parent 458ce76 commit 9f29d6c

40 files changed

+39
-182
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
@@ -172,8 +172,8 @@
172172
#![feature(const_trait_impl)]
173173
#![feature(decl_macro)]
174174
#![feature(deprecated_suggestion)]
175-
#![feature(doc_cfg)]
176-
#![feature(doc_cfg_hide)]
175+
#![cfg_attr(bootstrap, feature(doc_cfg))]
176+
#![cfg_attr(bootstrap, feature(doc_cfg_hide))]
177177
#![feature(doc_notable_trait)]
178178
#![feature(extern_types)]
179179
#![feature(f128)]

library/std/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,8 @@
301301
#![feature(concat_idents)]
302302
#![feature(decl_macro)]
303303
#![feature(deprecated_suggestion)]
304-
#![feature(doc_cfg)]
305-
#![feature(doc_cfg_hide)]
304+
#![cfg_attr(bootstrap, feature(doc_cfg))]
305+
#![cfg_attr(bootstrap, feature(doc_cfg_hide))]
306306
#![feature(doc_masked)]
307307
#![feature(doc_notable_trait)]
308308
#![feature(dropck_eyepatch)]

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.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 {}

tests/rustdoc-ui/invalid-cfg.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error: `cfg` is not followed by parentheses
2-
--> $DIR/invalid-cfg.rs:2:7
2+
--> $DIR/invalid-cfg.rs:1:7
33
|
44
LL | #[doc(cfg = "x")]
55
| ^^^^^^^^^ help: expected syntax is: `cfg(/* predicate */)`
66

77
error: multiple `cfg` predicates are specified
8-
--> $DIR/invalid-cfg.rs:3:14
8+
--> $DIR/invalid-cfg.rs:2:14
99
|
1010
LL | #[doc(cfg(x, y))]
1111
| ^
+3-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
#![feature(doc_cfg_hide)]
1+
#![doc(auto_cfg(hide = "test"))] //~ ERROR
2+
#![doc(auto_cfg(hide))] //~ ERROR
23

3-
#![doc(cfg_hide = "test")] //~ ERROR
4-
#![doc(cfg_hide)] //~ ERROR
5-
6-
#[doc(cfg_hide(doc))] //~ ERROR
4+
#[doc(auto_cfg(hide(doc)))]
75
pub fn foo() {}
+9-20
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,16 @@
1-
error: this attribute can only be applied at the crate level
2-
--> $DIR/doc_cfg_hide.rs:6:7
1+
error: `#![doc(auto_cfg(hide(...)))]` only expects a list of items
2+
--> $DIR/doc_cfg_hide.rs:1:17
33
|
4-
LL | #[doc(cfg_hide(doc))]
5-
| ^^^^^^^^^^^^^
4+
LL | #![doc(auto_cfg(hide = "test"))]
5+
| ^^^^^^^^^^^^^
66
|
7-
= note: read <https://doc.rust-lang.org/nightly/rustdoc/the-doc-attribute.html#at-the-crate-level> for more information
87
= note: `#[deny(invalid_doc_attributes)]` on by default
9-
help: to apply to the crate, use an inner attribute
10-
|
11-
LL | #![doc(cfg_hide(doc))]
12-
| +
13-
14-
error: `#[doc(cfg_hide(...))]` takes a list of attributes
15-
--> $DIR/doc_cfg_hide.rs:3:8
16-
|
17-
LL | #![doc(cfg_hide = "test")]
18-
| ^^^^^^^^^^^^^^^^^
198

20-
error: `#[doc(cfg_hide(...))]` takes a list of attributes
21-
--> $DIR/doc_cfg_hide.rs:4:8
9+
error: `#![doc(auto_cfg(hide(...)))]` only expects a list of items
10+
--> $DIR/doc_cfg_hide.rs:2:17
2211
|
23-
LL | #![doc(cfg_hide)]
24-
| ^^^^^^^^
12+
LL | #![doc(auto_cfg(hide))]
13+
| ^^^^
2514

26-
error: aborting due to 3 previous errors
15+
error: aborting due to 2 previous errors
2716

tests/rustdoc/cfg_doc_reexport.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(doc_cfg)]
21
#![feature(no_core, lang_items)]
32

43
#![crate_name = "foo"]

tests/rustdoc/doc-auto-cfg.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(doc_auto_cfg)]
21
#![crate_name = "foo"]
32

43
//@ has foo/fn.foo.html

tests/rustdoc/doc-cfg-hide.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#![crate_name = "oud"]
2-
#![feature(doc_auto_cfg, doc_cfg, doc_cfg_hide)]
3-
42
#![doc(auto_cfg(hide(feature = "solecism")))]
53

64
//@ has 'oud/struct.Solecism.html'

tests/rustdoc/doc-cfg-implicit.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![crate_name = "funambulism"]
2-
#![feature(doc_auto_cfg, doc_cfg)]
32

43
//@ has 'funambulism/struct.Disorbed.html'
54
//@ count - '//*[@class="stab portability"]' 1

tests/rustdoc/doc-cfg-inherit-from-module-79201.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// https://github.com/rust-lang/rust/issues/79201
22
#![crate_name="foo"]
33

4-
#![feature(doc_cfg)]
5-
64
//@ has 'foo/trait.Foo.html'
75
//@ count - '//*[@class="stab portability"]' 6
86
//@ matches - '//*[@class="stab portability"]' 'crate feature foo-root'

0 commit comments

Comments
 (0)