diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2020-04-07 13:26:09 -0700 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2020-05-04 09:52:40 -0700 |
| commit | 75f066dc687e9a40e193ff059491b208a98291aa (patch) | |
| tree | 8acaee23882eb633da58315a281a06bf8834e87b /src/test | |
| parent | 6318d24ad8440fa30428b405be1174478e9536e3 (diff) | |
| download | rust-75f066dc687e9a40e193ff059491b208a98291aa.tar.gz rust-75f066dc687e9a40e193ff059491b208a98291aa.zip | |
Handle binop on unbound type param
When encountering a binary operation involving a type parameter that has no bindings, suggest adding the appropriate bound.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/issues/issue-6738.stderr | 5 | ||||
| -rw-r--r-- | src/test/ui/type/type-check/missing_trait_impl.stderr | 10 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/test/ui/issues/issue-6738.stderr b/src/test/ui/issues/issue-6738.stderr index 82b670bd03b..a428ff7e91f 100644 --- a/src/test/ui/issues/issue-6738.stderr +++ b/src/test/ui/issues/issue-6738.stderr @@ -6,7 +6,10 @@ LL | self.x += v.x; | | | cannot use `+=` on type `T` | - = note: `T` might need a bound for `std::ops::AddAssign` +help: consider restricting type parameter `T` + | +LL | impl<T: std::ops::AddAssign> Foo<T> { + | ^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/type/type-check/missing_trait_impl.stderr b/src/test/ui/type/type-check/missing_trait_impl.stderr index 7186d6a542d..30df1261cef 100644 --- a/src/test/ui/type/type-check/missing_trait_impl.stderr +++ b/src/test/ui/type/type-check/missing_trait_impl.stderr @@ -6,7 +6,10 @@ LL | let z = x + y; | | | T | - = note: `T` might need a bound for `std::ops::Add` +help: consider restricting type parameter `T` + | +LL | fn foo<T: std::ops::Add<Output = T>>(x: T, y: T) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0368]: binary assignment operation `+=` cannot be applied to type `T` --> $DIR/missing_trait_impl.rs:9:5 @@ -16,7 +19,10 @@ LL | x += x; | | | cannot use `+=` on type `T` | - = note: `T` might need a bound for `std::ops::AddAssign` +help: consider restricting type parameter `T` + | +LL | fn bar<T: std::ops::AddAssign>(x: T) { + | ^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors |
