diff --git a/tests/ui/const-generics/generic_const_exprs/auxiliary/feature-attribute-missing-in-dependent-crate-ice-aux.rs b/tests/ui/const-generics/generic_const_exprs/auxiliary/feature-attribute-missing-in-dependent-crate-ice-aux.rs new file mode 100644 index 0000000000000..3902454c14cdb --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/auxiliary/feature-attribute-missing-in-dependent-crate-ice-aux.rs @@ -0,0 +1,9 @@ +#![feature(generic_const_exprs)] + +pub struct Error(()); + +pub trait FromSlice: Sized { + const SIZE: usize = std::mem::size_of::(); + + fn validate_slice(bytes: &[[u8; Self::SIZE]]) -> Result<(), Error>; +} diff --git a/tests/ui/const-generics/generic_const_exprs/feature-attribute-missing-in-dependent-crate-ice.rs b/tests/ui/const-generics/generic_const_exprs/feature-attribute-missing-in-dependent-crate-ice.rs new file mode 100644 index 0000000000000..b9537014767ea --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/feature-attribute-missing-in-dependent-crate-ice.rs @@ -0,0 +1,19 @@ +//! Regression test to ensure that using the `generic_const_exprs` feature in a library crate +//! without enabling it in a dependent crate does not lead to an ICE. +//! +//! Issue: + +//@ aux-build:feature-attribute-missing-in-dependent-crate-ice-aux.rs + +extern crate feature_attribute_missing_in_dependent_crate_ice_aux as aux; + +struct Wrapper(i64); + +impl aux::FromSlice for Wrapper { + fn validate_slice(_: &[[u8; Self::SIZE]]) -> Result<(), aux::Error> { + //~^ ERROR generic `Self` types are currently not permitted in anonymous constants + Ok(()) + } +} + +fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/feature-attribute-missing-in-dependent-crate-ice.stderr b/tests/ui/const-generics/generic_const_exprs/feature-attribute-missing-in-dependent-crate-ice.stderr new file mode 100644 index 0000000000000..5c3306651426b --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/feature-attribute-missing-in-dependent-crate-ice.stderr @@ -0,0 +1,14 @@ +error: generic `Self` types are currently not permitted in anonymous constants + --> $DIR/feature-attribute-missing-in-dependent-crate-ice.rs:13:33 + | +LL | fn validate_slice(_: &[[u8; Self::SIZE]]) -> Result<(), aux::Error> { + | ^^^^ + | +note: not a concrete type + --> $DIR/feature-attribute-missing-in-dependent-crate-ice.rs:12:41 + | +LL | impl aux::FromSlice for Wrapper { + | ^^^^^^^^^^ + +error: aborting due to 1 previous error +