Kind of low-key hilarious that someone thought this was a serious enough issue to actually submit that code. I wonder if there is a written spec that helps to judge which integers should be considered "problematic" and which ones aren't.
Maybe they just didn't want the checker to flag itself.
I remember there was a similar check inside Google, where any file containing the words "DO NOT SUBMIT" will cause the presubmit check to fail. Naturally the presubmit checker needs to look for that string, but it couldn't trivially include the string as-is because that would prevent the presubmit checker from being submitted.
(Motivation for something like this is that if you inserted some extra logging statements or similar for debugging, you would add "DO NOT SUBMIT" in nearby comments, so that you will remember to remove them later).
It's also fun if you want to include that string in a template file so that users of the template don't forget to fill in the template before submitting.
The actual diff in question [1] does show that there have been multiple cases where such "magic" numbers did appear in rustc, so that the lint is meant to catch any such known cases to reduce possibly resulting complaints in advance, no matter you like them or not. (This is also why the list is not as exhaustive, as it needn't to be.)
And now I can't unrememeber and feel totally compelled to a) translate them and b) use them in my code somewhere.
Cannot help but think this is a deliberate pun, to get cynic's imagination going ... did they do this to poke fun at the PC brigade asking for it, or were they actually seriously believing it would make users look the other way ? Either option is funny.
(practically, used only "F0015601D" ... as IPv6 link-local address. No, wasn't a honeypot service)
if your coworker says 'ana over in sales is a babe' they're almost certainly commenting on her appearance, not just mentioning her gender. even if they don't explicitly mention her b16 b00b5, you may reasonably wonder if they're judging you on the same basis, and in particular whether you'd have a better yearly peer evaluation if you were a dowdy man instead of a dowdy woman
if they instead say 'leslie over in sales is a dood' they're just being explicit about his gender, perhaps because someone thought he was female
i'm not endorsing any value judgments for or against these statements, just explaining what other people's thinking (factually) is which leads to the kind of value judgments that lead to policies against putting b00b135 in your source code
i suspect cafed00d was included as a (possibly counterproductive) gesture to allay equity concerns like yours rather than because of any serious concern that a cafed00d constant would cause anyone any concern on its own
It's probably based on the Hexspeak Wikipedia page [1], which contains 7 "babe" constants and only 2 "d00d" constants. So we already had much more "babe" magic constants to start with, I wonder why... ;-)
A lot of my posts are mildly cryptic and meant to be humorous, but I’ll just put this out here seriously. I think anyone who originates an identifier like DEADBABE is a sick pup.
No wonder the compile times are so slow. Rustc comes with built-in content moderation!
Anyway I think they forgot a few, like 173406926 (// Intentionally written in decimal rather than hex).
Seems like they just checked https://en.wikipedia.org/wiki/Hexspeak. Kind of a weak effort, overall.
Really? Current mainstream political shibboleths are more important than for example their stance on module versioning or on whether C code should have a right to exist?
it seems likely that the degree of importance they accord to current mainstream political shibboleths is informative about the community's value system and decision-making process, and therefore how it will change its policy on module versioning and c code in the next few years
probably some people will think it's encouraging information, and others will think it's discouraging information, but either way it's important information
So someone using "0xCAFEBABE" or whatever, do you really think women take it personally, or what is the problem here? If I were to use it, there would be no target, and I doubt in most common uses there are any, so it does not make much sense to me.
I’ve never liked those hex words, especially the sexually connoted ones, but at the same time I find the existence of code checking for them very cringy.
Because every word and every combination of hexadecimal characters is "potentially offensive", and because those prone to taking offense are perfectly capable of finding it anywhere that they want to anyway?
> Because every word and every combination of hexadecimal characters is "potentially offensive"
No they are not. There are plenty of harmless combinations, like 0x1235679a or other with English words like 0xcafebad0.
Offensive was a bit of a strong word here, I was mostly paraphrasing the dictionary. However in male-dominated field, using an objectifying word targeting 50% of the world population is definitely in poor taste.
Most important of all, it looks unprofessional. It don't think it would look professional for HR to put jokes in our salary sheets, and I think the same applies to company code.
But there is a target here, too. "Ana" and "Leslie". I get the "b00b" ones may be "bad" in the sense that those are sexually explicit nouns, but as for "d00d" or "babe", not so much as it requires a target.
It's a mystery, lost to the sands of time. IMO, it's highly unlikely anyone will ever discover why the maintainers of the Rust compiler decided to lint their codebase for a dozen or so magic numbers.
It's fairly simple - and I don't know why no one has pointed this out already.
If everyone starts to use the same magic numbers then they are no longer magic and you can end up with strange corner case bugs and holes where a magic number used in one context is mistaken for a magic number in another context.
the github commit's "conversations" log for the commit has a few notes you need to log in for to view. But then, the maintainer who merged said "it's just a few constants". Which is fair enough.
I think this would more belong into clippy; it'd be easier extensible then, and less "magic". But I'm just a 0xf001 who's intentions are 0x900d ... please don't let me 0xbe misunderst0x0d.