Skip to content

Commit 1d20fc2

Browse files
authored
Rollup merge of #154764 - jakubadamw:issue-113870-114056-118278, r=jackh726
Add tests for three ICEs that have already been fixed Closes #113870. Closes #114056. Closes #118278.
2 parents 82c7a39 + fedb021 commit 1d20fc2

5 files changed

Lines changed: 143 additions & 0 deletions
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//! Regression test for https://github.com/rust-lang/rust/issues/113870
2+
3+
#![feature(generic_const_exprs)]
4+
#![allow(incomplete_features)]
5+
6+
const fn allow<'b, 'b>() -> usize
7+
//~^ ERROR the name `'b` is already used for a generic parameter in this item's generic parameters
8+
where
9+
for<'b> [u8; foo::<'a, 'b>()]: Sized,
10+
//~^ ERROR lifetime name `'b` shadows a lifetime name that is already in scope
11+
//~| ERROR use of undeclared lifetime name `'a`
12+
//~| ERROR cannot capture late-bound lifetime in constant
13+
{
14+
4
15+
}
16+
17+
const fn foo<'a, 'b>() -> usize
18+
where
19+
&'a (): Sized,
20+
&'b (): Sized,
21+
{
22+
4
23+
}
24+
//~^ ERROR `main` function not found in crate
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
error[E0403]: the name `'b` is already used for a generic parameter in this item's generic parameters
2+
--> $DIR/escaping-late-bound-region-in-canonical-ice-113870.rs:6:20
3+
|
4+
LL | const fn allow<'b, 'b>() -> usize
5+
| -- ^^ already used
6+
| |
7+
| first use of `'b`
8+
9+
error[E0496]: lifetime name `'b` shadows a lifetime name that is already in scope
10+
--> $DIR/escaping-late-bound-region-in-canonical-ice-113870.rs:9:9
11+
|
12+
LL | const fn allow<'b, 'b>() -> usize
13+
| -- first declared here
14+
...
15+
LL | for<'b> [u8; foo::<'a, 'b>()]: Sized,
16+
| ^^ lifetime `'b` already in scope
17+
18+
error[E0261]: use of undeclared lifetime name `'a`
19+
--> $DIR/escaping-late-bound-region-in-canonical-ice-113870.rs:9:24
20+
|
21+
LL | for<'b> [u8; foo::<'a, 'b>()]: Sized,
22+
| ^^ undeclared lifetime
23+
|
24+
= note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
25+
help: consider making the bound lifetime-generic with a new `'a` lifetime
26+
|
27+
LL | for<'a, 'b> [u8; foo::<'a, 'b>()]: Sized,
28+
| +++
29+
help: consider introducing lifetime `'a` here
30+
|
31+
LL | const fn allow<'a, 'b, 'b>() -> usize
32+
| +++
33+
34+
error[E0601]: `main` function not found in crate `escaping_late_bound_region_in_canonical_ice_113870`
35+
--> $DIR/escaping-late-bound-region-in-canonical-ice-113870.rs:23:2
36+
|
37+
LL | }
38+
| ^ consider adding a `main` function to `$DIR/escaping-late-bound-region-in-canonical-ice-113870.rs`
39+
40+
error: cannot capture late-bound lifetime in constant
41+
--> $DIR/escaping-late-bound-region-in-canonical-ice-113870.rs:9:28
42+
|
43+
LL | const fn allow<'b, 'b>() -> usize
44+
| -- lifetime defined here
45+
...
46+
LL | for<'b> [u8; foo::<'a, 'b>()]: Sized,
47+
| ^^
48+
49+
error: aborting due to 5 previous errors
50+
51+
Some errors have detailed explanations: E0261, E0403, E0496, E0601.
52+
For more information about an error, try `rustc --explain E0261`.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//! Regression test for https://github.com/rust-lang/rust/issues/118278
2+
3+
//@ check-pass
4+
5+
#![allow(incomplete_features)]
6+
#![feature(generic_const_exprs)]
7+
8+
pub trait Foo {
9+
const SIZE: usize;
10+
}
11+
12+
impl Foo for u64 {
13+
const SIZE: usize = 8;
14+
}
15+
16+
pub struct Wrapper<T>
17+
where
18+
T: Foo,
19+
[(); T::SIZE]:,
20+
{
21+
pub t: T,
22+
}
23+
24+
pub fn bar() -> Wrapper<impl Foo> {
25+
Wrapper { t: 10 }
26+
}
27+
28+
fn main() {}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//! Regression test for https://github.com/rust-lang/rust/issues/114056
2+
3+
struct P<Q>(Q);
4+
5+
impl<Q> P<Q> {
6+
fn foo(&self) {
7+
self.partial_cmp(())
8+
//~^ ERROR the method `partial_cmp` exists for reference `&P<Q>`, but its trait bounds were not satisfied
9+
}
10+
}
11+
12+
fn main() {}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
error[E0599]: the method `partial_cmp` exists for reference `&P<Q>`, but its trait bounds were not satisfied
2+
--> $DIR/index-out-of-bounds-on-partial-cmp-ice-114056.rs:7:14
3+
|
4+
LL | struct P<Q>(Q);
5+
| ----------- doesn't satisfy `P<Q>: Iterator` or `P<Q>: PartialOrd<_>`
6+
...
7+
LL | self.partial_cmp(())
8+
| ^^^^^^^^^^^ method cannot be called on `&P<Q>` due to unsatisfied trait bounds
9+
|
10+
= note: the following trait bounds were not satisfied:
11+
`P<Q>: PartialOrd<_>`
12+
which is required by `&P<Q>: PartialOrd<&_>`
13+
`&P<Q>: Iterator`
14+
which is required by `&mut &P<Q>: Iterator`
15+
`P<Q>: Iterator`
16+
which is required by `&mut P<Q>: Iterator`
17+
note: the trait `Iterator` must be implemented
18+
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
19+
help: consider annotating `P<Q>` with `#[derive(PartialEq, PartialOrd)]`
20+
|
21+
LL + #[derive(PartialEq, PartialOrd)]
22+
LL | struct P<Q>(Q);
23+
|
24+
25+
error: aborting due to 1 previous error
26+
27+
For more information about this error, try `rustc --explain E0599`.

0 commit comments

Comments
 (0)