News for hackers. Stuff that matters.
Re:Resigning as Asahi Linux project lead by umanwizard on Thursday February 13, 2025 @12:07PM (#43038305)
> Any backwards incompatibilities are explicitly opt-in through the edition system, or fixing a compiler bug.

This is a very persistent myth, but it’s wrong. Adding methods to any trait can break BC (because its name might conflict with a user-defined method), and the Rust project adds methods to standard library traits all the time.

Re:Resigning as Asahi Linux project lead by purplesyringa on Thursday February 13, 2025 @12:46PM (#43038864)
This is true, strictly speaking, but rarely causes problems. Inherent methods are prioritized over trait methods, so this only causes problems if two traits suddenly define a single method, and the method is invoked in an ambiguous context.

This is a rare situation, and std thrives to prevent it. For example, in [1], a certain trait method was called extend_one instead of push for this reason. Crater runs are also used to make sure the breakage is as rare as T-libs-api has expected. The Linux kernel in particular only uses core and not std, which makes this even more unlikely.

[1]: https://github.com/rust-lang/rust/issues/72631

Re:Resigning as Asahi Linux project lead by umanwizard on Thursday February 13, 2025 @01:05PM (#43039126)
Okay, but “they try to avoid issues” is not the same as “they guarantee never to intentionally break BC except to fix compiler bugs”.
Re:Resigning as Asahi Linux project lead by sophacles on Thursday February 13, 2025 @12:46PM (#43038865)
That's just not true. If the user has defined on the struct and a trait also has the method name, the struct's impl is used. Multiple traits can have methods named the same too.

https://play.rust-lang.org/?version=stable&mode=debug&editio...

Re:Resigning as Asahi Linux project lead by umanwizard on Thursday February 13, 2025 @01:02PM (#43039087)
My comment might have been technically wrong as originally stated; I’ve since edited to try to correct/clarify.

What I really meant is the case where a method is added to a standard struct impl that conflicts with a user-defined trait.

For example, you might have implemented some trait OptionExt on Option with a method called foo. If now a method called foo is added to the standard option struct, it will conflict.

Re:Resigning as Asahi Linux project lead by sophacles on Thursday February 13, 2025 @01:26PM (#43039381)
Look at the linked code - it literally shows what happens in that case. What happens is not what you're saying.
Re:Resigning as Asahi Linux project lead by umanwizard on Thursday February 13, 2025 @01:40PM (#43039537)
This code compiles on 1.81 and fails to compile on 1.82: https://godbolt.org/z/9GbbMKjcf
Re:Resigning as Asahi Linux project lead by estebank on Thursday February 13, 2025 @04:28PM (#43041606)
You are always free to use fully-qualified paths to protect yourself from any change in your dependencies (including std) that would break inference (by making more than one method resolve).
Re:Resigning as Asahi Linux project lead by gpderetta on Thursday February 13, 2025 @01:30PM (#43039426)
That's true for literally every non static function in C, given the lack of namespaces. So it can't be a blocker.
Re:Resigning as Asahi Linux project lead by umanwizard on Thursday February 13, 2025 @01:35PM (#43039481)
New versions of gcc don't cause new C standard library functions to exist.