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> {
16501650 hir:: MatchSource :: IfLetDesugar { .. } => "`if let` arms have compatible types" ,
16511651 _ => "match arms have compatible types" ,
16521652 } ,
1653- IfExpression { .. } => "if and else have compatible types" ,
1653+ IfExpression { .. } => "if and else have incompatible types" ,
16541654 IfExpressionWithNoElse => "if missing an else returns ()" ,
16551655 MainFunctionType => "`main` function has the correct type" ,
16561656 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> {
247247}
248248
249249impl < ' 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+ ) {
254256 use self :: TypeError :: * ;
255257
256- match err. clone ( ) {
258+ match err {
257259 Sorts ( values) => {
258260 let expected_str = values. expected . sort_string ( self ) ;
259261 let found_str = values. found . sort_string ( self ) ;
260262 if expected_str == found_str && expected_str == "closure" {
261263 db. note ( "no two closures, even if identical, have the same type" ) ;
262264 db. help ( "consider boxing your closure and/or using it as a trait object" ) ;
263265 }
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+ }
264275 if let ( ty:: Infer ( ty:: IntVar ( _) ) , ty:: Float ( _) ) =
265276 ( & values. found . sty , & values. expected . sty ) // Issue #53280
266277 {
You can’t perform that action at this time.
0 commit comments