Handle empty where-clause better

This commit is contained in:
Michael Goulet 2022-06-05 17:37:45 -07:00
parent 8506b7d4e0
commit 9c47afe9fa
23 changed files with 78 additions and 59 deletions

View file

@ -6,7 +6,7 @@ LL | a.iter().map(|a| a*a)
| |
| &T
|
help: consider introducing a `where` bound, but there might be an alternative better way to express this requirement
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
LL | fn func<'a, T>(a: &'a [T]) -> impl Iterator<Item=&'a T> where &T: Mul<&T> {
| +++++++++++++++++

View file

@ -2,6 +2,11 @@ fn foo<T: PartialEq>(a: &T, b: T) {
a == b; //~ ERROR E0277
}
fn foo2<T: PartialEq>(a: &T, b: T) where {
a == b; //~ ERROR E0277
}
fn main() {
foo(&1, 1);
foo2(&1, 1);
}

View file

@ -5,11 +5,23 @@ LL | a == b;
| ^^ no implementation for `&T == T`
|
= help: the trait `PartialEq<T>` is not implemented for `&T`
help: consider introducing a `where` bound, but there might be an alternative better way to express this requirement
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
LL | fn foo<T: PartialEq>(a: &T, b: T) where &T: PartialEq<T> {
| ++++++++++++++++++++++
error: aborting due to previous error
error[E0277]: can't compare `&T` with `T`
--> $DIR/partialeq_help.rs:6:7
|
LL | a == b;
| ^^ no implementation for `&T == T`
|
= help: the trait `PartialEq<T>` is not implemented for `&T`
help: consider extending the `where` clause, but there might be an alternative better way to express this requirement
|
LL | fn foo2<T: PartialEq>(a: &T, b: T) where &T: PartialEq<T> {
| ++++++++++++++++
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.

View file

@ -15,7 +15,7 @@ note: required by a bound in `Foo::Bar`
|
LL | type Bar: ~const std::ops::Add;
| ^^^^^^^^^^^^^^^^^^^^ required by this bound in `Foo::Bar`
help: consider introducing a `where` bound, but there might be an alternative better way to express this requirement
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
LL | impl const Foo for NonConstAdd where NonConstAdd: ~const Add {
| +++++++++++++++++++++++++++++

View file

@ -14,7 +14,7 @@ note: required by a bound in `foo`
|
LL | const fn foo<T>() where T: ~const Tr {}
| ^^^^^^^^^ required by this bound in `foo`
help: consider introducing a `where` bound, but there might be an alternative better way to express this requirement
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
LL | pub trait Foo where (): ~const Tr {
| +++++++++++++++++++

View file

@ -20,7 +20,7 @@ note: required by a bound in `X::U`
|
LL | type U: PartialEq<T>;
| ^^^^^^^^^^^^ required by this bound in `X::U`
help: consider introducing a `where` bound, but there might be an alternative better way to express this requirement
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
LL | impl<B: 'static, T> X<B> for T where &'static B: PartialEq<B> {
| ++++++++++++++++++++++++++++++

View file

@ -13,7 +13,7 @@ help: consider annotating `a::Inner<T>` with `#[derive(Debug)]`
|
LL | #[derive(Debug)]
|
help: consider introducing a `where` bound, but there might be an alternative better way to express this requirement
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
LL | struct Outer<T>(Inner<T>) where a::Inner<T>: Debug;
| ++++++++++++++++++++++++

View file

@ -15,7 +15,7 @@ help: consider annotating `S<T>` with `#[derive(PartialEq)]`
|
LL | #[derive(PartialEq)]
|
help: consider introducing a `where` bound, but there might be an alternative better way to express this requirement
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
LL | pub fn foo<T>(s: S<T>, t: S<T>) where S<T>: PartialEq {
| +++++++++++++++++++++

View file

@ -2,7 +2,7 @@
use std::io::{BufRead, BufReader, Read, Write};
fn issue_81421<T: Read + Write>(mut stream: T) { //~ HELP consider introducing a `where` bound
fn issue_81421<T: Read + Write>(mut stream: T) { //~ HELP consider introducing a `where` clause
let initial_message = format!("Hello world");
let mut buffer: Vec<u8> = Vec::new();
let bytes_written = stream.write_all(initial_message.as_bytes());

View file

@ -16,7 +16,7 @@ help: consider removing the leading `&`-reference
LL - let mut stream_reader = BufReader::new(&stream);
LL + let mut stream_reader = BufReader::new(stream);
|
help: consider introducing a `where` bound, but there might be an alternative better way to express this requirement
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
LL | fn issue_81421<T: Read + Write>(mut stream: T) where &T: std::io::Read {
| +++++++++++++++++++++++

View file

@ -6,7 +6,7 @@ LL | a * b
| |
| &T
|
help: consider introducing a `where` bound, but there might be an alternative better way to express this requirement
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
LL | fn foo<T: MyMul<f64, f64>>(a: &T, b: f64) -> f64 where &T: Mul<f64> {
| ++++++++++++++++++

View file

@ -49,7 +49,7 @@ error[E0277]: the trait bound `u64: From<T>` is not satisfied
LL | <u64 as From<T>>::from;
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `From<T>` is not implemented for `u64`
|
help: consider introducing a `where` bound, but there might be an alternative better way to express this requirement
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
LL | fn check<T: Iterator, U: ?Sized>() where u64: From<T> {
| ++++++++++++++++++
@ -60,7 +60,7 @@ error[E0277]: the trait bound `u64: From<<T as Iterator>::Item>` is not satisfie
LL | <u64 as From<<T as Iterator>::Item>>::from;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `From<<T as Iterator>::Item>` is not implemented for `u64`
|
help: consider introducing a `where` bound, but there might be an alternative better way to express this requirement
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
LL | fn check<T: Iterator, U: ?Sized>() where u64: From<<T as Iterator>::Item> {
| ++++++++++++++++++++++++++++++++++++++

View file

@ -5,7 +5,7 @@ LL | (a, a)
| ^ the trait `From<&A>` is not implemented for `&'static B`
|
= note: required because of the requirements on the impl of `Into<&'static B>` for `&A`
help: consider introducing a `where` bound, but there might be an alternative better way to express this requirement
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
LL | fn f<A, B: 'static>(a: &'static A, b: B) -> (X<A, B>, X<B, A>) where &'static B: From<&A> {
| ++++++++++++++++++++++++++