-
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
Clarify our story with as
and type placeholders.
#12894
Comments
Triage: this is still a problem, and is now worse because EDIT: I originally misread the issue |
now works just fine. |
|
Ugh, sorry :( |
Interestingly, the fact that |
Not really. The casted-to type ( I feel like we should move it to cast checking. Should I write a PR? |
This is how it is supposed to work, yes, but I think there are cases where the value is not fully inferred before casts are processed. At some point I was introducing more hard errors before cast checking for unresolved variables, and I got errors for this reason, and had to modify the code some. I'd have to go back digging to be more precise though. |
the problem is that now "type_is_known_to_be_sized" now returns false when called on a type with ty_err inside - this prevents spurious errors (we may want to move the check to check::cast anyway - see rust-lang#12894).
the problem is that now "type_is_known_to_be_sized" now returns false when called on a type with ty_err inside - this prevents spurious errors (we may want to move the check to check::cast anyway - see rust-lang#12894).
the problem is that now "type_is_known_to_be_sized" now returns false when called on a type with ty_err inside - this prevents spurious errors (we may want to move the check to check::cast anyway - see rust-lang#12894).
The following now successfully compiles, so we've effectively clarified the story, since as far as I know we cannot change this in a backwards compatible way. Closing since there appears to be nothing left to do in this issue.
|
…lyxyas [`manual_div_ceil`]: init Suggest using `div_ceil()` instead of manual implementation for basic cases. Partially fixes rust-lang#12894 changelog: new lint: [`manual_div_ceil`]
Right now the compiler accepts partial type hints for casts with
as
like this:However, it fails with a fully unrestricted type on the right hand side with a unhelpful error message:
To quote @nikomatsakis:
"The reason that the type check doesn't work is because we check immediately that the
as
conversion is legal. We could just say that the type of<expr> as T
isT
and then go back and check later that the type conversion is legal once types are known. I kind of like that."There are three possible ways to resolve this:
as
, which means fixing theas _
case.as
, which means preventing partial type hints inas
in general.as _
, while allowing partial type hints otherwise. This means catching the error case and emitting a useful error message.The text was updated successfully, but these errors were encountered: