Skip to content

Commit 877f293

Browse files
authored
Rollup merge of #122988 - matthiaskrgr:icetests, r=petrochenkov
add even more tests! Fixes #109869 Fixes #110453 Fixes #109020 Fixes #108580 Fixes #108220 Fixes #113045 Fixes #113133 Fixes #114464 Fixes #116599 Fixes #119731
2 parents 9b4ee1b + e4d816e commit 877f293

23 files changed

+526
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// ICE cannot convert Refree.. to a region vid
2+
// issue: rust-lang/rust#114464
3+
4+
#![feature(generic_const_exprs)]
5+
#![allow(incomplete_features)]
6+
7+
fn test<const N: usize>() {}
8+
9+
fn wow<'a>() {
10+
test::<{
11+
let _: &'a ();
12+
//~^ ERROR cannot capture late-bound lifetime in constant
13+
3
14+
}>();
15+
}
16+
17+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error: cannot capture late-bound lifetime in constant
2+
--> $DIR/convert-refree-region-vid-ice-114464.rs:11:17
3+
|
4+
LL | fn wow<'a>() {
5+
| -- lifetime defined here
6+
LL | test::<{
7+
LL | let _: &'a ();
8+
| ^^
9+
10+
error: aborting due to 1 previous error
11+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// ICE no entry found for key generics_of
2+
// issue: rust-lang/rust#113133
3+
4+
#![allow(incomplete_features)]
5+
#![feature(generic_const_exprs, non_lifetime_binders)]
6+
7+
pub fn foo()
8+
where
9+
for<const N: usize = { const fn bar() {} bar(); 1 }> ():,
10+
//~^ ERROR defaults for generic parameters are not allowed in `for<...>` binders
11+
{}
12+
13+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: defaults for generic parameters are not allowed in `for<...>` binders
2+
--> $DIR/no-entry-found-for-key-ice-gce-nlb-113133.rs:9:9
3+
|
4+
LL | for<const N: usize = { const fn bar() {} bar(); 1 }> ():,
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
7+
error: aborting due to 1 previous error
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// rust-lang/rust#119731
2+
// ICE ... unevaluated constant UnevaluatedConst
3+
4+
#![feature(generic_const_exprs)]
5+
#![allow(incomplete_features)]
6+
7+
mod v20 {
8+
const v4: usize = 512;
9+
pub type v11 = [[usize; v4]; v4];
10+
//~^ WARN type `v11` should have an upper camel case name
11+
const v2: v11 = [[256; v4]; v4];
12+
13+
const v0: [[usize; v4]; v4] = v6(v8);
14+
//~^ ERROR cannot find value `v8` in this scope
15+
//~| ERROR cannot find function `v6` in this scope
16+
pub struct v17<const v10: usize, const v7: v11> {
17+
//~^ WARN type `v17` should have an upper camel case name
18+
//~| ERROR `[[usize; v4]; v4]` is forbidden as the type of a const generic parameter
19+
_p: (),
20+
}
21+
22+
impl v17<512, v0> {
23+
pub const fn v21() -> v18 {}
24+
//~^ ERROR cannot find type `v18` in this scope
25+
}
26+
27+
impl<const v10: usize> v17<v10, v2> {
28+
//~^ ERROR maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#1}
29+
//~| ERROR maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#1}
30+
pub const fn v21() -> v18 {
31+
//~^ ERROR cannot find type `v18` in this scope
32+
v18 { _p: () }
33+
//~^ ERROR cannot find struct, variant or union type `v18` in this scope
34+
}
35+
}
36+
}
37+
pub use v20::{v13, v17};
38+
//~^ ERROR unresolved import `v20::v13`
39+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
error[E0432]: unresolved import `v20::v13`
2+
--> $DIR/unevaluated-const-ice-119731.rs:37:15
3+
|
4+
LL | pub use v20::{v13, v17};
5+
| ^^^
6+
| |
7+
| no `v13` in `v20`
8+
| help: a similar name exists in the module: `v11`
9+
10+
error[E0425]: cannot find value `v8` in this scope
11+
--> $DIR/unevaluated-const-ice-119731.rs:13:38
12+
|
13+
LL | const v0: [[usize; v4]; v4] = v6(v8);
14+
| ^^ not found in this scope
15+
16+
error[E0412]: cannot find type `v18` in this scope
17+
--> $DIR/unevaluated-const-ice-119731.rs:23:31
18+
|
19+
LL | pub type v11 = [[usize; v4]; v4];
20+
| --------------------------------- similarly named type alias `v11` defined here
21+
...
22+
LL | pub const fn v21() -> v18 {}
23+
| ^^^ help: a type alias with a similar name exists: `v11`
24+
25+
error[E0412]: cannot find type `v18` in this scope
26+
--> $DIR/unevaluated-const-ice-119731.rs:30:31
27+
|
28+
LL | pub type v11 = [[usize; v4]; v4];
29+
| --------------------------------- similarly named type alias `v11` defined here
30+
...
31+
LL | pub const fn v21() -> v18 {
32+
| ^^^ help: a type alias with a similar name exists: `v11`
33+
34+
error[E0422]: cannot find struct, variant or union type `v18` in this scope
35+
--> $DIR/unevaluated-const-ice-119731.rs:32:13
36+
|
37+
LL | pub type v11 = [[usize; v4]; v4];
38+
| --------------------------------- similarly named type alias `v11` defined here
39+
...
40+
LL | v18 { _p: () }
41+
| ^^^ help: a type alias with a similar name exists: `v11`
42+
43+
warning: type `v11` should have an upper camel case name
44+
--> $DIR/unevaluated-const-ice-119731.rs:9:14
45+
|
46+
LL | pub type v11 = [[usize; v4]; v4];
47+
| ^^^ help: convert the identifier to upper camel case (notice the capitalization): `V11`
48+
|
49+
= note: `#[warn(non_camel_case_types)]` on by default
50+
51+
warning: type `v17` should have an upper camel case name
52+
--> $DIR/unevaluated-const-ice-119731.rs:16:16
53+
|
54+
LL | pub struct v17<const v10: usize, const v7: v11> {
55+
| ^^^ help: convert the identifier to upper camel case (notice the capitalization): `V17`
56+
57+
error[E0425]: cannot find function `v6` in this scope
58+
--> $DIR/unevaluated-const-ice-119731.rs:13:35
59+
|
60+
LL | const v0: [[usize; v4]; v4] = v6(v8);
61+
| ^^ not found in this scope
62+
63+
error: `[[usize; v4]; v4]` is forbidden as the type of a const generic parameter
64+
--> $DIR/unevaluated-const-ice-119731.rs:16:48
65+
|
66+
LL | pub struct v17<const v10: usize, const v7: v11> {
67+
| ^^^
68+
|
69+
= note: the only supported types are integers, `bool` and `char`
70+
help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
71+
|
72+
LL + #![feature(adt_const_params)]
73+
|
74+
75+
error: maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#1}
76+
--> $DIR/unevaluated-const-ice-119731.rs:27:37
77+
|
78+
LL | impl<const v10: usize> v17<v10, v2> {
79+
| ^^
80+
81+
error: maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#1}
82+
--> $DIR/unevaluated-const-ice-119731.rs:27:37
83+
|
84+
LL | impl<const v10: usize> v17<v10, v2> {
85+
| ^^
86+
|
87+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
88+
89+
error: aborting due to 9 previous errors; 2 warnings emitted
90+
91+
Some errors have detailed explanations: E0412, E0422, E0425, E0432.
92+
For more information about an error, try `rustc --explain E0412`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// ICE assertion failed: matches!(self.def_kind(ct.def.did), DefKind :: AnonConst)
2+
// issue: rust-lang/rust#108220
3+
//@ check-pass
4+
5+
#![feature(associated_const_equality)]
6+
#![allow(unused)]
7+
8+
use std::marker::PhantomData;
9+
10+
pub struct NoPin;
11+
12+
pub trait SetAlternate<const A: u8> {}
13+
14+
impl SetAlternate<0> for NoPin {}
15+
16+
pub trait PinA<PER> {
17+
const A: u8;
18+
}
19+
20+
impl<PER> PinA<PER> for NoPin {
21+
const A: u8 = 0;
22+
}
23+
24+
pub trait Pins<USART> {}
25+
26+
impl<USART, T, const TA: u8> Pins<USART> for T where
27+
T: PinA<USART, A = { TA }> + SetAlternate<TA>
28+
{
29+
}
30+
31+
struct Serial<USART>(PhantomData<USART>);
32+
33+
impl<USART> Serial<USART> where NoPin: Pins<USART> {}
34+
35+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// ICE expected ReFree to map to ReEarlyBound
2+
// issue: rust-lang/rust#108580
3+
//@ check-pass
4+
5+
trait Foo {
6+
fn bar(&self) -> impl Iterator<Item = impl Sized> + '_;
7+
}
8+
9+
impl Foo for () {
10+
fn bar(&self) -> impl Iterator + '_ {
11+
//~^ WARN impl trait in impl method signature does not match trait method signature
12+
vec![()].into_iter()
13+
}
14+
}
15+
16+
pub fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
warning: impl trait in impl method signature does not match trait method signature
2+
--> $DIR/expeced-refree-to-map-to-reearlybound-ice-108580.rs:10:22
3+
|
4+
LL | fn bar(&self) -> impl Iterator<Item = impl Sized> + '_;
5+
| ------------------------------------- return type from trait method defined here
6+
...
7+
LL | fn bar(&self) -> impl Iterator + '_ {
8+
| ^^^^^^^^^^^^^^^^^^
9+
|
10+
= note: add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate
11+
= note: we are soliciting feedback, see issue #121718 <https://github.com/rust-lang/rust/issues/121718> for more information
12+
= note: `#[warn(refining_impl_trait_internal)]` on by default
13+
help: replace the return type so that it matches the trait
14+
|
15+
LL | fn bar(&self) -> impl Iterator<Item = impl Sized> + '_ {
16+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17+
18+
warning: 1 warning emitted
19+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// ICE in mir building with captured value of unresolved type
2+
// None in compiler/rustc_mir_build/src/build/expr/as_place.rs
3+
// issue: rust-lang/rust#110453
4+
//@ edition:2021
5+
6+
#![crate_type="lib"]
7+
8+
pub struct B;
9+
pub fn a() -> B { B }
10+
11+
mod handlers {
12+
pub struct C(B);
13+
//~^ ERROR cannot find type `B` in this scope
14+
pub fn c() -> impl Fn() -> C {
15+
let a1 = ();
16+
|| C((crate::a(), a1).into())
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0412]: cannot find type `B` in this scope
2+
--> $DIR/mir-build-2021-closure-capture-ice-110453-1.rs:12:18
3+
|
4+
LL | pub struct C(B);
5+
| ^ not found in this scope
6+
|
7+
help: consider importing this struct
8+
|
9+
LL + use crate::B;
10+
|
11+
12+
error: aborting due to 1 previous error
13+
14+
For more information about this error, try `rustc --explain E0412`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// ICE in mir building with captured value of unresolved type
2+
// None in compiler/rustc_mir_build/src/build/expr/as_place.rs
3+
// issue: rust-lang/rust#110453
4+
//@ edition:2021
5+
6+
#![crate_type="lib"]
7+
8+
pub fn dup(f: impl Fn(i32) -> i32) -> impl Fn(as_str) -> i32 {
9+
//~^ ERROR cannot find type `as_str` in this scope
10+
move |a| f(a * 2)
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0412]: cannot find type `as_str` in this scope
2+
--> $DIR/mir-build-2021-closure-capture-ice-110453-2.rs:8:47
3+
|
4+
LL | pub fn dup(f: impl Fn(i32) -> i32) -> impl Fn(as_str) -> i32 {
5+
| ^^^^^^ not found in this scope
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0412`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// ICE unexpected inference var
2+
// issue: rust-lang/rust#116599
3+
//@ check-pass
4+
5+
pub trait EvaluateConstMethods {
6+
type Trait: TraitWithConstMethods;
7+
8+
/// **This block breaks**
9+
const DATA_3: Data3 = {
10+
<<<Self::Trait as TraitWithConstMethods>::Method2 as ConstFn<_, _>>::Body<
11+
<<Self::Trait as TraitWithConstMethods>::Method1 as ConstFn<_, _>>::Body<ContainsData1>,
12+
> as Contains<_>>::ITEM
13+
};
14+
}
15+
16+
pub trait TraitWithConstMethods {
17+
/// "const trait method" of signature `fn(Data1) -> Data2`
18+
type Method1: ConstFn<Data1, Data2>;
19+
20+
/// "const trait method" of signature `fn(Data2) -> Data3`
21+
type Method2: ConstFn<Data2, Data3>;
22+
}
23+
24+
/// A trait which tries to implement const methods in traits
25+
pub trait ConstFn<Arg, Ret> {
26+
type Body<T: Contains<Arg>>: Contains<Ret>;
27+
}
28+
29+
/// A ZST which represents / "contains" a const value which can be pass to a [`ConstFn`]
30+
pub trait Contains<T> {
31+
const ITEM: T;
32+
}
33+
34+
pub struct ContainsData1;
35+
impl Contains<Data1> for ContainsData1 {
36+
const ITEM: Data1 = Data1 {};
37+
}
38+
39+
// Arbitrary data
40+
pub struct Data1 {}
41+
pub struct Data2 {}
42+
pub struct Data3 {}
43+
44+
pub fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// ICE min_specialization:
2+
// Ok(['?0, Const { ty: usize, kind: Leaf(0x0000000000000000) }]) is not fully resolved
3+
// issue: rust-lang/rust#113045
4+
5+
#![feature(min_specialization)]
6+
7+
trait X {}
8+
9+
impl<'a, const N: usize> X for [(); N] {}
10+
11+
impl<'a, Unconstrained> X for [(); 0] {}
12+
//~^ ERROR the type parameter `Unconstrained` is not constrained by the impl trait, self type, or predicates
13+
//~| ERROR specialization impl does not specialize any associated items
14+
15+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0207]: the type parameter `Unconstrained` is not constrained by the impl trait, self type, or predicates
2+
--> $DIR/ice-const-not-fully-resolved-113045.rs:11:10
3+
|
4+
LL | impl<'a, Unconstrained> X for [(); 0] {}
5+
| ^^^^^^^^^^^^^ unconstrained type parameter
6+
7+
error: specialization impl does not specialize any associated items
8+
--> $DIR/ice-const-not-fully-resolved-113045.rs:11:1
9+
|
10+
LL | impl<'a, Unconstrained> X for [(); 0] {}
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
|
13+
note: impl is a specialization of this impl
14+
--> $DIR/ice-const-not-fully-resolved-113045.rs:9:1
15+
|
16+
LL | impl<'a, const N: usize> X for [(); N] {}
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18+
19+
error: aborting due to 2 previous errors
20+
21+
For more information about this error, try `rustc --explain E0207`.

0 commit comments

Comments
 (0)