Skip to content

Commit 512f5eb

Browse files
committed
Unify wording on long_ty_path everywhere
1 parent 09a8017 commit 512f5eb

File tree

4 files changed

+24
-23
lines changed

4 files changed

+24
-23
lines changed

compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,7 +1928,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
19281928
&self,
19291929
trace: &TypeTrace<'tcx>,
19301930
terr: TypeError<'tcx>,
1931-
path: &mut Option<PathBuf>,
1931+
long_ty_path: &mut Option<PathBuf>,
19321932
) -> Vec<TypeErrorAdditionalDiags> {
19331933
let mut suggestions = Vec::new();
19341934
let span = trace.cause.span;
@@ -2007,7 +2007,8 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
20072007
})
20082008
| ObligationCauseCode::BlockTailExpression(.., source)) = code
20092009
&& let hir::MatchSource::TryDesugar(_) = source
2010-
&& let Some((expected_ty, found_ty)) = self.values_str(trace.values, &trace.cause, path)
2010+
&& let Some((expected_ty, found_ty)) =
2011+
self.values_str(trace.values, &trace.cause, long_ty_path)
20112012
{
20122013
suggestions.push(TypeErrorAdditionalDiags::TryCannotConvert {
20132014
found: found_ty.content(),
@@ -2137,11 +2138,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
21372138
&self,
21382139
values: ValuePairs<'tcx>,
21392140
cause: &ObligationCause<'tcx>,
2140-
file: &mut Option<PathBuf>,
2141+
long_ty_path: &mut Option<PathBuf>,
21412142
) -> Option<(DiagStyledString, DiagStyledString)> {
21422143
match values {
21432144
ValuePairs::Regions(exp_found) => self.expected_found_str(exp_found),
2144-
ValuePairs::Terms(exp_found) => self.expected_found_str_term(exp_found, file),
2145+
ValuePairs::Terms(exp_found) => self.expected_found_str_term(exp_found, long_ty_path),
21452146
ValuePairs::Aliases(exp_found) => self.expected_found_str(exp_found),
21462147
ValuePairs::ExistentialTraitRef(exp_found) => self.expected_found_str(exp_found),
21472148
ValuePairs::ExistentialProjection(exp_found) => self.expected_found_str(exp_found),
@@ -2181,7 +2182,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
21812182
fn expected_found_str_term(
21822183
&self,
21832184
exp_found: ty::error::ExpectedFound<ty::Term<'tcx>>,
2184-
path: &mut Option<PathBuf>,
2185+
long_ty_path: &mut Option<PathBuf>,
21852186
) -> Option<(DiagStyledString, DiagStyledString)> {
21862187
let exp_found = self.resolve_vars_if_possible(exp_found);
21872188
if exp_found.references_error() {
@@ -2198,11 +2199,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
21982199
let exp_s = exp.content();
21992200
let fnd_s = fnd.content();
22002201
if exp_s.len() > len {
2201-
let exp_s = self.tcx.short_string(expected, path);
2202+
let exp_s = self.tcx.short_string(expected, long_ty_path);
22022203
exp = DiagStyledString::highlighted(exp_s);
22032204
}
22042205
if fnd_s.len() > len {
2205-
let fnd_s = self.tcx.short_string(found, path);
2206+
let fnd_s = self.tcx.short_string(found, long_ty_path);
22062207
fnd = DiagStyledString::highlighted(fnd_s);
22072208
}
22082209
(exp, fnd)

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,7 +1604,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
16041604
projection_term: ty::AliasTerm<'tcx>,
16051605
normalized_ty: ty::Term<'tcx>,
16061606
expected_ty: ty::Term<'tcx>,
1607-
file: &mut Option<PathBuf>,
1607+
long_ty_path: &mut Option<PathBuf>,
16081608
) -> Option<(String, Span, Option<Span>)> {
16091609
let trait_def_id = projection_term.trait_def_id(self.tcx);
16101610
let self_ty = projection_term.self_ty();
@@ -1644,25 +1644,25 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
16441644
};
16451645
let item = match self_ty.kind() {
16461646
ty::FnDef(def, _) => self.tcx.item_name(*def).to_string(),
1647-
_ => self.tcx.short_string(self_ty, file),
1647+
_ => self.tcx.short_string(self_ty, long_ty_path),
16481648
};
1649-
let expected_ty = self.tcx.short_string(expected_ty, file);
1650-
let normalized_ty = self.tcx.short_string(normalized_ty, file);
1649+
let expected_ty = self.tcx.short_string(expected_ty, long_ty_path);
1650+
let normalized_ty = self.tcx.short_string(normalized_ty, long_ty_path);
16511651
Some((format!(
16521652
"expected `{item}` to return `{expected_ty}`, but it returns `{normalized_ty}`",
16531653
), span, closure_span))
16541654
} else if self.tcx.is_lang_item(trait_def_id, LangItem::Future) {
1655-
let self_ty = self.tcx.short_string(self_ty, file);
1656-
let expected_ty = self.tcx.short_string(expected_ty, file);
1657-
let normalized_ty = self.tcx.short_string(normalized_ty, file);
1655+
let self_ty = self.tcx.short_string(self_ty, long_ty_path);
1656+
let expected_ty = self.tcx.short_string(expected_ty, long_ty_path);
1657+
let normalized_ty = self.tcx.short_string(normalized_ty, long_ty_path);
16581658
Some((format!(
16591659
"expected `{self_ty}` to be a future that resolves to `{expected_ty}`, but it \
16601660
resolves to `{normalized_ty}`"
16611661
), span, None))
16621662
} else if Some(trait_def_id) == self.tcx.get_diagnostic_item(sym::Iterator) {
1663-
let self_ty = self.tcx.short_string(self_ty, file);
1664-
let expected_ty = self.tcx.short_string(expected_ty, file);
1665-
let normalized_ty = self.tcx.short_string(normalized_ty, file);
1663+
let self_ty = self.tcx.short_string(self_ty, long_ty_path);
1664+
let expected_ty = self.tcx.short_string(expected_ty, long_ty_path);
1665+
let normalized_ty = self.tcx.short_string(normalized_ty, long_ty_path);
16661666
Some((format!(
16671667
"expected `{self_ty}` to be an iterator that yields `{expected_ty}`, but it \
16681668
yields `{normalized_ty}`"
@@ -2514,7 +2514,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
25142514
predicate_constness: Option<ty::BoundConstness>,
25152515
append_const_msg: Option<AppendConstMessage>,
25162516
post_message: String,
2517-
long_ty_file: &mut Option<PathBuf>,
2517+
long_ty_path: &mut Option<PathBuf>,
25182518
) -> String {
25192519
message
25202520
.and_then(|cannot_do_this| {
@@ -2540,7 +2540,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
25402540
"the trait bound `{}` is not satisfied{post_message}",
25412541
self.tcx.short_string(
25422542
trait_predicate.print_with_bound_constness(predicate_constness),
2543-
long_ty_file,
2543+
long_ty_path,
25442544
),
25452545
)
25462546
})

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
9999
&self,
100100
trait_pred: ty::PolyTraitPredicate<'tcx>,
101101
obligation: &PredicateObligation<'tcx>,
102-
long_ty_file: &mut Option<PathBuf>,
102+
long_ty_path: &mut Option<PathBuf>,
103103
) -> OnUnimplementedNote {
104104
if trait_pred.polarity() != ty::PredicatePolarity::Positive {
105105
return OnUnimplementedNote::default();
@@ -281,7 +281,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
281281
GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { .. } => {
282282
if let Some(ty) = trait_pred.trait_ref.args[param.index as usize].as_type()
283283
{
284-
self.tcx.short_string(ty, long_ty_file)
284+
self.tcx.short_string(ty, long_ty_path)
285285
} else {
286286
trait_pred.trait_ref.args[param.index as usize].to_string()
287287
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5368,7 +5368,7 @@ pub(super) fn get_explanation_based_on_obligation<'tcx>(
53685368
obligation: &PredicateObligation<'tcx>,
53695369
trait_predicate: ty::PolyTraitPredicate<'tcx>,
53705370
pre_message: String,
5371-
file: &mut Option<PathBuf>,
5371+
long_ty_path: &mut Option<PathBuf>,
53725372
) -> String {
53735373
if let ObligationCauseCode::MainFunctionType = obligation.cause.code() {
53745374
"consider using `()`, or a `Result`".to_owned()
@@ -5387,7 +5387,7 @@ pub(super) fn get_explanation_based_on_obligation<'tcx>(
53875387
format!(
53885388
"{pre_message}the trait `{}` is not implemented for{desc} `{}`",
53895389
trait_predicate.print_modifiers_and_trait_path(),
5390-
tcx.short_string(trait_predicate.self_ty().skip_binder(), file),
5390+
tcx.short_string(trait_predicate.self_ty().skip_binder(), long_ty_path),
53915391
)
53925392
} else {
53935393
// "the trait bound `T: !Send` is not satisfied" reads better than "`!Send` is

0 commit comments

Comments
 (0)