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