Skip to content

Commit 38a3323

Browse files
committed
Minor fixes of short_string handling
1 parent 1f42999 commit 38a3323

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
312312
&obligation,
313313
leaf_trait_predicate,
314314
pre_message,
315+
err.long_ty_path(),
315316
);
316317

317318
self.check_for_binding_assigned_block_without_tail_expression(

compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use std::assert_matches::debug_assert_matches;
44
use std::borrow::Cow;
55
use std::iter;
6+
use std::path::PathBuf;
67

78
use itertools::{EitherOrBoth, Itertools};
89
use rustc_abi::ExternAbi;
@@ -1368,17 +1369,18 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
13681369
);
13691370
let self_ty_str =
13701371
self.tcx.short_string(old_pred.self_ty().skip_binder(), err.long_ty_path());
1372+
let trait_path = self
1373+
.tcx
1374+
.short_string(old_pred.print_modifiers_and_trait_path(), err.long_ty_path());
1375+
13711376
if has_custom_message {
13721377
err.note(msg);
13731378
} else {
13741379
err.messages = vec![(rustc_errors::DiagMessage::from(msg), Style::NoStyle)];
13751380
}
13761381
err.span_label(
13771382
span,
1378-
format!(
1379-
"the trait `{}` is not implemented for `{self_ty_str}`",
1380-
old_pred.print_modifiers_and_trait_path()
1381-
),
1383+
format!("the trait `{trait_path}` is not implemented for `{self_ty_str}`"),
13821384
);
13831385
};
13841386

@@ -5356,6 +5358,7 @@ pub(super) fn get_explanation_based_on_obligation<'tcx>(
53565358
obligation: &PredicateObligation<'tcx>,
53575359
trait_predicate: ty::PolyTraitPredicate<'tcx>,
53585360
pre_message: String,
5361+
file: &mut Option<PathBuf>,
53595362
) -> String {
53605363
if let ObligationCauseCode::MainFunctionType = obligation.cause.code() {
53615364
"consider using `()`, or a `Result`".to_owned()
@@ -5374,7 +5377,7 @@ pub(super) fn get_explanation_based_on_obligation<'tcx>(
53745377
format!(
53755378
"{pre_message}the trait `{}` is not implemented for{desc} `{}`",
53765379
trait_predicate.print_modifiers_and_trait_path(),
5377-
tcx.short_string(trait_predicate.self_ty().skip_binder(), &mut None),
5380+
tcx.short_string(trait_predicate.self_ty().skip_binder(), file),
53785381
)
53795382
} else {
53805383
// "the trait bound `T: !Send` is not satisfied" reads better than "`!Send` is

0 commit comments

Comments
 (0)