Skip to content

Commit d357049

Browse files
committed
Minor fixes of short_string handling
1 parent 8d89ab7 commit d357049

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;
@@ -1369,17 +1370,18 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
13691370
);
13701371
let self_ty_str =
13711372
self.tcx.short_string(old_pred.self_ty().skip_binder(), err.long_ty_path());
1373+
let trait_path = self
1374+
.tcx
1375+
.short_string(old_pred.print_modifiers_and_trait_path(), err.long_ty_path());
1376+
13721377
if has_custom_message {
13731378
err.note(msg);
13741379
} else {
13751380
err.messages = vec![(rustc_errors::DiagMessage::from(msg), Style::NoStyle)];
13761381
}
13771382
err.span_label(
13781383
span,
1379-
format!(
1380-
"the trait `{}` is not implemented for `{self_ty_str}`",
1381-
old_pred.print_modifiers_and_trait_path()
1382-
),
1384+
format!("the trait `{trait_path}` is not implemented for `{self_ty_str}`"),
13831385
);
13841386
};
13851387

@@ -5366,6 +5368,7 @@ pub(super) fn get_explanation_based_on_obligation<'tcx>(
53665368
obligation: &PredicateObligation<'tcx>,
53675369
trait_predicate: ty::PolyTraitPredicate<'tcx>,
53685370
pre_message: String,
5371+
file: &mut Option<PathBuf>,
53695372
) -> String {
53705373
if let ObligationCauseCode::MainFunctionType = obligation.cause.code() {
53715374
"consider using `()`, or a `Result`".to_owned()
@@ -5384,7 +5387,7 @@ pub(super) fn get_explanation_based_on_obligation<'tcx>(
53845387
format!(
53855388
"{pre_message}the trait `{}` is not implemented for{desc} `{}`",
53865389
trait_predicate.print_modifiers_and_trait_path(),
5387-
tcx.short_string(trait_predicate.self_ty().skip_binder(), &mut None),
5390+
tcx.short_string(trait_predicate.self_ty().skip_binder(), file),
53885391
)
53895392
} else {
53905393
// "the trait bound `T: !Send` is not satisfied" reads better than "`!Send` is

0 commit comments

Comments
 (0)