forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When suggesting associated fn with type parameters, include in the st…
…ructured suggestion
- Loading branch information
Showing
6 changed files
with
195 additions
and
3 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
21 changes: 21 additions & 0 deletions
21
src/test/ui/suggestions/missing-assoc-fn-applicable-suggestions.fixed
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,21 @@ | ||
// run-rustfix | ||
trait TraitB { | ||
type Item; | ||
} | ||
|
||
trait TraitA<A> { | ||
type Type; | ||
fn bar<T>(_: T) -> Self; | ||
fn baz<T>(_: T) -> Self where T: TraitB, <T as TraitB>::Item: Copy; | ||
} | ||
|
||
struct S; | ||
struct Type; | ||
|
||
impl TraitA<()> for S { //~ ERROR not all trait items implemented | ||
fn baz<T>(_: T) -> Self where T: TraitB, <T as TraitB>::Item: std::marker::Copy { unimplemented!() } | ||
fn bar<T>(_: T) -> Self { unimplemented!() } | ||
type Type = Type; | ||
} | ||
|
||
fn main() {} |
18 changes: 18 additions & 0 deletions
18
src/test/ui/suggestions/missing-assoc-fn-applicable-suggestions.rs
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,18 @@ | ||
// run-rustfix | ||
trait TraitB { | ||
type Item; | ||
} | ||
|
||
trait TraitA<A> { | ||
type Type; | ||
fn bar<T>(_: T) -> Self; | ||
fn baz<T>(_: T) -> Self where T: TraitB, <T as TraitB>::Item: Copy; | ||
} | ||
|
||
struct S; | ||
struct Type; | ||
|
||
impl TraitA<()> for S { //~ ERROR not all trait items implemented | ||
} | ||
|
||
fn main() {} |
16 changes: 16 additions & 0 deletions
16
src/test/ui/suggestions/missing-assoc-fn-applicable-suggestions.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,16 @@ | ||
error[E0046]: not all trait items implemented, missing: `Type`, `bar`, `baz` | ||
--> $DIR/missing-assoc-fn-applicable-suggestions.rs:15:1 | ||
| | ||
LL | type Type; | ||
| ---------- `Type` from trait | ||
LL | fn bar<T>(_: T) -> Self; | ||
| ------------------------ `bar` from trait | ||
LL | fn baz<T>(_: T) -> Self where T: TraitB, <T as TraitB>::Item: Copy; | ||
| ------------------------------------------------------------------- `baz` from trait | ||
... | ||
LL | impl TraitA<()> for S { | ||
| ^^^^^^^^^^^^^^^^^^^^^ missing `Type`, `bar`, `baz` in implementation | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0046`. |
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 @@ | ||
trait TraitB { | ||
type Item; | ||
} | ||
|
||
trait TraitA<A> { | ||
fn foo<T: TraitB<Item = A>>(_: T) -> Self; | ||
fn bar<T>(_: T) -> Self; | ||
fn baz<T>(_: T) -> Self where T: TraitB, <T as TraitB>::Item: Copy; | ||
fn bat<T: TraitB<Item: Copy>>(_: T) -> Self; //~ ERROR associated type bounds are unstable | ||
} | ||
|
||
struct S; | ||
|
||
impl TraitA<()> for S { //~ ERROR not all trait items implemented | ||
} | ||
|
||
use std::iter::FromIterator; | ||
struct X; | ||
impl FromIterator<()> for X { //~ ERROR not all trait items implemented | ||
} | ||
|
||
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,36 @@ | ||
error[E0658]: associated type bounds are unstable | ||
--> $DIR/missing-assoc-fn.rs:9:22 | ||
| | ||
LL | fn bat<T: TraitB<Item: Copy>>(_: T) -> Self; | ||
| ^^^^^^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/52662 | ||
= help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable | ||
|
||
error[E0046]: not all trait items implemented, missing: `foo`, `bar`, `baz`, `bat` | ||
--> $DIR/missing-assoc-fn.rs:14:1 | ||
| | ||
LL | fn foo<T: TraitB<Item = A>>(_: T) -> Self; | ||
| ------------------------------------------ `foo` from trait | ||
LL | fn bar<T>(_: T) -> Self; | ||
| ------------------------ `bar` from trait | ||
LL | fn baz<T>(_: T) -> Self where T: TraitB, <T as TraitB>::Item: Copy; | ||
| ------------------------------------------------------------------- `baz` from trait | ||
LL | fn bat<T: TraitB<Item: Copy>>(_: T) -> Self; | ||
| -------------------------------------------- `bat` from trait | ||
... | ||
LL | impl TraitA<()> for S { | ||
| ^^^^^^^^^^^^^^^^^^^^^ missing `foo`, `bar`, `baz`, `bat` in implementation | ||
|
||
error[E0046]: not all trait items implemented, missing: `from_iter` | ||
--> $DIR/missing-assoc-fn.rs:19:1 | ||
| | ||
LL | impl FromIterator<()> for X { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `from_iter` in implementation | ||
| | ||
= help: implement the missing item: `fn from_iter<T>(_: T) -> Self where T: std::iter::IntoIterator, std::iter::IntoIterator::Item = A { unimplemented!() }` | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
Some errors have detailed explanations: E0046, E0658. | ||
For more information about an error, try `rustc --explain E0046`. |