Remove unused part of return value from replace_bound_vars_with_placeholders

This commit is contained in:
Matthew Jasper 2020-06-28 20:27:59 +01:00
parent 1b07991574
commit d4d9e7f67f
5 changed files with 12 additions and 20 deletions

View file

@ -2,7 +2,7 @@
//! the end of the file for details. //! the end of the file for details.
use super::combine::CombineFields; use super::combine::CombineFields;
use super::{HigherRankedType, InferCtxt, PlaceholderMap}; use super::{HigherRankedType, InferCtxt};
use crate::infer::CombinedSnapshot; use crate::infer::CombinedSnapshot;
use rustc_middle::ty::relate::{Relate, RelateResult, TypeRelation}; use rustc_middle::ty::relate::{Relate, RelateResult, TypeRelation};
@ -33,7 +33,7 @@ impl<'a, 'tcx> CombineFields<'a, 'tcx> {
self.infcx.commit_if_ok(|_| { self.infcx.commit_if_ok(|_| {
// First, we instantiate each bound region in the supertype with a // First, we instantiate each bound region in the supertype with a
// fresh placeholder region. // fresh placeholder region.
let (b_prime, _) = self.infcx.replace_bound_vars_with_placeholders(&b); let b_prime = self.infcx.replace_bound_vars_with_placeholders(&b);
// Next, we instantiate each bound region in the subtype // Next, we instantiate each bound region in the subtype
// with a fresh region variable. These region variables -- // with a fresh region variable. These region variables --
@ -66,10 +66,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
/// the [rustc dev guide]. /// the [rustc dev guide].
/// ///
/// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/traits/hrtb.html /// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/traits/hrtb.html
pub fn replace_bound_vars_with_placeholders<T>( pub fn replace_bound_vars_with_placeholders<T>(&self, binder: &ty::Binder<T>) -> T
&self,
binder: &ty::Binder<T>,
) -> (T, PlaceholderMap<'tcx>)
where where
T: TypeFoldable<'tcx>, T: TypeFoldable<'tcx>,
{ {
@ -122,7 +119,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
next_universe, binder, result, map, next_universe, binder, result, map,
); );
(result, map) result
} }
/// See `infer::region_constraints::RegionConstraintCollector::leak_check`. /// See `infer::region_constraints::RegionConstraintCollector::leak_check`.

View file

@ -351,11 +351,6 @@ pub struct InferCtxt<'a, 'tcx> {
universe: Cell<ty::UniverseIndex>, universe: Cell<ty::UniverseIndex>,
} }
/// A map returned by `replace_bound_vars_with_placeholders()`
/// indicating the placeholder region that each late-bound region was
/// replaced with.
pub type PlaceholderMap<'tcx> = BTreeMap<ty::BoundRegion, ty::Region<'tcx>>;
/// See the `error_reporting` module for more details. /// See the `error_reporting` module for more details.
#[derive(Clone, Debug, PartialEq, Eq, TypeFoldable)] #[derive(Clone, Debug, PartialEq, Eq, TypeFoldable)]
pub enum ValuePairs<'tcx> { pub enum ValuePairs<'tcx> {
@ -992,7 +987,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
} }
Some(self.commit_if_ok(|_snapshot| { Some(self.commit_if_ok(|_snapshot| {
let (ty::SubtypePredicate { a_is_expected, a, b }, _) = let ty::SubtypePredicate { a_is_expected, a, b } =
self.replace_bound_vars_with_placeholders(&predicate); self.replace_bound_vars_with_placeholders(&predicate);
let ok = self.at(cause, param_env).sub_exp(a_is_expected, a, b)?; let ok = self.at(cause, param_env).sub_exp(a_is_expected, a, b)?;
@ -1007,7 +1002,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
predicate: ty::PolyRegionOutlivesPredicate<'tcx>, predicate: ty::PolyRegionOutlivesPredicate<'tcx>,
) -> UnitResult<'tcx> { ) -> UnitResult<'tcx> {
self.commit_if_ok(|_snapshot| { self.commit_if_ok(|_snapshot| {
let (ty::OutlivesPredicate(r_a, r_b), _) = let ty::OutlivesPredicate(r_a, r_b) =
self.replace_bound_vars_with_placeholders(&predicate); self.replace_bound_vars_with_placeholders(&predicate);
let origin = SubregionOrigin::from_obligation_cause(cause, || { let origin = SubregionOrigin::from_obligation_cause(cause, || {
RelateRegionParamBound(cause.span) RelateRegionParamBound(cause.span)

View file

@ -167,7 +167,7 @@ pub(super) fn poly_project_and_unify_type<'cx, 'tcx>(
let infcx = selcx.infcx(); let infcx = selcx.infcx();
infcx.commit_if_ok(|_snapshot| { infcx.commit_if_ok(|_snapshot| {
let (placeholder_predicate, _) = let placeholder_predicate =
infcx.replace_bound_vars_with_placeholders(&obligation.predicate); infcx.replace_bound_vars_with_placeholders(&obligation.predicate);
let placeholder_obligation = obligation.with(placeholder_predicate); let placeholder_obligation = obligation.with(placeholder_predicate);

View file

@ -253,7 +253,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let trait_obligations: Vec<PredicateObligation<'_>> = let trait_obligations: Vec<PredicateObligation<'_>> =
self.infcx.commit_unconditionally(|_| { self.infcx.commit_unconditionally(|_| {
let poly_trait_ref = obligation.predicate.to_poly_trait_ref(); let poly_trait_ref = obligation.predicate.to_poly_trait_ref();
let (trait_ref, _) = let trait_ref =
self.infcx.replace_bound_vars_with_placeholders(&poly_trait_ref); self.infcx.replace_bound_vars_with_placeholders(&poly_trait_ref);
let cause = obligation.derived_cause(ImplDerivedObligation); let cause = obligation.derived_cause(ImplDerivedObligation);
self.impl_or_trait_obligations( self.impl_or_trait_obligations(
@ -437,7 +437,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
debug!("confirm_trait_alias_candidate({:?}, {:?})", obligation, alias_def_id); debug!("confirm_trait_alias_candidate({:?}, {:?})", obligation, alias_def_id);
self.infcx.commit_unconditionally(|_| { self.infcx.commit_unconditionally(|_| {
let (predicate, _) = let predicate =
self.infcx().replace_bound_vars_with_placeholders(&obligation.predicate); self.infcx().replace_bound_vars_with_placeholders(&obligation.predicate);
let trait_ref = predicate.trait_ref; let trait_ref = predicate.trait_ref;
let trait_def_id = trait_ref.def_id; let trait_def_id = trait_ref.def_id;

View file

@ -1161,7 +1161,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
obligation: &TraitObligation<'tcx>, obligation: &TraitObligation<'tcx>,
) -> Option<ty::PolyTraitRef<'tcx>> { ) -> Option<ty::PolyTraitRef<'tcx>> {
let poly_trait_predicate = self.infcx().resolve_vars_if_possible(&obligation.predicate); let poly_trait_predicate = self.infcx().resolve_vars_if_possible(&obligation.predicate);
let (placeholder_trait_predicate, _) = let placeholder_trait_predicate =
self.infcx().replace_bound_vars_with_placeholders(&poly_trait_predicate); self.infcx().replace_bound_vars_with_placeholders(&poly_trait_predicate);
debug!( debug!(
"match_projection_obligation_against_definition_bounds: \ "match_projection_obligation_against_definition_bounds: \
@ -1640,7 +1640,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let ty: ty::Binder<Ty<'tcx>> = ty::Binder::bind(ty); // <----/ let ty: ty::Binder<Ty<'tcx>> = ty::Binder::bind(ty); // <----/
self.infcx.commit_unconditionally(|_| { self.infcx.commit_unconditionally(|_| {
let (placeholder_ty, _) = self.infcx.replace_bound_vars_with_placeholders(&ty); let placeholder_ty = self.infcx.replace_bound_vars_with_placeholders(&ty);
let Normalized { value: normalized_ty, mut obligations } = let Normalized { value: normalized_ty, mut obligations } =
ensure_sufficient_stack(|| { ensure_sufficient_stack(|| {
project::normalize_with_depth( project::normalize_with_depth(
@ -1708,7 +1708,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
return Err(()); return Err(());
} }
let (placeholder_obligation, _) = let placeholder_obligation =
self.infcx().replace_bound_vars_with_placeholders(&obligation.predicate); self.infcx().replace_bound_vars_with_placeholders(&obligation.predicate);
let placeholder_obligation_trait_ref = placeholder_obligation.trait_ref; let placeholder_obligation_trait_ref = placeholder_obligation.trait_ref;