-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Allow overloaded literals #1425
Comments
This would actually be pretty easy to do, but A) it'll only work in contexts where the type of the literal is known before the typechecker reaches the literal (so the above would work, as would |
I don't know the typechecker well enough to say how invasive this is, and/or how determinstic this can be made. I would want it to be very predictable. |
Email summary of IRC discussion: https://mail.mozilla.org/pipermail/rust-dev/2012-March/001461.html Any other preferences? I believe niko is working on refactoring typeck presently. |
I would really really really like this to be implemented. I'm creating an emulator and I cast my u16's to ints before alting them because I can't read the pattern matching when it looks like:
compared to
I find myself using ints so much less than uints, u8s, etc. The syntax may be logical but its extraordinarily hard to read. |
I have some good ideas for implementing this. |
The pull request I just put in (#2469) is a stab at making it possible to drop the "u" suffix under certain conditions. From talking to @nikomatsakis, it sounds like a more principled approach would have to involve creating a new kind of type variable and doing unification on those, separately from the existing type vars; this is more of a quick hack. |
I'm getting started on a less hacky solution to this one. |
In this commit: * Change the lit_int_unsuffixed AST node to not carry a type, since it doesn't need one * Don't print "(unsuffixed)" when pretty-printing unsuffixed integer literals * Just print "I" instead of "(integral)" for integral type variables * Set up trans to use the information that will be gathered during typeck to construct the appropriate constants for unsuffixed int literals * Add logic for handling int_ty_sets in typeck::infer * Clean up unnecessary code in typeck::infer * Add missing mk_ functions to middle::ty * Add ty_var_integral to a few of the type utility functions it was missing from in middle::ty
Sorry for all the commit spam on this issue. I'm getting close to having something that works well. e3f73e4 has some examples of tests that I have passing locally. I'm hoping to be able to un-xfail these and enable suffix inference in the compiler soon... |
As of 3cf582b, suffix inference has landed and seems to be working well enough to close this bug. (Yay!) Please open new bugs for specific issues you encounter with it. |
…line_asm Implement AES-NI and SHA256 crypto intrinsics using inline asm
…obzol Bump `rustc_{codegen_ssa,llvm}` `cc` to 1.2.16 to fix `x86` Windows jobs on newest Windows SDK Part of rust-lang#137733. Bump `rustc_{codegen_ssa,llvm}` `cc` to 1.2.16 which contains rust-lang/cc-rs#1425 to help with rust-lang#137733. Previously tested in rust-lang#137724. #### `cc` changelog between 1.2.13 and 1.2.16 <details> <summary>`cc` changes since 1.2.13 up to and including 1.2.16</summary> ##### [1.2.16](rust-lang/cc-rs@cc-v1.2.15...cc-v1.2.16) - 2025-02-28 ###### Fixed - force windows compiler to run in `out_dir` to prevent artifacts in cwd (rust-lang#1415) ###### Other - use `/arch:SSE2` for `x86` target arch (rust-lang#1425) - Regenerate windows-sys binding ([rust-lang#1422](rust-lang/cc-rs#1422)) - Regenerate target info ([rust-lang#1418](rust-lang/cc-rs#1418)) - Add LIB var when compiling flag_check (rust-lang#1417) - Change flag ordering ([rust-lang#1403](rust-lang/cc-rs#1403)) - Fix archiver detection for musl cross compilation ([rust-lang#1404](rust-lang/cc-rs#1404)) ##### [1.2.15](rust-lang/cc-rs@cc-v1.2.14...cc-v1.2.15) - 2025-02-21 ###### Other - Regenerate target info ([rust-lang#1406](rust-lang/cc-rs#1406)) - Always read from all `CFLAGS`-style flags ([rust-lang#1401](rust-lang/cc-rs#1401)) - Simplify the error output on failed `Command` invocation ([rust-lang#1397](rust-lang/cc-rs#1397)) ##### [1.2.14](rust-lang/cc-rs@cc-v1.2.13...cc-v1.2.14) - 2025-02-14 ###### Other - Regenerate target info ([rust-lang#1398](rust-lang/cc-rs#1398)) - Add support for setting `-gdwarf-{version}` based on RUSTFLAGS ([rust-lang#1395](rust-lang/cc-rs#1395)) - Add support for alternative network stack io-sock on QNX 7.1 aarch64 and x86_64 ([rust-lang#1312](rust-lang/cc-rs#1312)) </details> r? `@Kobzol`
Rollup merge of rust-lang#137788 - jieyouxu:bump-compiler-cc, r=lqd,Kobzol Bump `rustc_{codegen_ssa,llvm}` `cc` to 1.2.16 to fix `x86` Windows jobs on newest Windows SDK Part of rust-lang#137733. Bump `rustc_{codegen_ssa,llvm}` `cc` to 1.2.16 which contains rust-lang/cc-rs#1425 to help with rust-lang#137733. Previously tested in rust-lang#137724. #### `cc` changelog between 1.2.13 and 1.2.16 <details> <summary>`cc` changes since 1.2.13 up to and including 1.2.16</summary> ##### [1.2.16](rust-lang/cc-rs@cc-v1.2.15...cc-v1.2.16) - 2025-02-28 ###### Fixed - force windows compiler to run in `out_dir` to prevent artifacts in cwd (rust-lang#1415) ###### Other - use `/arch:SSE2` for `x86` target arch (rust-lang#1425) - Regenerate windows-sys binding ([rust-lang#1422](rust-lang/cc-rs#1422)) - Regenerate target info ([rust-lang#1418](rust-lang/cc-rs#1418)) - Add LIB var when compiling flag_check (rust-lang#1417) - Change flag ordering ([rust-lang#1403](rust-lang/cc-rs#1403)) - Fix archiver detection for musl cross compilation ([rust-lang#1404](rust-lang/cc-rs#1404)) ##### [1.2.15](rust-lang/cc-rs@cc-v1.2.14...cc-v1.2.15) - 2025-02-21 ###### Other - Regenerate target info ([rust-lang#1406](rust-lang/cc-rs#1406)) - Always read from all `CFLAGS`-style flags ([rust-lang#1401](rust-lang/cc-rs#1401)) - Simplify the error output on failed `Command` invocation ([rust-lang#1397](rust-lang/cc-rs#1397)) ##### [1.2.14](rust-lang/cc-rs@cc-v1.2.13...cc-v1.2.14) - 2025-02-14 ###### Other - Regenerate target info ([rust-lang#1398](rust-lang/cc-rs#1398)) - Add support for setting `-gdwarf-{version}` based on RUSTFLAGS ([rust-lang#1395](rust-lang/cc-rs#1395)) - Add support for alternative network stack io-sock on QNX 7.1 aarch64 and x86_64 ([rust-lang#1312](rust-lang/cc-rs#1312)) </details> r? `@Kobzol`
let i: uint = 0
is not valid and this frustrates almost everybody. Maybe there's some compromise that solves the biggest problem.The text was updated successfully, but these errors were encountered: