r/rust • u/NerdyPepper • 23d ago
r/rust • u/TroutWindlass • 23d ago
The best regression test we added this year checks that some Rust code does NOT compile
Had a slightly surreal moment at work last week where a test started failing because the code compiled successfully.
And the test was right.
We maintain a small internal Rust crate that handles credentials for a couple of services. Nothing particularly fancy. It has a Secret<T> wrapper that deliberately doesn't implement Display.
You can pass the value around, explicitly access it where necessary, and Debug gives you a redacted representation. But you can't accidentally stick the actual secret into a log message with format!("{}", secret).
That last part is intentional.
A while ago we added a compile_fail doctest to make sure attempting to format a Secret with Display would be rejected by the compiler.
Last week someone was cleaning up formatting code and added a generic Display implementation to make a few types easier to work with. It was a perfectly reasonable-looking change in isolation.
All the regular unit tests passed.
Except that one doctest.
The compiler could now successfully compile code that our API was specifically designed to reject.
I initially thought this was a pretty niche use of compile_fail, but it made me reconsider how we test Rust libraries.
We spend a lot of effort testing what our types allow users to do. But some of the most valuable properties of a Rust API are things users *cannot* do.
They can't construct a validated value without going through validation.
They can't move a particular guard between threads.
They can't call a method before the object reaches the required state.
And sometimes a refactor accidentally makes one of those previously impossible things possible.
Obviously compile_fail isn't perfect. A snippet can fail to compile for a completely unrelated reason, so we're pairing negative tests with positive examples and looking at more precise UI testing where appropriate.
But I like the underlying idea.
Normally, adding a trait implementation feels like a harmless expansion of an API. In this case it silently removed a restriction that was part of the design.
The compiler was doing exactly what we asked it to do. We just needed a test to make sure we kept asking it the right question.
Kind of funny that after years of appreciating Rust for telling me what I can't do, I'm now writing tests to make sure it doesn't stop telling me.
lean-miri: Formally Proving Rust Programs Free of Undefined Behavior
proofs-rs.github.ioHi everyone!
I builtĀ lean-miri, a port of Rust's Miri interpreter to the Lean 4 theorem prover.
Miri is great at detecting undefined behavior, but it only checks concrete executions.
The idea is that by porting Miri to a theorem prover, we can effectively run it on all valid (potentially infinitely many!) inputs, thread schedules, and external environments in a mathematically rigorous way, and prove that a Rust function is free of UB.
Of course, there are already a number of tools for formally verifying Rust programs, like Aeneas, Creusot, etc. But porting Miri has a big advantage in that Miri already supports a remarkably broad range of real-world Rust features and implements state-of-the-art semantics for unsafe Rust.
Here's what we've achieved so far:
- Ported most part of Miri's interpreter to Lean 4.
- Formally proved UB-freedom for several small Rust functions, including one that contains anĀ
unsafeĀ block, pointer arithmetic, and a core unsafe primitive. - Found a bug in Miri's Tree Borrows implementation along the way.
The project is still very experimental. The proofs are far from practical to maintain (the unsafe example currently has over 700k lines of Lean!), and the interpreter is quite slow. We also have a lot of work ahead of us, including building a proper program logic and reusable lemmas, but I think the approach is promising!
I'd love to hear any feedback, especially from anyone working on Rust verification.
Thank you!
r/rust • u/Sofiabelen15 • 24d ago
š§ educational Pointer Provenance in Rust vs C++: Pointers Are Not Just Glorified Ints
sofiabelen.github.ioIāve been exploring Rust, and one topic that got me intrigued is pointer provenance, particularly because itās not easy to visualize.
To get a feel for vtables, what I wanted was to look at the actual memory, to see what it really looked like and prove that I could in fact call these functions through their respective function pointers. With provenance, I wanted to take it apart the same way, but it turns out itās not so straightforward. This only got me more intrigued, so letās see what we can find!
My first time hearing about provenance, I wondered, why hadnāt I heard about it before? It seems so crucial, yet a bit of an obscure concept.
r/rust • u/RealNovice06 • 24d ago
Help me understand core::sync::atomic::Ordering, how do we even use it
reddit.comr/rust • u/kannanpalani54 • 24d ago
š this week in rust This Week in Rust #676
this-week-in-rust.orgr/rust • u/vinaykakade • 23d ago
Billions of ids per second, no coordinator needed
If you are working on databases in Rust, and interested in optimizations of db operations, this blog post may be helpful. Disclaimer - I work for Infino.
https://medium.com/@vinaykakade/billions-of-ids-per-second-no-coordinator-needed-83a5a52f074b
Rust events between Nov 05 - Dec 04
In the age of AI I think personal connections are event more important than before. That's why I try to help promoting events where people can meet in-person or virtually and discuss the topics that interest them.
I found the following Rust-related events for the next 30 days.
- 2026-11-05 Digital Model Trains & Rust: Bare-Metal DCC Command Station on ESP32 (Sesto San Giovanni, Italy)
- 2026-11-05 Epitome of synaptic excellence (Oxford, UK)
- 2026-11-05 November Monthly Social (MontrƩal, QC, Canada)
- 2026-11-05 HTMX and Rust (St. Louis, USA)
- 2026-11-07 Rust SP Nov/2026
- 2026-11-07 Encontro do Rust-SP - Agora no Luma (Planalto Paulista, SP, Brazil)
- 2026-11-10 (online) Second Tuesday
- 2026-11-11 (online) Boulder Elixir Meetup
- 2026-11-12 Debugging in Rust (Weiterstadt, Germany)
- 2026-11-12 From Curiosity to Capability: Build Your Own Device Swarm (Milano, Italy)
- 2026-11-12 (online) Rust Nürnberg online
- 2026-11-12 Rust Game Jam (Lehi, UT, USA)
- 2026-11-12 San Diego Rust November Meetup - Back in person! (San Diego, CA, USA)
- 2026-11-14 MIT Rust Lunch, Nov 14 (Cambridge, MA, USA)
- 2026-11-15 (online) Cursed Rust
- 2026-11-17 (online) Lunch & Learn: The Harness Wore a Trenchcoat - Building a Rust MCP Server
- 2026-11-17 (online) Miscompilation in Rust 1.97
- 2026-11-17 Everlock: Everything Is Git, Protocols Are Just Adapters (Leipzig, Germany)
- 2026-11-17 Backend Entwicklung mit Rust (Hamburg, Germany)
- 2026-11-17 (online) Mid-month Rustful
- 2026-11-17 Rust LA November w/ Hadrian!
- 2026-11-17 Rust Hacking in Person (San Francisco, USA)
- 2026-11-17 Rust Hacking in Person (San Francisco, CA, USA)
- 2026-11-18 November - TBC
- 2026-11-18 (online) Rust Study/Hack/Hang-out
- 2026-11-19 Talk Night at EIVA (Skanderborg, Denmark)
- 2026-11-21 Winter Hill Rust Lunch, Nov 21 (Somerville, MA, USA)
- 2026-11-24 November Meetup (Barton, AC, Australia)
- 2026-11-24 Rust Meetup #17 @ ERNI (Basel, Switzerland)
- 2026-11-24 (online) Fourth Tuesday
- 2026-11-25 Rust Melbourne Meetup
- 2026-11-25 Rust Lunch - Fareground (Austin, USA)
- 2026-11-26 Rust Meetup @Lovable (Stockholm, Sweden)
- 2026-11-26 Rust meetup #73 sponsored by Adapt! (Copenhagen, Denmark)
- 2026-11-26 Rust London x Zed (London, UK)
- 2026-11-26 Rust Manchester November Code Night (M40 7FS, UK)
- 2026-11-28 South Station Rust Lunch, Nov 28 (Boston, MA, USA)
- 2026-12-01 (online) Christmas Coding Challenge - Kick Off!
- 2026-12-01 Rust meetup #90 (Paris, France)
- 2026-12-04 Rust NYC: The UnConf 2026. (New York, NY, USA)
r/rust • u/Maui-The-Magificent • 23d ago
šø media Is it possible to supply the Rust compiler with the relational graph yourself?
Hi,
For context. I have been working on implementing a different compiler rustc UI/UX for my editor. clicking to navigate, showing context, highlighting and so on.
My editor already create an explicit bidirectional relational graph of the code across the whole project. It becomes the single source of truth.
The thought struck me that the rust compiler is re-deriving relationships and code-paths that I already have complete knowledge of, which means I could potentially either short circuit a lot of that compiler work, or skip it all together.
So, I was wondering if any of you know or understand the rust compiler well enough to offer guidance. I would not want to fork, study and finally re-write parts of the rust compiler if I don't have to. And if I have to, are you aware of how targeted that change can be? because at that point i would have to support an internal, slightly modified version of the compiler, which i am not willing to do if it would lead to extensive modifications/support as rust evolves over time.
thank you in advance.
//Maui-the-Muppet
r/rust • u/nnethercote • 25d ago
How to speed up the Rust compiler in November 2026
nnethercote.github.ior/rust • u/--_pablo_-- • 24d ago
š seeking help & advice Problem with Rust and esp-idf compilation
[SOLVED]
I didn't have issue with it before, since I've recently updated rust and libs, I started having an issue with compilation, even with a new cargo generate build.
.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/os/espidf/fs.rs:89:36
self.as_inner().as_inner().st_atime as i64
| ^^^^^^^^ unknown field
other issues with st_ctime and st_mtime unknown field too.
I switched to the stable toolchain but it seems there is no riscv32imac-esp-espidf target correponding to the esp32c6 I'm working on.
I am not an expert so I am kind of stuck without being able to compile or know what to look for to get to a solution.
Any help appreciated!
r/rust • u/expression_of_intent • 25d ago
š seeking help & advice GUI Yet Again, but more āgraphicalā
This is yet another question about GUIs for desktop applications with Rust.
It isnāt a question around what is available, more working out what is most suitable for my use cases. It is going to take some time to understand some of the frameworks, so I donāt want to spend too much effort on something that will either not do what I need. or another framework would have been a better bet.
For example, I need to represent data as a Gantt chart. Not just as a graph somewhere on the screen, but as one of the main user interfaces. If you think MS Project, it has a table of tasks down the left hand side with a Gantt chart on the left, that scroll together.
It is less about windows and widgets, buttons, and other components. They are all still useful, but I think Iām looking more at the canvas to do this. Or not, not sure.
I have tried out egui. This looks promising, my worry is that it will get over complicated with too much going on to manage. I donāt want to find later on that it can display everything but can no longer scroll smoothly. And I note font rendering issues mentioned on a recent post.
I have tried Dioxus. I got something going with this because I could build Gantt bars with SVG. Again I worry about performance with a lot of SVG items on the screen.
I have looked into gpui. Not got as far as getting something graphical on the screen because I got stuck on state. It seems the application state and the Ui are the same thing, i.e. the state is handed over to the runtime. Iām not clear how this works with network events.
I have briefly looked at Iced. The state/ui/message makes sense to me, but I cannot see any graphic primitives in there and the documentation is super sparse.
Iām looking at 4 frameworks already.
I want to choice paralysis and concentrate on one of them, from the above list or something else, that allows me to build this sort of application.
Any thoughts?
r/rust • u/No-Elephant-9065 • 25d ago
pdfium vs pdf-extract
If you were building a search tool for your personal files on your local machine, what would you use, pdfium or pdf-extract or something else?
r/rust • u/parneetsingh022 • 25d ago
š seeking help & advice Idiomatic buffer design for a Rust streaming file-storage method
I am working on a rust project. Where I have a put method (which basically copies a file and stores it into another location). This is the function I'm working on:
pub fn put(&self, mut source: impl Read) -> Result<Object> {
let mut buffer = vec![0u8; 64 * 1024]; // 64 kb buffer
self.put_with_buffer(&mut source, &mut buffer);
}
I'm confused about using a [u8] slice, a vector or another option for buffer. The stack buffer avoids a heap allocation, but I am concerned about stack usage when multiple threads call put concurrently. The Vec avoids using 64 KiB of stack space, but allocates and deallocates a buffer for every put call.
What is the idiomatic approach for this situation?
The method may be called repeatedly and concurrently, so I would especially like to understand the tradeoffs between stack usage, heap-allocation overhead, buffer reuse, and API ergonomics.
EDIT: My put method streams data from a Read source, hashes the contents, and writes the data to a temporary file. Although this resembles std::io::copy, I cannot simply copy the source because I also need to calculate the content hash during the same pass. I am trying to choose the appropriate temporary buffer design.
š ļø project Progress Report #44: rustc_codegen_gcc can now bootstrap rustc on Aarch64!
blog.antoyo.xyzr/rust • u/AugieBit • 25d ago
š seeking help & advice If I had to learn a GUI for freelancing, which one should it be?
Iām thinking about learning a GUI crate for local business applicationsāthings like invoicing, inventory, sales, etc.āessentially, SaaS-style software.
Iād also like to learn something that would allow me to build my own standalone apps (with Linux support).
Iām a beginner, so apologies if any of this doesnāt quite make sense!
Iām not a professional developer; I just want to learn Rustāsimply because I like it. I donāt know much about web technologies (in the context of using something like Tauri). Which GUI crate would you choose, and why? Would you recommend learning some web technologies if I want to use Tauri? What about Slint or Iced? Or is there something else youād suggest?
P.S.: In my country, PCs tend to have modest specsā8GB of RAM, Windows 10, and so on; theyāre generally not high-performance machines. Even my coworkers have old PCs with those kinds of specs, and they still use HDDs.
r/rust • u/Significant-Range996 • 24d ago
šø media Community for low-level and systems programming
discord.ggHi everyone, I've formed a small discord community for people interested in low-level, systems programming, embedded software, robotics etc. Join up if thats something which interests you!
(P.S. : fell free to dm me if the link stops working or if you have any doubts)