File tree Expand file tree Collapse file tree 3 files changed +29
-0
lines changed
src/test/ui/const_evaluatable Expand file tree Collapse file tree 3 files changed +29
-0
lines changed File renamed without changes.
Original file line number Diff line number Diff line change 1+ // check-pass
2+
3+ const fn foo < T > ( ) -> usize {
4+ if std:: mem:: size_of :: < * mut T > ( ) < 8 { // size of *mut T does not depend on T
5+ std:: mem:: size_of :: < T > ( )
6+ } else {
7+ 8
8+ }
9+ }
10+
11+ fn test < T > ( ) {
12+ let _ = [ 0 ; foo :: < T > ( ) ] ;
13+ //~^ WARN cannot use constants which depend on generic parameters in types
14+ //~| WARN this was previously accepted by the compiler but is being phased out
15+ }
16+
17+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ warning: cannot use constants which depend on generic parameters in types
2+ --> $DIR/function-call.rs:12:17
3+ |
4+ LL | let _ = [0; foo::<T>()];
5+ | ^^^^^^^^^^
6+ |
7+ = note: `#[warn(const_evaluatable_unchecked)]` on by default
8+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
9+ = note: for more information, see TODO
10+
11+ warning: 1 warning emitted
12+
You can’t perform that action at this time.
0 commit comments