Skip to content

Commit a5de4fb

Browse files
authored
Rollup merge of #122863 - matthiaskrgr:teest, r=lcnr
add more ice tests fixes #119275 fixes #113017 fixes #112824 fixes #112823 fixes #121472 fixes #110696
2 parents 3164a47 + e68cb00 commit a5de4fb

12 files changed

+306
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// test for ICE "no entry found for key" in generics_of.rs #113017
2+
3+
#![feature(generic_const_exprs)]
4+
#![allow(incomplete_features)]
5+
6+
pub fn foo()
7+
where
8+
for<const N: usize = { || {}; 1 }> ():,
9+
//~^ ERROR only lifetime parameters can be used in this context
10+
//~^^ ERROR defaults for generic parameters are not allowed in `for<...>` binders
11+
{}
12+
13+
pub fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0658]: only lifetime parameters can be used in this context
2+
--> $DIR/ice-generics_of-no-entry-found-for-key-113017.rs:8:15
3+
|
4+
LL | for<const N: usize = { || {}; 1 }> ():,
5+
| ^
6+
|
7+
= note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
8+
= help: add `#![feature(non_lifetime_binders)]` to the crate attributes to enable
9+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
10+
11+
error: defaults for generic parameters are not allowed in `for<...>` binders
12+
--> $DIR/ice-generics_of-no-entry-found-for-key-113017.rs:8:9
13+
|
14+
LL | for<const N: usize = { || {}; 1 }> ():,
15+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
16+
17+
error: aborting due to 2 previous errors
18+
19+
For more information about this error, try `rustc --explain E0658`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// test for ICE #119275 "no entry found for key" in predicates_of.rs
2+
3+
#![feature(generic_const_exprs)]
4+
#![allow(incomplete_features)]
5+
6+
fn bug<const N: Nat>(&self)
7+
//~^ ERROR `self` parameter is only allowed in associated functions
8+
//~^^ ERROR cannot find type `Nat` in this scope
9+
where
10+
for<const N: usize = 3, T = u32> [(); COT::BYTES]:,
11+
//~^ ERROR only lifetime parameters can be used in this context
12+
//~^^ ERROR defaults for generic parameters are not allowed in `for<...>` binders
13+
//~^^^ ERROR defaults for generic parameters are not allowed in `for<...>` binders
14+
//~^^^^ ERROR failed to resolve: use of undeclared type `COT`
15+
{
16+
}
17+
18+
pub fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
error: `self` parameter is only allowed in associated functions
2+
--> $DIR/ice-predicates-of-no-entry-found-for-key-119275.rs:6:22
3+
|
4+
LL | fn bug<const N: Nat>(&self)
5+
| ^^^^^ not semantically valid as function parameter
6+
|
7+
= note: associated functions are those in `impl` or `trait` definitions
8+
9+
error[E0412]: cannot find type `Nat` in this scope
10+
--> $DIR/ice-predicates-of-no-entry-found-for-key-119275.rs:6:17
11+
|
12+
LL | fn bug<const N: Nat>(&self)
13+
| ^^^ not found in this scope
14+
15+
error[E0658]: only lifetime parameters can be used in this context
16+
--> $DIR/ice-predicates-of-no-entry-found-for-key-119275.rs:10:15
17+
|
18+
LL | for<const N: usize = 3, T = u32> [(); COT::BYTES]:,
19+
| ^ ^
20+
|
21+
= note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
22+
= help: add `#![feature(non_lifetime_binders)]` to the crate attributes to enable
23+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
24+
25+
error: defaults for generic parameters are not allowed in `for<...>` binders
26+
--> $DIR/ice-predicates-of-no-entry-found-for-key-119275.rs:10:9
27+
|
28+
LL | for<const N: usize = 3, T = u32> [(); COT::BYTES]:,
29+
| ^^^^^^^^^^^^^^^^^^
30+
31+
error: defaults for generic parameters are not allowed in `for<...>` binders
32+
--> $DIR/ice-predicates-of-no-entry-found-for-key-119275.rs:10:29
33+
|
34+
LL | for<const N: usize = 3, T = u32> [(); COT::BYTES]:,
35+
| ^^^^^^^
36+
37+
error[E0433]: failed to resolve: use of undeclared type `COT`
38+
--> $DIR/ice-predicates-of-no-entry-found-for-key-119275.rs:10:43
39+
|
40+
LL | for<const N: usize = 3, T = u32> [(); COT::BYTES]:,
41+
| ^^^ use of undeclared type `COT`
42+
43+
error: aborting due to 6 previous errors
44+
45+
Some errors have detailed explanations: E0412, E0433, E0658.
46+
For more information about an error, try `rustc --explain E0412`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// test for #112824 ICE type mismatching when copying!
2+
3+
pub struct Opcode(pub u8);
4+
5+
pub struct Opcode2(&'a S);
6+
//~^ ERROR use of undeclared lifetime name `'a`
7+
//~^^ ERROR cannot find type `S` in this scope
8+
9+
impl Opcode2 {
10+
pub const OP2: Opcode2 = Opcode2(Opcode(0x1));
11+
}
12+
13+
pub fn example2(msg_type: Opcode2) -> impl FnMut(&[u8]) {
14+
move |i| match msg_type {
15+
Opcode2::OP2 => unimplemented!(),
16+
//~^ ERROR could not evaluate constant pattern
17+
}
18+
}
19+
20+
pub fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
error[E0261]: use of undeclared lifetime name `'a`
2+
--> $DIR/ice-type-mismatch-when-copying-112824.rs:5:21
3+
|
4+
LL | pub struct Opcode2(&'a S);
5+
| - ^^ undeclared lifetime
6+
| |
7+
| help: consider introducing lifetime `'a` here: `<'a>`
8+
9+
error[E0412]: cannot find type `S` in this scope
10+
--> $DIR/ice-type-mismatch-when-copying-112824.rs:5:24
11+
|
12+
LL | pub struct Opcode2(&'a S);
13+
| ^ not found in this scope
14+
|
15+
help: you might be missing a type parameter
16+
|
17+
LL | pub struct Opcode2<S>(&'a S);
18+
| +++
19+
20+
error: could not evaluate constant pattern
21+
--> $DIR/ice-type-mismatch-when-copying-112824.rs:15:9
22+
|
23+
LL | Opcode2::OP2 => unimplemented!(),
24+
| ^^^^^^^^^^^^
25+
26+
error: aborting due to 3 previous errors
27+
28+
Some errors have detailed explanations: E0261, E0412.
29+
For more information about an error, try `rustc --explain E0261`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// test for ICE #112823
2+
// Unexpected parameter Type(Repr) when substituting in region
3+
4+
#![feature(impl_trait_in_assoc_type)]
5+
6+
use std::future::Future;
7+
8+
trait Stream {}
9+
10+
trait X {
11+
type LineStream<'a, Repr>
12+
where
13+
Self: 'a;
14+
type LineStreamFut<'a, Repr>
15+
where
16+
Self: 'a;
17+
}
18+
19+
struct Y;
20+
21+
impl X for Y {
22+
type LineStream<'c, 'd> = impl Stream;
23+
//~^ ERROR type `LineStream` has 0 type parameters but its trait declaration has 1 type parameter
24+
type LineStreamFut<'a, Repr> = impl Future<Output = Self::LineStream<'a, Repr>>;
25+
fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {}
26+
//~^ ERROR `()` is not a future
27+
//~^^ method `line_stream` is not a member of trait `X`
28+
}
29+
30+
pub fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
error[E0407]: method `line_stream` is not a member of trait `X`
2+
--> $DIR/ice-unexpected-param-type-whensubstituting-in-region-112823.rs:25:5
3+
|
4+
LL | fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {}
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `X`
6+
7+
error[E0049]: type `LineStream` has 0 type parameters but its trait declaration has 1 type parameter
8+
--> $DIR/ice-unexpected-param-type-whensubstituting-in-region-112823.rs:22:21
9+
|
10+
LL | type LineStream<'a, Repr>
11+
| -- ----
12+
| |
13+
| expected 1 type parameter
14+
...
15+
LL | type LineStream<'c, 'd> = impl Stream;
16+
| ^^ ^^
17+
| |
18+
| found 0 type parameters
19+
20+
error[E0277]: `()` is not a future
21+
--> $DIR/ice-unexpected-param-type-whensubstituting-in-region-112823.rs:25:43
22+
|
23+
LL | fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {}
24+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not a future
25+
|
26+
= help: the trait `Future` is not implemented for `()`
27+
28+
error: aborting due to 3 previous errors
29+
30+
Some errors have detailed explanations: E0049, E0277, E0407.
31+
For more information about an error, try `rustc --explain E0049`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// test for #110696
2+
// failed to resolve instance for <Scope<()> as MyIndex<()>>::my_index
3+
// ignore-tidy-linelength
4+
5+
#![feature(type_alias_impl_trait)]
6+
7+
use std::marker::PhantomData;
8+
9+
10+
trait MyIndex<T> {
11+
type O;
12+
fn my_index(self) -> Self::O;
13+
}
14+
trait MyFrom<T>: Sized {
15+
type Error;
16+
fn my_from(value: T) -> Result<Self, Self::Error>;
17+
}
18+
19+
20+
trait F {}
21+
impl F for () {}
22+
type DummyT<T> = impl F;
23+
fn _dummy_t<T>() -> DummyT<T> {}
24+
25+
struct Phantom1<T>(PhantomData<T>);
26+
struct Phantom2<T>(PhantomData<T>);
27+
struct Scope<T>(Phantom2<DummyT<T>>);
28+
29+
impl<T> Scope<T> {
30+
fn new() -> Self {
31+
unimplemented!()
32+
}
33+
}
34+
35+
impl<T> MyFrom<Phantom2<T>> for Phantom1<T> {
36+
type Error = ();
37+
fn my_from(_: Phantom2<T>) -> Result<Self, Self::Error> {
38+
unimplemented!()
39+
}
40+
}
41+
42+
impl<T: MyFrom<Phantom2<DummyT<U>>>, U> MyIndex<DummyT<T>> for Scope<U> {
43+
//~^ ERROR the type parameter `T` is not constrained by the impl
44+
type O = T;
45+
fn my_index(self) -> Self::O {
46+
MyFrom::my_from(self.0).ok().unwrap()
47+
}
48+
}
49+
50+
fn main() {
51+
let _pos: Phantom1<DummyT<()>> = Scope::new().my_index();
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
2+
--> $DIR/ice-failed-to-resolve-instance-for-110696.rs:42:6
3+
|
4+
LL | impl<T: MyFrom<Phantom2<DummyT<U>>>, U> MyIndex<DummyT<T>> for Scope<U> {
5+
| ^ unconstrained type parameter
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0207`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// test for ICE #121472 index out of bounds un_derefer.rs
2+
#![feature(type_alias_impl_trait)]
3+
4+
trait T {}
5+
6+
type Alias<'a> = impl T;
7+
8+
struct S;
9+
impl<'a> T for &'a S {}
10+
11+
fn with_positive(fun: impl Fn(Alias<'_>)) {}
12+
13+
fn main() {
14+
with_positive(|&n| ());
15+
//~^ ERROR mismatched types
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/underef-index-out-of-bounds-121472.rs:14:20
3+
|
4+
LL | type Alias<'a> = impl T;
5+
| ------ the expected opaque type
6+
...
7+
LL | with_positive(|&n| ());
8+
| ^^
9+
| |
10+
| expected opaque type, found `&_`
11+
| expected due to this
12+
|
13+
= note: expected opaque type `Alias<'_>`
14+
found reference `&_`
15+
help: consider removing `&` from the pattern
16+
|
17+
LL - with_positive(|&n| ());
18+
LL + with_positive(|n| ());
19+
|
20+
21+
error: aborting due to 1 previous error
22+
23+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)