11 ms·
Rust 1.59.0 with inline assembly support etc.
- mleonhard 5y agoDear Rust Team, Thank you for your hard work! Rust helps me be more productive. It makes our systems more reliable, which reduces stress. And sometimes I have fun while working with it. :)
- Kelteseth 5y ago> Today's release falls on the day in which the world's attention is captured by the sudden invasion of Ukraine by Putin's forces. Before going into the details of the new Rust release, we'd like to state that we stand in solidarity with the people of Ukraine and express our support for all people affected by this conflict.
- dthul 5y agoReally looking forward to const generics becoming more and more useful in the future! A current limitation I hit yesterday is that you can't use a (non-literal) expression as a const generic parameter yet. I wanted to specify 32KiB as "32 * 1024" but had to write "32768" instead.
- nynx 5y agoYou can use constant expressions in const generics in many cases. https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=1c1073976ef2fda5fcd4be32cea49e92 https://play.rust-lang.org/?version=stable&mode=debug&editio...
- dthul 5y agoThanks! I didn't realize that it required curly braces and only went off of the red squiggly line my IDE put there instead of reading the helpful compiler output.
- rhn_mk1 5y agoI'm always hitting the limitation that I can't use a const parameter on a trait like a const generic. As an example, this is disallowed: struct Helper<B: Buffer> { x: [u8; B::SIZE], }
- tiddles 5y agoGlad to see inline asm is finally stabilised, that's one less reason to use nightly for osdev!
- kibwen 5y agoAnd support for the `#[naked]` attribute will likely be stabilizing within the next few months (source: I'm getting sponsored to work on it), allowing one to write functions that have precise control over the stack, which is useful for interrupt handlers.
- eddyb 5y agoDon't you want "interrupt ABIs" for that specific usecase? IIRC `#[naked]` are only really guaranteed to allow inline assembly, so it's like defining a function in `global_asm!` except for monomorphization and generally interfacing better with the rest of the language.
- kibwen 5y agoI'm not aware of any proposal for interrupt ABIs, but in the meantime naked functions essentially allow you to create ad-hoc interruput ABIs. Do you have a link?
- steveklabnik 5y agohttps://github.com/rust-lang/rust/issues/40180 https://github.com/rust-lang/rust/issues/40180 was the first one; and Phil has created a pre-RFC a few days ago: https://internals.rust-lang.org/t/pre-rfc-interrupt-calling-conventions/16182 https://internals.rust-lang.org/t/pre-rfc-interrupt-calling-... (That said you're right that naked functions still have a place for doing this, I can't imagine the compiler would grow stable support for every random ABI someone could come up with. But for more well-known ones it's a nice thing.)
- eddyb 5y ago
- ezekiel68 5y agoGood stuff in here. But since they found a bug which caused them to disable incremental compilation by default for this release, I'll likely skip this one and wait a few weeks for 1.60.0 (which these release notes state will likely address the problem and restore default incremental compilation)
- DougBTX 5y agoHave to say I’ve not been following this in any detail, but it was also disabled in 1.52.1, has it been re-enabled again in the meantime? https://blog.rust-lang.org/2021/05/10/Rust-1.52.1.html https://blog.rust-lang.org/2021/05/10/Rust-1.52.1.html
- nicoburns 5y agoYes, it had. There have been ongoing minor bugs (most people won't hit them, and if they do they can just do a fresh build) which they've been fixing over time. But apparently some of the fixes exposed a worse bug this time around, and it wasn't caught until just before the release.
- estebank 5y agoPart of the reason they weren't caught is because it got fixed on nightly right after the previous beta cut off. If the same bug had been present on nightly it would have been picked up quickly.
- kibwen 5y agoAlternatively you can use Rust beta today: `rustup toolchain install beta && rustup default beta`. You'll be doing everyone a favor, as the fact that relatively few people use beta regularly is part of the reason that this issue didn't surface until the last minute. (Plenty of people use beta for CI, which is great, but CI obviously doesn't exercise incremental compilation).
- black_puppydog 5y agoErrrrr.... so you mean you'd rather have the bug, thank you very much? :) Why not just "export RUSTC_FORCE_INCREMENTAL=1" in your env and hope for the best then? :P
- Arnavion 5y agoNot mentioned, but the previous release's feature of capturing idents in format strings automatically did not work for `unreachable!`, ie `let x = 5; unreachable!("{x}");` panicked with the message `"{x}"` instead of `"5"`. This is fixed in 1.59
- benibela 5y agoInline assembly? Is that not too unsafe for Rust?
- josephcsible 5y agoIt's only usable in unsafe blocks.
- throwawayninja 5y agoMy favorite thing about rust is that it has no magic "don't look behind the curtain and your programs will be safe" guard - instead, you define the guard yourself; it's just unnecessary for 99% of code, and within the 1% where you are defining your own curtain the borrow checker et al still try to uphold outside guarantees, making it difficult to shoot _anything_ besides the correct target with rust.
- pjmlp 5y agoYou can still get it wrong, careful with the advocacy. https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=rust https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=rust
- littlestymaar 5y agoYou can still get it wrong, it's just way rarer. (95% of the CVEs listed here are simply “program can trigger UB”, which in the C or C++ land isn't worth a CVE in itself)
- pjmlp 5y agoRare is not never, hence why the advocacy message should be done in a better way.
- lijogdfljk 5y agoI'd be curious to see how many of those are actually safe code though, eh? I've written hundreds of thousands of lines of Rust. Can we estimate how much UB i've introduced?
- rackjack 5y ago`ControlFlow` is a nice QoL addition.
- exitcode0 5y agoNeat! Interestingly Ada has had this feature since its inception around 1983 (use in action with CPUID - https://gist.github.com/AdaDoom3/6466215 https://gist.github.com/AdaDoom3/6466215).
- pjmlp 5y agoIt is nothing new, all high level systems programming languages used to have inline Assembly, and ESPOL in 1961 already had intrisics instead.
- pornel 5y agoRust is meant to be a practical language, not a research project, so it’s not playing the game of firsts: http://venge.net/graydon/talks/intro-talk-2.pdf http://venge.net/graydon/talks/intro-talk-2.pdf > Rust is a language that mostly cribs from past languages. Nothing new […] > Rust picks from 80s / early 90s languages
- tikkabhuna 5y agoVery much a rust newbie. What is this syntax called? > inout(reg) a, inout looks like a function but I don't see how that works with the `a` variable. Is this some magic specifically for asm!?
- yberreby 5y agoThis is specific to asm!. It is a macro, and you can use macros to implement custom syntactic constructs.
- tikkabhuna 5y agoThanks! I'll have to take a look at the Macros section of the book.
- kibwen 5y agoSee also the documentation on inline assembly here: https://doc.rust-lang.org/nightly/reference/inline-assembly.html https://doc.rust-lang.org/nightly/reference/inline-assembly.... .
- alpaca128 5y agoThe Little Book of Rust Macros[0] is also worth a look imho, it helped me a lot when I started learning macros. [0] https://veykril.github.io/tlborm/introduction.html https://veykril.github.io/tlborm/introduction.html
- ostenning 5y agoThanks! Been using rust for a while now and macros seem to be kind of like the final Frontier of Rust development
- alpaca128 5y agoI don't have any problems with macros but I still don't get traits & trait objects. The combination of weird syntax, error messages and unexpected limitations confuses me every time. I'm getting the impression that abstraction isn't quite my thing. Luckily there's still enums. Not as flexible but they make sense to me and don't sprinkle annotation boilerplate everywhere.
- mrlonglong 5y agoI really appreciated the inline ASM in the nightlies when doing a tutorial on working with the RISC-V architecture. Glad it's gone stable.
- ncmncm 5y agoIt was only a few years ago (2015?) that people asking for destructured assignment were treated like simpletons, with a long, jargon-laden explanation how the language formal syntax for destructured "let" was incompatible with assignment syntax as it was then, as if syntax were not something that could be extended anytime, or as if there would be no choice but to express it using the same nonterminals for both. Yet, here it is. I was not fooled, but the attitude left a deep impression.
- kibwen 5y agoThe amount of implied persecution in this comment makes it hard to take this seriously. The original proposals for this suggested extending the full pattern grammar to the LHS of assignments, which would have been a bad idea. Instead, and indeed as you suggest, people came up with a different proposal that hardcoded a subset of the pattern grammar into this context in order to support a majority of what people would like to use this feature for. I have a hard time believing anyone associated with the project treated anyone like a simpleton at any point of the process; problems with the proposal were pointed out and solutions were found.
- ncmncm 5y agoYou may believe whatever you like, but the evidence is all preserved where anybody may read it. And, notably, it is now, six, seven? years later; it could have been implemented any time, including right then. It was not my proposal, and I was not persecuted, so that projection is pure fantasy.
- pcwalton 5y agoPeople disagree about proposed language features. That's not a surprise. It's a sign of a healthy community where debate is encouraged. Besides, C++ ships features at a glacial pace compared to Rust, so I'm not sure what your point is.
- ncmncm 5y agoIt is one thing not to implement a requested feature, entirely another to invent transparently dishonest reasons why it cannot be done.
- pc2g4d 5y agoLooks like a great release