diff options
| author | Scott McMurray <scottmcm@users.noreply.github.com> | 2019-02-17 23:55:45 -0800 |
|---|---|---|
| committer | Scott McMurray <scottmcm@users.noreply.github.com> | 2019-02-17 23:55:45 -0800 |
| commit | 9312ca10b6cd672c4fa1da4b4a3cc232f7d7dde6 (patch) | |
| tree | 5899be62a498dda7613e97bdc6a1c3626b2f3c8b /src | |
| parent | 16ca0b9f6335db824e44629be1cafb6e3fcc4628 (diff) | |
| download | rust-9312ca10b6cd672c4fa1da4b4a3cc232f7d7dde6.tar.gz rust-9312ca10b6cd672c4fa1da4b4a3cc232f7d7dde6.zip | |
Add a note about 2018e if someone uses `try {` in 2015e
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_resolve/error_reporting.rs | 4 | ||||
| -rw-r--r-- | src/test/ui/try-block/try-block-in-edition2015.stderr | 2 |
2 files changed, 6 insertions, 0 deletions
diff --git a/src/librustc_resolve/error_reporting.rs b/src/librustc_resolve/error_reporting.rs index 8300e691bbe..fe9ae8b8300 100644 --- a/src/librustc_resolve/error_reporting.rs +++ b/src/librustc_resolve/error_reporting.rs @@ -251,6 +251,10 @@ impl<'a> Resolver<'a> { format!("{}!", path_str), Applicability::MaybeIncorrect, ); + if path_str == "try" && span.rust_2015() { + err.note("if you want the `try` keyword, \ + you need to be in the 2018 edition"); + } } (Def::TyAlias(..), PathSource::Trait(_)) => { err.span_label(span, "type aliases cannot be used as traits"); diff --git a/src/test/ui/try-block/try-block-in-edition2015.stderr b/src/test/ui/try-block/try-block-in-edition2015.stderr index a7b81060d3d..7394fec6f36 100644 --- a/src/test/ui/try-block/try-block-in-edition2015.stderr +++ b/src/test/ui/try-block/try-block-in-edition2015.stderr @@ -16,6 +16,8 @@ error[E0574]: expected struct, variant or union type, found macro `try` | LL | let try_result: Option<_> = try { | ^^^ help: use `!` to invoke the macro: `try!` + | + = note: if you want the `try` keyword, you need to be in the 2018 edition error: aborting due to 2 previous errors |
