Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a note about 2018e if someone uses try { in 2015e #58555

Merged
merged 1 commit into from
Feb 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/librustc_resolve/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/try-block/try-block-in-edition2015.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down