Clean up code a bit:
* Remove "bool_to_options" feature * Update version for compiler feature * rustfmt
This commit is contained in:
parent
56e5f61494
commit
8fac41a530
7 changed files with 25 additions and 17 deletions
|
@ -676,7 +676,7 @@ declare_features! (
|
||||||
(active, closure_track_caller, "1.57.0", Some(87417), None),
|
(active, closure_track_caller, "1.57.0", Some(87417), None),
|
||||||
|
|
||||||
/// Allows `#[doc(cfg_hide(...))]`.
|
/// Allows `#[doc(cfg_hide(...))]`.
|
||||||
(active, doc_cfg_hide, "1.53.0", Some(43781), None),
|
(active, doc_cfg_hide, "1.57.0", Some(43781), None),
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// feature-group-end: actual feature gates
|
// feature-group-end: actual feature gates
|
||||||
|
|
|
@ -65,9 +65,10 @@
|
||||||
#![doc(
|
#![doc(
|
||||||
html_playground_url = "https://play.rust-lang.org/",
|
html_playground_url = "https://play.rust-lang.org/",
|
||||||
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
|
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
|
||||||
test(no_crate_inject, attr(allow(unused_variables), deny(warnings))),
|
test(no_crate_inject, attr(allow(unused_variables), deny(warnings)))
|
||||||
)]
|
)]
|
||||||
#![cfg_attr(not(bootstrap),
|
#![cfg_attr(
|
||||||
|
not(bootstrap),
|
||||||
doc(cfg_hide(not(test), not(any(test, bootstrap)), target_has_atomic = "ptr"))
|
doc(cfg_hide(not(test), not(any(test, bootstrap)), target_has_atomic = "ptr"))
|
||||||
)]
|
)]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
|
@ -58,9 +58,10 @@
|
||||||
html_playground_url = "https://play.rust-lang.org/",
|
html_playground_url = "https://play.rust-lang.org/",
|
||||||
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
|
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
|
||||||
test(no_crate_inject, attr(deny(warnings))),
|
test(no_crate_inject, attr(deny(warnings))),
|
||||||
test(attr(allow(dead_code, deprecated, unused_variables, unused_mut))),
|
test(attr(allow(dead_code, deprecated, unused_variables, unused_mut)))
|
||||||
)]
|
)]
|
||||||
#![cfg_attr(not(bootstrap),
|
#![cfg_attr(
|
||||||
|
not(bootstrap),
|
||||||
doc(cfg_hide(
|
doc(cfg_hide(
|
||||||
not(test),
|
not(test),
|
||||||
target_pointer_width = "16",
|
target_pointer_width = "16",
|
||||||
|
|
|
@ -193,11 +193,9 @@
|
||||||
html_playground_url = "https://play.rust-lang.org/",
|
html_playground_url = "https://play.rust-lang.org/",
|
||||||
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
|
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
|
||||||
test(no_crate_inject, attr(deny(warnings))),
|
test(no_crate_inject, attr(deny(warnings))),
|
||||||
test(attr(allow(dead_code, deprecated, unused_variables, unused_mut))),
|
test(attr(allow(dead_code, deprecated, unused_variables, unused_mut)))
|
||||||
)]
|
|
||||||
#![cfg_attr(not(bootstrap),
|
|
||||||
doc(cfg_hide(not(test), not(any(test, bootstrap))))
|
|
||||||
)]
|
)]
|
||||||
|
#![cfg_attr(not(bootstrap), doc(cfg_hide(not(test), not(any(test, bootstrap)))))]
|
||||||
// Don't link to std. We are std.
|
// Don't link to std. We are std.
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![warn(deprecated_in_future)]
|
#![warn(deprecated_in_future)]
|
||||||
|
|
|
@ -786,7 +786,9 @@ impl AttributesExt for [ast::Attribute] {
|
||||||
fn single(self) -> Option<Self::Item> {
|
fn single(self) -> Option<Self::Item> {
|
||||||
let mut iter = self.into_iter();
|
let mut iter = self.into_iter();
|
||||||
let item = iter.next()?;
|
let item = iter.next()?;
|
||||||
iter.next().is_none().then_some(())?;
|
if iter.next().is_some() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
Some(item)
|
Some(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -802,16 +804,19 @@ impl AttributesExt for [ast::Attribute] {
|
||||||
if doc_cfg.peek().is_some() {
|
if doc_cfg.peek().is_some() {
|
||||||
doc_cfg
|
doc_cfg
|
||||||
.filter_map(|attr| {
|
.filter_map(|attr| {
|
||||||
Cfg::parse(&attr).map_err(|e| sess.diagnostic().span_err(e.span, e.msg)).ok()
|
Cfg::parse(&attr)
|
||||||
|
.map_err(|e| sess.diagnostic().span_err(e.span, e.msg))
|
||||||
|
.ok()
|
||||||
})
|
})
|
||||||
.fold(Cfg::True, |cfg, new_cfg| cfg & new_cfg)
|
.fold(Cfg::True, |cfg, new_cfg| cfg & new_cfg)
|
||||||
} else {
|
} else {
|
||||||
self
|
self.iter()
|
||||||
.iter()
|
|
||||||
.filter(|attr| attr.has_name(sym::cfg))
|
.filter(|attr| attr.has_name(sym::cfg))
|
||||||
.filter_map(|attr| Some(attr.meta_item_list()?.single()?.meta_item()?.clone()))
|
.filter_map(|attr| Some(attr.meta_item_list()?.single()?.meta_item()?.clone()))
|
||||||
.filter_map(|attr| {
|
.filter_map(|attr| {
|
||||||
Cfg::parse(&attr).map_err(|e| sess.diagnostic().span_err(e.span, e.msg)).ok()
|
Cfg::parse(&attr)
|
||||||
|
.map_err(|e| sess.diagnostic().span_err(e.span, e.msg))
|
||||||
|
.ok()
|
||||||
})
|
})
|
||||||
.filter(|cfg| !hidden_cfg.contains(cfg))
|
.filter(|cfg| !hidden_cfg.contains(cfg))
|
||||||
.fold(Cfg::True, |cfg, new_cfg| cfg & new_cfg)
|
.fold(Cfg::True, |cfg, new_cfg| cfg & new_cfg)
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#![feature(rustc_private)]
|
#![feature(rustc_private)]
|
||||||
#![feature(array_methods)]
|
#![feature(array_methods)]
|
||||||
#![feature(assert_matches)]
|
#![feature(assert_matches)]
|
||||||
#![feature(bool_to_option)]
|
|
||||||
#![feature(box_patterns)]
|
#![feature(box_patterns)]
|
||||||
#![feature(control_flow_enum)]
|
#![feature(control_flow_enum)]
|
||||||
#![feature(box_syntax)]
|
#![feature(box_syntax)]
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
|
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::CRATE_HIR_ID;
|
|
||||||
use rustc_hir::def::{DefKind, Res};
|
use rustc_hir::def::{DefKind, Res};
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_hir::Node;
|
use rustc_hir::Node;
|
||||||
|
use rustc_hir::CRATE_HIR_ID;
|
||||||
use rustc_middle::middle::privacy::AccessLevel;
|
use rustc_middle::middle::privacy::AccessLevel;
|
||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
use rustc_span;
|
use rustc_span;
|
||||||
|
@ -99,7 +99,11 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.cx.cache.hidden_cfg = self.cx.tcx.hir().attrs(CRATE_HIR_ID)
|
self.cx.cache.hidden_cfg = self
|
||||||
|
.cx
|
||||||
|
.tcx
|
||||||
|
.hir()
|
||||||
|
.attrs(CRATE_HIR_ID)
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|attr| attr.has_name(sym::doc))
|
.filter(|attr| attr.has_name(sym::doc))
|
||||||
.flat_map(|attr| attr.meta_item_list().into_iter().flatten())
|
.flat_map(|attr| attr.meta_item_list().into_iter().flatten())
|
||||||
|
|
Loading…
Add table
Reference in a new issue