-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
non_fmt_panics cannot migrate to 2021 for assert with non-string payload #87313
Comments
I'm not sure there's much we can/should do automatically here. In these cases, the user probably meant to have a assert!(v.is_empty(), true); // throws a Box<Any> containing `true` if v is not empty |
Yea, this is likely a "won't fix", though I think it would be good to leave this open for tracking purposes. I'm wondering if it would make sense to include known migration limitations like this in the edition guide? |
Working on this now, to make the |
Both of those would have resulted in |
I think I just hit something similar, I got the following error message:
But the suggestion doesn't work because |
Yeah, the I think we can just check if either Display or Debug is implemented and suggest something that works. #87982 looks at the type too to see if the argument is a string. Checking if the type has a trait implemented should be doable there too. I'll look into that soon. Edit: filed #87999 for that. |
…=cjgillot Add automatic migration for assert!(.., string). Fixes part of rust-lang#87313.
…=cjgillot Add automatic migration for assert!(.., string). Fixes part of rust-lang#87313.
…jgillot Add automatic migration for assert!(.., string). Fixes part of rust-lang#87313.
I tried this code:
I expected to see this happen: This includes a machine-applicable fix to migrate to 2021.
Instead, this happened: The suggestion is
MaybeIncorrect
preventing automatic migration.Part of the problem is that there isn't an easy way to convert this to
panic_any
. For example, it could convert to:which is pretty awful and probably has other downsides. Trying to format with
{:?}
is also probably not a reliable option, since it would require the payload to impl Debug, and the user's code may be relying on catching the panic and inspecting the payload.I don't know what is really practical here.
Meta
rustc 1.55.0-nightly (014026d1a 2021-07-19)
The text was updated successfully, but these errors were encountered: