Skip to content

Commit 594bdd5

Browse files
authored
Unrolled build for rust-lang#122837
Rollup merge of rust-lang#122837 - matthiaskrgr:fix_122549, r=petrochenkov add test for rust-lang#122549 Fixes rust-lang#122549
2 parents 0ad927c + daa6553 commit 594bdd5

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Regression test for https://github.com/rust-lang/rust/issues/122549
2+
// was fixed by https://github.com/rust-lang/rust/pull/122749
3+
4+
trait ConstChunksExactTrait<T> {
5+
fn const_chunks_exact<const N: usize>(&self) -> ConstChunksExact<'a, T, { N }>;
6+
//~^ ERROR undeclared lifetime
7+
}
8+
9+
impl<T> ConstChunksExactTrait<T> for [T] {}
10+
//~^ ERROR not all trait items implemented, missing: `const_chunks_exact`
11+
struct ConstChunksExact<'rem, T: 'a, const N: usize> {}
12+
//~^ ERROR use of undeclared lifetime name `'a`
13+
//~^^ ERROR lifetime parameter
14+
//~^^^ ERROR type parameter
15+
impl<'a, T, const N: usize> Iterator for ConstChunksExact<'a, T, {}> {
16+
//~^ ERROR the const parameter `N` is not constrained by the impl trait, self type, or predicates
17+
//~^^ ERROR mismatched types
18+
type Item = &'a [T; N];
19+
}
20+
21+
fn main() {
22+
let slice = &[1i32, 2, 3, 4, 5, 6, 7, 8, 9, 10];
23+
24+
let mut iter = [[1, 2, 3], [4, 5, 6], [7, 8, 9]].iter();
25+
26+
for a in slice.const_chunks_exact::<3>() {
27+
assert_eq!(a, iter.next().unwrap());
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
error[E0261]: use of undeclared lifetime name `'a`
2+
--> $DIR/ice-unexpected-inference-var-122549.rs:5:70
3+
|
4+
LL | fn const_chunks_exact<const N: usize>(&self) -> ConstChunksExact<'a, T, { N }>;
5+
| ^^ undeclared lifetime
6+
|
7+
help: consider introducing lifetime `'a` here
8+
|
9+
LL | fn const_chunks_exact<'a, const N: usize>(&self) -> ConstChunksExact<'a, T, { N }>;
10+
| +++
11+
help: consider introducing lifetime `'a` here
12+
|
13+
LL | trait ConstChunksExactTrait<'a, T> {
14+
| +++
15+
16+
error[E0261]: use of undeclared lifetime name `'a`
17+
--> $DIR/ice-unexpected-inference-var-122549.rs:11:34
18+
|
19+
LL | struct ConstChunksExact<'rem, T: 'a, const N: usize> {}
20+
| - ^^ undeclared lifetime
21+
| |
22+
| help: consider introducing lifetime `'a` here: `'a,`
23+
24+
error[E0046]: not all trait items implemented, missing: `const_chunks_exact`
25+
--> $DIR/ice-unexpected-inference-var-122549.rs:9:1
26+
|
27+
LL | fn const_chunks_exact<const N: usize>(&self) -> ConstChunksExact<'a, T, { N }>;
28+
| ------------------------------------------------------------------------------- `const_chunks_exact` from trait
29+
...
30+
LL | impl<T> ConstChunksExactTrait<T> for [T] {}
31+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `const_chunks_exact` in implementation
32+
33+
error[E0392]: lifetime parameter `'rem` is never used
34+
--> $DIR/ice-unexpected-inference-var-122549.rs:11:25
35+
|
36+
LL | struct ConstChunksExact<'rem, T: 'a, const N: usize> {}
37+
| ^^^^ unused lifetime parameter
38+
|
39+
= help: consider removing `'rem`, referring to it in a field, or using a marker such as `PhantomData`
40+
41+
error[E0392]: type parameter `T` is never used
42+
--> $DIR/ice-unexpected-inference-var-122549.rs:11:31
43+
|
44+
LL | struct ConstChunksExact<'rem, T: 'a, const N: usize> {}
45+
| ^ unused type parameter
46+
|
47+
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
48+
49+
error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates
50+
--> $DIR/ice-unexpected-inference-var-122549.rs:15:13
51+
|
52+
LL | impl<'a, T, const N: usize> Iterator for ConstChunksExact<'a, T, {}> {
53+
| ^^^^^^^^^^^^^^ unconstrained const parameter
54+
|
55+
= note: expressions using a const parameter must map each value to a distinct output value
56+
= note: proving the result of expressions other than the parameter are unique is not supported
57+
58+
error[E0308]: mismatched types
59+
--> $DIR/ice-unexpected-inference-var-122549.rs:15:66
60+
|
61+
LL | impl<'a, T, const N: usize> Iterator for ConstChunksExact<'a, T, {}> {
62+
| ^^ expected `usize`, found `()`
63+
64+
error: aborting due to 7 previous errors
65+
66+
Some errors have detailed explanations: E0046, E0207, E0261, E0308, E0392.
67+
For more information about an error, try `rustc --explain E0046`.

0 commit comments

Comments
 (0)