-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
suggest enabling generic_const_exprs feature if const is unevaluatable
- Loading branch information
1 parent
b07d59f
commit 109cdc7
Showing
5 changed files
with
109 additions
and
25 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
21 changes: 21 additions & 0 deletions
21
src/test/ui/const-generics/generic_const_exprs/auxiliary/issue-94287-aux.rs
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,21 @@ | ||
#![feature(generic_const_exprs)] | ||
|
||
use std::str::FromStr; | ||
|
||
pub struct If<const CONDITION: bool>; | ||
|
||
pub trait True {} | ||
|
||
impl True for If<true> {} | ||
|
||
pub struct FixedI32<const FRAC: u32>; | ||
|
||
impl<const FRAC: u32> FromStr for FixedI32<FRAC> | ||
where | ||
If<{ FRAC <= 32 }>: True, | ||
{ | ||
type Err = (); | ||
fn from_str(_s: &str) -> Result<Self, Self::Err> { | ||
unimplemented!() | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/test/ui/const-generics/generic_const_exprs/issue-94287.rs
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,10 @@ | ||
// aux-build:issue-94287-aux.rs | ||
// build-fail | ||
|
||
extern crate issue_94287_aux; | ||
|
||
use std::str::FromStr; | ||
|
||
fn main() { | ||
let _ = <issue_94287_aux::FixedI32<16>>::from_str(""); | ||
} |
14 changes: 14 additions & 0 deletions
14
src/test/ui/const-generics/generic_const_exprs/issue-94287.stderr
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,14 @@ | ||
error: failed to evaluate generic const expression | ||
--> $DIR/auxiliary/issue-94287-aux.rs:15:8 | ||
| | ||
LL | If<{ FRAC <= 32 }>: True, | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= note: the crate this constant originates from uses `#![feature(generic_const_exprs)]` | ||
help: consider enabling this feature | ||
| | ||
LL | #![feature(generic_const_exprs)] | ||
| | ||
|
||
error: aborting due to previous error | ||
|