Hacker News new | past | comments | ask | show | jobs | submit login

There's worse. When your trait adds function foo and your code does obj.foo(), if the underlying type later adds a foo method, compilation breaks. This is very common with traits that usefully add useful methods that are missing in libstd... which break when said method is finally added there.



I ran into this case yesterday, for some cases there are warnings now. In this case I used ".div_ceil(...)" from from the Num [0] crate.

   (some_integer).div_ceil(&2)
                  ^^^^^^^^

    = warning: once this associated item is added to the standard library, the ambiguity may cause an error or change in  behavior!
    = note: for more information, see issue #48919 <https://github.com/rust-lang/rust/issues/48919>
    = help: call with fully qualified syntax `num::Integer::div_ceil(...)` to keep using the current method
    = note: `#[warn(unstable_name_collisions)]` on by default
[0]: https://crates.io/crates/num


This warning happens during the time the method is added to libstd but is still unstable.


Given that all important codebases should have CI that rejects warnings and runs clippy I would say it is acceptable.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: