libc icon indicating copy to clipboard operation
libc copied to clipboard

Remove "placeholder constants"

Open workingjubilee opened this issue 2 years ago • 3 comments

It's common for C APIs to define constant values to denote the "last" value in a set of constants, like ELAST or IPPROTO_MAX. This seems prone to weird bugs, and these constants provide very marginal benefit to Rust programmers. Since we're considering some breakage anyways, we should just remove these values where we are made aware of them.

See:

  • https://github.com/rust-lang/libc/issues/1896
  • https://github.com/rust-lang/libc/pull/3040

workingjubilee avatar Mar 02 '23 02:03 workingjubilee

👍, before 0.3, I'd like to deprecate these values.

JohnTitor avatar Mar 03 '23 11:03 JohnTitor

Noticed that we have a lot of *MAX consts and deprecating manually is quite hard. We could write a script but it can cause a false positive, hmm. For now, I've edited the PR template to mention this concern.

JohnTitor avatar Apr 19 '23 19:04 JohnTitor

An alternative to deleting these placeholder constants would be to still provide them but not make any guarantees about their value moving forward. This means that we would be free to change the value of these constants without it being considered a breaking change.

CI tests should specifically exclude these, although it would be nice to make CI fail only if our value for such constants is lower than the one on the system.

Amanieu avatar Mar 15 '24 18:03 Amanieu