Const_trait: found 1 const parameter

Hi,
When I am trying to have a const trait, I am having the following error:

error[E0049]: method `as_message` has 1 const parameter but its trait declaration has 0 const parameters
  --> src/main.rs:18:1
   |
18 | #[const_trait]
   | ^^^^^^^^^^^^^^ found 1 const parameter
19 | pub trait AsMessage {
20 |     fn as_message(&self) -> Message;
   |                  - expected 0 const parameters

For more information about this error, try `rustc --explain E0049`.

I provide the link in Rust playground for an example. If I remove the #[const_trait] and remove const from trait implementations, it compiles and works. I wonder what the cause is. If you can help me on that issue, I'd appreciate that.

Thanks in advance.

This compiles (no idea why):

Apparently, const traits are undergoing a rewrite and are under heavy development. If you want to contribute in any way asking in the zulip channel is probably the best idea.

1 Like

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.