-
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
Rustc asks for Reflect, which is unstable, when it could be asking for Any which is stable #33807
Comments
There is supposed to be a note: Lines 456 to 457 in 34fd686
But it's not triggering. It used to work on stable, but is broken on beta. cc @GuillaumeGomez |
@tinco: Do you have a shorter code sample by any chance? |
Reproduction: use std::any::Any;
fn log<T>(value: &T) {
let value_any = value as &Any;
// try to convert our value to a String. If successful, we want to
// output the String's length as well as its value. If not, it's a
// different type: just print it out unadorned.
match value_any.downcast_ref::<String>() {
Some(as_string) => {
}
None => {
}
}
}
fn main() {}
Looks like it does mention |
That's what I got as well so I concluded it wasn't what he did. But maybe this is already solved in nightly? |
It mentions |
This was tagged regression-from-stable-to-beta but that was a cycle ago so it is now a regression-from-stable-to-stable (albeit a quite minor one). rustc 1.8.0 prints this in response to @jonas-schievink's code:
The fifth line (first note) is not printed by 1.9.0 or later versions. |
@durka: I updated the tag. |
@rust-lang/compiler and/or @durka is this likely to get fixed or should we give up on this? Does seem a shame to live with this regression, but given that it's been on stable for a while (and Reflect will probably disappear anyway) perhaps it is not worth fixing? |
@nrc It's good idea to track the underlying diagnostics regression (@jonathandturner may be interested). |
|
Do we have any code that actually reproduces the problem? |
current error message:
|
Conclusion for @rust-lang/compiler meeting: current behavior appears to be correct, so we believe problem is fixed, can call this I-needs-test. |
triage: P-low |
Actually, this was misunderstood. The problem is that at some point we decided (perhaps incorrectly) that this kind of message we see now is higher priority that |
OK, that's weird to me (why not print both), but if it was deliberate then this can be closed. |
Closing per previous comments. |
Hi,
I had a latenight coding session and ran into this error:
Seems like an easy fix, add Reflect to the type constraint of the T, but that yields this exception:
That #27749 looks like it won't soon be solved and probably #31844 will supersede it in some way. So this advice from the compiler of adding Reflect is not very nice.
Perhaps we could have it recommend implementing Any instead? Or at least mention Any would do it as well? Most rookies won't know that Any is basically Reflect+'static.
Here's my forum question about this topic with the code that threw the error.
The text was updated successfully, but these errors were encountered: