/// ```rust
/// impl Foo { fn test() -> [u8; std::mem::size_of::<Self>()] {} }
/// ```
+ /// We do however allow `Self` in repeat expression even if it is generic to not break code
+ /// which already works on stable while causing the `const_evaluatable_unchecked` future compat lint.
///
- /// FIXME(lazy_normalization_consts): Remove this bodge once this feature is stable.
+ /// FIXME(lazy_normalization_consts): Remove this bodge once that feature is stable.
SelfTy(Option<DefId> /* trait */, Option<(DefId, bool)> /* impl */),
ToolMod, // e.g., `rustfmt` in `#[rustfmt::skip]`
// check-pass
+#![feature(min_const_generics)]
#![allow(dead_code)]
fn foo<T>() {
const ASSOC: usize = 4;
fn test() {
- [0; Self::ASSOC];
+ let _ = [0; Self::ASSOC];
+ //~^ WARN cannot use constants which depend on generic parameters in types
+ //~| WARN this was previously accepted by the compiler but is being phased out
+ }
+}
+
+struct Bar<const N: usize>;
+
+impl<const N: usize> Bar<N> {
+ const ASSOC: usize = 4;
+
+ fn test() {
+ let _ = [0; Self::ASSOC];
//~^ WARN cannot use constants which depend on generic parameters in types
//~| WARN this was previously accepted by the compiler but is being phased out
}
warning: cannot use constants which depend on generic parameters in types
- --> $DIR/const-evaluatable-unchecked.rs:5:9
+ --> $DIR/const-evaluatable-unchecked.rs:6:9
|
LL | [0; std::mem::size_of::<*mut T>()];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: for more information, see issue #76200 <https://github.com/rust-lang/rust/issues/76200>
warning: cannot use constants which depend on generic parameters in types
- --> $DIR/const-evaluatable-unchecked.rs:16:13
+ --> $DIR/const-evaluatable-unchecked.rs:17:21
|
-LL | [0; Self::ASSOC];
- | ^^^^^^^^^^^
+LL | let _ = [0; Self::ASSOC];
+ | ^^^^^^^^^^^
|
= 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>
-warning: 2 warnings emitted
+warning: cannot use constants which depend on generic parameters in types
+ --> $DIR/const-evaluatable-unchecked.rs:29:21
+ |
+LL | let _ = [0; Self::ASSOC];
+ | ^^^^^^^^^^^
+ |
+ = 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>
+
+warning: 3 warnings emitted