We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I tried this code:
pub mod reproduce { #[const_trait] pub trait ConstFrom<T>: Sized { #[must_use] fn const_from(value: T) -> Self; } #[const_trait] pub trait ConstAddAssign<Rhs = Self> { fn const_add_assign(&mut self, rhs: Rhs); } pub fn incr42<T>(mut x: T) where T: const ConstFrom<u8> + for<'a> ConstAddAssign<&'a T>, { let delta = T::const_from(42u8); x.const_add_assign(&delta) } // fail to compile pub const fn const_incr42<T>(mut x: T) where T: ~const ConstFrom<u8> + for<'a> ~const ConstAddAssign<&'a T>, { let delta = T::const_from(42u8); x.const_add_assign(&delta) } }
I expected to see this happen: compile OK when HRTB + const trait
Instead, this happened: compile fail when HRTB + const trait
rustc --version --verbose:
rustc --version --verbose
rustc 1.87.0-nightly (3ea711f17 2025-03-09) binary: rustc commit-hash: 3ea711f17e3946ac3f4df11691584e2c56b4b0cf commit-date: 2025-03-09 host: x86_64-unknown-linux-gnu release: 1.87.0-nightly LLVM version: 20.1.0
<backtrace>
Prev
#67792 (comment)
The text was updated successfully, but these errors were encountered:
Thanks for opening an issue. However, as I also wrote in #67792 (comment), for now you just need to add T: ~const Destruct: Playground.
T: ~const Destruct
So this works as intended atm. In the future, whether, when & where you need to write ~cons Destruct may change. See rust-lang/rfcs#3762.
~cons Destruct
Sorry, something went wrong.
Syntax Error: expected comma
No branches or pull requests
I tried this code:
I expected to see this happen: compile OK when HRTB + const trait
Instead, this happened: compile fail when HRTB + const trait
Meta
rustc --version --verbose
:Backtrace
Related
Prev
#67792 (comment)
The text was updated successfully, but these errors were encountered: