@@ -166,14 +166,14 @@ impl UseDiagnostic<'_> {
166
166
/// Return a descriptor of the value at the use site
167
167
fn descr ( & self ) -> & ' static str {
168
168
match self {
169
- Self :: TryConversion { .. } => "`?` error " ,
169
+ Self :: TryConversion { .. } => "error for `?` operator " ,
170
170
}
171
171
}
172
172
173
173
/// Return a descriptor of the type at the use site
174
174
fn type_descr ( & self ) -> & ' static str {
175
175
match self {
176
- Self :: TryConversion { .. } => "`?` error type " ,
176
+ Self :: TryConversion { .. } => "error type for `?` operator " ,
177
177
}
178
178
}
179
179
@@ -188,20 +188,17 @@ impl UseDiagnostic<'_> {
188
188
fn attach_note ( & self , err : & mut DiagnosticBuilder < ' _ > ) {
189
189
match * self {
190
190
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" ;
193
192
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 ) => {
199
196
format ! ( "{} into a type implementing `From<{}>`" , intro, pre_ty)
200
197
}
201
- ( "_" , _ ) => {
198
+ ( true , false ) => {
202
199
format ! ( "{} into `{}` using the `From` trait" , intro, post_ty)
203
200
}
204
- ( _ , _ ) => {
201
+ ( false , false ) => {
205
202
format ! (
206
203
"{} into `{}` using its implementation of `From<{}>`" ,
207
204
intro, post_ty, pre_ty
0 commit comments