forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#106322 - compiler-errors:CollectAllMismatch…
…es-infer-vars, r=oli-obk Handle inference variables in `CollectAllMismatches` correctly 1. Fix rust-lang#106240 2. Treat int/float type variables correctly (see `src/test/ui/iterators/invalid-iterator-chain-with-int-infer.rs`), so we can point out things like "`Iterator::Item` changed to `{integer}` here"
- Loading branch information
Showing
5 changed files
with
78 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
struct Foo<T, const N: usize> { | ||
array: [T; N], | ||
} | ||
|
||
trait Bar<const N: usize> {} | ||
|
||
impl<T, const N: usize> Foo<T, N> { | ||
fn trigger(self) { | ||
self.unsatisfied() | ||
//~^ ERROR the trait bound `T: Bar<N>` is not satisfied | ||
} | ||
|
||
fn unsatisfied(self) | ||
where | ||
T: Bar<N>, | ||
{ | ||
} | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
error[E0277]: the trait bound `T: Bar<N>` is not satisfied | ||
--> $DIR/ct-var-in-collect_all_mismatches.rs:9:14 | ||
| | ||
LL | self.unsatisfied() | ||
| ^^^^^^^^^^^ the trait `Bar<N>` is not implemented for `T` | ||
| | ||
note: required by a bound in `Foo::<T, N>::unsatisfied` | ||
--> $DIR/ct-var-in-collect_all_mismatches.rs:15:12 | ||
| | ||
LL | fn unsatisfied(self) | ||
| ----------- required by a bound in this | ||
LL | where | ||
LL | T: Bar<N>, | ||
| ^^^^^^ required by this bound in `Foo::<T, N>::unsatisfied` | ||
help: consider restricting type parameter `T` | ||
| | ||
LL | impl<T: Bar<N>, const N: usize> Foo<T, N> { | ||
| ++++++++ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
fn main() { | ||
let x = Some(()).iter().map(|()| 1).sum::<f32>(); | ||
//~^ ERROR a value of type `f32` cannot be made by summing an iterator over elements of type `{integer}` | ||
} |
24 changes: 24 additions & 0 deletions
24
tests/ui/iterators/invalid-iterator-chain-with-int-infer.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
error[E0277]: a value of type `f32` cannot be made by summing an iterator over elements of type `{integer}` | ||
--> $DIR/invalid-iterator-chain-with-int-infer.rs:2:41 | ||
| | ||
LL | let x = Some(()).iter().map(|()| 1).sum::<f32>(); | ||
| ^^^ value of type `f32` cannot be made by summing a `std::iter::Iterator<Item={integer}>` | ||
| | ||
= help: the trait `Sum<{integer}>` is not implemented for `f32` | ||
= help: the following other types implement trait `Sum<A>`: | ||
<f32 as Sum<&'a f32>> | ||
<f32 as Sum> | ||
note: the method call chain might not have had the expected associated types | ||
--> $DIR/invalid-iterator-chain-with-int-infer.rs:2:29 | ||
| | ||
LL | let x = Some(()).iter().map(|()| 1).sum::<f32>(); | ||
| -------- ------ ^^^^^^^^^^^ `Iterator::Item` changed to `{integer}` here | ||
| | | | ||
| | `Iterator::Item` is `&()` here | ||
| this expression has type `Option<()>` | ||
note: required by a bound in `std::iter::Iterator::sum` | ||
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |