You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Uses of "do catch" suggest non-working "try" instead #53672
let action : Result<Action, Error> = do catch {
let signed_action = base64::decode(form.signed_action.as_str())?;
let signed_action: SignedAction = deserialize_from_slice(signed_action.as_slice())?;
signed_action.verify(&config.secrets.action_signing_key)?
};
after updating nightly, this does not compile any more. It says
error: found removed `do catch` syntax
--> src/routes.rs:164:42
|
164 | let action : Result<Action, Error> = do catch {
| ^^
|
= help: Following RFC #2388, the new non-placeholder syntax is `try`
So I tried
let action : Result<Action, Error> = try {
let signed_action = base64::decode(form.signed_action.as_str())?;
let signed_action: SignedAction = deserialize_from_slice(signed_action.as_slice())?;
signed_action.verify(&config.secrets.action_signing_key)?
};
but that does not compile either
error: expected identifier, found keyword `let`
--> src/routes.rs:164:9
|
163 | let action : Result<Action, Error> = try {
| --- while parsing this struct
164 | let signed_action = base64::decode(form.signed_action.as_str())?;
| ^^^ expected identifier, found keyword
I have also tried try catch, to no avail.
At the very least, the error message about "do catch" needs to be improved, as its advise is clearly incorrect. But also, I wonder what I should do now :D I guess I'll use an immediately-applied closure again...
This was very confusing to run into (for some reason this error occurs on Travis, but not locally for me). It'd make much more sense to me to allow do catch before the 2018 edition.
Activity
Centril commentedon Aug 25, 2018
cc @scottmcm
scottmcm commentedon Aug 25, 2018
@RalfJung Oh, right, the error message should mention that you need to be in the 2018 edition.
(I could also make
do catchordo trywork temporarily in 2015, I suppose...)durka commentedon Aug 25, 2018
So is
do catchgoing to be removed from 2015 with no replacement? That's not very nice.Centril commentedon Aug 27, 2018
@durka It was never the plan to stabilize
do catch; it was always a temporary syntax.scottmcm commentedon Aug 27, 2018
@durka Do you have a case where you have nightly 2015 code that cannot migrate to nightly 2018?
jonhoo commentedon Sep 6, 2018
I'm confused. Even with
#![feature(rust_2018_preview)]the syntax
still does not work?
jonhoo commentedon Sep 6, 2018
Ahh, it looks like you also need
edition = 2018in yourCargo.tomlas outlined in the transition guide.varkor commentedon Sep 13, 2018
This was very confusing to run into (for some reason this error occurs on Travis, but not locally for me). It'd make much more sense to me to allow
do catchbefore the 2018 edition.Rollup merge of rust-lang#58555 - scottmcm:try-2015, r=Centril
Rollup merge of rust-lang#58555 - scottmcm:try-2015, r=Centril
scottmcm commentedon Feb 23, 2019
I've closed this now that there's an additional message about the edition on
try. That's not amazing, but this is also a nightly-only thing.Have you perchance been able to use
try{}in nightly 2018 edition now, @RalfJung?RalfJung commentedon Feb 23, 2019
Yes, they seem to work as intended. :)