From dea8a16af55e319a41e9451959c68d7a24fcdc5a Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Sat, 26 Sep 2020 17:20:14 -0400 Subject: [PATCH] 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. --- .../rustc_errors/src/diagnostic_builder.rs | 8 +-- .../rustc_typeck/src/check/method/suggest.rs | 53 ++++++++++++------- compiler/rustc_typeck/src/lib.rs | 1 + .../hr-associated-type-bound-2.rs | 2 +- .../hr-associated-type-bound-2.stderr | 6 +-- .../derives/derive-assoc-type-not-impl.stderr | 6 +-- src/test/ui/hrtb/issue-30786.migrate.stderr | 12 ++--- src/test/ui/hrtb/issue-30786.nll.stderr | 12 ++--- src/test/ui/hrtb/issue-30786.rs | 8 +-- src/test/ui/issues/issue-21596.stderr | 6 +-- src/test/ui/issues/issue-31173.rs | 2 +- src/test/ui/issues/issue-31173.stderr | 6 +-- src/test/ui/issues/issue-35677.rs | 2 +- src/test/ui/issues/issue-35677.stderr | 6 +-- .../option-as_deref.rs | 2 +- .../option-as_deref.stderr | 6 +-- .../option-as_deref_mut.rs | 2 +- .../option-as_deref_mut.stderr | 6 +-- .../result-as_deref.rs | 2 +- .../result-as_deref.stderr | 6 +-- .../result-as_deref_mut.rs | 2 +- .../result-as_deref_mut.stderr | 6 +-- src/test/ui/issues/issue-57362-2.rs | 2 +- src/test/ui/issues/issue-57362-2.stderr | 6 +-- src/test/ui/issues/issue-69725.rs | 2 +- src/test/ui/issues/issue-69725.stderr | 6 +-- src/test/ui/methods/method-call-err-msg.rs | 2 +- .../ui/methods/method-call-err-msg.stderr | 6 +-- src/test/ui/mir/issue-80742.stderr | 6 +-- src/test/ui/mismatched_types/issue-36053-2.rs | 2 +- .../ui/mismatched_types/issue-36053-2.stderr | 6 +-- .../method-help-unsatisfied-bound.rs | 2 +- .../method-help-unsatisfied-bound.stderr | 6 +-- .../nll/issue-57642-higher-ranked-subtype.rs | 2 +- .../issue-57642-higher-ranked-subtype.stderr | 6 +-- .../specialization-trait-not-implemented.rs | 2 +- ...pecialization-trait-not-implemented.stderr | 6 +-- .../missing-trait-bounds-for-method-call.rs | 4 +- ...issing-trait-bounds-for-method-call.stderr | 12 ++--- .../suggestions/mut-borrow-needed-by-trait.rs | 2 +- .../mut-borrow-needed-by-trait.stderr | 6 +-- src/test/ui/union/union-derive-clone.rs | 2 +- src/test/ui/union/union-derive-clone.stderr | 6 +-- src/test/ui/unique-object-noncopyable.rs | 2 +- src/test/ui/unique-object-noncopyable.stderr | 6 +-- src/test/ui/unique-pinned-nocopy.rs | 2 +- src/test/ui/unique-pinned-nocopy.stderr | 6 +-- 47 files changed, 144 insertions(+), 128 deletions(-) diff --git a/compiler/rustc_errors/src/diagnostic_builder.rs b/compiler/rustc_errors/src/diagnostic_builder.rs index f165a60336a6a..37902dddff46d 100644 --- a/compiler/rustc_errors/src/diagnostic_builder.rs +++ b/compiler/rustc_errors/src/diagnostic_builder.rs @@ -74,11 +74,10 @@ macro_rules! forward { }); }; - // Forward pattern for &mut self -> &mut Self, with S: Into - // type parameter. No obvious way to make this more generic. + // Forward pattern for &mut self -> &mut Self, with generic parameters. ( $(#[$attrs:meta])* - pub fn $n:ident>( + pub fn $n:ident<$($generic:ident: $bound:path),*>( &mut self, $($name:ident: $ty:ty),* $(,)? @@ -86,7 +85,7 @@ macro_rules! forward { ) => { $(#[$attrs])* forward_inner_docs!(concat!("See [`Diagnostic::", stringify!($n), "()`].") => - pub fn $n>(&mut self, $($name: $ty),*) -> &mut Self { + pub fn $n<$($generic: $bound),*>(&mut self, $($name: $ty),*) -> &mut Self { self.0.diagnostic.$n($($name),*); self }); @@ -398,6 +397,7 @@ impl<'a> DiagnosticBuilder<'a> { self } + forward!(pub fn set_primary_message>(&mut self, msg: M) -> &mut Self); forward!(pub fn set_span>(&mut self, sp: S) -> &mut Self); forward!(pub fn code(&mut self, s: DiagnosticId) -> &mut Self); diff --git a/compiler/rustc_typeck/src/check/method/suggest.rs b/compiler/rustc_typeck/src/check/method/suggest.rs index c553fda49c308..d49c7cae8222b 100644 --- a/compiler/rustc_typeck/src/check/method/suggest.rs +++ b/compiler/rustc_typeck/src/check/method/suggest.rs @@ -446,6 +446,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } + let mut label_span_not_found = || { + if unsatisfied_predicates.is_empty() { + err.span_label(span, format!("{item_kind} not found in `{ty_str}`")); + } else { + err.span_label(span, format!("{item_kind} cannot be called on `{ty_str}` due to unsatisfied trait bounds")); + } + self.tcx.sess.trait_methods_not_found.borrow_mut().insert(orig_span); + }; + // If the method name is the name of a field with a function or closure type, // give a helping note that it has to be called as `(x.f)(...)`. if let SelfSource::MethodCall(expr) = source { @@ -501,12 +510,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let field_kind = if is_accessible { "field" } else { "private field" }; err.span_label(item_name.span, format!("{}, not a method", field_kind)); } else if lev_candidate.is_none() && static_sources.is_empty() { - err.span_label(span, format!("{} not found in `{}`", item_kind, ty_str)); - self.tcx.sess.trait_methods_not_found.borrow_mut().insert(orig_span); + label_span_not_found(); } } else { - err.span_label(span, format!("{} not found in `{}`", item_kind, ty_str)); - self.tcx.sess.trait_methods_not_found.borrow_mut().insert(orig_span); + label_span_not_found(); } if self.is_fn_ty(&rcvr_ty, span) { @@ -721,10 +728,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .map(|(_, path)| path) .collect::>() .join("\n"); + let actual_prefix = actual.prefix_string(); + err.set_primary_message(&format!( + "the {item_kind} `{item_name}` exists for {actual_prefix} `{ty_str}`, but its trait bounds were not satisfied" + )); err.note(&format!( - "the method `{}` exists but the following trait bounds were not \ - satisfied:\n{}", - item_name, bound_list + "the following trait bounds were not satisfied:\n{bound_list}" )); } } @@ -742,7 +751,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); } - if actual.is_enum() { + // Don't emit a suggestion if we found an actual method + // that had unsatisfied trait bounds + if unsatisfied_predicates.is_empty() && actual.is_enum() { let adt_def = actual.ty_adt_def().expect("enum is not an ADT"); if let Some(suggestion) = lev_distance::find_best_match_for_name( &adt_def.variants.iter().map(|s| s.ident.name).collect::>(), @@ -778,17 +789,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err.span_label(span, msg); } } else if let Some(lev_candidate) = lev_candidate { - let def_kind = lev_candidate.kind.as_def_kind(); - err.span_suggestion( - span, - &format!( - "there is {} {} with a similar name", - def_kind.article(), - def_kind.descr(lev_candidate.def_id), - ), - lev_candidate.ident.to_string(), - Applicability::MaybeIncorrect, - ); + // Don't emit a suggestion if we found an actual method + // that had unsatisfied trait bounds + if unsatisfied_predicates.is_empty() { + let def_kind = lev_candidate.kind.as_def_kind(); + err.span_suggestion( + span, + &format!( + "there is {} {} with a similar name", + def_kind.article(), + def_kind.descr(lev_candidate.def_id), + ), + lev_candidate.ident.to_string(), + Applicability::MaybeIncorrect, + ); + } } return Some(err); diff --git a/compiler/rustc_typeck/src/lib.rs b/compiler/rustc_typeck/src/lib.rs index dde4a62ffbf3d..ad92d816c9836 100644 --- a/compiler/rustc_typeck/src/lib.rs +++ b/compiler/rustc_typeck/src/lib.rs @@ -60,6 +60,7 @@ This API is completely unstable and subject to change. #![feature(bool_to_option)] #![feature(box_syntax)] #![feature(crate_visibility_modifier)] +#![feature(format_args_capture)] #![feature(in_band_lifetimes)] #![feature(is_sorted)] #![feature(nll)] diff --git a/src/test/ui/associated-types/hr-associated-type-bound-2.rs b/src/test/ui/associated-types/hr-associated-type-bound-2.rs index 7ff0fede28cfe..78ee28b17d4b3 100644 --- a/src/test/ui/associated-types/hr-associated-type-bound-2.rs +++ b/src/test/ui/associated-types/hr-associated-type-bound-2.rs @@ -17,5 +17,5 @@ where fn main() { 1u32.f("abc"); - //~^ ERROR no method named `f` found for type `u32` in the current scope + //~^ ERROR the method } diff --git a/src/test/ui/associated-types/hr-associated-type-bound-2.stderr b/src/test/ui/associated-types/hr-associated-type-bound-2.stderr index 20b6659bbc19b..043d1ac76de9a 100644 --- a/src/test/ui/associated-types/hr-associated-type-bound-2.stderr +++ b/src/test/ui/associated-types/hr-associated-type-bound-2.stderr @@ -1,10 +1,10 @@ -error[E0599]: no method named `f` found for type `u32` in the current scope +error[E0599]: the method `f` exists for type `u32`, but its trait bounds were not satisfied --> $DIR/hr-associated-type-bound-2.rs:19:10 | LL | 1u32.f("abc"); - | ^ method not found in `u32` + | ^ method cannot be called on `u32` due to unsatisfied trait bounds | - = note: the method `f` exists but the following trait bounds were not satisfied: + = note: the following trait bounds were not satisfied: `>::U: Clone` which is required by `u32: X` diff --git a/src/test/ui/derives/derive-assoc-type-not-impl.stderr b/src/test/ui/derives/derive-assoc-type-not-impl.stderr index 92ba4f0704fef..ffee7004f8f8e 100644 --- a/src/test/ui/derives/derive-assoc-type-not-impl.stderr +++ b/src/test/ui/derives/derive-assoc-type-not-impl.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `clone` found for struct `Bar` in the current scope +error[E0599]: the method `clone` exists for struct `Bar`, but its trait bounds were not satisfied --> $DIR/derive-assoc-type-not-impl.rs:18:30 | LL | struct Bar { @@ -11,7 +11,7 @@ LL | struct NotClone; | ---------------- doesn't satisfy `NotClone: Clone` ... LL | Bar:: { x: 1 }.clone(); - | ^^^^^ method not found in `Bar` + | ^^^^^ method cannot be called on `Bar` due to unsatisfied trait bounds | ::: $SRC_DIR/core/src/clone.rs:LL:COL | @@ -21,7 +21,7 @@ LL | fn clone(&self) -> Self; | the method is available for `Arc>` here | the method is available for `Rc>` here | - = note: the method `clone` exists but the following trait bounds were not satisfied: + = note: the following trait bounds were not satisfied: `NotClone: Clone` which is required by `Bar: Clone` = help: items from traits can only be used if the trait is implemented and in scope diff --git a/src/test/ui/hrtb/issue-30786.migrate.stderr b/src/test/ui/hrtb/issue-30786.migrate.stderr index 90a7cadca41b7..a769872d83a52 100644 --- a/src/test/ui/hrtb/issue-30786.migrate.stderr +++ b/src/test/ui/hrtb/issue-30786.migrate.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `filterx` found for struct `Map` in the current scope +error[E0599]: the method `filterx` exists for struct `Map`, but its trait bounds were not satisfied --> $DIR/issue-30786.rs:128:22 | LL | pub struct Map { @@ -8,9 +8,9 @@ LL | pub struct Map { | doesn't satisfy `_: StreamExt` ... LL | let filter = map.filterx(|x: &_| true); - | ^^^^^^^ method not found in `Map` + | ^^^^^^^ method cannot be called on `Map` due to unsatisfied trait bounds | - = note: the method `filterx` exists but the following trait bounds were not satisfied: + = note: the following trait bounds were not satisfied: `&'a mut Map: Stream` which is required by `Map: StreamExt` `&'a mut &Map: Stream` @@ -18,7 +18,7 @@ LL | let filter = map.filterx(|x: &_| true); `&'a mut &mut Map: Stream` which is required by `&mut Map: StreamExt` -error[E0599]: no method named `countx` found for struct `Filter fn(&'r u64) -> &'r u64 {identity::}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>` in the current scope +error[E0599]: the method `countx` exists for struct `Filter fn(&'r u64) -> &'r u64 {identity::}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>`, but its trait bounds were not satisfied --> $DIR/issue-30786.rs:141:24 | LL | pub struct Filter { @@ -28,9 +28,9 @@ LL | pub struct Filter { | doesn't satisfy `_: StreamExt` ... LL | let count = filter.countx(); - | ^^^^^^ method not found in `Filter fn(&'r u64) -> &'r u64 {identity::}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>` + | ^^^^^^ method cannot be called on `Filter fn(&'r u64) -> &'r u64 {identity::}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>` due to unsatisfied trait bounds | - = note: the method `countx` exists but the following trait bounds were not satisfied: + = note: the following trait bounds were not satisfied: `&'a mut Filter fn(&'r u64) -> &'r u64 {identity::}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: Stream` which is required by `Filter fn(&'r u64) -> &'r u64 {identity::}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: StreamExt` `&'a mut &Filter fn(&'r u64) -> &'r u64 {identity::}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: Stream` diff --git a/src/test/ui/hrtb/issue-30786.nll.stderr b/src/test/ui/hrtb/issue-30786.nll.stderr index 90a7cadca41b7..a769872d83a52 100644 --- a/src/test/ui/hrtb/issue-30786.nll.stderr +++ b/src/test/ui/hrtb/issue-30786.nll.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `filterx` found for struct `Map` in the current scope +error[E0599]: the method `filterx` exists for struct `Map`, but its trait bounds were not satisfied --> $DIR/issue-30786.rs:128:22 | LL | pub struct Map { @@ -8,9 +8,9 @@ LL | pub struct Map { | doesn't satisfy `_: StreamExt` ... LL | let filter = map.filterx(|x: &_| true); - | ^^^^^^^ method not found in `Map` + | ^^^^^^^ method cannot be called on `Map` due to unsatisfied trait bounds | - = note: the method `filterx` exists but the following trait bounds were not satisfied: + = note: the following trait bounds were not satisfied: `&'a mut Map: Stream` which is required by `Map: StreamExt` `&'a mut &Map: Stream` @@ -18,7 +18,7 @@ LL | let filter = map.filterx(|x: &_| true); `&'a mut &mut Map: Stream` which is required by `&mut Map: StreamExt` -error[E0599]: no method named `countx` found for struct `Filter fn(&'r u64) -> &'r u64 {identity::}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>` in the current scope +error[E0599]: the method `countx` exists for struct `Filter fn(&'r u64) -> &'r u64 {identity::}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>`, but its trait bounds were not satisfied --> $DIR/issue-30786.rs:141:24 | LL | pub struct Filter { @@ -28,9 +28,9 @@ LL | pub struct Filter { | doesn't satisfy `_: StreamExt` ... LL | let count = filter.countx(); - | ^^^^^^ method not found in `Filter fn(&'r u64) -> &'r u64 {identity::}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>` + | ^^^^^^ method cannot be called on `Filter fn(&'r u64) -> &'r u64 {identity::}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>` due to unsatisfied trait bounds | - = note: the method `countx` exists but the following trait bounds were not satisfied: + = note: the following trait bounds were not satisfied: `&'a mut Filter fn(&'r u64) -> &'r u64 {identity::}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: Stream` which is required by `Filter fn(&'r u64) -> &'r u64 {identity::}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: StreamExt` `&'a mut &Filter fn(&'r u64) -> &'r u64 {identity::}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: Stream` diff --git a/src/test/ui/hrtb/issue-30786.rs b/src/test/ui/hrtb/issue-30786.rs index 8ce5c090b543e..278c5441ecfb7 100644 --- a/src/test/ui/hrtb/issue-30786.rs +++ b/src/test/ui/hrtb/issue-30786.rs @@ -126,8 +126,8 @@ fn variant1() { // guess. let map = source.mapx(|x: &_| x); let filter = map.filterx(|x: &_| true); - //[migrate]~^ ERROR no method named `filterx` - //[nll]~^^ ERROR no method named `filterx` + //[migrate]~^ ERROR the method + //[nll]~^^ ERROR the method } fn variant2() { @@ -139,8 +139,8 @@ fn variant2() { let map = source.mapx(identity); let filter = map.filterx(|x: &_| true); let count = filter.countx(); - //[migrate]~^ ERROR no method named `countx` - //[nll]~^^ ERROR no method named `countx` + //[migrate]~^ ERROR the method + //[nll]~^^ ERROR the method } fn main() {} diff --git a/src/test/ui/issues/issue-21596.stderr b/src/test/ui/issues/issue-21596.stderr index 70b975524e0c8..b0524f056ef7f 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 26195318380d2..40475426cff7a 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) { //~^ 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 d371703e29587..0b7ffc39646a6 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, [closure@$DIR/issue-31173.rs:6:39: 9:6]>>` in the current scope +error[E0599]: the method `collect` exists for struct `Cloned, [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, [closure@$DIR/issue-31173.rs:6:39: 9:6]>>` + | ^^^^^^^ method cannot be called on `Cloned, [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 { LL | pub struct TakeWhile { | -------------------------- 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: `, [closure@$DIR/issue-31173.rs:6:39: 9:6]> as Iterator>::Item = &_` which is required by `Cloned, [closure@$DIR/issue-31173.rs:6:39: 9:6]>>: Iterator` `Cloned, [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 ba2d503d7fcf1..15d139790625e 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(this: &HashSet, other: &HashSet) -> 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 afdc5d68ca39a..ab59e5d1acf6a 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` in the current scope +error[E0599]: the method `is_subset` exists for reference `&HashSet`, but its trait bounds were not satisfied --> $DIR/issue-35677.rs:4:10 | LL | this.is_subset(other) - | ^^^^^^^^^ method not found in `&HashSet` + | ^^^^^^^^^ method cannot be called on `&HashSet` 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 153ca0843d6a5..160cfc3d46c39 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 a8cd98b610784..21fc3b2bdd1f7 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 11d5378fe304d..ff5095ce3d723 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 08399fcea7c97..c86b024de21a6 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 f713dee507f5b..4232f14d2d3d8 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 933e8a0c44bc5..e41c04ee89e0f 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 3af7033dd5dd3..3507d1d8e7e3e 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 69d85126f1006..372d056fc1908 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 870d7f28ba953..a0b0ea1d03893 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 = ::make_g(); //~ ERROR no function or associated item + let x = ::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 47cc64ec470a5..3b6cffeafe4c2 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 = ::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 b8130b41f2167..7c77293945eb7 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() { let _ = Struct::::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 3f70dbcc2a0f4..48c71d76af097 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` in the current scope +error[E0599]: the method `clone` exists for struct `Struct`, but its trait bounds were not satisfied --> $DIR/issue-69725.rs:7:32 | LL | let _ = Struct::::new().clone(); - | ^^^^^ method not found in `Struct` + | ^^^^^ method cannot be called on `Struct` 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>` here | the method is available for `Rc>` 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: Clone` diff --git a/src/test/ui/methods/method-call-err-msg.rs b/src/test/ui/methods/method-call-err-msg.rs index 9bfacc7babf2e..86d00ca376026 100644 --- a/src/test/ui/methods/method-call-err-msg.rs +++ b/src/test/ui/methods/method-call-err-msg.rs @@ -16,7 +16,7 @@ fn main() { let y = Foo; y.zero() - .take() //~ ERROR no method named `take` found + .take() //~ ERROR the method .one(0); y.three::(); //~ ERROR this function takes 3 arguments but 0 arguments were supplied } diff --git a/src/test/ui/methods/method-call-err-msg.stderr b/src/test/ui/methods/method-call-err-msg.stderr index 60f9eeeca27fe..ffeacfe15dd06 100644 --- a/src/test/ui/methods/method-call-err-msg.stderr +++ b/src/test/ui/methods/method-call-err-msg.stderr @@ -40,7 +40,7 @@ note: associated function defined here LL | fn two(self, _: isize, _: isize) -> Foo { self } | ^^^ ---- -------- -------- -error[E0599]: no method named `take` found for struct `Foo` in the current scope +error[E0599]: the method `take` exists for struct `Foo`, but its trait bounds were not satisfied --> $DIR/method-call-err-msg.rs:19:7 | LL | pub struct Foo; @@ -50,9 +50,9 @@ LL | pub struct Foo; | doesn't satisfy `Foo: Iterator` ... LL | .take() - | ^^^^ method not found in `Foo` + | ^^^^ method cannot be called on `Foo` due to unsatisfied trait bounds | - = note: the method `take` exists but the following trait bounds were not satisfied: + = note: the following trait bounds were not satisfied: `Foo: Iterator` which is required by `&mut Foo: Iterator` = help: items from traits can only be used if the trait is implemented and in scope diff --git a/src/test/ui/mir/issue-80742.stderr b/src/test/ui/mir/issue-80742.stderr index 26f9c786ba13b..8cbd0220e6768 100644 --- a/src/test/ui/mir/issue-80742.stderr +++ b/src/test/ui/mir/issue-80742.stderr @@ -12,7 +12,7 @@ LL | intrinsics::size_of::() LL | [u8; size_of::() + 1]: , | -------------- inside `Inline::::{constant#0}` at $DIR/issue-80742.rs:23:10 -error[E0599]: no function or associated item named `new` found for struct `Inline` in the current scope +error[E0599]: the function or associated item `new` exists for struct `Inline`, but its trait bounds were not satisfied --> $DIR/issue-80742.rs:31:36 | LL | / struct Inline @@ -25,14 +25,14 @@ LL | | } | |_- function or associated item `new` not found for this ... LL | let dst = Inline::::new(0); - | ^^^ function or associated item not found in `Inline` + | ^^^ function or associated item cannot be called on `Inline` due to unsatisfied trait bounds | ::: $SRC_DIR/core/src/fmt/mod.rs:LL:COL | LL | pub trait Debug { | --------------- doesn't satisfy `dyn Debug: Sized` | - = note: the method `new` exists but the following trait bounds were not satisfied: + = note: the following trait bounds were not satisfied: `dyn Debug: Sized` error[E0080]: evaluation of constant value failed diff --git a/src/test/ui/mismatched_types/issue-36053-2.rs b/src/test/ui/mismatched_types/issue-36053-2.rs index 9035e3380b0c5..17d2292baaf68 100644 --- a/src/test/ui/mismatched_types/issue-36053-2.rs +++ b/src/test/ui/mismatched_types/issue-36053-2.rs @@ -5,6 +5,6 @@ use std::iter::once; fn main() { once::<&str>("str").fuse().filter(|a: &str| true).count(); - //~^ ERROR no method named `count` + //~^ ERROR the method //~| ERROR type mismatch in closure arguments } diff --git a/src/test/ui/mismatched_types/issue-36053-2.stderr b/src/test/ui/mismatched_types/issue-36053-2.stderr index 2efd37b4738a5..69ae3d8cbd0e5 100644 --- a/src/test/ui/mismatched_types/issue-36053-2.stderr +++ b/src/test/ui/mismatched_types/issue-36053-2.stderr @@ -6,11 +6,11 @@ LL | once::<&str>("str").fuse().filter(|a: &str| true).count(); | | | expected signature of `for<'r> fn(&'r &str) -> _` -error[E0599]: no method named `count` found for struct `Filter>, [closure@$DIR/issue-36053-2.rs:7:39: 7:53]>` in the current scope +error[E0599]: the method `count` exists for struct `Filter>, [closure@$DIR/issue-36053-2.rs:7:39: 7:53]>`, but its trait bounds were not satisfied --> $DIR/issue-36053-2.rs:7:55 | LL | once::<&str>("str").fuse().filter(|a: &str| true).count(); - | -------------- ^^^^^ method not found in `Filter>, [closure@$DIR/issue-36053-2.rs:7:39: 7:53]>` + | -------------- ^^^^^ method cannot be called on `Filter>, [closure@$DIR/issue-36053-2.rs:7:39: 7:53]>` due to unsatisfied trait bounds | | | doesn't satisfy `<_ as FnOnce<(&&str,)>>::Output = bool` | doesn't satisfy `_: FnMut<(&&str,)>` @@ -20,7 +20,7 @@ LL | once::<&str>("str").fuse().filter(|a: &str| true).count(); LL | pub struct Filter { | ----------------------- doesn't satisfy `_: Iterator` | - = note: the method `count` exists but the following trait bounds were not satisfied: + = note: the following trait bounds were not satisfied: `<[closure@$DIR/issue-36053-2.rs:7:39: 7:53] as FnOnce<(&&str,)>>::Output = bool` which is required by `Filter>, [closure@$DIR/issue-36053-2.rs:7:39: 7:53]>: Iterator` `[closure@$DIR/issue-36053-2.rs:7:39: 7:53]: FnMut<(&&str,)>` diff --git a/src/test/ui/mismatched_types/method-help-unsatisfied-bound.rs b/src/test/ui/mismatched_types/method-help-unsatisfied-bound.rs index 58ceaffc96400..f85c10d78c54d 100644 --- a/src/test/ui/mismatched_types/method-help-unsatisfied-bound.rs +++ b/src/test/ui/mismatched_types/method-help-unsatisfied-bound.rs @@ -3,5 +3,5 @@ struct Foo; fn main() { let a: Result<(), Foo> = Ok(()); a.unwrap(); - //~^ ERROR no method named `unwrap` found + //~^ ERROR the method } diff --git a/src/test/ui/mismatched_types/method-help-unsatisfied-bound.stderr b/src/test/ui/mismatched_types/method-help-unsatisfied-bound.stderr index 67f79a8147b9b..92a88cbdb34a3 100644 --- a/src/test/ui/mismatched_types/method-help-unsatisfied-bound.stderr +++ b/src/test/ui/mismatched_types/method-help-unsatisfied-bound.stderr @@ -1,13 +1,13 @@ -error[E0599]: no method named `unwrap` found for enum `std::result::Result<(), Foo>` in the current scope +error[E0599]: the method `unwrap` exists for enum `std::result::Result<(), Foo>`, but its trait bounds were not satisfied --> $DIR/method-help-unsatisfied-bound.rs:5:7 | LL | struct Foo; | ----------- doesn't satisfy `Foo: Debug` ... LL | a.unwrap(); - | ^^^^^^ method not found in `std::result::Result<(), Foo>` + | ^^^^^^ method cannot be called on `std::result::Result<(), Foo>` due to unsatisfied trait bounds | - = note: the method `unwrap` exists but the following trait bounds were not satisfied: + = note: the following trait bounds were not satisfied: `Foo: Debug` error: aborting due to previous error diff --git a/src/test/ui/nll/issue-57642-higher-ranked-subtype.rs b/src/test/ui/nll/issue-57642-higher-ranked-subtype.rs index 36c54628317e9..b222b90e4af24 100644 --- a/src/test/ui/nll/issue-57642-higher-ranked-subtype.rs +++ b/src/test/ui/nll/issue-57642-higher-ranked-subtype.rs @@ -31,7 +31,7 @@ impl Y for fn(T) { } fn higher_ranked_region_has_lost_its_binder() { - let x = ::make_g(); //~ ERROR no function + let x = ::make_g(); //~ ERROR the function } fn magical() { diff --git a/src/test/ui/nll/issue-57642-higher-ranked-subtype.stderr b/src/test/ui/nll/issue-57642-higher-ranked-subtype.stderr index f69098193429c..95811ea05b873 100644 --- a/src/test/ui/nll/issue-57642-higher-ranked-subtype.stderr +++ b/src/test/ui/nll/issue-57642-higher-ranked-subtype.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-57642-higher-ranked-subtype.rs:34:25 | LL | let x = ::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/specialization/defaultimpl/specialization-trait-not-implemented.rs b/src/test/ui/specialization/defaultimpl/specialization-trait-not-implemented.rs index 35e3b8725a82a..6834d57362991 100644 --- a/src/test/ui/specialization/defaultimpl/specialization-trait-not-implemented.rs +++ b/src/test/ui/specialization/defaultimpl/specialization-trait-not-implemented.rs @@ -20,5 +20,5 @@ default impl Foo for T { fn main() { println!("{}", MyStruct.foo_one()); - //~^ ERROR no method named `foo_one` found + //~^ ERROR the method } diff --git a/src/test/ui/specialization/defaultimpl/specialization-trait-not-implemented.stderr b/src/test/ui/specialization/defaultimpl/specialization-trait-not-implemented.stderr index fb623c97f4209..16ffc661fe0a3 100644 --- a/src/test/ui/specialization/defaultimpl/specialization-trait-not-implemented.stderr +++ b/src/test/ui/specialization/defaultimpl/specialization-trait-not-implemented.stderr @@ -8,7 +8,7 @@ LL | #![feature(specialization)] = note: see issue #31844 for more information = help: consider using `min_specialization` instead, which is more stable and complete -error[E0599]: no method named `foo_one` found for struct `MyStruct` in the current scope +error[E0599]: the method `foo_one` exists for struct `MyStruct`, but its trait bounds were not satisfied --> $DIR/specialization-trait-not-implemented.rs:22:29 | LL | struct MyStruct; @@ -18,9 +18,9 @@ LL | struct MyStruct; | doesn't satisfy `MyStruct: Foo` ... LL | println!("{}", MyStruct.foo_one()); - | ^^^^^^^ method not found in `MyStruct` + | ^^^^^^^ method cannot be called on `MyStruct` due to unsatisfied trait bounds | - = note: the method `foo_one` exists but the following trait bounds were not satisfied: + = note: the following trait bounds were not satisfied: `MyStruct: Foo` = help: items from traits can only be used if the trait is implemented and in scope note: `Foo` defines an item `foo_one`, perhaps you need to implement it diff --git a/src/test/ui/suggestions/missing-trait-bounds-for-method-call.rs b/src/test/ui/suggestions/missing-trait-bounds-for-method-call.rs index fefdf149f556c..afd47f71c2cbf 100644 --- a/src/test/ui/suggestions/missing-trait-bounds-for-method-call.rs +++ b/src/test/ui/suggestions/missing-trait-bounds-for-method-call.rs @@ -12,7 +12,7 @@ impl Bar for Foo {} impl Foo { fn bar(&self) { self.foo(); - //~^ ERROR no method named `foo` found for reference `&Foo` in the current scope + //~^ ERROR the method } } @@ -25,7 +25,7 @@ impl Bar for Fin {} impl Fin { fn bar(&self) { self.foo(); - //~^ ERROR no method named `foo` found for reference `&Fin` in the current scope + //~^ ERROR the method } } fn main() {} diff --git a/src/test/ui/suggestions/missing-trait-bounds-for-method-call.stderr b/src/test/ui/suggestions/missing-trait-bounds-for-method-call.stderr index eb695379b580d..c7376b0007f97 100644 --- a/src/test/ui/suggestions/missing-trait-bounds-for-method-call.stderr +++ b/src/test/ui/suggestions/missing-trait-bounds-for-method-call.stderr @@ -1,13 +1,13 @@ -error[E0599]: no method named `foo` found for reference `&Foo` in the current scope +error[E0599]: the method `foo` exists for reference `&Foo`, but its trait bounds were not satisfied --> $DIR/missing-trait-bounds-for-method-call.rs:14:14 | LL | struct Foo { | ------------- doesn't satisfy `Foo: Bar` ... LL | self.foo(); - | ^^^ method not found in `&Foo` + | ^^^ method cannot be called on `&Foo` due to unsatisfied trait bounds | - = note: the method `foo` exists but the following trait bounds were not satisfied: + = note: the following trait bounds were not satisfied: `T: Bar` which is required by `Foo: Bar` `T: Default` @@ -17,16 +17,16 @@ help: consider restricting the type parameters to satisfy the trait bounds LL | struct Foo where T: Bar, T: Default { | ^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0599]: no method named `foo` found for reference `&Fin` in the current scope +error[E0599]: the method `foo` exists for reference `&Fin`, but its trait bounds were not satisfied --> $DIR/missing-trait-bounds-for-method-call.rs:27:14 | LL | struct Fin where T: Bar { | -------------------------- doesn't satisfy `Fin: Bar` ... LL | self.foo(); - | ^^^ method not found in `&Fin` + | ^^^ method cannot be called on `&Fin` due to unsatisfied trait bounds | - = note: the method `foo` exists but the following trait bounds were not satisfied: + = note: the following trait bounds were not satisfied: `T: Default` which is required by `Fin: Bar` help: consider restricting the type parameter to satisfy the trait bound diff --git a/src/test/ui/suggestions/mut-borrow-needed-by-trait.rs b/src/test/ui/suggestions/mut-borrow-needed-by-trait.rs index f8b86377187c5..924bfd82eb832 100644 --- a/src/test/ui/suggestions/mut-borrow-needed-by-trait.rs +++ b/src/test/ui/suggestions/mut-borrow-needed-by-trait.rs @@ -19,5 +19,5 @@ fn main() { //~| ERROR the trait bound `&dyn std::io::Write: std::io::Write` is not satisfied //~| ERROR the trait bound `&dyn std::io::Write: std::io::Write` is not satisfied - writeln!(fp, "hello world").unwrap(); //~ ERROR no method named `write_fmt` found for struct + writeln!(fp, "hello world").unwrap(); //~ ERROR the method } diff --git a/src/test/ui/suggestions/mut-borrow-needed-by-trait.stderr b/src/test/ui/suggestions/mut-borrow-needed-by-trait.stderr index 8a9a1e5793588..3120b739c0295 100644 --- a/src/test/ui/suggestions/mut-borrow-needed-by-trait.stderr +++ b/src/test/ui/suggestions/mut-borrow-needed-by-trait.stderr @@ -33,18 +33,18 @@ LL | pub struct BufWriter { | = note: `std::io::Write` is implemented for `&mut dyn std::io::Write`, but not for `&dyn std::io::Write` -error[E0599]: no method named `write_fmt` found for struct `BufWriter<&dyn std::io::Write>` in the current scope +error[E0599]: the method `write_fmt` exists for struct `BufWriter<&dyn std::io::Write>`, but its trait bounds were not satisfied --> $DIR/mut-borrow-needed-by-trait.rs:22:5 | LL | writeln!(fp, "hello world").unwrap(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ method not found in `BufWriter<&dyn std::io::Write>` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ method cannot be called on `BufWriter<&dyn std::io::Write>` due to unsatisfied trait bounds | ::: $SRC_DIR/std/src/io/buffered/bufwriter.rs:LL:COL | LL | pub struct BufWriter { | ------------------------------ doesn't satisfy `BufWriter<&dyn std::io::Write>: std::io::Write` | - = note: the method `write_fmt` exists but the following trait bounds were not satisfied: + = note: the following trait bounds were not satisfied: `&dyn std::io::Write: std::io::Write` which is required by `BufWriter<&dyn std::io::Write>: std::io::Write` = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/src/test/ui/union/union-derive-clone.rs b/src/test/ui/union/union-derive-clone.rs index 753a9f74d03e4..7ab19edb47179 100644 --- a/src/test/ui/union/union-derive-clone.rs +++ b/src/test/ui/union/union-derive-clone.rs @@ -32,5 +32,5 @@ struct CloneNoCopy; fn main() { let u = U5 { a: ManuallyDrop::new(CloneNoCopy) }; - let w = u.clone(); //~ ERROR no method named `clone` found for union `U5` + let w = u.clone(); //~ ERROR the method } diff --git a/src/test/ui/union/union-derive-clone.stderr b/src/test/ui/union/union-derive-clone.stderr index e18f457a8b6f5..a793bf58d23e2 100644 --- a/src/test/ui/union/union-derive-clone.stderr +++ b/src/test/ui/union/union-derive-clone.stderr @@ -11,7 +11,7 @@ LL | pub struct AssertParamIsCopy { | = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0599]: no method named `clone` found for union `U5` in the current scope +error[E0599]: the method `clone` exists for union `U5`, but its trait bounds were not satisfied --> $DIR/union-derive-clone.rs:35:15 | LL | union U5 { @@ -24,7 +24,7 @@ LL | struct CloneNoCopy; | ------------------- doesn't satisfy `CloneNoCopy: Copy` ... LL | let w = u.clone(); - | ^^^^^ method not found in `U5` + | ^^^^^ method cannot be called on `U5` due to unsatisfied trait bounds | ::: $SRC_DIR/core/src/clone.rs:LL:COL | @@ -34,7 +34,7 @@ LL | fn clone(&self) -> Self; | the method is available for `Arc>` here | the method is available for `Rc>` here | - = note: the method `clone` exists but the following trait bounds were not satisfied: + = note: the following trait bounds were not satisfied: `CloneNoCopy: Copy` which is required by `U5: Clone` diff --git a/src/test/ui/unique-object-noncopyable.rs b/src/test/ui/unique-object-noncopyable.rs index dd38a7190aa0e..d243b8f34dbcf 100644 --- a/src/test/ui/unique-object-noncopyable.rs +++ b/src/test/ui/unique-object-noncopyable.rs @@ -21,5 +21,5 @@ impl Foo for Bar { fn main() { let x = box Bar { x: 10 }; let y: Box = x as Box; - let _z = y.clone(); //~ ERROR no method named `clone` found + let _z = y.clone(); //~ ERROR the method } diff --git a/src/test/ui/unique-object-noncopyable.stderr b/src/test/ui/unique-object-noncopyable.stderr index 09cbb8753387a..4bbacfc0a8b60 100644 --- a/src/test/ui/unique-object-noncopyable.stderr +++ b/src/test/ui/unique-object-noncopyable.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `clone` found for struct `Box` in the current scope +error[E0599]: the method `clone` exists for struct `Box`, but its trait bounds were not satisfied --> $DIR/unique-object-noncopyable.rs:24:16 | LL | trait Foo { @@ -8,7 +8,7 @@ LL | trait Foo { | doesn't satisfy `dyn Foo: Sized` ... LL | let _z = y.clone(); - | ^^^^^ method not found in `Box` + | ^^^^^ method cannot be called on `Box` due to unsatisfied trait bounds | ::: $SRC_DIR/core/src/clone.rs:LL:COL | @@ -26,7 +26,7 @@ LL | | #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator LL | | >(Unique, A); | |________________- doesn't satisfy `Box: Clone` | - = note: the method `clone` exists but the following trait bounds were not satisfied: + = note: the following trait bounds were not satisfied: `dyn Foo: Sized` which is required by `Box: Clone` `dyn Foo: Clone` diff --git a/src/test/ui/unique-pinned-nocopy.rs b/src/test/ui/unique-pinned-nocopy.rs index 4c30450c70455..8edaeef51e061 100644 --- a/src/test/ui/unique-pinned-nocopy.rs +++ b/src/test/ui/unique-pinned-nocopy.rs @@ -9,6 +9,6 @@ impl Drop for R { fn main() { let i = Box::new(R { b: true }); - let _j = i.clone(); //~ ERROR no method named `clone` found + let _j = i.clone(); //~ ERROR the method println!("{:?}", i); } diff --git a/src/test/ui/unique-pinned-nocopy.stderr b/src/test/ui/unique-pinned-nocopy.stderr index bc081024182af..dd0b7fc5489ce 100644 --- a/src/test/ui/unique-pinned-nocopy.stderr +++ b/src/test/ui/unique-pinned-nocopy.stderr @@ -1,11 +1,11 @@ -error[E0599]: no method named `clone` found for struct `Box` in the current scope +error[E0599]: the method `clone` exists for struct `Box`, but its trait bounds were not satisfied --> $DIR/unique-pinned-nocopy.rs:12:16 | LL | struct R { | -------- doesn't satisfy `R: Clone` ... LL | let _j = i.clone(); - | ^^^^^ method not found in `Box` + | ^^^^^ method cannot be called on `Box` due to unsatisfied trait bounds | ::: $SRC_DIR/core/src/clone.rs:LL:COL | @@ -23,7 +23,7 @@ LL | | #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator LL | | >(Unique, A); | |________________- doesn't satisfy `Box: Clone` | - = note: the method `clone` exists but the following trait bounds were not satisfied: + = note: the following trait bounds were not satisfied: `R: Clone` which is required by `Box: Clone` = help: items from traits can only be used if the trait is implemented and in scope