Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deviant Rust: how can I disable all the warnings and checks possible?

Let's assume I wanted to write horrific and evil code that compiled with rustc. How many compiler-checks, type-checks, and warnings can I disable without recompiling Rust? And how would I go about doing it?

I'm looking for the Perl equivalent of no warnings; no strict;


Obviously I know this isn't good advice. I want to understand the configuration options of rustc the fun way.

like image 943
NO WAR WITH RUSSIA Avatar asked Jan 01 '26 20:01

NO WAR WITH RUSSIA


1 Answers

You should be to silence warnings, and any unused arguments, etc. with #![allow(warnings, unused)]. However, I don't believe you can disable type checks or other compile errors: doing so would be pretty antithetical to a compiler's purpose. You would likely need to generate a syntax tree and then remove any errors by deleting lines from the source until the code compiles (or based on error suggestions), similar to how fuckitpy works.

For example, to silence all warnings, etc.:

#![allow(warnings, unused)]

unsafe fn iHaTeReAdAbLeCoDe(arg: u8, unused_arg: u32) -> u8 {
    let x: i32;
    arg
}

pub fn main() {
    print!("{:?}", unsafe {

                iHaTeReAdAbLeCoDe(5, 0)
    });
}

Please don't do this.

like image 123
Alexander Huszagh Avatar answered Jan 03 '26 12:01

Alexander Huszagh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!