mirror of https://github.com/astral-sh/ruff
Merge e31f9286f2 into b0bc990cbf
This commit is contained in:
commit
c19d6d3bc6
|
|
@ -1,14 +1,30 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::sync::LazyLock;
|
use std::sync::LazyLock;
|
||||||
|
|
||||||
|
use crate::warn_user_once;
|
||||||
|
|
||||||
|
const DEPRECATED_SELECTORS: [&str; 3] = ["R", "U", "IC"];
|
||||||
|
|
||||||
|
fn check_for_deprecation(code: &str) {
|
||||||
|
if DEPRECATED_SELECTORS.contains(&code) {
|
||||||
|
warn_user_once!(
|
||||||
|
"Using `{code}` as a selector is deprecated and will be removed in a future version."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the redirect target for the given code.
|
/// Returns the redirect target for the given code.
|
||||||
pub(crate) fn get_redirect_target(code: &str) -> Option<&'static str> {
|
pub(crate) fn get_redirect_target(code: &str) -> Option<&'static str> {
|
||||||
|
check_for_deprecation(code);
|
||||||
|
|
||||||
REDIRECTS.get(code).copied()
|
REDIRECTS.get(code).copied()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the code and the redirect target if the given code is a redirect.
|
/// Returns the code and the redirect target if the given code is a redirect.
|
||||||
/// (The same code is returned to obtain it with a static lifetime).
|
/// (The same code is returned to obtain it with a static lifetime).
|
||||||
pub(crate) fn get_redirect(code: &str) -> Option<(&'static str, &'static str)> {
|
pub(crate) fn get_redirect(code: &str) -> Option<(&'static str, &'static str)> {
|
||||||
|
check_for_deprecation(code);
|
||||||
|
|
||||||
REDIRECTS.get_key_value(code).map(|(k, v)| (*k, *v))
|
REDIRECTS.get_key_value(code).map(|(k, v)| (*k, *v))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue