@@ -60,8 +60,8 @@ use crate::traits::{
60
60
61
61
use rustc_data_structures:: fx:: { FxIndexMap , FxIndexSet } ;
62
62
use 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 ,
65
65
} ;
66
66
use rustc_hir as hir;
67
67
use rustc_hir:: def:: DefKind ;
@@ -945,8 +945,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
945
945
/// ```
946
946
fn highlight_outer (
947
947
& self ,
948
- value : & mut DiagnosticStyledString ,
949
- other_value : & mut DiagnosticStyledString ,
948
+ value : & mut DiagStyledString ,
949
+ other_value : & mut DiagStyledString ,
950
950
name : String ,
951
951
sub : ty:: GenericArgsRef < ' tcx > ,
952
952
pos : usize ,
@@ -1019,8 +1019,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
1019
1019
/// ```
1020
1020
fn cmp_type_arg (
1021
1021
& self ,
1022
- t1_out : & mut DiagnosticStyledString ,
1023
- t2_out : & mut DiagnosticStyledString ,
1022
+ t1_out : & mut DiagStyledString ,
1023
+ t2_out : & mut DiagStyledString ,
1024
1024
path : String ,
1025
1025
sub : & ' tcx [ ty:: GenericArg < ' tcx > ] ,
1026
1026
other_path : String ,
@@ -1048,8 +1048,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
1048
1048
/// Adds a `,` to the type representation only if it is appropriate.
1049
1049
fn push_comma (
1050
1050
& self ,
1051
- value : & mut DiagnosticStyledString ,
1052
- other_value : & mut DiagnosticStyledString ,
1051
+ value : & mut DiagStyledString ,
1052
+ other_value : & mut DiagStyledString ,
1053
1053
len : usize ,
1054
1054
pos : usize ,
1055
1055
) {
@@ -1064,7 +1064,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
1064
1064
& self ,
1065
1065
sig1 : & ty:: PolyFnSig < ' tcx > ,
1066
1066
sig2 : & ty:: PolyFnSig < ' tcx > ,
1067
- ) -> ( DiagnosticStyledString , DiagnosticStyledString ) {
1067
+ ) -> ( DiagStyledString , DiagStyledString ) {
1068
1068
let sig1 = & ( self . normalize_fn_sig ) ( * sig1) ;
1069
1069
let sig2 = & ( self . normalize_fn_sig ) ( * sig2) ;
1070
1070
@@ -1081,10 +1081,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
1081
1081
let ( lt2, sig2) = get_lifetimes ( sig2) ;
1082
1082
1083
1083
// 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 ( ) ) ) ;
1088
1086
1089
1087
// unsafe extern "C" for<'a> fn(&'a T) -> &'a T
1090
1088
// ^^^^^^
@@ -1173,15 +1171,11 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
1173
1171
1174
1172
/// Compares two given types, eliding parts that are the same between them and highlighting
1175
1173
/// 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 ) {
1181
1175
debug ! ( "cmp(t1={}, t1.kind={:?}, t2={}, t2.kind={:?})" , t1, t1. kind( ) , t2, t2. kind( ) ) ;
1182
1176
1183
1177
// helper functions
1184
- let recurse = |t1, t2, values : & mut ( DiagnosticStyledString , DiagnosticStyledString ) | {
1178
+ let recurse = |t1, t2, values : & mut ( DiagStyledString , DiagStyledString ) | {
1185
1179
let ( x1, x2) = self . cmp ( t1, t2) ;
1186
1180
( values. 0 ) . 0 . extend ( x1. 0 ) ;
1187
1181
( values. 1 ) . 0 . extend ( x2. 0 ) ;
@@ -1200,7 +1194,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
1200
1194
fn push_ref < ' tcx > (
1201
1195
region : ty:: Region < ' tcx > ,
1202
1196
mutbl : hir:: Mutability ,
1203
- s : & mut DiagnosticStyledString ,
1197
+ s : & mut DiagStyledString ,
1204
1198
) {
1205
1199
s. push_highlighted ( fmt_region ( region) ) ;
1206
1200
s. push_highlighted ( mutbl. prefix_str ( ) ) ;
@@ -1209,7 +1203,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
1209
1203
fn maybe_highlight < T : Eq + ToString > (
1210
1204
t1 : T ,
1211
1205
t2 : T ,
1212
- ( buf1, buf2) : & mut ( DiagnosticStyledString , DiagnosticStyledString ) ,
1206
+ ( buf1, buf2) : & mut ( DiagStyledString , DiagStyledString ) ,
1213
1207
tcx : TyCtxt < ' _ > ,
1214
1208
) {
1215
1209
let highlight = t1 != t2;
@@ -1228,7 +1222,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
1228
1222
mut1 : hir:: Mutability ,
1229
1223
r2 : ty:: Region < ' tcx > ,
1230
1224
mut2 : hir:: Mutability ,
1231
- ss : & mut ( DiagnosticStyledString , DiagnosticStyledString ) ,
1225
+ ss : & mut ( DiagStyledString , DiagStyledString ) ,
1232
1226
) {
1233
1227
let ( r1, r2) = ( fmt_region ( r1) , fmt_region ( r2) ) ;
1234
1228
if r1 != r2 {
@@ -1257,7 +1251,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
1257
1251
self . tcx . generics_of ( did1) . own_args_no_defaults ( self . tcx , sub1) ;
1258
1252
let sub_no_defaults_2 =
1259
1253
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 ( ) ) ;
1261
1255
let path1 = self . tcx . def_path_str ( did1) ;
1262
1256
let path2 = self . tcx . def_path_str ( did2) ;
1263
1257
if did1 == did2 {
@@ -1426,8 +1420,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
1426
1420
if split_idx >= min_len {
1427
1421
// paths are identical, highlight everything
1428
1422
(
1429
- DiagnosticStyledString :: highlighted ( t1_str) ,
1430
- DiagnosticStyledString :: highlighted ( t2_str) ,
1423
+ DiagStyledString :: highlighted ( t1_str) ,
1424
+ DiagStyledString :: highlighted ( t2_str) ,
1431
1425
)
1432
1426
} else {
1433
1427
let ( common, uniq1) = t1_str. split_at ( split_idx) ;
@@ -1446,29 +1440,28 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
1446
1440
1447
1441
// When finding `&T != &T`, compare the references, then recurse into pointee type
1448
1442
( & 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 ( ) ) ;
1450
1444
cmp_ty_refs ( r1, mutbl1, r2, mutbl2, & mut values) ;
1451
1445
recurse ( ref_ty1, ref_ty2, & mut values) ;
1452
1446
values
1453
1447
}
1454
1448
// When finding T != &T, highlight the borrow
1455
1449
( & ty:: Ref ( r1, ref_ty1, mutbl1) , _) => {
1456
- let mut values = ( DiagnosticStyledString :: new ( ) , DiagnosticStyledString :: new ( ) ) ;
1450
+ let mut values = ( DiagStyledString :: new ( ) , DiagStyledString :: new ( ) ) ;
1457
1451
push_ref ( r1, mutbl1, & mut values. 0 ) ;
1458
1452
recurse ( ref_ty1, t2, & mut values) ;
1459
1453
values
1460
1454
}
1461
1455
( _, & ty:: Ref ( r2, ref_ty2, mutbl2) ) => {
1462
- let mut values = ( DiagnosticStyledString :: new ( ) , DiagnosticStyledString :: new ( ) ) ;
1456
+ let mut values = ( DiagStyledString :: new ( ) , DiagStyledString :: new ( ) ) ;
1463
1457
push_ref ( r2, mutbl2, & mut values. 1 ) ;
1464
1458
recurse ( t1, ref_ty2, & mut values) ;
1465
1459
values
1466
1460
}
1467
1461
1468
1462
// When encountering tuples of the same size, highlight only the differing types
1469
1463
( & 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 ( "(" ) ) ;
1472
1465
let len = args1. len ( ) ;
1473
1466
for ( i, ( left, right) ) in args1. iter ( ) . zip ( args2) . enumerate ( ) {
1474
1467
recurse ( left, right, & mut values) ;
@@ -1518,7 +1511,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
1518
1511
( ty:: FnPtr ( sig1) , ty:: FnPtr ( sig2) ) => self . cmp_fn_sig ( sig1, sig2) ,
1519
1512
1520
1513
_ => {
1521
- let mut strs = ( DiagnosticStyledString :: new ( ) , DiagnosticStyledString :: new ( ) ) ;
1514
+ let mut strs = ( DiagStyledString :: new ( ) , DiagStyledString :: new ( ) ) ;
1522
1515
maybe_highlight ( t1, t2, & mut strs, self . tcx ) ;
1523
1516
strs
1524
1517
}
@@ -2217,7 +2210,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
2217
2210
fn values_str (
2218
2211
& self ,
2219
2212
values : ValuePairs < ' tcx > ,
2220
- ) -> Option < ( DiagnosticStyledString , DiagnosticStyledString , Option < PathBuf > ) > {
2213
+ ) -> Option < ( DiagStyledString , DiagStyledString , Option < PathBuf > ) > {
2221
2214
match values {
2222
2215
infer:: Regions ( exp_found) => self . expected_found_str ( exp_found) ,
2223
2216
infer:: Terms ( exp_found) => self . expected_found_str_term ( exp_found) ,
@@ -2250,7 +2243,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
2250
2243
fn expected_found_str_term (
2251
2244
& self ,
2252
2245
exp_found : ty:: error:: ExpectedFound < ty:: Term < ' tcx > > ,
2253
- ) -> Option < ( DiagnosticStyledString , DiagnosticStyledString , Option < PathBuf > ) > {
2246
+ ) -> Option < ( DiagStyledString , DiagStyledString , Option < PathBuf > ) > {
2254
2247
let exp_found = self . resolve_vars_if_possible ( exp_found) ;
2255
2248
if exp_found. references_error ( ) {
2256
2249
return None ;
@@ -2268,17 +2261,17 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
2268
2261
let mut path = None ;
2269
2262
if exp_s. len ( ) > len {
2270
2263
let exp_s = self . tcx . short_ty_string ( expected, & mut path) ;
2271
- exp = DiagnosticStyledString :: highlighted ( exp_s) ;
2264
+ exp = DiagStyledString :: highlighted ( exp_s) ;
2272
2265
}
2273
2266
if fnd_s. len ( ) > len {
2274
2267
let fnd_s = self . tcx . short_ty_string ( found, & mut path) ;
2275
- fnd = DiagnosticStyledString :: highlighted ( fnd_s) ;
2268
+ fnd = DiagStyledString :: highlighted ( fnd_s) ;
2276
2269
}
2277
2270
( exp, fnd, path)
2278
2271
}
2279
2272
_ => (
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 ( ) ) ,
2282
2275
None ,
2283
2276
) ,
2284
2277
} )
@@ -2288,15 +2281,15 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
2288
2281
fn expected_found_str < T : fmt:: Display + TypeFoldable < TyCtxt < ' tcx > > > (
2289
2282
& self ,
2290
2283
exp_found : ty:: error:: ExpectedFound < T > ,
2291
- ) -> Option < ( DiagnosticStyledString , DiagnosticStyledString , Option < PathBuf > ) > {
2284
+ ) -> Option < ( DiagStyledString , DiagStyledString , Option < PathBuf > ) > {
2292
2285
let exp_found = self . resolve_vars_if_possible ( exp_found) ;
2293
2286
if exp_found. references_error ( ) {
2294
2287
return None ;
2295
2288
}
2296
2289
2297
2290
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 ( ) ) ,
2300
2293
None ,
2301
2294
) )
2302
2295
}
0 commit comments