refactor: stop aliasing feature_test function

Having a public function named `test` is quite unspecific. Exporting it
both as `test` and `feature_test` results in inconsistent usage. Fix
this by renaming the function to `feature_test` and removing the alias.

Part of #12494
This commit is contained in:
Daniel Rainer
2026-04-04 02:33:40 +02:00
committed by Johannes Altmanninger
parent 8125f78a84
commit 65bc9b9e3e
5 changed files with 12 additions and 14 deletions

View File

@@ -163,7 +163,7 @@ pub struct FeatureMetadata {
static FEATURES: Features = Features::new();
/// Perform a feature test on the global set of features.
pub fn test(flag: FeatureFlag) -> bool {
pub fn feature_test(flag: FeatureFlag) -> bool {
#[cfg(test)]
if let Some(value) = LOCAL_OVERRIDE_STACK.with(|stack| {
for &(overridden_feature, value) in stack.borrow().iter().rev() {
@@ -178,8 +178,6 @@ pub fn test(flag: FeatureFlag) -> bool {
FEATURES.test(flag)
}
pub use test as feature_test;
/// Parses a comma-separated feature-flag string, updating ourselves with the values.
/// Feature names or group names may be prefixed with "no-" to disable them.
/// The special group name "all" may be used for those who like to live on the edge.
@@ -267,7 +265,7 @@ pub fn with_overridden_feature(flag: FeatureFlag, value: bool, test_fn: impl FnO
#[cfg(test)]
mod tests {
use super::{FeatureFlag, Features, METADATA, test, with_overridden_feature};
use super::{FeatureFlag, Features, METADATA, feature_test, with_overridden_feature};
use crate::prelude::*;
#[test]
@@ -296,16 +294,16 @@ fn test_feature_flags() {
#[test]
fn test_overridden_feature() {
with_overridden_feature(FeatureFlag::QuestionMarkNoGlob, true, || {
assert!(test(FeatureFlag::QuestionMarkNoGlob));
assert!(feature_test(FeatureFlag::QuestionMarkNoGlob));
});
with_overridden_feature(FeatureFlag::QuestionMarkNoGlob, false, || {
assert!(!test(FeatureFlag::QuestionMarkNoGlob));
assert!(!feature_test(FeatureFlag::QuestionMarkNoGlob));
});
with_overridden_feature(FeatureFlag::QuestionMarkNoGlob, false, || {
with_overridden_feature(FeatureFlag::QuestionMarkNoGlob, true, || {
assert!(test(FeatureFlag::QuestionMarkNoGlob));
assert!(feature_test(FeatureFlag::QuestionMarkNoGlob));
});
});
}

View File

@@ -5,7 +5,7 @@
use crate::env::{EnvStack, Environment as _};
use crate::fd_readable_set::{FdReadableSet, Timeout};
use crate::flog::{FloggableDebug, FloggableDisplay, flog};
use crate::future_feature_flags::{FeatureFlag, test as feature_test};
use crate::future_feature_flags::{FeatureFlag, feature_test};
use crate::key::{
self, Key, Modifiers, ViewportPosition, alt, canonicalize_control_char,
canonicalize_keyed_control_char, char_to_symbol, function_key, shift,

View File

@@ -3,7 +3,7 @@
use crate::{
common::{EscapeFlags, EscapeStringStyle, escape_string},
flog::FloggableDebug,
future_feature_flags::{FeatureFlag, test as feature_test},
future_feature_flags::{FeatureFlag, feature_test},
prelude::*,
reader::safe_get_terminal_mode_on_startup,
wutil::fish_wcstoul,

View File

@@ -239,7 +239,7 @@ fn redirect_tty_after_sighup() {
}
fn querying_allowed(vars: &dyn Environment) -> bool {
future_feature_flags::test(FeatureFlag::QueryTerm)
future_feature_flags::feature_test(FeatureFlag::QueryTerm)
&& !is_dumb()
&& {
// TODO(term-workaround)

View File

@@ -181,7 +181,7 @@ fn osc_0_or_1_terminal_title(out: &mut Outputter, is_1: bool, title: &[WString])
}
fn osc_133_prompt_start(out: &mut Outputter) -> bool {
if !future_feature_flags::test(FeatureFlag::MarkPrompt) {
if !future_feature_flags::feature_test(FeatureFlag::MarkPrompt) {
return false;
}
static TEST_BALLOON: OnceLock<()> = OnceLock::new();
@@ -194,7 +194,7 @@ fn osc_133_prompt_start(out: &mut Outputter) -> bool {
}
fn osc_133_prompt_end(out: &mut Outputter) -> bool {
if !future_feature_flags::test(FeatureFlag::MarkPrompt) {
if !future_feature_flags::feature_test(FeatureFlag::MarkPrompt) {
return false;
}
write_to_output!(out, "\x1b]133;B\x07");
@@ -202,7 +202,7 @@ fn osc_133_prompt_end(out: &mut Outputter) -> bool {
}
fn osc_133_command_start(out: &mut Outputter, command: &wstr) -> bool {
if !future_feature_flags::test(FeatureFlag::MarkPrompt) {
if !future_feature_flags::feature_test(FeatureFlag::MarkPrompt) {
return false;
}
write_to_output!(
@@ -214,7 +214,7 @@ fn osc_133_command_start(out: &mut Outputter, command: &wstr) -> bool {
}
fn osc_133_command_finished(out: &mut Outputter, exit_status: libc::c_int) -> bool {
if !future_feature_flags::test(FeatureFlag::MarkPrompt) {
if !future_feature_flags::feature_test(FeatureFlag::MarkPrompt) {
return false;
}
write_to_output!(out, "\x1b]133;D;{}\x07", exit_status);