Trying Rust2018, getting many warnings on `try` is a keyword

Hi there,

I’m trying out Rust 2018 on my small project and on all the #[derive(Serialize, Deserialize)] from serde, I’m getting this warning: warning:tryis a keyword in the 2018 edition

How do we solves these?


Ok forget my question. These were reported by cargo fix. Once edition properly activated, I got errors because the macro was not imported with a use, all solved now!

You shouldn’t be getting these warnings from dependencies (this case in particular might be bug in rustc or cargo fix), but if you wish to use try, in the 2018 edition you can use r#try. That being said, on your code you really want to use the ? operator instead.

I’m not using try at all, these traits come from serde I believe

This originates from:


Should this be reported to serde?

cc @dtolnay

I tried using serde_derive from a 2018 crate and was not able to reproduce this warning as of rustc 1.30.0-nightly (2f1547c0a 2018-09-11). How do I trigger the warning?

Let me check my Cargo.toml when I get home. And I was getting these when doing cargo fix only

serde related cargo config:

serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"

cargo lock:

name = "serde"
version = "1.0.77"
source = "registry+"

name = "serde_derive"
version = "1.0.77"
source = "registry+"
dependencies = [
 "proc-macro2 0.4.18 (registry+",
 "quote 0.6.8 (registry+",
 "syn 0.15.1 (registry+",

name = "serde_json"
version = "1.0.27"
source = "registry+"
dependencies = [
 "itoa 0.4.3 (registry+",
 "ryu 0.2.6 (registry+",
 "serde 1.0.77 (registry+",

Could you also post rustc --version and what feature flags you had turned on with !#[feature]?

What are the steps to take that trigger this warning? What do I write in and what commands do I run?

The warning was triggered only by using cargo fix and having #![feature(rust_2018_preview, uniform_paths)] in

The rustc version was nightly from the 8th in the evening (UK time)

in #![feature(rust_2018_preview, uniform_paths)]

command line:

cargo +nightly fix --edition
1 Like

@dtolnay to get rid of the warnings for all users on 2015, it might make sense to rename the try! macro to check! or something else internally.

Would this imply all crates keeping 2015 compatibility need to do these kinds of fixes to silence 2018 lints? If so, that feels like a poor user experience and is something the edition was supposed to hide. Should perhaps the link be updated?

1 Like

Serde issue: serde-rs/serde/1385.

I am not planning to rename anything in Serde right now. I believe our use of try is within the space of what needs to be supported by edition hygiene and cargo fix.


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.