Skip to content

Commit e3072a2

Browse files
Avoid InferCtxt::build in report_similar_impl_candidates
1 parent 3e7e1b1 commit e3072a2

File tree

1 file changed

+6
-10
lines changed
  • compiler/rustc_trait_selection/src/traits/error_reporting

1 file changed

+6
-10
lines changed

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

+6-10
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use super::{
99
};
1010
use crate::infer::error_reporting::{TyCategory, TypeAnnotationNeeded as ErrorCode};
1111
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
12-
use crate::infer::{self, InferCtxt, TyCtxtInferExt};
12+
use crate::infer::{self, InferCtxt};
1313
use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
1414
use crate::traits::query::normalize::QueryNormalizeExt as _;
1515
use crate::traits::specialize::to_pretty_impl_header;
@@ -1930,14 +1930,6 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
19301930
return report(normalized_impl_candidates, err);
19311931
}
19321932

1933-
let normalize = |candidate| {
1934-
let infcx = self.tcx.infer_ctxt().build();
1935-
infcx
1936-
.at(&ObligationCause::dummy(), ty::ParamEnv::empty())
1937-
.query_normalize(candidate)
1938-
.map_or(candidate, |normalized| normalized.value)
1939-
};
1940-
19411933
// Sort impl candidates so that ordering is consistent for UI tests.
19421934
// because the ordering of `impl_candidates` may not be deterministic:
19431935
// https://github.com/rust-lang/rust/pull/57475#issuecomment-455519507
@@ -1947,7 +1939,11 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
19471939
let mut normalized_impl_candidates_and_similarities = impl_candidates
19481940
.into_iter()
19491941
.map(|ImplCandidate { trait_ref, similarity }| {
1950-
let normalized = normalize(trait_ref);
1942+
// FIXME(compiler-errors): This should be using `NormalizeExt::normalize`
1943+
let normalized = self
1944+
.at(&ObligationCause::dummy(), ty::ParamEnv::empty())
1945+
.query_normalize(trait_ref)
1946+
.map_or(trait_ref, |normalized| normalized.value);
19511947
(similarity, normalized)
19521948
})
19531949
.collect::<Vec<_>>();

0 commit comments

Comments
 (0)