Skip to content

Commit

Permalink
Unrolled build for rust-lang#122837
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#122837 - matthiaskrgr:fix_122549, r=petrochenkov

add test for rust-lang#122549

Fixes rust-lang#122549
  • Loading branch information
rust-timer committed Mar 22, 2024
2 parents 0ad927c + daa6553 commit 594bdd5
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/ui/const-generics/ice-unexpected-inference-var-122549.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Regression test for https://github.com/rust-lang/rust/issues/122549
// was fixed by https://github.com/rust-lang/rust/pull/122749

trait ConstChunksExactTrait<T> {
fn const_chunks_exact<const N: usize>(&self) -> ConstChunksExact<'a, T, { N }>;
//~^ ERROR undeclared lifetime
}

impl<T> ConstChunksExactTrait<T> for [T] {}
//~^ ERROR not all trait items implemented, missing: `const_chunks_exact`
struct ConstChunksExact<'rem, T: 'a, const N: usize> {}
//~^ ERROR use of undeclared lifetime name `'a`
//~^^ ERROR lifetime parameter
//~^^^ ERROR type parameter
impl<'a, T, const N: usize> Iterator for ConstChunksExact<'a, T, {}> {
//~^ ERROR the const parameter `N` is not constrained by the impl trait, self type, or predicates
//~^^ ERROR mismatched types
type Item = &'a [T; N];
}

fn main() {
let slice = &[1i32, 2, 3, 4, 5, 6, 7, 8, 9, 10];

let mut iter = [[1, 2, 3], [4, 5, 6], [7, 8, 9]].iter();

for a in slice.const_chunks_exact::<3>() {
assert_eq!(a, iter.next().unwrap());
}
}
67 changes: 67 additions & 0 deletions tests/ui/const-generics/ice-unexpected-inference-var-122549.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
error[E0261]: use of undeclared lifetime name `'a`
--> $DIR/ice-unexpected-inference-var-122549.rs:5:70
|
LL | fn const_chunks_exact<const N: usize>(&self) -> ConstChunksExact<'a, T, { N }>;
| ^^ undeclared lifetime
|
help: consider introducing lifetime `'a` here
|
LL | fn const_chunks_exact<'a, const N: usize>(&self) -> ConstChunksExact<'a, T, { N }>;
| +++
help: consider introducing lifetime `'a` here
|
LL | trait ConstChunksExactTrait<'a, T> {
| +++

error[E0261]: use of undeclared lifetime name `'a`
--> $DIR/ice-unexpected-inference-var-122549.rs:11:34
|
LL | struct ConstChunksExact<'rem, T: 'a, const N: usize> {}
| - ^^ undeclared lifetime
| |
| help: consider introducing lifetime `'a` here: `'a,`

error[E0046]: not all trait items implemented, missing: `const_chunks_exact`
--> $DIR/ice-unexpected-inference-var-122549.rs:9:1
|
LL | fn const_chunks_exact<const N: usize>(&self) -> ConstChunksExact<'a, T, { N }>;
| ------------------------------------------------------------------------------- `const_chunks_exact` from trait
...
LL | impl<T> ConstChunksExactTrait<T> for [T] {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `const_chunks_exact` in implementation

error[E0392]: lifetime parameter `'rem` is never used
--> $DIR/ice-unexpected-inference-var-122549.rs:11:25
|
LL | struct ConstChunksExact<'rem, T: 'a, const N: usize> {}
| ^^^^ unused lifetime parameter
|
= help: consider removing `'rem`, referring to it in a field, or using a marker such as `PhantomData`

error[E0392]: type parameter `T` is never used
--> $DIR/ice-unexpected-inference-var-122549.rs:11:31
|
LL | struct ConstChunksExact<'rem, T: 'a, const N: usize> {}
| ^ unused type parameter
|
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`

error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates
--> $DIR/ice-unexpected-inference-var-122549.rs:15:13
|
LL | impl<'a, T, const N: usize> Iterator for ConstChunksExact<'a, T, {}> {
| ^^^^^^^^^^^^^^ unconstrained const parameter
|
= note: expressions using a const parameter must map each value to a distinct output value
= note: proving the result of expressions other than the parameter are unique is not supported

error[E0308]: mismatched types
--> $DIR/ice-unexpected-inference-var-122549.rs:15:66
|
LL | impl<'a, T, const N: usize> Iterator for ConstChunksExact<'a, T, {}> {
| ^^ expected `usize`, found `()`

error: aborting due to 7 previous errors

Some errors have detailed explanations: E0046, E0207, E0261, E0308, E0392.
For more information about an error, try `rustc --explain E0046`.

0 comments on commit 594bdd5

Please sign in to comment.