# Can't understand warning when using const\_evaluatable\_checked

**URL:** <https://users.rust-lang.org/t/cant-understand-warning-when-using-const-evaluatable-checked/55630>\
**Category:** help\
**Created:** [February 15, 2021, 7:39am UTC](https://users.rust-lang.org/t/cant-understand-warning-when-using-const-evaluatable-checked/55630 "2021-02-15T07:39:42Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zettroke](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/zettroke/32/19563_2.png) [@Zettroke](https://users.rust-lang.org/u/Zettroke)\
**Post date:** [February 15, 2021, 7:39am UTC](https://users.rust-lang.org/t/cant-understand-warning-when-using-const-evaluatable-checked/55630/1 "2021-02-15T07:39:43Z")

</div>

While developing [crate](https://github.com/Zettroke/const-writer) using const\_generics I found strange warning.

In method:

```rust
pub fn write_struct<T: ConstWriterAdapter>(writer: ConstWriter<T, 10>) -> ConstWriter<T, 0> {
    writer.write_u16_le(34).write_u16_le(2).write_u16_le(3).write_u16_le(4).write_u16_le(5)
}

```

I got:

```rust
warning: cannot use constants which depend on generic parameters in types
   --> src/lib.rs:493:12
    |
    | writer.write_u32_le(34).write_u16_le(2).write_u16_le(3).write_u16_le(4).write_u16_le(5)
    | ^^^^^^^^^^^^
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #76200 <https://github.com/rust-lang/rust/issues/76200>

```

There are few questions:

1. Why do I get this warning only in playground? Does playground uses some rustc flags? Or this is because I use rust on windows?

```rust
rustc 1.52.0-nightly (5fa22fe6f 2021-02-14)
binary: rustc
commit-hash: 5fa22fe6f821ac3801d05f624b123dda25fde32c
commit-date: 2021-02-14
host: x86_64-pc-windows-gnu
release: 1.52.0-nightly
LLVM version: 11.0.1

```

1. After reading linked issue I didn't get how it's connected with my code.  
You can check linked repo with lib or look at short definition there

```rust
pub struct ConstWriter<T: ConstWriterAdapter, const N: usize> {v: T}

impl<T: ConstWriterAdapter, const N: usize> ConstWriter<T, {N}> {
pub fn write_u32_le(self, value: u32) ->ConstWriter<T, {N - std::mem::size_of::<u32>()}> {
    ConstWriter { v: self.v }
}

```

If this warning really connected with my code, can you please describe me how.

---

<div class="post-metadata">

**Author:** ![mbrubeck](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/mbrubeck/32/648_2.png) [@mbrubeck](https://users.rust-lang.org/u/mbrubeck)\
**Post date:** [February 15, 2021, 6:04pm UTC](https://users.rust-lang.org/t/cant-understand-warning-when-using-const-evaluatable-checked/55630/2 "2021-02-15T18:04:03Z")

</div>

Since these features are still under active development, you might also want to ask questions like this on [Zulip](https://forge.rust-lang.org/platforms/zulip.html) in the [#project-const-generics](https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics) stream.

---

<div class="post-metadata">

**Author:** ![Yandros](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/yandros/32/8136_2.png) [@Yandros](https://users.rust-lang.org/u/Yandros)\
**Post date:** [February 15, 2021, 6:52pm UTC](https://users.rust-lang.org/t/cant-understand-warning-when-using-const-evaluatable-checked/55630/3 "2021-02-15T18:52:43Z")

</div>

> [@Zettroke](#):
>
> I get this warning only in playground

Could you share a link to that Playground snippet? I haven't been able to reproduce that warning even when testing multiple versions of the `nightly` toolchain (on macOS though):

- On old versions (before `const_evaluatable_checked`) get an error;

- Starting from `1.48.0` all the versions pass without any warning.

So it may be something that is Windows-specific, or commit specific; in all cases, being able to reproduce the problem would be quite helpful 🙂

---

<div class="post-metadata">

**Author:** ![Zettroke](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/zettroke/32/19563_2.png) [@Zettroke](https://users.rust-lang.org/u/Zettroke)\
**Post date:** [February 15, 2021, 8:23pm UTC](https://users.rust-lang.org/t/cant-understand-warning-when-using-const-evaluatable-checked/55630/5 "2021-02-15T20:23:57Z")

</div>

[playground](https://play.rust-lang.org/?version=nightly&mode=release&edition=2018&gist=fe292dac85d2ede8da5c084db7454991) there is a bunch of code

---

<div class="post-metadata">

**Author:** ![Cerber-Ursi](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/cerber-ursi/32/8315_2.png) [@Cerber-Ursi](https://users.rust-lang.org/u/Cerber-Ursi)\
**Post date:** [February 16, 2021, 2:49am UTC](https://users.rust-lang.org/t/cant-understand-warning-when-using-const-evaluatable-checked/55630/6 "2021-02-16T02:49:05Z")

</div>

Minimized this code by dropping unused parts: [playground](https://play.rust-lang.org/?version=nightly&mode=release&edition=2018&gist=617517f2dfd39f915cd074006af14378). No ideas what went wrong, though.

---

<div class="post-metadata">

**Author:** ![Yandros](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/yandros/32/8136_2.png) [@Yandros](https://users.rust-lang.org/u/Yandros)\
**Post date:** [February 16, 2021, 3:17pm UTC](https://users.rust-lang.org/t/cant-understand-warning-when-using-const-evaluatable-checked/55630/7 "2021-02-16T15:17:46Z")

</div>

I have investigated this a bit further, and submitted [a report on the associated tracking issue](https://github.com/rust-lang/rust/issues/76200#issuecomment-779903543).

---

<div class="post-metadata">

**Author:** ![Yandros](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/yandros/32/8136_2.png) [@Yandros](https://users.rust-lang.org/u/Yandros)\
**Post date:** [February 26, 2021, 10:42am UTC](https://users.rust-lang.org/t/cant-understand-warning-when-using-const-evaluatable-checked/55630/8 "2021-02-26T10:42:54Z")

</div>

> [@Yandros](#):
>
> submitted [a report on the associated tracking issue](https://github.com/rust-lang/rust/issues/76200#issuecomment-779903543)

From a recent comment there, it appears this warning (and the erroring variants) are not intended / a bug 🙂

---

<div class="post-metadata">

**Author:** ![system](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/system/32/51372_2.png) [@system](https://users.rust-lang.org/u/system)\
**Post date:** [May 27, 2021, 10:43am UTC](https://users.rust-lang.org/t/cant-understand-warning-when-using-const-evaluatable-checked/55630/9 "2021-05-27T10:43:21Z")

</div>

Closed on May 27, 2021, 10:43am UTC

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.
