mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-23 22:14:15 +00:00
5c414094ac
When a method not found on a type parameter could have been provided by any of multiple traits, suggest each trait individually, instead of a single suggestion to restrict the type parameter with *all* of them. Before: ``` error[E0599]: the method `cmp` exists for reference `&T`, but its trait bounds were not satisfied --> $DIR/method-on-unbounded-type-param.rs:5:10 | LL | (&a).cmp(&b) | ^^^ method cannot be called on `&T` due to unsatisfied trait bounds | = note: the following trait bounds were not satisfied: `T: Ord` which is required by `&T: Ord` `&T: Iterator` which is required by `&mut &T: Iterator` `T: Iterator` which is required by `&mut T: Iterator` help: consider restricting the type parameters to satisfy the trait bounds | LL | fn g<T>(a: T, b: T) -> std::cmp::Ordering where T: Iterator, T: Ord { | +++++++++++++++++++++++++ ``` After: ``` error[E0599]: the method `cmp` exists for reference `&T`, but its trait bounds were not satisfied --> $DIR/method-on-unbounded-type-param.rs:5:10 | LL | (&a).cmp(&b) | ^^^ method cannot be called on `&T` due to unsatisfied trait bounds | = note: the following trait bounds were not satisfied: `T: Ord` which is required by `&T: Ord` `&T: Iterator` which is required by `&mut &T: Iterator` `T: Iterator` which is required by `&mut T: Iterator` = help: items from traits can only be used if the type parameter is bounded by the trait help: the following traits define an item `cmp`, perhaps you need to restrict type parameter `T` with one of them: | LL | fn g<T: Ord>(a: T, b: T) -> std::cmp::Ordering { | +++++ LL | fn g<T: Iterator>(a: T, b: T) -> std::cmp::Ordering { | ++++++++++ ``` Fix #108428.
90 lines
2.8 KiB
Plaintext
90 lines
2.8 KiB
Plaintext
error[E0061]: this method takes 0 arguments but 1 argument was supplied
|
|
--> $DIR/method-call-err-msg.rs:13:7
|
|
|
|
|
LL | x.zero(0)
|
|
| ^^^^ -
|
|
| |
|
|
| unexpected argument of type `{integer}`
|
|
| help: remove the extra argument
|
|
|
|
|
note: method defined here
|
|
--> $DIR/method-call-err-msg.rs:5:8
|
|
|
|
|
LL | fn zero(self) -> Foo { self }
|
|
| ^^^^
|
|
|
|
error[E0061]: this method takes 1 argument but 0 arguments were supplied
|
|
--> $DIR/method-call-err-msg.rs:14:7
|
|
|
|
|
LL | .one()
|
|
| ^^^-- an argument of type `isize` is missing
|
|
|
|
|
note: method defined here
|
|
--> $DIR/method-call-err-msg.rs:6:8
|
|
|
|
|
LL | fn one(self, _: isize) -> Foo { self }
|
|
| ^^^ --------
|
|
help: provide the argument
|
|
|
|
|
LL | .one(/* isize */)
|
|
| ~~~~~~~~~~~~~
|
|
|
|
error[E0061]: this method takes 2 arguments but 1 argument was supplied
|
|
--> $DIR/method-call-err-msg.rs:15:7
|
|
|
|
|
LL | .two(0);
|
|
| ^^^--- an argument of type `isize` is missing
|
|
|
|
|
note: method defined here
|
|
--> $DIR/method-call-err-msg.rs:7:8
|
|
|
|
|
LL | fn two(self, _: isize, _: isize) -> Foo { self }
|
|
| ^^^ -------- --------
|
|
help: provide the argument
|
|
|
|
|
LL | .two(0, /* isize */);
|
|
| ~~~~~~~~~~~~~~~~
|
|
|
|
error[E0599]: `Foo` is not an iterator
|
|
--> $DIR/method-call-err-msg.rs:19:7
|
|
|
|
|
LL | pub struct Foo;
|
|
| -------------- method `take` not found for this struct because it doesn't satisfy `Foo: Iterator`
|
|
...
|
|
LL | / y.zero()
|
|
LL | | .take()
|
|
| | -^^^^ `Foo` is not an iterator
|
|
| |______|
|
|
|
|
|
|
|
|
= note: the following trait bounds were not satisfied:
|
|
`Foo: Iterator`
|
|
which is required by `&mut Foo: Iterator`
|
|
note: the trait `Iterator` must be implemented
|
|
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
|
|
= help: items from traits can only be used if the trait is implemented and in scope
|
|
= note: the following traits define an item `take`, perhaps you need to implement one of them:
|
|
candidate #1: `std::io::Read`
|
|
candidate #2: `Iterator`
|
|
|
|
error[E0061]: this method takes 3 arguments but 0 arguments were supplied
|
|
--> $DIR/method-call-err-msg.rs:21:7
|
|
|
|
|
LL | y.three::<usize>();
|
|
| ^^^^^^^^^^^^^^-- three arguments of type `usize`, `usize`, and `usize` are missing
|
|
|
|
|
note: method defined here
|
|
--> $DIR/method-call-err-msg.rs:8:8
|
|
|
|
|
LL | fn three<T>(self, _: T, _: T, _: T) -> Foo { self }
|
|
| ^^^^^ ---- ---- ----
|
|
help: provide the arguments
|
|
|
|
|
LL | y.three::<usize>(/* usize */, /* usize */, /* usize */);
|
|
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
error: aborting due to 5 previous errors
|
|
|
|
Some errors have detailed explanations: E0061, E0599.
|
|
For more information about an error, try `rustc --explain E0061`.
|