Skip to content

Using character class in regex! macro produces numerous warnings on deprecation of \uABCD #19879

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

Closed
nodakai opened this issue Dec 15, 2014 · 0 comments · Fixed by #19885
Closed

Comments

@nodakai
Copy link
Contributor

nodakai commented Dec 15, 2014

#![feature(phase)]

extern crate regex;
#[phase(plugin)]
extern crate regex_macros;

fn main() {
    regex!(r"\d");
}
<quote expansion>:1:3: 1:8 warning: \U00ABCD12 and \uABCD escapes are deprecated
<quote expansion>:1 '\u0660'
                      ^~~~~
<quote expansion>:1:3: 1:8 help: use \u{ABCD12} escapes instead
<quote expansion>:1 '\u0660'
                      ^~~~~
<quote expansion>:1:3: 1:8 warning: \U00ABCD12 and \uABCD escapes are deprecated
<quote expansion>:1 '\u0669'
                      ^~~~~
<quote expansion>:1:3: 1:8 help: use \u{ABCD12} escapes instead
<quote expansion>:1 '\u0669'
                      ^~~~~
...
<quote expansion>:3:7: 3:12 warning: \U00ABCD12 and \uABCD escapes are deprecated
<quote expansion>:3     '\u0660' ...'\u0669' => true,
                          ^~~~~                     
<quote expansion>:3:7: 3:12 help: use \u{ABCD12} escapes instead
<quote expansion>:3     '\u0660' ...'\u0669' => true,
                          ^~~~~                     
<quote expansion>:3:19: 3:24 warning: \U00ABCD12 and \uABCD escapes are deprecated
<quote expansion>:3     '\u0660' ...'\u0669' => true,
                                      ^~~~~         
<quote expansion>:3:19: 3:24 help: use \u{ABCD12} escapes instead
<quote expansion>:3     '\u0660' ...'\u0669' => true,
...

In this case libunicode::regex::PERLD which is essentially Nd_table is expanded into a sequence of old style Unicode literals \u0660 etc and produce numerous warnings like above.

When we focus on the latter half of the warnings, we notice they come from fn match_class() in libregex_macros:

    fn match_class(&self, casei: bool, ranges: &[(char, char)]) -> P<ast::Expr> {
        let mut arms = ranges.iter().map(|&(mut start, mut end)| {
            if casei {
                start = start.to_uppercase();
                end = end.to_uppercase();
            }
            let pat = self.cx.pat(self.sp, ast::PatRange(quote_expr!(self.cx, $start),
                                                         quote_expr!(self.cx, $end)));
            self.cx.arm(self.sp, vec!(pat), quote_expr!(self.cx, true))
        }).collect::<Vec<ast::Arm>>();

So, this problem is probably because the quote_expr! built-in macro outputs old style Unicode literals (or, some internal data structures indistinguishable from them?)

BenTheElder referenced this issue in websockets-rs/rust-websocket Dec 15, 2014
Keep the compiler happy - need to figure out where the \U00ABCD12 and
\uABCD warnings are coming from
alexcrichton added a commit to alexcrichton/rust that referenced this issue Dec 16, 2014
This changes the `escape_unicode` method on a `char` to use the new style of
unicode escapes in the language.

Closes rust-lang#19811
Closes rust-lang#19879
brson added a commit that referenced this issue Dec 16, 2014
This changes the `escape_unicode` method on a `char` to use the new style of
unicode escapes in the language.

Closes #19811
Closes #19879
alexcrichton added a commit to alexcrichton/rust that referenced this issue Dec 17, 2014
This changes the `escape_unicode` method on a `char` to use the new style of
unicode escapes in the language.

Closes rust-lang#19811
Closes rust-lang#19879
lnicola pushed a commit to lnicola/rust that referenced this issue May 28, 2025
fix: Fix IDE layer not resolving some macro calls
lnicola pushed a commit to lnicola/rust that referenced this issue May 28, 2025
fix: Fix IDE layer not resolving some macro calls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant