@@ -166,14 +166,14 @@ impl UseDiagnostic<'_> {
166166 /// Return a descriptor of the value at the use site
167167 fn descr ( & self ) -> & ' static str {
168168 match self {
169- Self :: TryConversion { .. } => "`?` error " ,
169+ Self :: TryConversion { .. } => "error for `?` operator " ,
170170 }
171171 }
172172
173173 /// Return a descriptor of the type at the use site
174174 fn type_descr ( & self ) -> & ' static str {
175175 match self {
176- Self :: TryConversion { .. } => "`?` error type " ,
176+ Self :: TryConversion { .. } => "error type for `?` operator " ,
177177 }
178178 }
179179
@@ -188,20 +188,17 @@ impl UseDiagnostic<'_> {
188188 fn attach_note ( & self , err : & mut DiagnosticBuilder < ' _ > ) {
189189 match * self {
190190 Self :: TryConversion { pre_ty, post_ty, .. } => {
191- let pre_ty = pre_ty. to_string ( ) ;
192- let post_ty = post_ty. to_string ( ) ;
191+ let intro = "`?` implicitly converts the error value" ;
193192
194- let intro = "the `?` operation implicitly converts the error value" ;
195-
196- let msg = match ( pre_ty. as_str ( ) , post_ty. as_str ( ) ) {
197- ( "_" , "_" ) => format ! ( "{} using the `From` trait" , intro) ,
198- ( _, "_" ) => {
193+ let msg = match ( pre_ty. is_ty_infer ( ) , post_ty. is_ty_infer ( ) ) {
194+ ( true , true ) => format ! ( "{} using the `From` trait" , intro) ,
195+ ( false , true ) => {
199196 format ! ( "{} into a type implementing `From<{}>`" , intro, pre_ty)
200197 }
201- ( "_" , _ ) => {
198+ ( true , false ) => {
202199 format ! ( "{} into `{}` using the `From` trait" , intro, post_ty)
203200 }
204- ( _ , _ ) => {
201+ ( false , false ) => {
205202 format ! (
206203 "{} into `{}` using its implementation of `From<{}>`" ,
207204 intro, post_ty, pre_ty
0 commit comments