diff --git a/src/rules/pyupgrade/helpers.rs b/src/rules/pyupgrade/helpers.rs index 99081f8498..6d3cfa8dbb 100644 --- a/src/rules/pyupgrade/helpers.rs +++ b/src/rules/pyupgrade/helpers.rs @@ -1,11 +1,12 @@ use once_cell::sync::Lazy; use regex::{Captures, Regex}; -static CURLY_ESCAPE: Lazy = Lazy::new(|| Regex::new(r"(\\N\{[^}]+})|([{}])").unwrap()); +static CURLY_BRACES: Lazy = Lazy::new(|| Regex::new(r"(\\N\{[^}]+})|([{}])").unwrap()); pub fn curly_escape(text: &str) -> String { - // We don't support emojis right now. - CURLY_ESCAPE + // Match all curly braces. This will include named unicode escapes (like + // \N{SNOWMAN}), which we _don't_ want to escape, so take care to preserve them. + CURLY_BRACES .replace_all(text, |caps: &Captures| { if let Some(match_) = caps.get(1) { match_.as_str().to_string()