From dea8a16af55e319a41e9451959c68d7a24fcdc5a Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Sat, 26 Sep 2020 17:20:14 -0400 Subject: 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. --- compiler/rustc_errors/src/diagnostic_builder.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'compiler/rustc_errors/src') diff --git a/compiler/rustc_errors/src/diagnostic_builder.rs b/compiler/rustc_errors/src/diagnostic_builder.rs index f165a60336a..37902dddff4 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); -- cgit 1.4.1-3-g733a5