Skip to content

Commit 6dd94d6

Browse files
committed
Add a regression test for an index-out-of-bounds ICE on partial_cmp
1 parent 2bf76b4 commit 6dd94d6

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

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)