Skip to content

Commit ac19dee

Browse files
committed
Rework the predicate "trafficking" to be more targetted
Rename `predicate` to `originating_projection`. Pass in only the `ProjectionPredicate` instead of the `Predicate` to avoid needing to destructure as much.
1 parent 18af25d commit ac19dee

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

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

+9-6
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
419419
error_code: TypeAnnotationNeeded,
420420
should_label_span: bool,
421421
param_env: ty::ParamEnv<'tcx>,
422-
predicate: Option<ty::Predicate<'tcx>>,
422+
originating_projection: Option<ty::ProjectionPredicate<'tcx>>,
423423
) -> Diag<'a> {
424424
let arg = self.resolve_vars_if_possible(arg);
425425
let arg_data = self.extract_inference_diagnostics_data(arg, None);
@@ -468,7 +468,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
468468
&& let Some(ty) = typeck_results.node_type_opt(rcvr.hir_id)
469469
{
470470
paths = self.get_fully_qualified_path_suggestions_from_impls(
471-
ty, def_id, true, param_env, predicate,
471+
ty,
472+
def_id,
473+
true,
474+
param_env,
475+
originating_projection,
472476
);
473477
}
474478

@@ -601,7 +605,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
601605
def_id,
602606
false,
603607
param_env,
604-
predicate,
608+
originating_projection,
605609
);
606610
if paths.len() > 20 || paths.is_empty() {
607611
// This will show the fallback impl, so the expression will have type
@@ -680,7 +684,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
680684
def_id: DefId,
681685
target_type: bool,
682686
param_env: ty::ParamEnv<'tcx>,
683-
predicate: Option<ty::Predicate<'tcx>>,
687+
originating_projection: Option<ty::ProjectionPredicate<'tcx>>,
684688
) -> Vec<String> {
685689
let tcx = self.infcx.tcx;
686690
let mut paths = vec![];
@@ -703,8 +707,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
703707
let filter = if let Some(ty::ProjectionPredicate {
704708
projection_term: ty::AliasTerm { def_id, .. },
705709
term,
706-
}) =
707-
predicate.and_then(|p| p.as_projection_clause()).map(|p| p.skip_binder())
710+
}) = originating_projection
708711
&& let ty::TermKind::Ty(assoc_ty) = term.unpack()
709712
&& tcx.item_name(def_id) == sym::Output
710713
&& [

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
535535
TypeAnnotationNeeded::E0284,
536536
true,
537537
obligation.param_env,
538-
Some(predicate),
538+
Some(data),
539539
)
540540
.with_note(format!("cannot satisfy `{predicate}`"))
541541
} else {

0 commit comments

Comments
 (0)