Skip to content

Commit af80b0f

Browse files
committed
do not lint doc_cfg as an unused feature
1 parent 7659cec commit af80b0f

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

compiler/rustc_middle/src/ty/context.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use rustc_session::config::CrateType;
4444
use rustc_session::cstore::{CrateStoreDyn, Untracked};
4545
use rustc_session::lint::Lint;
4646
use rustc_span::def_id::{CRATE_DEF_ID, DefPathHash, StableCrateId};
47-
use rustc_span::{DUMMY_SP, Ident, Span, Symbol, kw};
47+
use rustc_span::{DUMMY_SP, Ident, Span, Symbol, kw, sym};
4848
use rustc_type_ir::TyKind::*;
4949
pub use rustc_type_ir::lift::Lift;
5050
use rustc_type_ir::{CollectAndApply, TypeFlags, WithCachedTypeInfo, elaborate, search_graph};
@@ -1705,6 +1705,10 @@ impl<'tcx> TyCtxt<'tcx> {
17051705
// in downstream crates. It should never be linted, but should we
17061706
// hack this in the linter to ignore it?
17071707
&& f.as_str() != "restricted_std"
1708+
// `doc_cfg` affects rustdoc behavior: rustdoc checks it via
1709+
// `tcx.features().doc_cfg()`, but a normal rustc compilation may
1710+
// never observe that use. Do not lint it as unused here.
1711+
&& *f != sym::doc_cfg
17081712
})
17091713
.collect::<Vec<_>>();
17101714

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//@ check-pass
2+
//@ compile-flags: --check-cfg=cfg(feature,values("enabled_feature"))
3+
#![crate_type = "lib"]
4+
#![deny(unused_features)]
5+
#![feature(doc_cfg)]
6+
7+
#[cfg(feature = "enabled_feature")]
8+
pub fn foo() {}

0 commit comments

Comments
 (0)