]> git.lizzy.rs Git - rust.git/blob - tests/ui/const-generics/generic_const_exprs/dependence_lint.rs
Rollup merge of #106717 - klensy:typo, r=lcnr
[rust.git] / tests / ui / const-generics / generic_const_exprs / dependence_lint.rs
1 // revisions: full gce
2 // compile-flags: -Zdeduplicate-diagnostics=yes
3
4 #![cfg_attr(gce, feature(generic_const_exprs))]
5 #![allow(incomplete_features)]
6
7 use std::mem::size_of;
8
9 fn foo<T>() {
10     [0; size_of::<*mut T>()]; // lint on stable, error with `generic_const_exprs`
11     //[gce]~^ ERROR unconstrained
12     //[full]~^^ WARNING cannot use constants
13     //[full]~| WARNING this was previously accepted
14     let _: [u8; size_of::<*mut T>()]; // error on stable, error with gce
15     //[full]~^ ERROR generic parameters may not be used
16     //[gce]~^^ ERROR unconstrained generic
17     [0; if false { size_of::<T>() } else { 3 }]; // lint on stable, error with gce
18     //[gce]~^ ERROR overly complex
19     //[full]~^^ WARNING cannot use constants
20     //[full]~| WARNING this was previously accepted
21     let _: [u8; if true { size_of::<T>() } else { 3 }]; // error on stable, error with gce
22     //[full]~^ ERROR generic parameters may not be used
23     //[gce]~^^ ERROR overly complex
24 }
25
26 fn main() {}