diff options
| author | bors <bors@rust-lang.org> | 2021-01-28 12:09:50 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-01-28 12:09:50 +0000 |
| commit | 643a79af3d5a31fa87c8a4c9d7f8bc4ebe2add4b (patch) | |
| tree | f0f8524b6fcb838e1d6729926c48d7b37502c787 /src/test/ui/issues | |
| parent | 0e190206e2ff0c13d64701d9b4145bf89a2d0cab (diff) | |
| parent | dea8a16af55e319a41e9451959c68d7a24fcdc5a (diff) | |
Auto merge of #81149 - Aaron1011:feature/better-no-method-found-err, r=estebank
Avoid describing a method as 'not found' when bounds are unsatisfied Fixes #76267 When there is a single applicable method candidate, but its trait bounds are not satisfied, we avoid saying that the method is "not found". Insted, we update the error message to directly mention which bounds are not satisfied, rather than mentioning them in a note.
Diffstat (limited to 'src/test/ui/issues')
17 files changed, 35 insertions, 35 deletions
diff --git a/src/test/ui/issues/issue-21596.stderr b/src/test/ui/issues/issue-21596.stderr index 70b975524e0..b0524f056ef 100644 --- a/src/test/ui/issues/issue-21596.stderr +++ b/src/test/ui/issues/issue-21596.stderr @@ -1,12 +1,12 @@ -error[E0599]: no method named `to_string` found for raw pointer `*const u8` in the current scope +error[E0599]: the method `to_string` exists for raw pointer `*const u8`, but its trait bounds were not satisfied --> $DIR/issue-21596.rs:4:22 | LL | println!("{}", z.to_string()); - | ^^^^^^^^^ method not found in `*const u8` + | ^^^^^^^^^ method cannot be called on `*const u8` due to unsatisfied trait bounds | = note: try using `<*const T>::as_ref()` to get a reference to the type behind the pointer: https://doc.rust-lang.org/std/primitive.pointer.html#method.as_ref = note: using `<*const T>::as_ref()` on a pointer which is unaligned or points to invalid or uninitialized memory is undefined behavior - = note: the method `to_string` exists but the following trait bounds were not satisfied: + = note: the following trait bounds were not satisfied: `*const u8: std::fmt::Display` which is required by `*const u8: ToString` diff --git a/src/test/ui/issues/issue-31173.rs b/src/test/ui/issues/issue-31173.rs index 26195318380..40475426cff 100644 --- a/src/test/ui/issues/issue-31173.rs +++ b/src/test/ui/issues/issue-31173.rs @@ -11,7 +11,7 @@ pub fn get_tok(it: &mut IntoIter<u8>) { //~^ ERROR type mismatch resolving //~| expected type `u8` //~| found reference `&_` - .collect(); //~ ERROR no method named `collect` + .collect(); //~ ERROR the method } fn main() {} diff --git a/src/test/ui/issues/issue-31173.stderr b/src/test/ui/issues/issue-31173.stderr index d371703e295..0b7ffc39646 100644 --- a/src/test/ui/issues/issue-31173.stderr +++ b/src/test/ui/issues/issue-31173.stderr @@ -7,11 +7,11 @@ LL | .cloned() = note: expected type `u8` found reference `&_` -error[E0599]: no method named `collect` found for struct `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 9:6]>>` in the current scope +error[E0599]: the method `collect` exists for struct `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 9:6]>>`, but its trait bounds were not satisfied --> $DIR/issue-31173.rs:14:10 | LL | .collect(); - | ^^^^^^^ method not found in `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 9:6]>>` + | ^^^^^^^ method cannot be called on `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 9:6]>>` due to unsatisfied trait bounds | ::: $SRC_DIR/core/src/iter/adapters/cloned.rs:LL:COL | @@ -23,7 +23,7 @@ LL | pub struct Cloned<I> { LL | pub struct TakeWhile<I, P> { | -------------------------- doesn't satisfy `<_ as Iterator>::Item = &_` | - = note: the method `collect` exists but the following trait bounds were not satisfied: + = note: the following trait bounds were not satisfied: `<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 9:6]> as Iterator>::Item = &_` which is required by `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 9:6]>>: Iterator` `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 9:6]>>: Iterator` diff --git a/src/test/ui/issues/issue-35677.rs b/src/test/ui/issues/issue-35677.rs index ba2d503d7fc..15d13979062 100644 --- a/src/test/ui/issues/issue-35677.rs +++ b/src/test/ui/issues/issue-35677.rs @@ -2,7 +2,7 @@ use std::collections::HashSet; fn is_subset<T>(this: &HashSet<T>, other: &HashSet<T>) -> bool { this.is_subset(other) - //~^ ERROR no method named + //~^ ERROR the method } fn main() {} diff --git a/src/test/ui/issues/issue-35677.stderr b/src/test/ui/issues/issue-35677.stderr index afdc5d68ca3..ab59e5d1acf 100644 --- a/src/test/ui/issues/issue-35677.stderr +++ b/src/test/ui/issues/issue-35677.stderr @@ -1,10 +1,10 @@ -error[E0599]: no method named `is_subset` found for reference `&HashSet<T>` in the current scope +error[E0599]: the method `is_subset` exists for reference `&HashSet<T>`, but its trait bounds were not satisfied --> $DIR/issue-35677.rs:4:10 | LL | this.is_subset(other) - | ^^^^^^^^^ method not found in `&HashSet<T>` + | ^^^^^^^^^ method cannot be called on `&HashSet<T>` due to unsatisfied trait bounds | - = note: the method `is_subset` exists but the following trait bounds were not satisfied: + = note: the following trait bounds were not satisfied: `T: Eq` `T: Hash` diff --git a/src/test/ui/issues/issue-50264-inner-deref-trait/option-as_deref.rs b/src/test/ui/issues/issue-50264-inner-deref-trait/option-as_deref.rs index 153ca0843d6..160cfc3d46c 100644 --- a/src/test/ui/issues/issue-50264-inner-deref-trait/option-as_deref.rs +++ b/src/test/ui/issues/issue-50264-inner-deref-trait/option-as_deref.rs @@ -1,4 +1,4 @@ fn main() { let _result = &Some(42).as_deref(); -//~^ ERROR no method named `as_deref` found for enum `Option<{integer}>` +//~^ ERROR the method } diff --git a/src/test/ui/issues/issue-50264-inner-deref-trait/option-as_deref.stderr b/src/test/ui/issues/issue-50264-inner-deref-trait/option-as_deref.stderr index a8cd98b6107..21fc3b2bdd1 100644 --- a/src/test/ui/issues/issue-50264-inner-deref-trait/option-as_deref.stderr +++ b/src/test/ui/issues/issue-50264-inner-deref-trait/option-as_deref.stderr @@ -1,10 +1,10 @@ -error[E0599]: no method named `as_deref` found for enum `Option<{integer}>` in the current scope +error[E0599]: the method `as_deref` exists for enum `Option<{integer}>`, but its trait bounds were not satisfied --> $DIR/option-as_deref.rs:2:29 | LL | let _result = &Some(42).as_deref(); - | ^^^^^^^^ help: there is an associated function with a similar name: `as_ref` + | ^^^^^^^^ | - = note: the method `as_deref` exists but the following trait bounds were not satisfied: + = note: the following trait bounds were not satisfied: `{integer}: Deref` `<{integer} as Deref>::Target = _` diff --git a/src/test/ui/issues/issue-50264-inner-deref-trait/option-as_deref_mut.rs b/src/test/ui/issues/issue-50264-inner-deref-trait/option-as_deref_mut.rs index 11d5378fe30..ff5095ce3d7 100644 --- a/src/test/ui/issues/issue-50264-inner-deref-trait/option-as_deref_mut.rs +++ b/src/test/ui/issues/issue-50264-inner-deref-trait/option-as_deref_mut.rs @@ -1,4 +1,4 @@ fn main() { let _result = &mut Some(42).as_deref_mut(); -//~^ ERROR no method named `as_deref_mut` found for enum `Option<{integer}>` +//~^ ERROR the method } diff --git a/src/test/ui/issues/issue-50264-inner-deref-trait/option-as_deref_mut.stderr b/src/test/ui/issues/issue-50264-inner-deref-trait/option-as_deref_mut.stderr index 08399fcea7c..c86b024de21 100644 --- a/src/test/ui/issues/issue-50264-inner-deref-trait/option-as_deref_mut.stderr +++ b/src/test/ui/issues/issue-50264-inner-deref-trait/option-as_deref_mut.stderr @@ -1,10 +1,10 @@ -error[E0599]: no method named `as_deref_mut` found for enum `Option<{integer}>` in the current scope +error[E0599]: the method `as_deref_mut` exists for enum `Option<{integer}>`, but its trait bounds were not satisfied --> $DIR/option-as_deref_mut.rs:2:33 | LL | let _result = &mut Some(42).as_deref_mut(); - | ^^^^^^^^^^^^ method not found in `Option<{integer}>` + | ^^^^^^^^^^^^ method cannot be called on `Option<{integer}>` due to unsatisfied trait bounds | - = note: the method `as_deref_mut` exists but the following trait bounds were not satisfied: + = note: the following trait bounds were not satisfied: `{integer}: DerefMut` `<{integer} as Deref>::Target = _` diff --git a/src/test/ui/issues/issue-50264-inner-deref-trait/result-as_deref.rs b/src/test/ui/issues/issue-50264-inner-deref-trait/result-as_deref.rs index f713dee507f..4232f14d2d3 100644 --- a/src/test/ui/issues/issue-50264-inner-deref-trait/result-as_deref.rs +++ b/src/test/ui/issues/issue-50264-inner-deref-trait/result-as_deref.rs @@ -1,4 +1,4 @@ fn main() { let _result = &Ok(42).as_deref(); -//~^ ERROR no method named `as_deref` found +//~^ ERROR the method } diff --git a/src/test/ui/issues/issue-50264-inner-deref-trait/result-as_deref.stderr b/src/test/ui/issues/issue-50264-inner-deref-trait/result-as_deref.stderr index 933e8a0c44b..e41c04ee89e 100644 --- a/src/test/ui/issues/issue-50264-inner-deref-trait/result-as_deref.stderr +++ b/src/test/ui/issues/issue-50264-inner-deref-trait/result-as_deref.stderr @@ -1,10 +1,10 @@ -error[E0599]: no method named `as_deref` found for enum `std::result::Result<{integer}, _>` in the current scope +error[E0599]: the method `as_deref` exists for enum `std::result::Result<{integer}, _>`, but its trait bounds were not satisfied --> $DIR/result-as_deref.rs:2:27 | LL | let _result = &Ok(42).as_deref(); - | ^^^^^^^^ help: there is an associated function with a similar name: `as_ref` + | ^^^^^^^^ | - = note: the method `as_deref` exists but the following trait bounds were not satisfied: + = note: the following trait bounds were not satisfied: `{integer}: Deref` `<{integer} as Deref>::Target = _` diff --git a/src/test/ui/issues/issue-50264-inner-deref-trait/result-as_deref_mut.rs b/src/test/ui/issues/issue-50264-inner-deref-trait/result-as_deref_mut.rs index 3af7033dd5d..3507d1d8e7e 100644 --- a/src/test/ui/issues/issue-50264-inner-deref-trait/result-as_deref_mut.rs +++ b/src/test/ui/issues/issue-50264-inner-deref-trait/result-as_deref_mut.rs @@ -1,4 +1,4 @@ fn main() { let _result = &mut Ok(42).as_deref_mut(); -//~^ ERROR no method named `as_deref_mut` found +//~^ ERROR the method } diff --git a/src/test/ui/issues/issue-50264-inner-deref-trait/result-as_deref_mut.stderr b/src/test/ui/issues/issue-50264-inner-deref-trait/result-as_deref_mut.stderr index 69d85126f10..372d056fc19 100644 --- a/src/test/ui/issues/issue-50264-inner-deref-trait/result-as_deref_mut.stderr +++ b/src/test/ui/issues/issue-50264-inner-deref-trait/result-as_deref_mut.stderr @@ -1,10 +1,10 @@ -error[E0599]: no method named `as_deref_mut` found for enum `std::result::Result<{integer}, _>` in the current scope +error[E0599]: the method `as_deref_mut` exists for enum `std::result::Result<{integer}, _>`, but its trait bounds were not satisfied --> $DIR/result-as_deref_mut.rs:2:31 | LL | let _result = &mut Ok(42).as_deref_mut(); - | ^^^^^^^^^^^^ method not found in `std::result::Result<{integer}, _>` + | ^^^^^^^^^^^^ method cannot be called on `std::result::Result<{integer}, _>` due to unsatisfied trait bounds | - = note: the method `as_deref_mut` exists but the following trait bounds were not satisfied: + = note: the following trait bounds were not satisfied: `{integer}: DerefMut` `<{integer} as Deref>::Target = _` diff --git a/src/test/ui/issues/issue-57362-2.rs b/src/test/ui/issues/issue-57362-2.rs index 870d7f28ba9..a0b0ea1d038 100644 --- a/src/test/ui/issues/issue-57362-2.rs +++ b/src/test/ui/issues/issue-57362-2.rs @@ -19,7 +19,7 @@ impl<'a> X for fn(&'a ()) { } fn g() { - let x = <fn (&())>::make_g(); //~ ERROR no function or associated item + let x = <fn (&())>::make_g(); //~ ERROR the function } fn main() {} diff --git a/src/test/ui/issues/issue-57362-2.stderr b/src/test/ui/issues/issue-57362-2.stderr index 47cc64ec470..3b6cffeafe4 100644 --- a/src/test/ui/issues/issue-57362-2.stderr +++ b/src/test/ui/issues/issue-57362-2.stderr @@ -1,10 +1,10 @@ -error[E0599]: no function or associated item named `make_g` found for fn pointer `for<'r> fn(&'r ())` in the current scope +error[E0599]: the function or associated item `make_g` exists for fn pointer `for<'r> fn(&'r ())`, but its trait bounds were not satisfied --> $DIR/issue-57362-2.rs:22:25 | LL | let x = <fn (&())>::make_g(); - | ^^^^^^ function or associated item not found in `for<'r> fn(&'r ())` + | ^^^^^^ function or associated item cannot be called on `for<'r> fn(&'r ())` due to unsatisfied trait bounds | - = note: the method `make_g` exists but the following trait bounds were not satisfied: + = note: the following trait bounds were not satisfied: `for<'r> fn(&'r ()): X` = help: items from traits can only be used if the trait is implemented and in scope note: `X` defines an item `make_g`, perhaps you need to implement it diff --git a/src/test/ui/issues/issue-69725.rs b/src/test/ui/issues/issue-69725.rs index b8130b41f21..7c77293945e 100644 --- a/src/test/ui/issues/issue-69725.rs +++ b/src/test/ui/issues/issue-69725.rs @@ -5,7 +5,7 @@ use issue_69725::Struct; fn crash<A>() { let _ = Struct::<A>::new().clone(); - //~^ ERROR: no method named `clone` found + //~^ ERROR: the method } fn main() {} diff --git a/src/test/ui/issues/issue-69725.stderr b/src/test/ui/issues/issue-69725.stderr index 3f70dbcc2a0..48c71d76af0 100644 --- a/src/test/ui/issues/issue-69725.stderr +++ b/src/test/ui/issues/issue-69725.stderr @@ -1,8 +1,8 @@ -error[E0599]: no method named `clone` found for struct `Struct<A>` in the current scope +error[E0599]: the method `clone` exists for struct `Struct<A>`, but its trait bounds were not satisfied --> $DIR/issue-69725.rs:7:32 | LL | let _ = Struct::<A>::new().clone(); - | ^^^^^ method not found in `Struct<A>` + | ^^^^^ method cannot be called on `Struct<A>` due to unsatisfied trait bounds | ::: $DIR/auxiliary/issue-69725.rs:2:1 | @@ -17,7 +17,7 @@ LL | fn clone(&self) -> Self; | the method is available for `Arc<Struct<A>>` here | the method is available for `Rc<Struct<A>>` here | - = note: the method `clone` exists but the following trait bounds were not satisfied: + = note: the following trait bounds were not satisfied: `A: Clone` which is required by `Struct<A>: Clone` |
