# What's the correct procedure to add functionalities to the compiler?

**URL:** <https://internals.rust-lang.org/t/whats-the-correct-procedure-to-add-functionalities-to-the-compiler/12516>\
**Category:** Uncategorized\
**Created:** [June 8, 2020, 1:36pm UTC](https://internals.rust-lang.org/t/whats-the-correct-procedure-to-add-functionalities-to-the-compiler/12516 "2020-06-08T13:36:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![HuStmpHrrr](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/hustmphrrr/32/6924_2.png) [@HuStmpHrrr](https://internals.rust-lang.org/u/HuStmpHrrr)\
**Post date:** [June 8, 2020, 1:36pm UTC](https://internals.rust-lang.org/t/whats-the-correct-procedure-to-add-functionalities-to-the-compiler/12516/1 "2020-06-08T13:36:28Z")

</div>

When I am writing a new module or functions etc from ground up, I want to continuously compile to ensure there is no type error in the code. However, the compiler now throws an error saying my methods or functions are not used. Is there a recommended way to get around this?

---

<div class="post-metadata">

**Author:** ![steffahn](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/steffahn/32/13288_2.png) [@steffahn](https://internals.rust-lang.org/u/steffahn)\
**Post date:** [June 8, 2020, 1:52pm UTC](https://internals.rust-lang.org/t/whats-the-correct-procedure-to-add-functionalities-to-the-compiler/12516/2 "2020-06-08T13:52:47Z")

</div>

The compiler will only “warn” about unused functions, not “error” (the distinction is that warnings don’t make the compilation fail). If the warnings are in your way, you can disable them. Note that this is only recommendable during development, don’t forget to re-enable them when your code is done. Also, since warnings don’t influence compilation success, you could just as well try to simply ignore the warnings about unused functions, types, etc. since you know that you’re going to add code that uses them later.

If you really want to, one way to disable such warnings would be to place the line `#![allow(dead_code)]` at the beginning of your source file.

Also note that a better place to ask questions about how to use Rust would be [users.rust-lang.org](http://users.rust-lang.org).

---

<div class="post-metadata">

**Author:** ![HuStmpHrrr](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/hustmphrrr/32/6924_2.png) [@HuStmpHrrr](https://internals.rust-lang.org/u/HuStmpHrrr)\
**Post date:** [June 8, 2020, 2:32pm UTC](https://internals.rust-lang.org/t/whats-the-correct-procedure-to-add-functionalities-to-the-compiler/12516/3 "2020-06-08T14:32:19Z")

</div>

I am asking a question about compiler development, that's why I ask here:

```rust
error: method is never used: `variable`
...
error: aborting due to 14 previous errors

error: could not compile `rustc_codegen_llvm`.

```

an example error is here. The build of the compiler ends with errors saying I have unused code. Am I missing anything?

---

<div class="post-metadata">

**Author:** ![Tom-Phinney](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/tom-phinney/32/3299_2.png) [@Tom-Phinney](https://internals.rust-lang.org/u/Tom-Phinney)\
**Post date:** [June 8, 2020, 2:56pm UTC](https://internals.rust-lang.org/t/whats-the-correct-procedure-to-add-functionalities-to-the-compiler/12516/4 "2020-06-08T14:56:59Z")

</div>

This forum, IRLO, would be the appropriate forum for queries about plugins for `rustc` or about modifying MIR. However your question seems to be a general question about programming in Rust (because the `rustc` compiler is written in Rust). Those questions belong in URLO.

> [@HuStmpHrrr](#):
>
> Am I missing anything?

For a query in URLO, you need to supply sufficient details that someone might be able to help you. Given the specific details that you have provided, the best response actually is the one given in the prior post:

> [@steffahn](#):
>
> to disable such warnings … place the line `#![allow(dead_code)]` at the beginning of your source file.

---

<div class="post-metadata">

**Author:** ![wesleywiser](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/wesleywiser/32/2742_2.png) [@wesleywiser](https://internals.rust-lang.org/u/wesleywiser)\
**Post date:** [June 8, 2020, 3:00pm UTC](https://internals.rust-lang.org/t/whats-the-correct-procedure-to-add-functionalities-to-the-compiler/12516/5 "2020-06-08T15:00:04Z")

</div>

One thing that makes this question more specific to `rustc` is that we `#![deny(warnings)]` so unused variables and unused functions are treated as errors and break the build.

One simple thing you might try is to mark some of those functions as `pub`. Any externally visible `pub` functions are treated as used and any code called by them are transitively considered used as well. A well placed `pub` might make all those errors go away.

---

<div class="post-metadata">

**Author:** ![Aaron1011](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/aaron1011/32/2246_2.png) [@Aaron1011](https://internals.rust-lang.org/u/Aaron1011)\
**Post date:** [June 8, 2020, 3:01pm UTC](https://internals.rust-lang.org/t/whats-the-correct-procedure-to-add-functionalities-to-the-compiler/12516/6 "2020-06-08T15:01:57Z")

</div>

I would recommend settings `deny-warnings=false` in your local `config.toml`. You'll still need to fix all warnings for CI to pass, but they won't break your build locally.

---

<div class="post-metadata">

**Author:** ![steffahn](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/steffahn/32/13288_2.png) [@steffahn](https://internals.rust-lang.org/u/steffahn)\
**Post date:** [June 8, 2020, 3:59pm UTC](https://internals.rust-lang.org/t/whats-the-correct-procedure-to-add-functionalities-to-the-compiler/12516/7 "2020-06-08T15:59:07Z")

</div>

> [@HuStmpHrrr](#):
>
> I am asking a question about compiler development

I see. I might have not really read the title of your original post / this thread. Nonetheless, being more explicit about that you're trying to work on `rustc`, and also including the error message, might have helped avoid some confusion.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [September 6, 2020, 3:59pm UTC](https://internals.rust-lang.org/t/whats-the-correct-procedure-to-add-functionalities-to-the-compiler/12516/8 "2020-09-06T15:59:09Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
