Skip to content

Commit e2c7562

Browse files
Be better about bound vars
1 parent 74a1eb5 commit e2c7562

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

compiler/rustc_middle/src/ty/fast_reject.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ impl DeepRejectCtxt {
290290
// Impls cannot contain these types as these cannot be named directly.
291291
ty::FnDef(..) | ty::Closure(..) | ty::Generator(..) => false,
292292

293-
ty::Placeholder(..) => false,
293+
ty::Placeholder(..) | ty::Bound(..) => false,
294294

295295
// Depending on the value of `treat_obligation_params`, we either
296296
// treat generic parameters like placeholders or like inference variables.
@@ -310,7 +310,7 @@ impl DeepRejectCtxt {
310310

311311
ty::Error(_) => true,
312312

313-
ty::GeneratorWitness(..) | ty::GeneratorWitnessMIR(..) | ty::Bound(..) => {
313+
ty::GeneratorWitness(..) | ty::GeneratorWitnessMIR(..) => {
314314
bug!("unexpected obligation type: {:?}", obligation_ty)
315315
}
316316
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
6060
) -> Option<(DefId, SubstsRef<'tcx>)> {
6161
let tcx = self.tcx;
6262
let param_env = obligation.param_env;
63-
let trait_ref = tcx.erase_late_bound_regions(trait_ref);
63+
let trait_ref = self.instantiate_binder_with_placeholders(trait_ref);
6464
let trait_self_ty = trait_ref.self_ty();
6565

6666
let mut self_match_impls = vec![];

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
10601060
trait_pred: ty::PolyTraitPredicate<'tcx>,
10611061
) -> bool {
10621062
let self_ty = self.resolve_vars_if_possible(trait_pred.self_ty());
1063-
let ty = self.tcx.erase_late_bound_regions(self_ty);
1063+
let ty = self.instantiate_binder_with_placeholders(self_ty);
10641064
let Some(generics) = self.tcx.hir().get_generics(obligation.cause.body_id) else { return false };
10651065
let ty::Ref(_, inner_ty, hir::Mutability::Not) = ty.kind() else { return false };
10661066
let ty::Param(param) = inner_ty.kind() else { return false };

compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
396396
// still be provided by a manual implementation for
397397
// this trait and type.
398398
}
399-
ty::Param(..) | ty::Alias(ty::Projection, ..) => {
399+
ty::Param(..)
400+
| ty::Alias(ty::Projection, ..)
401+
| ty::Placeholder(..)
402+
| ty::Bound(..) => {
400403
// In these cases, we don't know what the actual
401404
// type is. Therefore, we cannot break it down
402405
// into its constituent types. So we don't
@@ -448,6 +451,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
448451
);
449452

450453
self.infcx.probe(|_snapshot| {
454+
if obligation.has_non_region_late_bound() {
455+
return;
456+
}
457+
451458
// The code below doesn't care about regions, and the
452459
// self-ty here doesn't escape this probe, so just erase
453460
// any LBR.

0 commit comments

Comments
 (0)