@@ -1618,18 +1618,8 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
16181618 {
16191619 let e = self . tcx . erase_and_anonymize_regions ( e) ;
16201620 let f = self . tcx . erase_and_anonymize_regions ( f) ;
1621- let mut expected = with_forced_trimmed_paths ! ( e. sort_string( self . tcx) ) ;
1622- let mut found = with_forced_trimmed_paths ! ( f. sort_string( self . tcx) ) ;
1623- if let ObligationCauseCode :: Pattern { span, .. } = cause. code ( )
1624- && let Some ( span) = span
1625- && !span. from_expansion ( )
1626- && cause. span . from_expansion ( )
1627- {
1628- // When the type error comes from a macro like `assert!()`, and we are pointing at
1629- // code the user wrote the cause and effect are reversed as the expected value is
1630- // what the macro expanded to.
1631- ( found, expected) = ( expected, found) ;
1632- }
1621+ let expected = with_forced_trimmed_paths ! ( e. sort_string( self . tcx) ) ;
1622+ let found = with_forced_trimmed_paths ! ( f. sort_string( self . tcx) ) ;
16331623 if expected == found {
16341624 label_or_note ( span, terr. to_string ( self . tcx ) ) ;
16351625 } else {
@@ -2152,9 +2142,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
21522142 ) -> Option < ( DiagStyledString , DiagStyledString ) > {
21532143 match values {
21542144 ValuePairs :: Regions ( exp_found) => self . expected_found_str ( exp_found) ,
2155- ValuePairs :: Terms ( exp_found) => {
2156- self . expected_found_str_term ( cause, exp_found, long_ty_path)
2157- }
2145+ ValuePairs :: Terms ( exp_found) => self . expected_found_str_term ( exp_found, long_ty_path) ,
21582146 ValuePairs :: Aliases ( exp_found) => self . expected_found_str ( exp_found) ,
21592147 ValuePairs :: ExistentialTraitRef ( exp_found) => self . expected_found_str ( exp_found) ,
21602148 ValuePairs :: ExistentialProjection ( exp_found) => self . expected_found_str ( exp_found) ,
@@ -2193,35 +2181,15 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
21932181
21942182 fn expected_found_str_term (
21952183 & self ,
2196- cause : & ObligationCause < ' tcx > ,
21972184 exp_found : ty:: error:: ExpectedFound < ty:: Term < ' tcx > > ,
21982185 long_ty_path : & mut Option < PathBuf > ,
21992186 ) -> Option < ( DiagStyledString , DiagStyledString ) > {
22002187 let exp_found = self . resolve_vars_if_possible ( exp_found) ;
22012188 if exp_found. references_error ( ) {
22022189 return None ;
22032190 }
2204- let ( mut expected, mut found) = ( exp_found. expected , exp_found. found ) ;
2205-
2206- if let ObligationCauseCode :: Pattern { span, .. } = cause. code ( )
2207- && let Some ( span) = span
2208- && !span. from_expansion ( )
2209- && cause. span . from_expansion ( )
2210- {
2211- // When the type error comes from a macro like `assert!()`, and we are pointing at
2212- // code the user wrote, the cause and effect are reversed as the expected value is
2213- // what the macro expanded to. So if the user provided a `Type` when the macro is
2214- // written in such a way that a `bool` was expected, we want to print:
2215- // = note: expected `bool`
2216- // found `Type`"
2217- // but as far as the compiler is concerned, after expansion what was expected was `Type`
2218- // = note: expected `Type`
2219- // found `bool`"
2220- // so we reverse them here to match user expectation.
2221- ( expected, found) = ( found, expected) ;
2222- }
22232191
2224- Some ( match ( expected. kind ( ) , found. kind ( ) ) {
2192+ Some ( match ( exp_found . expected . kind ( ) , exp_found . found . kind ( ) ) {
22252193 ( ty:: TermKind :: Ty ( expected) , ty:: TermKind :: Ty ( found) ) => {
22262194 let ( mut exp, mut fnd) = self . cmp ( expected, found) ;
22272195 // Use the terminal width as the basis to determine when to compress the printed
0 commit comments