Repository: brendanzab/gl-rs (language: rust)

Issue:
Quote expansion warnings
Even rust-xml is updated, I get the same quote expansion warnings of this kind (https://github.com/netvl/xml-rs/issues/34):

```
<quote expansion>:654:39: 654:48 warning: \U00ABCD12 and \uABCD escapes are deprecated
<quote expansion>:654                     '\U000e0100' ...'\U000e01ef' => true,
                                                            ^~~~~~~~~
<quote expansion>:654:39: 654:48 help: use \u{ABCD12} escapes instead
<quote expansion>:654                     '\U000e0100' ...'\U000e01ef' => true,
                                                            ^~~~~~~~~
```

Cargo says it compiles `Compiling xml-rs v0.1.2 (https://github.com/netvl/xml-rs#8e68b6cf)`

What is going on here?



Discussion / hints:
Probably some code being emitted by the `quote!` macro?

I see `quote_ty!` and `quote_item!`. Is this something that needs to be fixed in the `syntax` library?

In the meantime, is there a crate attribute to silence these warnings? They're getting in the way of other more important build errors.

Looks like rust-lang/rust/issues/19879.

We're using regexes [here](https://github.com/bjz/gl-rs/blob/2a465036b8cf27a25d0b982d89539feda00b7bd0/src/gl_generator/generators/mod.rs#L36) and [here](https://github.com/bjz/gl-rs/blob/2a465036b8cf27a25d0b982d89539feda00b7bd0/src/gl_generator/generators/mod.rs#L64)

We could try to remove them, but the code will probably be far more difficult to read.


Fix patch:
diff --git a/src/gl_generator/generators/mod.rs b/src/gl_generator/generators/mod.rs
index 1d08ba38..82f8707e 100644
--- a/src/gl_generator/generators/mod.rs
+++ b/src/gl_generator/generators/mod.rs
@@ -27,17 +27,23 @@ fn gen_enum_item(ecx: &ExtCtxt, enm: &Enum, types_prefix: &str) -> P<ast::Item>
         enm.ident.clone()
     };
 
+    // if the enum has the value of the form `((Type)Value)`, then `val_regexed` contains `(Type, Value)`
+    let val_regexed = {
+        if enm.value.starts_with("((") && enm.value.ends_with(")") {
+            let separator = enm.value.as_slice().chars().skip(2).position(|c| c == ')').unwrap();
+            Some((enm.value.slice(2, separator + 2), enm.value.slice_from(separator + 3).as_slice().trim_chars(')')))
+        } else {
+            None
+        }
+    };
+
     // computing the type of the enum
     let ty = {
         // some enums have a value of the form `((Type)Value)` ; if this is the case, we need to
         //  replace the type of the enum (which is GLenum by default) by the type in the expression
-
-        // matches `((a)b)`
-        let regex = regex!(r"\(\((\w+)\).+\)");
-
-        if (regex).is_match(enm.value.as_slice()) {
+        if let Some((ty, _)) = val_regexed {
             // if the value is like `((Type)Value)`, then the type is `types::Type`
-            regex.replace(enm.value.as_slice(), format!("{}$1", types_prefix).as_slice())
+            format!("{}{}", types_prefix, ty)
 
         } else if enm.value.as_slice().starts_with("\"") {
             // some values are of the form "Value" ; if this is the case, we use `&'static str`
@@ -61,8 +67,11 @@ fn gen_enum_item(ecx: &ExtCtxt, enm: &Enum, types_prefix: &str) -> P<ast::Item>
     let value = {
         // similar to the type, some values are `((Type)Value)`
         // replacing "((Type)Value)" by "Value as types::Type"
-        let regex = regex!(r"\(\((\w+)\)(.+)\)");
-        regex.replace(enm.value.as_slice(), format!("$2 as {}$1", types_prefix).as_slice())
+        if let Some((ty, val)) = val_regexed {
+            format!("{} as {}{}", val, types_prefix, ty)
+        } else {
+            enm.value.clone()
+        }
     };
 
     ecx.parse_item(format!("
diff --git a/src/gl_generator/lib.rs b/src/gl_generator/lib.rs
index ed1fba82..00d41341 100644
--- a/src/gl_generator/lib.rs
+++ b/src/gl_generator/lib.rs
@@ -86,11 +86,7 @@
 #[phase(plugin, link)]
 extern crate log;
 
-#[phase(plugin)]
-extern crate regex_macros;
-
 extern crate khronos_api;
-extern crate regex;
 extern crate rustc;
 extern crate syntax;
 


Test patch: