Skip to content

Commit b8302ce

Browse files
committed
Add a regression test for an ICE with the generic_const_exprs feature attribute.
It ensures that using the `generic_const_exprs` feature in a library crate without enabling it in a dependent crate does not lead to an ICE.
1 parent cb6785f commit b8302ce

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#![feature(generic_const_exprs)]
2+
3+
pub struct Error(());
4+
5+
pub trait FromSlice: Sized {
6+
const SIZE: usize = std::mem::size_of::<Self>();
7+
8+
fn validate_slice(bytes: &[[u8; Self::SIZE]]) -> Result<(), Error>;
9+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//! Regression test to ensure that using the `generic_const_exprs` feature in a library crate
2+
//! without enabling it in a dependent crate does not lead to an ICE.
3+
//!
4+
//! Issue: <https://github.com/rust-lang/rust/issues/129882>
5+
6+
//@ aux-build:feature-attribute-missing-in-dependent-crate-ice-aux.rs
7+
8+
extern crate feature_attribute_missing_in_dependent_crate_ice_aux as aux;
9+
10+
struct Wrapper<const F: usize>(i64);
11+
12+
impl<const F: usize> aux::FromSlice for Wrapper<F> {
13+
fn validate_slice(_: &[[u8; Self::SIZE]]) -> Result<(), aux::Error> {
14+
//~^ ERROR generic `Self` types are currently not permitted in anonymous constants
15+
Ok(())
16+
}
17+
}
18+
19+
fn main() {}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error: generic `Self` types are currently not permitted in anonymous constants
2+
--> $DIR/feature-attribute-missing-in-dependent-crate-ice.rs:13:33
3+
|
4+
LL | fn validate_slice(_: &[[u8; Self::SIZE]]) -> Result<(), aux::Error> {
5+
| ^^^^
6+
|
7+
note: not a concrete type
8+
--> $DIR/feature-attribute-missing-in-dependent-crate-ice.rs:12:41
9+
|
10+
LL | impl<const F: usize> aux::FromSlice for Wrapper<F> {
11+
| ^^^^^^^^^^
12+
13+
error: aborting due to 1 previous error
14+

0 commit comments

Comments
 (0)