Auto merge of #90423 - Aaron1011:deduplicate-projection, r=jackh726
Deduplicate projection sub-obligations
This commit is contained in:
commit
4c9bdf4cbb
1 changed files with 6 additions and 0 deletions
|
@ -20,6 +20,7 @@ use super::{Normalized, NormalizedTy, ProjectionCacheEntry, ProjectionCacheKey};
|
||||||
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
||||||
use crate::infer::{InferCtxt, InferOk, LateBoundRegionConversionTime};
|
use crate::infer::{InferCtxt, InferOk, LateBoundRegionConversionTime};
|
||||||
use crate::traits::error_reporting::InferCtxtExt as _;
|
use crate::traits::error_reporting::InferCtxtExt as _;
|
||||||
|
use rustc_data_structures::sso::SsoHashSet;
|
||||||
use rustc_data_structures::stack::ensure_sufficient_stack;
|
use rustc_data_structures::stack::ensure_sufficient_stack;
|
||||||
use rustc_errors::ErrorReported;
|
use rustc_errors::ErrorReported;
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
|
@ -944,9 +945,14 @@ fn opt_normalize_projection_type<'a, 'b, 'tcx>(
|
||||||
Normalized { value: projected_ty, obligations: projected_obligations }
|
Normalized { value: projected_ty, obligations: projected_obligations }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let mut deduped: SsoHashSet<_> = Default::default();
|
||||||
let mut canonical =
|
let mut canonical =
|
||||||
SelectionContext::with_query_mode(selcx.infcx(), TraitQueryMode::Canonical);
|
SelectionContext::with_query_mode(selcx.infcx(), TraitQueryMode::Canonical);
|
||||||
|
|
||||||
result.obligations.drain_filter(|projected_obligation| {
|
result.obligations.drain_filter(|projected_obligation| {
|
||||||
|
if !deduped.insert(projected_obligation.clone()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
// If any global obligations always apply, considering regions, then we don't
|
// If any global obligations always apply, considering regions, then we don't
|
||||||
// need to include them. The `is_global` check rules out inference variables,
|
// need to include them. The `is_global` check rules out inference variables,
|
||||||
// so there's no need for the caller of `opt_normalize_projection_type`
|
// so there's no need for the caller of `opt_normalize_projection_type`
|
||||||
|
|
Loading…
Reference in a new issue