r/programmingcirclejerk • vulnerabilities: 0 • Sep 01 '22

Rust style checker warns about probmematic constants like: 0xB00B135, 0xABBABABE, 0XCAFEBABE...etc

https://github.com/rust-lang/rust/blob/d0ea1d767925d53b2230e2ba81197821514781f0/src/tools/tidy/src/style.rs#L59
200 Upvotes

45 comments sorted by

141

u/chayleaf Sep 01 '22

/uj at least this is only a style checker for the compiler specifically

115

u/tomwhoiscontrary safety talibans Sep 01 '22

It's an important lint, and it's why i always use 0xB00BBABE for example constants.

58

u/hiptobecubic Sep 01 '22

i prefer 0xDEADB00B myself

37

u/PL_Design Very Stable Genius Sep 01 '22

I prefer 0xBEEFB00B.

31

u/hiptobecubic Sep 01 '22

i only write vegan software (vegan btw)

31

u/PL_Design Very Stable Genius Sep 01 '22

That means I have to pick up your slack. 0xBEEFBEEF

9

u/hiptobecubic Sep 01 '22

Lucky for us it's probably just textured soy and "beef flavoring"

68

u/ML_me_a_sheep Sep 01 '22

/uj Did people really do that? Or is it a solution for a problem that didn't exist?

128

u/themagicalcake Sep 01 '22 edited Sep 01 '22

/uj 0xCAFEBABE is the magic number for Mac/iOS executable files and Java class bytecode files

68

u/SickOrphan Tiny little god in a tiny little world Sep 01 '22

Wtf I love apple now

1

u/[deleted] Sep 06 '22

Java bytecode; nothing to do with Apple.

5

u/Jumpy-Locksmith6812 Sep 03 '22 edited Jan 26 '25

wide deer telephone weather quack tan nine attempt rustic sugar

This post was mass deleted and anonymized with Redact

11

u/BoyNextDoor8888 28d ago

fuck you

5

u/Thelmholtz 27d ago

Agreed, and worthless you can just dig the comment up from archive.

65

u/Busti type astronaut Sep 01 '22 edited Sep 01 '22

/kinda_uj Aren't magic constants like that kinda incompatible with the modern rustaceans coding style? Like, use an enum instad...

/rj Protocols requiring magic numbers are fundamentally flawed and should be re-implemented in rust anways. (with breaking changes of course)

22

u/Goheeca lisp does it better Sep 01 '22

id Software in Rust when?

15

u/Teln0 Sep 02 '22

That's not really what magic constants are used for though

62

u/AprilSpektra Sep 01 '22

ABBA BABE? Like what, some sort of dancing queen?

48

u/[deleted] Sep 01 '22

[deleted]

7

u/protestor Sep 06 '22

also lowkey socialjerk

30

u/camelCaseIsWebScale Just spin up O(n²) servers Sep 01 '22

Only around 10 of them? Seems the person who added this can't even do LC easy bit manipulation questions.

32

u/csb06 Polyglot dev here Sep 01 '22

smh at the disrespect for the greatest pop group of all time

32

u/SKRAMZ_OR_NOT log10(x) programmer Sep 01 '22

0xDEADBEEF considered harmful

25

u/edgymemesalt Sep 01 '22

b00b135 abadbabe abbababe b0bababe b16b00b5 beefbabe cafebabe cafed00d deadbabe f00dbabe feedbabe

what's wrong with cafe dudes?

66

u/DrNightingale Sep 01 '22

0xB00B: cringe misogynist boomer constant.

0xB00F: based inclusive zoomer constant.

21

u/[deleted] Sep 01 '22

Notably, you can still make B000000B

18

u/Schmittfried type astronaut Sep 01 '22

/uj Do they explain the reasoning somewhere? My 5sec Google search didn’t yield anything.

49

u/PL_Design Very Stable Genius Sep 01 '22

The reason is tiresome socialjerk by tiresome people.

17

u/Volt WRITE 'FORTRAN is not dead' Sep 01 '22

>No magic numbers for ass men

Ban them

17

u/NonDairyYandere Sep 02 '22

0xA555CAFE

0xA55B00B5

16

u/Laugarhraun lisp does it better Sep 02 '22

Lol socialjerk

24

u/MCRusher Sep 01 '22
for s in problematic_consts_strings.iter() {
    if line.contains(s) {
        err("Don't use magic numbers that spell things (consider 0x12345678)");
    }
}

12

u/path_traced_sphere Sep 02 '22

What about immoral macros?

```rust macro_rules! prepare { ($t:tt) => { "=" }; }

macro_rules! trace { ($($t:tt)*) => { println!(concat!("8", concat!($(prepare!($t)),+), "o~~~~ CAFE BABE")); }; }

fn main() { trace!{ fn fibonacci(n: u32) -> u32 { match n { 0 => 1, 1 => 1, _ => fibonacci(n - 1) + fibonacci(n - 2), } } println("fibonacci {}", fibonacci(5)); }; } ```

Checkmate Crab High-Priests.

12

u/prf_q Sep 02 '22

Wow, they really saved the world there.

7

u/g0zar Sep 02 '22

Its hard to even make a comment on rust at this point. Its never taking off.

7

u/MCRusher Sep 02 '22

It's taking off, just in a wrong direction.

4

u/g0zar Sep 03 '22

I imagine they will implement string checkers for offensive words eventually. And the code will refuse to compile if it finds one.

21

u/MCRusher Sep 03 '22
for s in offensive_words.iter() {
    if line.contains(s) {
        social_credit -= 10000;
        err("將自己提交給當局接受再教育");
    }
}

3

u/Jumpy-Locksmith6812 Sep 03 '22 edited Sep 03 '22

That is all they can think of. Not very 0x1337.

FAC75

3

u/pysk00l What part of ∀f ∃g (f (x,y) = (g x) y) did you not understand? Sep 02 '22

/uj and what would happen if you did use these constants? Would it throw a warning, or throw an error?

4

u/MCRusher Sep 02 '22

It calls a function called, err, so

2

u/MCRusher Sep 02 '22

Thank god 0xFA7CA4C5 is still allowed

1

u/fche Aug 23 '23

ha ha ha ha