From 653e1036ed5a343a7be7b2a73096c138efc51523 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 22 Sep 2025 13:58:02 +0200 Subject: Apply first review round suggestions --- compiler/rustc_feature/src/removed.rs | 2 ++ compiler/rustc_passes/messages.ftl | 4 ++-- compiler/rustc_span/src/symbol.rs | 1 + src/librustdoc/passes/propagate_doc_cfg.rs | 14 +------------- src/librustdoc/visit_ast.rs | 2 +- tests/rustdoc-ui/doc-cfg.stderr | 6 +++--- 6 files changed, 10 insertions(+), 19 deletions(-) diff --git a/compiler/rustc_feature/src/removed.rs b/compiler/rustc_feature/src/removed.rs index 32115535e99..71365da316c 100644 --- a/compiler/rustc_feature/src/removed.rs +++ b/compiler/rustc_feature/src/removed.rs @@ -101,6 +101,8 @@ declare_features! ( Some("never properly implemented; requires significant design work"), 127655), /// Allows deriving traits as per `SmartPointer` specification (removed, derive_smart_pointer, "1.84.0", Some(123430), Some("replaced by `CoercePointee`"), 131284), + /// Allows `#[doc(cfg_hide(...))]`. + (removed, doc_cfg_hide, "1.57.0", Some(43781), Some("merged into `doc_cfg`"), 138907), /// Allows using `#[doc(keyword = "...")]`. (removed, doc_keyword, "1.58.0", Some(51315), Some("merged into `#![feature(rustdoc_internals)]`"), 90420), diff --git a/compiler/rustc_passes/messages.ftl b/compiler/rustc_passes/messages.ftl index a5ff169e638..21fc1124c2f 100644 --- a/compiler/rustc_passes/messages.ftl +++ b/compiler/rustc_passes/messages.ftl @@ -144,7 +144,7 @@ passes_doc_cfg_hide_takes_list = `#[doc(cfg_hide(...))]` takes a list of attributes passes_doc_auto_cfg_expects_hide_or_show = - `only "hide" or "show" are allowed in "#[doc(auto_cfg(...))]"` + only `hide` or `show` are allowed in `#[doc(auto_cfg(...))]` passes_doc_auto_cfg_hide_show_expects_list = `#![doc(auto_cfg({$attr_name}(...)))]` expects a list of items @@ -153,7 +153,7 @@ passes_doc_auto_cfg_hide_show_unexpected_item = `#![doc(auto_cfg({$attr_name}(...)))]` only accepts identifiers or key/value items passes_doc_auto_cfg_wrong_literal = - `expected boolean for #[doc(auto_cfg = ...)]` + expected boolean for `#[doc(auto_cfg = ...)]` passes_doc_expect_str = doc {$attr_name} attribute expects a string: #[doc({$attr_name} = "a")] diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 79f00e2e94d..18c3faed932 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -878,6 +878,7 @@ symbols! { doc_alias, doc_auto_cfg, doc_cfg, + doc_cfg_hide, doc_keyword, doc_masked, doc_notable_trait, diff --git a/src/librustdoc/passes/propagate_doc_cfg.rs b/src/librustdoc/passes/propagate_doc_cfg.rs index ea77065ac07..4bcb60a9a40 100644 --- a/src/librustdoc/passes/propagate_doc_cfg.rs +++ b/src/librustdoc/passes/propagate_doc_cfg.rs @@ -33,19 +33,7 @@ struct CfgPropagator<'a, 'tcx> { /// Returns true if the provided `token` is a `cfg` ident. fn is_cfg_token(token: &TokenTree) -> bool { // We only keep `doc(cfg)` items. - matches!( - token, - TokenTree::Token( - Token { - kind: TokenKind::Ident( - ident, - _, - ), - .. - }, - _, - ) if *ident == sym::cfg, - ) + matches!(token, TokenTree::Token(Token { kind: TokenKind::Ident(sym::cfg, _,), .. }, _,),) } /// We only want to keep `#[cfg()]` and `#[doc(cfg())]` attributes so we rebuild a vec of diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index ac67871b0cb..dc9889cec21 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -9,7 +9,7 @@ use rustc_hir::attrs::AttributeKind; use rustc_hir::def::{DefKind, MacroKinds, Res}; use rustc_hir::def_id::{DefId, DefIdMap, LocalDefId, LocalDefIdSet}; use rustc_hir::intravisit::{Visitor, walk_body, walk_item}; -use rustc_hir::{CRATE_HIR_ID, Node, find_attr}; +use rustc_hir::{Node, find_attr}; use rustc_middle::hir::nested_filter; use rustc_middle::ty::TyCtxt; use rustc_span::Span; diff --git a/tests/rustdoc-ui/doc-cfg.stderr b/tests/rustdoc-ui/doc-cfg.stderr index 13f62e50d90..49e8c324fac 100644 --- a/tests/rustdoc-ui/doc-cfg.stderr +++ b/tests/rustdoc-ui/doc-cfg.stderr @@ -1,4 +1,4 @@ -error: `only "hide" or "show" are allowed in "#[doc(auto_cfg(...))]"` +error: only `hide` or `show` are allowed in `#[doc(auto_cfg(...))]` --> $DIR/doc-cfg.rs:11:7 | LL | #[doc(auto_cfg(42))] @@ -30,13 +30,13 @@ error: `#![doc(auto_cfg(hide(...)))]` only accepts identifiers or key/value item LL | #[doc(auto_cfg(hide(foo::bar)))] | ^^^^^^^^ -error: `expected boolean for #[doc(auto_cfg = ...)]` +error: expected boolean for `#[doc(auto_cfg = ...)]` --> $DIR/doc-cfg.rs:16:7 | LL | #[doc(auto_cfg = 42)] | ^^^^^^^^^^^^^ -error: `expected boolean for #[doc(auto_cfg = ...)]` +error: expected boolean for `#[doc(auto_cfg = ...)]` --> $DIR/doc-cfg.rs:17:7 | LL | #[doc(auto_cfg = "a")] -- cgit 1.4.1-3-g733a5