Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Remove deprecated methods from FeatureChecker #905

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 0 additions & 46 deletions core/feature_checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ fn warn_legacy_flag(_feature: &str, _api_name: &str) {}

pub struct FeatureChecker {
features: BTreeSet<&'static str>,
// TODO(bartlomieju): remove once we migrate away from `--unstable` flag
// in the CLI.
legacy_unstable: bool,
warn_on_legacy_unstable: bool,
exit_cb: ExitCb,
warn_cb: WarnCb,
}
Expand All @@ -32,8 +28,6 @@ impl Default for FeatureChecker {
fn default() -> Self {
Self {
features: Default::default(),
legacy_unstable: false,
warn_on_legacy_unstable: false,
exit_cb: Box::new(exit),
warn_cb: Box::new(warn_legacy_flag),
}
Expand All @@ -44,8 +38,6 @@ impl Debug for FeatureChecker {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("FeatureChecker")
.field("features", &self.features)
.field("legacy_unstable", &self.legacy_unstable)
.field("warn_on_legacy_unstable", &self.warn_on_legacy_unstable)
.finish()
}
}
Expand Down Expand Up @@ -82,34 +74,6 @@ impl FeatureChecker {
(self.exit_cb)(feature, api_name);
}
}

#[inline(always)]
pub fn check_or_exit_with_legacy_fallback(
&self,
feature: &str,
api_name: &str,
) {
if !self.features.contains(feature) {
if self.legacy_unstable {
if self.warn_on_legacy_unstable {
(self.warn_cb)(feature, api_name);
}
return;
}

(self.exit_cb)(feature, api_name);
}
}

// TODO(bartlomieju): remove this.
pub fn enable_legacy_unstable(&mut self) {
self.legacy_unstable = true;
}

// TODO(bartlomieju): remove this.
pub fn warn_on_legacy_unstable(&mut self) {
self.warn_on_legacy_unstable = true;
}
}

#[cfg(test)]
Expand Down Expand Up @@ -144,15 +108,5 @@ mod tests {
assert_eq!(EXIT_COUNT.load(Ordering::Relaxed), 0);
checker.check_or_exit("fizzbuzz", "foo");
assert_eq!(EXIT_COUNT.load(Ordering::Relaxed), 1);

checker.enable_legacy_unstable();
checker.check_or_exit_with_legacy_fallback("fizzbuzz", "foo");
assert_eq!(EXIT_COUNT.load(Ordering::Relaxed), 1);
assert_eq!(WARN_COUNT.load(Ordering::Relaxed), 0);

checker.warn_on_legacy_unstable();
checker.check_or_exit_with_legacy_fallback("fizzbuzz", "foo");
assert_eq!(EXIT_COUNT.load(Ordering::Relaxed), 1);
assert_eq!(WARN_COUNT.load(Ordering::Relaxed), 1);
}
}
Loading