Evan Carroll
Evan Carroll

Reputation: 1

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.

Upvotes: 16

Views: 7936

Answers (1)

Alex Huszagh
Alex Huszagh

Reputation: 14584

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.

Upvotes: 19

Related Questions