File tree 2 files changed +12
-11
lines changed
rustc_trait_selection/src/traits/error_reporting
2 files changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -570,15 +570,13 @@ impl<'a> Parser<'a> {
570
570
let expect = tokens_to_string ( & expected) ;
571
571
let actual = super :: token_descr ( & self . token ) ;
572
572
let ( msg_exp, ( label_sp, label_exp) ) = if expected. len ( ) > 1 {
573
+ let fmt = format ! ( "expected one of {expect}, found {actual}" ) ;
573
574
let short_expect = if expected. len ( ) > 6 {
574
575
format ! ( "{} possible tokens" , expected. len( ) )
575
576
} else {
576
- expect. clone ( )
577
+ expect
577
578
} ;
578
- (
579
- format ! ( "expected one of {expect}, found {actual}" ) ,
580
- ( self . prev_token . span . shrink_to_hi ( ) , format ! ( "expected one of {short_expect}" ) ) ,
581
- )
579
+ ( fmt, ( self . prev_token . span . shrink_to_hi ( ) , format ! ( "expected one of {short_expect}" ) ) )
582
580
} else if expected. is_empty ( ) {
583
581
(
584
582
format ! ( "unexpected token: {actual}" ) ,
Original file line number Diff line number Diff line change @@ -2944,22 +2944,25 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
2944
2944
rustc_transmute:: Answer :: No ( reason) => {
2945
2945
let dst = trait_ref. skip_binder ( ) . substs . type_at ( 0 ) ;
2946
2946
let src = trait_ref. skip_binder ( ) . substs . type_at ( 1 ) ;
2947
- let custom_err_msg = format ! ( "`{src}` cannot be safely transmuted into `{dst}` in the defining scope of `{scope}`" ) . to_string ( ) ;
2947
+ let custom_err_msg = format ! (
2948
+ "`{src}` cannot be safely transmuted into `{dst}` in the defining scope of `{scope}`"
2949
+ ) ;
2948
2950
let reason_msg = match reason {
2949
2951
rustc_transmute:: Reason :: SrcIsUnspecified => {
2950
- format ! ( "`{src}` does not have a well-specified layout" ) . to_string ( )
2952
+ format ! ( "`{src}` does not have a well-specified layout" )
2951
2953
}
2954
+
2952
2955
rustc_transmute:: Reason :: DstIsUnspecified => {
2953
- format ! ( "`{dst}` does not have a well-specified layout" ) . to_string ( )
2956
+ format ! ( "`{dst}` does not have a well-specified layout" )
2954
2957
}
2958
+
2955
2959
rustc_transmute:: Reason :: DstIsBitIncompatible => {
2956
2960
format ! ( "At least one value of `{src}` isn't a bit-valid value of `{dst}`" )
2957
- . to_string ( )
2958
2961
}
2962
+
2959
2963
rustc_transmute:: Reason :: DstIsPrivate => format ! (
2960
2964
"`{dst}` is or contains a type or field that is not visible in that scope"
2961
- )
2962
- . to_string ( ) ,
2965
+ ) ,
2963
2966
// FIXME(bryangarza): Include the number of bytes of src and dst
2964
2967
rustc_transmute:: Reason :: DstIsTooBig => {
2965
2968
format ! ( "The size of `{src}` is smaller than the size of `{dst}`" )
You can’t perform that action at this time.
0 commit comments