Update unop path, fix tests

This commit is contained in:
Will Crichton 2022-04-25 19:14:09 -07:00
parent 4d0fe27896
commit dc41dbaf8e
5 changed files with 51 additions and 94 deletions

View file

@ -1,46 +0,0 @@
// run-rustfix
use std::ops::Add;
struct A<B>(B);
impl<B> Add for A<B> where B: Add + Add<Output = B> {
type Output = Self;
fn add(self, rhs: Self) -> Self {
A(self.0 + rhs.0) //~ ERROR mismatched types
}
}
struct C<B>(B);
impl<B: Add + Add<Output = B>> Add for C<B> {
type Output = Self;
fn add(self, rhs: Self) -> Self {
Self(self.0 + rhs.0) //~ ERROR mismatched types
}
}
struct D<B>(B);
impl<B: std::ops::Add> Add for D<B> {
type Output = Self;
fn add(self, rhs: Self) -> Self {
Self(self.0 + rhs.0) //~ ERROR cannot add `B` to `B`
}
}
struct E<B>(B);
impl<B: Add> Add for E<B> where B: Add<Output = B>, B: Add<Output = B> {
//~^ ERROR equality constraints are not yet supported in `where` clauses
type Output = Self;
fn add(self, rhs: Self) -> Self {
Self(self.0 + rhs.0) //~ ERROR mismatched types
}
}
fn main() {}

View file

@ -1,5 +1,3 @@
// run-rustfix
use std::ops::Add;
struct A<B>(B);

View file

@ -1,5 +1,5 @@
error: equality constraints are not yet supported in `where` clauses
--> $DIR/missing-bounds.rs:37:33
--> $DIR/missing-bounds.rs:35:33
|
LL | impl<B: Add> Add for E<B> where <B as Add>::Output = B {
| ^^^^^^^^^^^^^^^^^^^^^^ not supported
@ -11,7 +11,7 @@ LL | impl<B: Add> Add for E<B> where B: Add<Output = B> {
| ~~~~~~~~~~~~~~~~~~
error[E0308]: mismatched types
--> $DIR/missing-bounds.rs:11:11
--> $DIR/missing-bounds.rs:9:11
|
LL | impl<B> Add for A<B> where B: Add {
| - this type parameter
@ -24,7 +24,7 @@ LL | A(self.0 + rhs.0)
= note: expected type parameter `B`
found associated type `<B as Add>::Output`
note: tuple struct defined here
--> $DIR/missing-bounds.rs:5:8
--> $DIR/missing-bounds.rs:3:8
|
LL | struct A<B>(B);
| ^
@ -34,7 +34,7 @@ LL | impl<B> Add for A<B> where B: Add + Add<Output = B> {
| +++++++++++++++++
error[E0308]: mismatched types
--> $DIR/missing-bounds.rs:21:14
--> $DIR/missing-bounds.rs:19:14
|
LL | impl<B: Add> Add for C<B> {
| - this type parameter
@ -47,7 +47,7 @@ LL | Self(self.0 + rhs.0)
= note: expected type parameter `B`
found associated type `<B as Add>::Output`
note: tuple struct defined here
--> $DIR/missing-bounds.rs:15:8
--> $DIR/missing-bounds.rs:13:8
|
LL | struct C<B>(B);
| ^
@ -57,7 +57,7 @@ LL | impl<B: Add + Add<Output = B>> Add for C<B> {
| +++++++++++++++++
error[E0369]: cannot add `B` to `B`
--> $DIR/missing-bounds.rs:31:21
--> $DIR/missing-bounds.rs:29:21
|
LL | Self(self.0 + rhs.0)
| ------ ^ ----- B
@ -70,7 +70,7 @@ LL | impl<B: std::ops::Add> Add for D<B> {
| +++++++++++++++
error[E0308]: mismatched types
--> $DIR/missing-bounds.rs:42:14
--> $DIR/missing-bounds.rs:40:14
|
LL | impl<B: Add> Add for E<B> where <B as Add>::Output = B {
| - this type parameter
@ -83,7 +83,7 @@ LL | Self(self.0 + rhs.0)
= note: expected type parameter `B`
found associated type `<B as Add>::Output`
note: tuple struct defined here
--> $DIR/missing-bounds.rs:35:8
--> $DIR/missing-bounds.rs:33:8
|
LL | struct E<B>(B);
| ^

View file

@ -32,8 +32,8 @@ LL | let y = -x;
|
help: consider restricting type parameter `T`
|
LL | fn baz<T: std::ops::Neg<Output = T>>(x: T) {
| +++++++++++++++++++++++++++
LL | fn baz<T: std::ops::Neg>(x: T) {
| +++++++++++++++
error[E0600]: cannot apply unary operator `!` to type `T`
--> $DIR/missing_trait_impl.rs:14:13
@ -43,8 +43,8 @@ LL | let y = !x;
|
help: consider restricting type parameter `T`
|
LL | fn baz<T: std::ops::Not<Output = T>>(x: T) {
| +++++++++++++++++++++++++++
LL | fn baz<T: std::ops::Not>(x: T) {
| +++++++++++++++
error[E0614]: type `T` cannot be dereferenced
--> $DIR/missing_trait_impl.rs:15:13