Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #60048 - estebank:issue-54954, r=sanxiyn
Fix ICE on const evaluation of const method Fix #54954.
- Loading branch information
Showing
3 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#![feature(const_fn)] | ||
|
||
const ARR_LEN: usize = Tt::const_val::<[i8; 123]>(); | ||
//~^ ERROR constant contains unimplemented expression type | ||
|
||
trait Tt { | ||
const fn const_val<T: Sized>() -> usize { | ||
//~^ ERROR trait fns cannot be declared const | ||
core::mem::size_of::<T>() | ||
} | ||
} | ||
|
||
fn f(z: [f32; ARR_LEN]) -> [f32; ARR_LEN] { | ||
z | ||
} | ||
|
||
fn main() { | ||
let _ = f([1f32; ARR_LEN]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
error[E0379]: trait fns cannot be declared const | ||
--> $DIR/issue-54954.rs:7:5 | ||
| | ||
LL | const fn const_val<T: Sized>() -> usize { | ||
| ^^^^^ trait fns cannot be const | ||
|
||
error[E0019]: constant contains unimplemented expression type | ||
--> $DIR/issue-54954.rs:3:24 | ||
| | ||
LL | const ARR_LEN: usize = Tt::const_val::<[i8; 123]>(); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors occurred: E0019, E0379. | ||
For more information about an error, try `rustc --explain E0019`. |