forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#94440 - compiler-errors:issue-94282, r=lcnr
Better error for normalization errors from parent crates that use `#![feature(generic_const_exprs)]` This PR implements a somewhat rudimentary heuristic to suggest using `#![feature(generic_const_exprs)]` in a child crate when a function from a foreign crate (that may have used `#![feature(generic_const_exprs)]`) fails to normalize during codegen. cc: rust-lang#79018 cc: rust-lang#94287
- Loading branch information
Showing
4 changed files
with
108 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
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 | ||
|