Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions tests/ui/higher-ranked/relate-bound-region-ice-144033.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Regression test for <https://github.com/rust-lang/rust/issues/144033>.
// This used to ICE with "cannot relate bound region" instead of emitting
// normal errors.

trait FooMut {
fn bar<I>(self, _: I)
where
for<'b> &'b I: Iterator<Item = &'b ()>;
}

impl FooMut for () {
fn bar<I>(self, _: I)
where
for<'b> &'b I: Iterator,
{
let collection = std::iter::empty::<()>().map(|_| &());
self.bar(collection)
//~^ ERROR expected `&I` to be an iterator that yields `&()`
//~| ERROR mismatched types
}
}

fn main() {}
53 changes: 53 additions & 0 deletions tests/ui/higher-ranked/relate-bound-region-ice-144033.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
error[E0271]: expected `&I` to be an iterator that yields `&()`, but it yields `<&I as Iterator>::Item`
--> $DIR/relate-bound-region-ice-144033.rs:17:18
|
LL | self.bar(collection)
| --- ^^^^^^^^^^ expected `&()`, found associated type
| |
| required by a bound introduced by this call
|
= note: expected reference `&()`
found associated type `<&I as Iterator>::Item`
= help: consider constraining the associated type `<&I as Iterator>::Item` to `&()`
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
note: the method call chain might not have had the expected associated types
--> $DIR/relate-bound-region-ice-144033.rs:16:51
|
LL | let collection = std::iter::empty::<()>().map(|_| &());
| ------------------------ ^^^^^^^^^^^^ `Iterator::Item` is `&()` here
| |
| this expression has type `Empty<()>`
note: required by a bound in `FooMut::bar`
--> $DIR/relate-bound-region-ice-144033.rs:8:33
|
LL | fn bar<I>(self, _: I)
| --- required by a bound in this associated function
LL | where
LL | for<'b> &'b I: Iterator<Item = &'b ()>;
| ^^^^^^^^^^^^^ required by this bound in `FooMut::bar`

error[E0308]: mismatched types
--> $DIR/relate-bound-region-ice-144033.rs:17:18
|
LL | fn bar<I>(self, _: I)
| - expected this type parameter
...
LL | let collection = std::iter::empty::<()>().map(|_| &());
| --- the found closure
LL | self.bar(collection)
| --- ^^^^^^^^^^ expected type parameter `I`, found `Map<Empty<()>, {closure@...}>`
| |
| arguments to this method are incorrect
|
= note: expected type parameter `I`
found struct `Map<std::iter::Empty<()>, {closure@$DIR/relate-bound-region-ice-144033.rs:16:55: 16:58}>`
note: method defined here
--> $DIR/relate-bound-region-ice-144033.rs:6:8
|
LL | fn bar<I>(self, _: I)
| ^^^ -

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0271, E0308.
For more information about an error, try `rustc --explain E0271`.
Loading