Try keyword reservation breaks macro try


#1

Hi there, I have some code I’m converting from rust pre-2018 to rust post-2018, and I’ve faced the issue that I’m trying to call the try macro, but am ending up with a reserved keyword error…:

error: expected expression, found reserved keyword `try`
  --> opengles_graphics/src/shader_utils.rs:55:24
   |
55 |         let location = try!(attribute_location(program, name));
   |                        ^^^ expected expression

error: expected expression, found reserved keyword `try`
  --> opengles_graphics/src/glyph_cache.rs:51:24
   |
51 |         let mut file = try!(File::open(font));
   |                        ^^^ expected expression

Was this done on purpose, or by accident?


#2

The try! macro has been superseded by ? for a while. If you still want to use try! specifically, you can use the raw identifier syntax: r#try!(foo).


#3

Also get familiar with cargo fix tool, it may safe you time.