@@ -60,8 +60,8 @@ use crate::traits::{
6060
6161use rustc_data_structures:: fx:: { FxIndexMap , FxIndexSet } ;
6262use rustc_errors:: {
63- codes:: * , pluralize, struct_span_code_err, Applicability , Diag , DiagCtxt ,
64- DiagnosticStyledString , ErrorGuaranteed , IntoDiagnosticArg ,
63+ codes:: * , pluralize, struct_span_code_err, Applicability , Diag , DiagCtxt , DiagStyledString ,
64+ ErrorGuaranteed , IntoDiagnosticArg ,
6565} ;
6666use rustc_hir as hir;
6767use rustc_hir:: def:: DefKind ;
@@ -945,8 +945,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
945945 /// ```
946946 fn highlight_outer (
947947 & self ,
948- value : & mut DiagnosticStyledString ,
949- other_value : & mut DiagnosticStyledString ,
948+ value : & mut DiagStyledString ,
949+ other_value : & mut DiagStyledString ,
950950 name : String ,
951951 sub : ty:: GenericArgsRef < ' tcx > ,
952952 pos : usize ,
@@ -1019,8 +1019,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
10191019 /// ```
10201020 fn cmp_type_arg (
10211021 & self ,
1022- t1_out : & mut DiagnosticStyledString ,
1023- t2_out : & mut DiagnosticStyledString ,
1022+ t1_out : & mut DiagStyledString ,
1023+ t2_out : & mut DiagStyledString ,
10241024 path : String ,
10251025 sub : & ' tcx [ ty:: GenericArg < ' tcx > ] ,
10261026 other_path : String ,
@@ -1048,8 +1048,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
10481048 /// Adds a `,` to the type representation only if it is appropriate.
10491049 fn push_comma (
10501050 & self ,
1051- value : & mut DiagnosticStyledString ,
1052- other_value : & mut DiagnosticStyledString ,
1051+ value : & mut DiagStyledString ,
1052+ other_value : & mut DiagStyledString ,
10531053 len : usize ,
10541054 pos : usize ,
10551055 ) {
@@ -1064,7 +1064,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
10641064 & self ,
10651065 sig1 : & ty:: PolyFnSig < ' tcx > ,
10661066 sig2 : & ty:: PolyFnSig < ' tcx > ,
1067- ) -> ( DiagnosticStyledString , DiagnosticStyledString ) {
1067+ ) -> ( DiagStyledString , DiagStyledString ) {
10681068 let sig1 = & ( self . normalize_fn_sig ) ( * sig1) ;
10691069 let sig2 = & ( self . normalize_fn_sig ) ( * sig2) ;
10701070
@@ -1081,10 +1081,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
10811081 let ( lt2, sig2) = get_lifetimes ( sig2) ;
10821082
10831083 // unsafe extern "C" for<'a> fn(&'a T) -> &'a T
1084- let mut values = (
1085- DiagnosticStyledString :: normal ( "" . to_string ( ) ) ,
1086- DiagnosticStyledString :: normal ( "" . to_string ( ) ) ,
1087- ) ;
1084+ let mut values =
1085+ ( DiagStyledString :: normal ( "" . to_string ( ) ) , DiagStyledString :: normal ( "" . to_string ( ) ) ) ;
10881086
10891087 // unsafe extern "C" for<'a> fn(&'a T) -> &'a T
10901088 // ^^^^^^
@@ -1173,15 +1171,11 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
11731171
11741172 /// Compares two given types, eliding parts that are the same between them and highlighting
11751173 /// relevant differences, and return two representation of those types for highlighted printing.
1176- pub fn cmp (
1177- & self ,
1178- t1 : Ty < ' tcx > ,
1179- t2 : Ty < ' tcx > ,
1180- ) -> ( DiagnosticStyledString , DiagnosticStyledString ) {
1174+ pub fn cmp ( & self , t1 : Ty < ' tcx > , t2 : Ty < ' tcx > ) -> ( DiagStyledString , DiagStyledString ) {
11811175 debug ! ( "cmp(t1={}, t1.kind={:?}, t2={}, t2.kind={:?})" , t1, t1. kind( ) , t2, t2. kind( ) ) ;
11821176
11831177 // helper functions
1184- let recurse = |t1, t2, values : & mut ( DiagnosticStyledString , DiagnosticStyledString ) | {
1178+ let recurse = |t1, t2, values : & mut ( DiagStyledString , DiagStyledString ) | {
11851179 let ( x1, x2) = self . cmp ( t1, t2) ;
11861180 ( values. 0 ) . 0 . extend ( x1. 0 ) ;
11871181 ( values. 1 ) . 0 . extend ( x2. 0 ) ;
@@ -1200,7 +1194,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
12001194 fn push_ref < ' tcx > (
12011195 region : ty:: Region < ' tcx > ,
12021196 mutbl : hir:: Mutability ,
1203- s : & mut DiagnosticStyledString ,
1197+ s : & mut DiagStyledString ,
12041198 ) {
12051199 s. push_highlighted ( fmt_region ( region) ) ;
12061200 s. push_highlighted ( mutbl. prefix_str ( ) ) ;
@@ -1209,7 +1203,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
12091203 fn maybe_highlight < T : Eq + ToString > (
12101204 t1 : T ,
12111205 t2 : T ,
1212- ( buf1, buf2) : & mut ( DiagnosticStyledString , DiagnosticStyledString ) ,
1206+ ( buf1, buf2) : & mut ( DiagStyledString , DiagStyledString ) ,
12131207 tcx : TyCtxt < ' _ > ,
12141208 ) {
12151209 let highlight = t1 != t2;
@@ -1228,7 +1222,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
12281222 mut1 : hir:: Mutability ,
12291223 r2 : ty:: Region < ' tcx > ,
12301224 mut2 : hir:: Mutability ,
1231- ss : & mut ( DiagnosticStyledString , DiagnosticStyledString ) ,
1225+ ss : & mut ( DiagStyledString , DiagStyledString ) ,
12321226 ) {
12331227 let ( r1, r2) = ( fmt_region ( r1) , fmt_region ( r2) ) ;
12341228 if r1 != r2 {
@@ -1257,7 +1251,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
12571251 self . tcx . generics_of ( did1) . own_args_no_defaults ( self . tcx , sub1) ;
12581252 let sub_no_defaults_2 =
12591253 self . tcx . generics_of ( did2) . own_args_no_defaults ( self . tcx , sub2) ;
1260- let mut values = ( DiagnosticStyledString :: new ( ) , DiagnosticStyledString :: new ( ) ) ;
1254+ let mut values = ( DiagStyledString :: new ( ) , DiagStyledString :: new ( ) ) ;
12611255 let path1 = self . tcx . def_path_str ( did1) ;
12621256 let path2 = self . tcx . def_path_str ( did2) ;
12631257 if did1 == did2 {
@@ -1426,8 +1420,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
14261420 if split_idx >= min_len {
14271421 // paths are identical, highlight everything
14281422 (
1429- DiagnosticStyledString :: highlighted ( t1_str) ,
1430- DiagnosticStyledString :: highlighted ( t2_str) ,
1423+ DiagStyledString :: highlighted ( t1_str) ,
1424+ DiagStyledString :: highlighted ( t2_str) ,
14311425 )
14321426 } else {
14331427 let ( common, uniq1) = t1_str. split_at ( split_idx) ;
@@ -1446,29 +1440,28 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
14461440
14471441 // When finding `&T != &T`, compare the references, then recurse into pointee type
14481442 ( & ty:: Ref ( r1, ref_ty1, mutbl1) , & ty:: Ref ( r2, ref_ty2, mutbl2) ) => {
1449- let mut values = ( DiagnosticStyledString :: new ( ) , DiagnosticStyledString :: new ( ) ) ;
1443+ let mut values = ( DiagStyledString :: new ( ) , DiagStyledString :: new ( ) ) ;
14501444 cmp_ty_refs ( r1, mutbl1, r2, mutbl2, & mut values) ;
14511445 recurse ( ref_ty1, ref_ty2, & mut values) ;
14521446 values
14531447 }
14541448 // When finding T != &T, highlight the borrow
14551449 ( & ty:: Ref ( r1, ref_ty1, mutbl1) , _) => {
1456- let mut values = ( DiagnosticStyledString :: new ( ) , DiagnosticStyledString :: new ( ) ) ;
1450+ let mut values = ( DiagStyledString :: new ( ) , DiagStyledString :: new ( ) ) ;
14571451 push_ref ( r1, mutbl1, & mut values. 0 ) ;
14581452 recurse ( ref_ty1, t2, & mut values) ;
14591453 values
14601454 }
14611455 ( _, & ty:: Ref ( r2, ref_ty2, mutbl2) ) => {
1462- let mut values = ( DiagnosticStyledString :: new ( ) , DiagnosticStyledString :: new ( ) ) ;
1456+ let mut values = ( DiagStyledString :: new ( ) , DiagStyledString :: new ( ) ) ;
14631457 push_ref ( r2, mutbl2, & mut values. 1 ) ;
14641458 recurse ( t1, ref_ty2, & mut values) ;
14651459 values
14661460 }
14671461
14681462 // When encountering tuples of the same size, highlight only the differing types
14691463 ( & ty:: Tuple ( args1) , & ty:: Tuple ( args2) ) if args1. len ( ) == args2. len ( ) => {
1470- let mut values =
1471- ( DiagnosticStyledString :: normal ( "(" ) , DiagnosticStyledString :: normal ( "(" ) ) ;
1464+ let mut values = ( DiagStyledString :: normal ( "(" ) , DiagStyledString :: normal ( "(" ) ) ;
14721465 let len = args1. len ( ) ;
14731466 for ( i, ( left, right) ) in args1. iter ( ) . zip ( args2) . enumerate ( ) {
14741467 recurse ( left, right, & mut values) ;
@@ -1518,7 +1511,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
15181511 ( ty:: FnPtr ( sig1) , ty:: FnPtr ( sig2) ) => self . cmp_fn_sig ( sig1, sig2) ,
15191512
15201513 _ => {
1521- let mut strs = ( DiagnosticStyledString :: new ( ) , DiagnosticStyledString :: new ( ) ) ;
1514+ let mut strs = ( DiagStyledString :: new ( ) , DiagStyledString :: new ( ) ) ;
15221515 maybe_highlight ( t1, t2, & mut strs, self . tcx ) ;
15231516 strs
15241517 }
@@ -2217,7 +2210,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
22172210 fn values_str (
22182211 & self ,
22192212 values : ValuePairs < ' tcx > ,
2220- ) -> Option < ( DiagnosticStyledString , DiagnosticStyledString , Option < PathBuf > ) > {
2213+ ) -> Option < ( DiagStyledString , DiagStyledString , Option < PathBuf > ) > {
22212214 match values {
22222215 infer:: Regions ( exp_found) => self . expected_found_str ( exp_found) ,
22232216 infer:: Terms ( exp_found) => self . expected_found_str_term ( exp_found) ,
@@ -2250,7 +2243,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
22502243 fn expected_found_str_term (
22512244 & self ,
22522245 exp_found : ty:: error:: ExpectedFound < ty:: Term < ' tcx > > ,
2253- ) -> Option < ( DiagnosticStyledString , DiagnosticStyledString , Option < PathBuf > ) > {
2246+ ) -> Option < ( DiagStyledString , DiagStyledString , Option < PathBuf > ) > {
22542247 let exp_found = self . resolve_vars_if_possible ( exp_found) ;
22552248 if exp_found. references_error ( ) {
22562249 return None ;
@@ -2268,17 +2261,17 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
22682261 let mut path = None ;
22692262 if exp_s. len ( ) > len {
22702263 let exp_s = self . tcx . short_ty_string ( expected, & mut path) ;
2271- exp = DiagnosticStyledString :: highlighted ( exp_s) ;
2264+ exp = DiagStyledString :: highlighted ( exp_s) ;
22722265 }
22732266 if fnd_s. len ( ) > len {
22742267 let fnd_s = self . tcx . short_ty_string ( found, & mut path) ;
2275- fnd = DiagnosticStyledString :: highlighted ( fnd_s) ;
2268+ fnd = DiagStyledString :: highlighted ( fnd_s) ;
22762269 }
22772270 ( exp, fnd, path)
22782271 }
22792272 _ => (
2280- DiagnosticStyledString :: highlighted ( exp_found. expected . to_string ( ) ) ,
2281- DiagnosticStyledString :: highlighted ( exp_found. found . to_string ( ) ) ,
2273+ DiagStyledString :: highlighted ( exp_found. expected . to_string ( ) ) ,
2274+ DiagStyledString :: highlighted ( exp_found. found . to_string ( ) ) ,
22822275 None ,
22832276 ) ,
22842277 } )
@@ -2288,15 +2281,15 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
22882281 fn expected_found_str < T : fmt:: Display + TypeFoldable < TyCtxt < ' tcx > > > (
22892282 & self ,
22902283 exp_found : ty:: error:: ExpectedFound < T > ,
2291- ) -> Option < ( DiagnosticStyledString , DiagnosticStyledString , Option < PathBuf > ) > {
2284+ ) -> Option < ( DiagStyledString , DiagStyledString , Option < PathBuf > ) > {
22922285 let exp_found = self . resolve_vars_if_possible ( exp_found) ;
22932286 if exp_found. references_error ( ) {
22942287 return None ;
22952288 }
22962289
22972290 Some ( (
2298- DiagnosticStyledString :: highlighted ( exp_found. expected . to_string ( ) ) ,
2299- DiagnosticStyledString :: highlighted ( exp_found. found . to_string ( ) ) ,
2291+ DiagStyledString :: highlighted ( exp_found. expected . to_string ( ) ) ,
2292+ DiagStyledString :: highlighted ( exp_found. found . to_string ( ) ) ,
23002293 None ,
23012294 ) )
23022295 }
0 commit comments