Skip to content

Commit 2f6966d

Browse files
Remove check-cfg condition
1 parent 605b60b commit 2f6966d

File tree

3 files changed

+4
-28
lines changed

3 files changed

+4
-28
lines changed

src/librustdoc/clean/cfg.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use std::{fmt, mem, ops};
88
use itertools::Either;
99
use rustc_ast::{LitKind, MetaItem, MetaItemInner, MetaItemKind, MetaItemLit};
1010
use rustc_data_structures::fx::FxHashSet;
11-
use rustc_session::parse::ParseSess;
1211
use rustc_span::Span;
1312
use rustc_span::symbol::{Symbol, sym};
1413

@@ -128,20 +127,6 @@ impl Cfg {
128127
Self::parse_nested(cfg, &FxHashSet::default()).map(|ret| ret.unwrap())
129128
}
130129

131-
/// Checks whether the given configuration can be matched in the current session.
132-
///
133-
/// Equivalent to `attr::cfg_matches`.
134-
pub(crate) fn matches(&self, psess: &ParseSess) -> bool {
135-
match *self {
136-
Cfg::False => false,
137-
Cfg::True => true,
138-
Cfg::Not(ref child) => !child.matches(psess),
139-
Cfg::All(ref sub_cfgs) => sub_cfgs.iter().all(|sub_cfg| sub_cfg.matches(psess)),
140-
Cfg::Any(ref sub_cfgs) => sub_cfgs.iter().any(|sub_cfg| sub_cfg.matches(psess)),
141-
Cfg::Cfg(name, value) => psess.config.contains(&(name, value)),
142-
}
143-
}
144-
145130
/// Whether the configuration consists of just `Cfg` or `Not`.
146131
fn is_simple(&self) -> bool {
147132
match self {

src/librustdoc/clean/types.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ pub(crate) fn hir_attr_lists<'a, I: IntoIterator<Item = &'a hir::Attribute>>(
10371037
/// This type keeps track of (doc) cfg information as we go down the item tree.
10381038
#[derive(Clone, Debug)]
10391039
pub(crate) struct CfgInfo {
1040-
/// List of currently active `doc(auto_cfg(hide(...)))` cfgs,minus currently active
1040+
/// List of currently active `doc(auto_cfg(hide(...)))` cfgs, minus currently active
10411041
/// `doc(auto_cfg(show(...)))` cfgs.
10421042
hidden_cfg: FxHashSet<Cfg>,
10431043
/// Current computed `cfg`. Each time we enter a new item, this field is updated as well while
@@ -1054,13 +1054,11 @@ pub(crate) struct CfgInfo {
10541054
impl Default for CfgInfo {
10551055
fn default() -> Self {
10561056
Self {
1057-
hidden_cfg: [
1057+
hidden_cfg: FxHashSet::from_iter([
10581058
Cfg::Cfg(sym::test, None),
10591059
Cfg::Cfg(sym::doc, None),
10601060
Cfg::Cfg(sym::doctest, None),
1061-
]
1062-
.into_iter()
1063-
.collect(),
1061+
]),
10641062
current_cfg: Cfg::True,
10651063
auto_cfg_active: true,
10661064
parent_is_doc_cfg: false,

src/librustdoc/doctest/rust.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rustc_span::source_map::SourceMap;
1414
use rustc_span::{BytePos, DUMMY_SP, FileName, Pos, Span, sym};
1515

1616
use super::{DocTestVisitor, ScrapedDocTest};
17-
use crate::clean::{Attributes, CfgInfo, extract_cfg_from_attrs};
17+
use crate::clean::Attributes;
1818
use crate::html::markdown::{self, ErrorCodes, LangString, MdRelLine};
1919

2020
struct RustCollector {
@@ -119,13 +119,6 @@ impl HirCollector<'_> {
119119
nested: F,
120120
) {
121121
let ast_attrs = self.tcx.hir_attrs(self.tcx.local_def_id_to_hir_id(def_id));
122-
if let Some(ref cfg) =
123-
extract_cfg_from_attrs(ast_attrs.iter(), self.tcx, &mut CfgInfo::default())
124-
&& !cfg.matches(&self.tcx.sess.psess)
125-
{
126-
return;
127-
}
128-
129122
// Try collecting `#[doc(test(attr(...)))]`
130123
let old_global_crate_attrs_len = self.collector.global_crate_attrs.len();
131124
for doc_test_attrs in ast_attrs

0 commit comments

Comments
 (0)