Closed as not planned
Description
I tried this code in the playground (using Rust nightly):
#![allow(unexpected_cfgs)]
#![cfg_attr(
feature = "nightly",
feature(associated_const_equality)
)]
pub trait NeedsDrop {
const NEEDS_DROP: bool;
}
impl<T> NeedsDrop for T {
const NEEDS_DROP: bool = std::mem::needs_drop::<T>();
}
pub trait Foo {}
#[cfg(feature = "nightly")]
impl<T> Foo for T where T: NeedsDrop<NEEDS_DROP = true> {}
I expected to see this happen:
- Given that the playground knows no feature called "nightly" (no Cargo.toml defined), the
cfg_attr
at the beginning doesn't apply i.e. theassociated_const_equality
feature isn't enabled. - Additionally, I also expected the
impl
block at the last line (which depends onassociated_const_equality
) to be excluded from conditional compilation.
Instead, this happened: the compiler complained that the impl
block uses a nightly feature that isn't enabled (rather than ignoring the impl
block altogether).
Compiling playground v0.0.1 (/playground)
error[E0658]: associated const equality is incomplete
--> src/lib.rs:18:38
|
18 | impl<T> Foo for T where T: NeedsDrop<NEEDS_DROP = true> {}
| ^^^^^^^^^^^^^^^^^
|
= note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information
= help: add `#![feature(associated_const_equality)]` to the crate attributes to enable
= note: this compiler was built on 2025-05-12; consider upgrading it if it is out of date
For more information about this error, try `rustc --explain E0658`.
error: could not compile `playground` (lib) due to 1 previous error
Meta
Using the nightly compiler in the playground (https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024).
From the error message:
= note: this compiler was built on 2025-05-12; consider upgrading it if it is out of date