I've thought about this off and on for a while, and I have yet to come to API design that works well. Conceptually, with extreme control over niche optimization (that I'm pretty sure rustc doesn't have at the moment) it is possible to have a Result<FiniteF32, FpError> that is identical in representation to f32 and furthermore can implement Add<Result<FiniteF32, FpError>> in such a way that it compiles down to exactly the same as f32 addition (as infinities and NaNs in IEEE 754 are generally s...| Rust Internals - Latest posts
I had first change my project from C to rust, but when I almost completed the project, I found my target platform aarch64-unknown-nto-qnx700 is tier 3 support for official Rust team. So, I think I will have to compile such toolchain by myself. However, I googled and search more compile manuals from AI, all method failed for me. But, I don't want to rewrite my project in C or rollback to C in future. So, any body who has a tested compile solution to share will be very very appreciated. Thanks ...| Rust Internals - Latest posts
One important thing to note is that an &'a mut T<'b> can be converted to an exists<'c> &'a mut T<'c>, but it can't soundly be converted to an &'a mut exists<'c> T<'c>. The former type allows changing the value but requires the lifetime to be the same, whereas the latter type allows changing both the value and the lifetime. The latter type is still sound as long as it was obtained by actually taking a reference to an exists<'c> T<'c> - overwriting the lifetime is fine at that point, cause nobo...| Rust Internals - Latest posts
My function returns impl Iterator. From one branch, I want to return std::iter::Once and from another branch I want to return std::iter::Repeat: use std::iter; fn trues(is_infinite: bool) -> impl Iterator<Item = bool> { if is_infinite { iter::repeat(true) } else { iter::once(true) } } let trues: impl Iterator<Item = bool> = trues(true); for tru in trues {} This feels like it should work - but of course what actually happens is impl Iterator hides the underlying type. There still must be just ...| Rust Internals - Latest posts
I'm not sure how useful this would be in practice, given that you'd likely use the async/await syntax instead, but should the following be allowed/possible and if not: Why not? I don't know enough details about pin project (and future changes to improve its usability), so I don't really know how useful this'd be for those implementing a Future (combinator) in practice. use std::task::Poll; pub fn foo() -> Poll<()> { bar()?; Poll::Ready(()) } fn bar() -> Poll<()> { todo!() } the ? operator can...| Rust Internals - Latest posts
Would git subtree help you in any way as an alternative to submodules?| Rust Internals - Latest posts
See libs-team#504, especially the history of why a generic impl isn't always correct.| Rust Internals - Latest posts
I really do not understand how it is less confusing having to learn: the specific structure of every crate ( because everyone will make a different choice) the actual correct structure that in contrast with #include in C you should only mod a module once, while the wrong way to mod a module from multiple modules can be valid it is almost always wrong and leads to really confusing errors (i suspect this will be the biggest hurdle) not making cycles with modules by accident that yes you are all...| Rust Internals - Latest posts
I can see your profile without issue.| Rust Internals - Latest posts
If/when you bring this to the cargo team, it would be good to include reproduction steps as well as characterize the performance impact (when it happens, how slow it can be, and end-user impact). In addition to the problems you gave, note that the function you linked to specifically calls out that it is blocking and why. Git source updates use progress bars, there is no support for concurrent progress bars in cargo, so these must be disabled for concurrent source updates. Should I add support...| Rust Internals - Latest posts
Yes. (Or perhaps mod foo = "parent/foo.rs".) No. Having that information there, in all cases, even though it would usually be redundant, is in fact the thing I want. It would not be annoying noise to me. It would be consistency and reduced cognitive load. It would be collapsing the special case and the normal case together, making there no longer be any special cases. It might make more sense to you if I turn it on its head: I believe that Rust would be easier to learn and easier to work with...| Rust Internals - Latest posts
(Most recent version on GitHub) Feature Name: abi_aarch64_indirect_return Start Date: 2025-08-24 RFC PR: rust-lang/rfcs#0000 Rust Issue: rust-lang/rust#0000 Summary Introduce a new target-specific calling convention aarch64-indirect-return, which will pass the first argument as if it was an indirect result location pointer (that is, through the x8 register). This would make it possible for Rust to interoperate with C++ functions that return non-trivial C++ objects on aarch64. Motivation Cur...| Rust Internals
Discussions around the design and implementation of The Rust Programming Language| Rust Internals
there's a lot of arguments for and against this, but i think a lot of these don't matter, because many crates are already shipping prebuilt artifacts. ideally this could also be integrated with some sort of deterministic build system. the simplest implementation would be a per-crate (not per package) table that maps a target triple and a rust version (may be ignored for crates with a stable ABI or ones that are cli-only) to a hash and url for that crate's output. may need another layer of nes...| Rust Internals
The full proposal document is in our tag-std repository. It's too long to read in this post, considering there are more conversations going on. We are experimenting this feature on verify-rust-std, Rust for Linux, and Asterinas OS. Any idea and feedback is welcome! ❤ Summary This RFC proposes a DSL (domain-specific language)-based mechanism for specifying safety properties, aiming to standardize how safety descriptions are written in API documentation. On the one hand, it seeks to...| Rust Internals
Continuing the discussion from Pure annotation for stateless functions, since I think it was getting off-topic: For future readers, in the previous topic there was a thread about when functions are pure, and how panics and loops interact with pure functions. Maybe, let me lay out the definitions I'm using, Pure function: a function when given the same inputs, returns the same outputs, and produces no effects Total function: a function which always returns normally (does not diverge), but it...| Rust Internals
They can: fn main() { let mut foo = Vec::new(); let bar: &mut Vec = &mut foo; std::panic::catch_unwind(std::panic::AssertUnwindSafe(move || { bar.push(42); panic!(); })).unwrap_err(); assert_eq!(foo[0], 42); println!("Mutable reference crossed panic boundary"); }| Rust Internals
Proposal: Add a .pick(val) Method to Collection Types Hello Rust community, I'd like to propose (or at least start a conversation around) the addition of a .pick(val) method to standard collection types like Vec, HashSet, and HashMap. What .pick(val) Would Do This method would search for a given value (or key), and: Return it if found Panic if not found Example (on Vec): let nums = vec![1, 2, 3]; let x = nums.pick(2); // returns 2 let y = nums.pick(4); // panics: "Value not f...| Rust Internals
Discussions around the design and implementation of The Rust Programming Language| Rust Internals
Discussions around the design and implementation of The Rust Programming Language| Rust Internals
Please add support for generating markdown files from rust documentation comments. By generating markdown files, we can easily add these files to our github projects as the documentation of the project and these markdown files are simple in syntax and can be read on github within the browser like any other README.md file is for any github repo.| Rust Internals
Feature Name: doc_gfm_alerts Start Date: 2025-06-13 RFC PR: Rust Issue: Summary Adding github compatible markdown alerts to rust documenation. Motivation Uses a markdown like syntax instead of html; Adding more kind of alerts for rust documentation; More consistent render beetween docs.rs and github. Guide-level explanation In one hand, github has added a new extension to its markdown syntax : New Markdown extension: Alerts provide distinctive styling for significant content. This extensio...| Rust Internals
Discussions around the design and implementation of The Rust Programming Language| Rust Internals
Summary Add a built-in #[derive(Error)] macro to std::error, inspired by thiserror, to reduce boilerplate for custom error types. Motivation Most Rust projects need custom errors, but implementing std::error::Error, Display and From is verbose. thiserror solves this elegantly, but adds a dependency and cannot be used in all environments. Example #[derive(Error, Debug)] enum MyError { #[error("not found")] NotFound, #[error("IO error")] Io(#[from] std::io::Error), }| Rust Internals
While discussing the "dedented string literals" RFC I noticed that Rust's treatment of newlines in source text does not appear to match what the Unicode annex that we're using as a normative reference for 'whitespace' says is supposed to happen. The Rust reference says that "whitespace" is defined as any sequence of Unicode Pattern_White_Space characters with a reference to UAX#31 for the definition of Pattern_White_Space. The Rust reference doesn't, as far as I can tell, make very much disti...| Rust Internals
I just posted the first post of what I expect to be an "irregular series" of posts, entitled Adventures in consensus: In the talk I gave at Rust LATAM, I said that the Rust project has always emphasized finding the best solution, rather than winning the argument. I think this is one of our deepest values. It's also one of the hardest for us to uphold. Let's face it -- when you're having a conversation, it's easy to get attached to specific proposals. It's easy to have those proposals change ...| Rust Internals
I’ve been posting a bunch of blog posts on dyn async in traits. I just realized I never made an internals thread to discuss them! Fixed. Part 1 Part 2 Part 3 Part 4 Part 5| Rust Internals
In my last post, I talked about the new “pinned references” which guarantee that the data at the memory it points to will not, ever, be moved elsewhere. I explained how they enable giving a safe API to code that could previously only be exposed with unsafe, and how one could go about proving such a thing. This post is about another application of pinned references—another API whose safety relies on the pinning guarantees: Intrusive collections. It turns out that pinned references can al...| Rust Internals
Recently, a new API for “pinned references” has landed as a new unstable feature in the standard library. The purpose of these references is to express that the data at the memory it points to will not, ever, be moved elsewhere. Others have written about why this is important in the context of async IO. The purpose of this post is to take a closer, more formal look at that API: We are going to take a stab at extending the RustBelt model of types with support for pinning. https://www.ralfj...| Rust Internals
RFC 2349 proposing a new set of APIs to deal with types that cannot be safely moved around - especially generators and async functions. You can read more details of the design in the RFC. This thread is a sidebar to discuss the names of these types. The names proposed in the RFC were arrived at ‘evolutionarily’ as several different previous APIs converged into the present one. So they’re not necessarily very good. The relationship between the three items (review of the RFC) The trait Mo...| Rust Internals
Secretly and behind the scenes more and more Rust code lives a life before main. What is life before main? It's code that executes before the rust runtime has been initialized in main. This is something that Rust does not support but because the world needs to support C++ static initializers and __attribute__((constructor)) in C, it's also possible to get Rust code to execute this way. The popular crate for this is ctor. Using it is probably not a great idea, but unfortunately there are lots ...| Rust Internals