@@ -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 ;
@@ -943,8 +943,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
943943 /// ```
944944 fn highlight_outer (
945945 & self ,
946- value : & mut DiagnosticStyledString ,
947- other_value : & mut DiagnosticStyledString ,
946+ value : & mut DiagStyledString ,
947+ other_value : & mut DiagStyledString ,
948948 name : String ,
949949 sub : ty:: GenericArgsRef < ' tcx > ,
950950 pos : usize ,
@@ -1017,8 +1017,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
10171017 /// ```
10181018 fn cmp_type_arg (
10191019 & self ,
1020- t1_out : & mut DiagnosticStyledString ,
1021- t2_out : & mut DiagnosticStyledString ,
1020+ t1_out : & mut DiagStyledString ,
1021+ t2_out : & mut DiagStyledString ,
10221022 path : String ,
10231023 sub : & ' tcx [ ty:: GenericArg < ' tcx > ] ,
10241024 other_path : String ,
@@ -1046,8 +1046,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
10461046 /// Adds a `,` to the type representation only if it is appropriate.
10471047 fn push_comma (
10481048 & self ,
1049- value : & mut DiagnosticStyledString ,
1050- other_value : & mut DiagnosticStyledString ,
1049+ value : & mut DiagStyledString ,
1050+ other_value : & mut DiagStyledString ,
10511051 len : usize ,
10521052 pos : usize ,
10531053 ) {
@@ -1062,7 +1062,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
10621062 & self ,
10631063 sig1 : & ty:: PolyFnSig < ' tcx > ,
10641064 sig2 : & ty:: PolyFnSig < ' tcx > ,
1065- ) -> ( DiagnosticStyledString , DiagnosticStyledString ) {
1065+ ) -> ( DiagStyledString , DiagStyledString ) {
10661066 let sig1 = & ( self . normalize_fn_sig ) ( * sig1) ;
10671067 let sig2 = & ( self . normalize_fn_sig ) ( * sig2) ;
10681068
@@ -1079,10 +1079,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
10791079 let ( lt2, sig2) = get_lifetimes ( sig2) ;
10801080
10811081 // unsafe extern "C" for<'a> fn(&'a T) -> &'a T
1082- let mut values = (
1083- DiagnosticStyledString :: normal ( "" . to_string ( ) ) ,
1084- DiagnosticStyledString :: normal ( "" . to_string ( ) ) ,
1085- ) ;
1082+ let mut values =
1083+ ( DiagStyledString :: normal ( "" . to_string ( ) ) , DiagStyledString :: normal ( "" . to_string ( ) ) ) ;
10861084
10871085 // unsafe extern "C" for<'a> fn(&'a T) -> &'a T
10881086 // ^^^^^^
@@ -1171,15 +1169,11 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
11711169
11721170 /// Compares two given types, eliding parts that are the same between them and highlighting
11731171 /// relevant differences, and return two representation of those types for highlighted printing.
1174- pub fn cmp (
1175- & self ,
1176- t1 : Ty < ' tcx > ,
1177- t2 : Ty < ' tcx > ,
1178- ) -> ( DiagnosticStyledString , DiagnosticStyledString ) {
1172+ pub fn cmp ( & self , t1 : Ty < ' tcx > , t2 : Ty < ' tcx > ) -> ( DiagStyledString , DiagStyledString ) {
11791173 debug ! ( "cmp(t1={}, t1.kind={:?}, t2={}, t2.kind={:?})" , t1, t1. kind( ) , t2, t2. kind( ) ) ;
11801174
11811175 // helper functions
1182- let recurse = |t1, t2, values : & mut ( DiagnosticStyledString , DiagnosticStyledString ) | {
1176+ let recurse = |t1, t2, values : & mut ( DiagStyledString , DiagStyledString ) | {
11831177 let ( x1, x2) = self . cmp ( t1, t2) ;
11841178 ( values. 0 ) . 0 . extend ( x1. 0 ) ;
11851179 ( values. 1 ) . 0 . extend ( x2. 0 ) ;
@@ -1198,7 +1192,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
11981192 fn push_ref < ' tcx > (
11991193 region : ty:: Region < ' tcx > ,
12001194 mutbl : hir:: Mutability ,
1201- s : & mut DiagnosticStyledString ,
1195+ s : & mut DiagStyledString ,
12021196 ) {
12031197 s. push_highlighted ( fmt_region ( region) ) ;
12041198 s. push_highlighted ( mutbl. prefix_str ( ) ) ;
@@ -1207,7 +1201,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
12071201 fn maybe_highlight < T : Eq + ToString > (
12081202 t1 : T ,
12091203 t2 : T ,
1210- ( buf1, buf2) : & mut ( DiagnosticStyledString , DiagnosticStyledString ) ,
1204+ ( buf1, buf2) : & mut ( DiagStyledString , DiagStyledString ) ,
12111205 tcx : TyCtxt < ' _ > ,
12121206 ) {
12131207 let highlight = t1 != t2;
@@ -1226,7 +1220,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
12261220 mut1 : hir:: Mutability ,
12271221 r2 : ty:: Region < ' tcx > ,
12281222 mut2 : hir:: Mutability ,
1229- ss : & mut ( DiagnosticStyledString , DiagnosticStyledString ) ,
1223+ ss : & mut ( DiagStyledString , DiagStyledString ) ,
12301224 ) {
12311225 let ( r1, r2) = ( fmt_region ( r1) , fmt_region ( r2) ) ;
12321226 if r1 != r2 {
@@ -1255,7 +1249,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
12551249 self . tcx . generics_of ( did1) . own_args_no_defaults ( self . tcx , sub1) ;
12561250 let sub_no_defaults_2 =
12571251 self . tcx . generics_of ( did2) . own_args_no_defaults ( self . tcx , sub2) ;
1258- let mut values = ( DiagnosticStyledString :: new ( ) , DiagnosticStyledString :: new ( ) ) ;
1252+ let mut values = ( DiagStyledString :: new ( ) , DiagStyledString :: new ( ) ) ;
12591253 let path1 = self . tcx . def_path_str ( did1) ;
12601254 let path2 = self . tcx . def_path_str ( did2) ;
12611255 if did1 == did2 {
@@ -1424,8 +1418,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
14241418 if split_idx >= min_len {
14251419 // paths are identical, highlight everything
14261420 (
1427- DiagnosticStyledString :: highlighted ( t1_str) ,
1428- DiagnosticStyledString :: highlighted ( t2_str) ,
1421+ DiagStyledString :: highlighted ( t1_str) ,
1422+ DiagStyledString :: highlighted ( t2_str) ,
14291423 )
14301424 } else {
14311425 let ( common, uniq1) = t1_str. split_at ( split_idx) ;
@@ -1444,29 +1438,28 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
14441438
14451439 // When finding `&T != &T`, compare the references, then recurse into pointee type
14461440 ( & ty:: Ref ( r1, ref_ty1, mutbl1) , & ty:: Ref ( r2, ref_ty2, mutbl2) ) => {
1447- let mut values = ( DiagnosticStyledString :: new ( ) , DiagnosticStyledString :: new ( ) ) ;
1441+ let mut values = ( DiagStyledString :: new ( ) , DiagStyledString :: new ( ) ) ;
14481442 cmp_ty_refs ( r1, mutbl1, r2, mutbl2, & mut values) ;
14491443 recurse ( ref_ty1, ref_ty2, & mut values) ;
14501444 values
14511445 }
14521446 // When finding T != &T, highlight the borrow
14531447 ( & ty:: Ref ( r1, ref_ty1, mutbl1) , _) => {
1454- let mut values = ( DiagnosticStyledString :: new ( ) , DiagnosticStyledString :: new ( ) ) ;
1448+ let mut values = ( DiagStyledString :: new ( ) , DiagStyledString :: new ( ) ) ;
14551449 push_ref ( r1, mutbl1, & mut values. 0 ) ;
14561450 recurse ( ref_ty1, t2, & mut values) ;
14571451 values
14581452 }
14591453 ( _, & ty:: Ref ( r2, ref_ty2, mutbl2) ) => {
1460- let mut values = ( DiagnosticStyledString :: new ( ) , DiagnosticStyledString :: new ( ) ) ;
1454+ let mut values = ( DiagStyledString :: new ( ) , DiagStyledString :: new ( ) ) ;
14611455 push_ref ( r2, mutbl2, & mut values. 1 ) ;
14621456 recurse ( t1, ref_ty2, & mut values) ;
14631457 values
14641458 }
14651459
14661460 // When encountering tuples of the same size, highlight only the differing types
14671461 ( & ty:: Tuple ( args1) , & ty:: Tuple ( args2) ) if args1. len ( ) == args2. len ( ) => {
1468- let mut values =
1469- ( DiagnosticStyledString :: normal ( "(" ) , DiagnosticStyledString :: normal ( "(" ) ) ;
1462+ let mut values = ( DiagStyledString :: normal ( "(" ) , DiagStyledString :: normal ( "(" ) ) ;
14701463 let len = args1. len ( ) ;
14711464 for ( i, ( left, right) ) in args1. iter ( ) . zip ( args2) . enumerate ( ) {
14721465 recurse ( left, right, & mut values) ;
@@ -1516,7 +1509,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
15161509 ( ty:: FnPtr ( sig1) , ty:: FnPtr ( sig2) ) => self . cmp_fn_sig ( sig1, sig2) ,
15171510
15181511 _ => {
1519- let mut strs = ( DiagnosticStyledString :: new ( ) , DiagnosticStyledString :: new ( ) ) ;
1512+ let mut strs = ( DiagStyledString :: new ( ) , DiagStyledString :: new ( ) ) ;
15201513 maybe_highlight ( t1, t2, & mut strs, self . tcx ) ;
15211514 strs
15221515 }
@@ -2215,7 +2208,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
22152208 fn values_str (
22162209 & self ,
22172210 values : ValuePairs < ' tcx > ,
2218- ) -> Option < ( DiagnosticStyledString , DiagnosticStyledString , Option < PathBuf > ) > {
2211+ ) -> Option < ( DiagStyledString , DiagStyledString , Option < PathBuf > ) > {
22192212 match values {
22202213 infer:: Regions ( exp_found) => self . expected_found_str ( exp_found) ,
22212214 infer:: Terms ( exp_found) => self . expected_found_str_term ( exp_found) ,
@@ -2248,7 +2241,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
22482241 fn expected_found_str_term (
22492242 & self ,
22502243 exp_found : ty:: error:: ExpectedFound < ty:: Term < ' tcx > > ,
2251- ) -> Option < ( DiagnosticStyledString , DiagnosticStyledString , Option < PathBuf > ) > {
2244+ ) -> Option < ( DiagStyledString , DiagStyledString , Option < PathBuf > ) > {
22522245 let exp_found = self . resolve_vars_if_possible ( exp_found) ;
22532246 if exp_found. references_error ( ) {
22542247 return None ;
@@ -2266,17 +2259,17 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
22662259 let mut path = None ;
22672260 if exp_s. len ( ) > len {
22682261 let exp_s = self . tcx . short_ty_string ( expected, & mut path) ;
2269- exp = DiagnosticStyledString :: highlighted ( exp_s) ;
2262+ exp = DiagStyledString :: highlighted ( exp_s) ;
22702263 }
22712264 if fnd_s. len ( ) > len {
22722265 let fnd_s = self . tcx . short_ty_string ( found, & mut path) ;
2273- fnd = DiagnosticStyledString :: highlighted ( fnd_s) ;
2266+ fnd = DiagStyledString :: highlighted ( fnd_s) ;
22742267 }
22752268 ( exp, fnd, path)
22762269 }
22772270 _ => (
2278- DiagnosticStyledString :: highlighted ( exp_found. expected . to_string ( ) ) ,
2279- DiagnosticStyledString :: highlighted ( exp_found. found . to_string ( ) ) ,
2271+ DiagStyledString :: highlighted ( exp_found. expected . to_string ( ) ) ,
2272+ DiagStyledString :: highlighted ( exp_found. found . to_string ( ) ) ,
22802273 None ,
22812274 ) ,
22822275 } )
@@ -2286,15 +2279,15 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
22862279 fn expected_found_str < T : fmt:: Display + TypeFoldable < TyCtxt < ' tcx > > > (
22872280 & self ,
22882281 exp_found : ty:: error:: ExpectedFound < T > ,
2289- ) -> Option < ( DiagnosticStyledString , DiagnosticStyledString , Option < PathBuf > ) > {
2282+ ) -> Option < ( DiagStyledString , DiagStyledString , Option < PathBuf > ) > {
22902283 let exp_found = self . resolve_vars_if_possible ( exp_found) ;
22912284 if exp_found. references_error ( ) {
22922285 return None ;
22932286 }
22942287
22952288 Some ( (
2296- DiagnosticStyledString :: highlighted ( exp_found. expected . to_string ( ) ) ,
2297- DiagnosticStyledString :: highlighted ( exp_found. found . to_string ( ) ) ,
2289+ DiagStyledString :: highlighted ( exp_found. expected . to_string ( ) ) ,
2290+ DiagStyledString :: highlighted ( exp_found. found . to_string ( ) ) ,
22982291 None ,
22992292 ) )
23002293 }
0 commit comments