Streamline find_lang_feature_issue
.
It currently processes `ACTIVE_FEATURES` separately from `ACCEPTED_FEATURES`, `REMOVED_FEATURES`, and `STABLE_REMOVED_FEATURES`, for no good reason. This commit treats them uniformly.
This commit is contained in:
parent
3c1b60c1b4
commit
1ddb2872dd
@ -79,8 +79,8 @@ pub enum UnstableFeatures {
|
|||||||
impl UnstableFeatures {
|
impl UnstableFeatures {
|
||||||
/// This takes into account `RUSTC_BOOTSTRAP`.
|
/// This takes into account `RUSTC_BOOTSTRAP`.
|
||||||
///
|
///
|
||||||
/// If `krate` is [`Some`], then setting `RUSTC_BOOTSTRAP=krate` will enable the nightly features.
|
/// If `krate` is [`Some`], then setting `RUSTC_BOOTSTRAP=krate` will enable the nightly
|
||||||
/// Otherwise, only `RUSTC_BOOTSTRAP=1` will work.
|
/// features. Otherwise, only `RUSTC_BOOTSTRAP=1` will work.
|
||||||
pub fn from_environment(krate: Option<&str>) -> Self {
|
pub fn from_environment(krate: Option<&str>) -> Self {
|
||||||
// `true` if this is a feature-staged build, i.e., on the beta or stable channel.
|
// `true` if this is a feature-staged build, i.e., on the beta or stable channel.
|
||||||
let disable_unstable_features =
|
let disable_unstable_features =
|
||||||
@ -107,21 +107,20 @@ impl UnstableFeatures {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn find_lang_feature_issue(feature: Symbol) -> Option<NonZeroU32> {
|
fn find_lang_feature_issue(feature: Symbol) -> Option<NonZeroU32> {
|
||||||
if let Some(info) = ACTIVE_FEATURES.iter().find(|t| t.name == feature) {
|
// Search in all the feature lists.
|
||||||
info.issue
|
let found = []
|
||||||
} else {
|
|
||||||
// search in Accepted, Removed, or Stable Removed features
|
|
||||||
let found = ACCEPTED_FEATURES
|
|
||||||
.iter()
|
.iter()
|
||||||
|
.chain(ACTIVE_FEATURES)
|
||||||
|
.chain(ACCEPTED_FEATURES)
|
||||||
.chain(REMOVED_FEATURES)
|
.chain(REMOVED_FEATURES)
|
||||||
.chain(STABLE_REMOVED_FEATURES)
|
.chain(STABLE_REMOVED_FEATURES)
|
||||||
.find(|t| t.name == feature);
|
.find(|t| t.name == feature);
|
||||||
|
|
||||||
match found {
|
match found {
|
||||||
Some(found) => found.issue,
|
Some(found) => found.issue,
|
||||||
None => panic!("feature `{feature}` is not declared anywhere"),
|
None => panic!("feature `{feature}` is not declared anywhere"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const fn to_nonzero(n: Option<u32>) -> Option<NonZeroU32> {
|
const fn to_nonzero(n: Option<u32>) -> Option<NonZeroU32> {
|
||||||
// Can be replaced with `n.and_then(NonZeroU32::new)` if that is ever usable
|
// Can be replaced with `n.and_then(NonZeroU32::new)` if that is ever usable
|
||||||
|
Loading…
x
Reference in New Issue
Block a user