Skip to content

Commit 9312ca1

Browse files
committed
Add a note about 2018e if someone uses try { in 2015e
1 parent 16ca0b9 commit 9312ca1

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/librustc_resolve/error_reporting.rs

+4
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,10 @@ impl<'a> Resolver<'a> {
251251
format!("{}!", path_str),
252252
Applicability::MaybeIncorrect,
253253
);
254+
if path_str == "try" && span.rust_2015() {
255+
err.note("if you want the `try` keyword, \
256+
you need to be in the 2018 edition");
257+
}
254258
}
255259
(Def::TyAlias(..), PathSource::Trait(_)) => {
256260
err.span_label(span, "type aliases cannot be used as traits");

src/test/ui/try-block/try-block-in-edition2015.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ error[E0574]: expected struct, variant or union type, found macro `try`
1616
|
1717
LL | let try_result: Option<_> = try {
1818
| ^^^ help: use `!` to invoke the macro: `try!`
19+
|
20+
= note: if you want the `try` keyword, you need to be in the 2018 edition
1921

2022
error: aborting due to 2 previous errors
2123

0 commit comments

Comments
 (0)