File tree Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -1650,7 +1650,7 @@ impl<'tcx> ObligationCause<'tcx> {
1650
1650
hir:: MatchSource :: IfLetDesugar { .. } => "`if let` arms have compatible types" ,
1651
1651
_ => "match arms have compatible types" ,
1652
1652
} ,
1653
- IfExpression { .. } => "if and else have compatible types" ,
1653
+ IfExpression { .. } => "if and else have incompatible types" ,
1654
1654
IfExpressionWithNoElse => "if missing an else returns ()" ,
1655
1655
MainFunctionType => "`main` function has the correct type" ,
1656
1656
StartFunctionType => "`start` function has the correct type" ,
Original file line number Diff line number Diff line change @@ -247,20 +247,31 @@ impl<'tcx> ty::TyS<'tcx> {
247
247
}
248
248
249
249
impl < ' tcx > TyCtxt < ' tcx > {
250
- pub fn note_and_explain_type_err ( self ,
251
- db : & mut DiagnosticBuilder < ' _ > ,
252
- err : & TypeError < ' tcx > ,
253
- sp : Span ) {
250
+ pub fn note_and_explain_type_err (
251
+ self ,
252
+ db : & mut DiagnosticBuilder < ' _ > ,
253
+ err : & TypeError < ' tcx > ,
254
+ sp : Span ,
255
+ ) {
254
256
use self :: TypeError :: * ;
255
257
256
- match err. clone ( ) {
258
+ match err {
257
259
Sorts ( values) => {
258
260
let expected_str = values. expected . sort_string ( self ) ;
259
261
let found_str = values. found . sort_string ( self ) ;
260
262
if expected_str == found_str && expected_str == "closure" {
261
263
db. note ( "no two closures, even if identical, have the same type" ) ;
262
264
db. help ( "consider boxing your closure and/or using it as a trait object" ) ;
263
265
}
266
+ if expected_str == found_str && expected_str == "opaque type" { // Issue #63167
267
+ db. note ( "distinct uses of `impl Trait` result in different opaque types" ) ;
268
+ let e_str = values. expected . to_string ( ) ;
269
+ let f_str = values. found . to_string ( ) ;
270
+ if & e_str == & f_str && & e_str == "impl std::future::Future" {
271
+ db. help ( "if both futures resolve to the same type, consider `await`ing \
272
+ on both of them") ;
273
+ }
274
+ }
264
275
if let ( ty:: Infer ( ty:: IntVar ( _) ) , ty:: Float ( _) ) =
265
276
( & values. found . sty , & values. expected . sty ) // Issue #53280
266
277
{
You can’t perform that action at this time.
0 commit comments