Auto merge of #109202 - compiler-errors:new-solver-fast-reject-faster-2, r=lcnr

Don't pass `TreatProjections` separately to `fast_reject`

Don't pass `TreatProjections` separately to `fast_reject`, and instead use the original approach of switching on two variants of `TreatParams` (undoes this: https://github.com/rust-lang/rust/pull/108830#pullrequestreview-1330371417).

Fixes the regression introduced in https://github.com/rust-lang/rust/pull/108830#issuecomment-1468116419
This commit is contained in:
bors 2023-03-23 23:53:56 +00:00
commit cf073ec2cb
7 changed files with 53 additions and 80 deletions

View file

@ -3,7 +3,7 @@ use super::OverlapError;
use crate::traits;
use rustc_errors::ErrorGuaranteed;
use rustc_hir::def_id::DefId;
use rustc_middle::ty::fast_reject::{self, SimplifiedType, TreatParams, TreatProjections};
use rustc_middle::ty::fast_reject::{self, SimplifiedType, TreatParams};
use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt};
pub use rustc_middle::traits::specialization_graph::*;
@ -49,12 +49,9 @@ impl<'tcx> ChildrenExt<'tcx> for Children {
/// Insert an impl into this set of children without comparing to any existing impls.
fn insert_blindly(&mut self, tcx: TyCtxt<'tcx>, impl_def_id: DefId) {
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap().skip_binder();
if let Some(st) = fast_reject::simplify_type(
tcx,
trait_ref.self_ty(),
TreatParams::AsCandidateKey,
TreatProjections::AsCandidateKey,
) {
if let Some(st) =
fast_reject::simplify_type(tcx, trait_ref.self_ty(), TreatParams::AsCandidateKey)
{
debug!("insert_blindly: impl_def_id={:?} st={:?}", impl_def_id, st);
self.non_blanket_impls.entry(st).or_default().push(impl_def_id)
} else {
@ -69,12 +66,9 @@ impl<'tcx> ChildrenExt<'tcx> for Children {
fn remove_existing(&mut self, tcx: TyCtxt<'tcx>, impl_def_id: DefId) {
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap().skip_binder();
let vec: &mut Vec<DefId>;
if let Some(st) = fast_reject::simplify_type(
tcx,
trait_ref.self_ty(),
TreatParams::AsCandidateKey,
TreatProjections::AsCandidateKey,
) {
if let Some(st) =
fast_reject::simplify_type(tcx, trait_ref.self_ty(), TreatParams::AsCandidateKey)
{
debug!("remove_existing: impl_def_id={:?} st={:?}", impl_def_id, st);
vec = self.non_blanket_impls.get_mut(&st).unwrap();
} else {
@ -310,12 +304,8 @@ impl<'tcx> GraphExt<'tcx> for Graph {
let mut parent = trait_def_id;
let mut last_lint = None;
let simplified = fast_reject::simplify_type(
tcx,
trait_ref.self_ty(),
TreatParams::AsCandidateKey,
TreatProjections::AsCandidateKey,
);
let simplified =
fast_reject::simplify_type(tcx, trait_ref.self_ty(), TreatParams::AsCandidateKey);
// Descend the specialization tree, where `parent` is the current parent node.
loop {