Skip to content

Commit 0f425a6

Browse files
committed
remove dead code
1 parent 6b36e86 commit 0f425a6

File tree

1 file changed

+4
-67
lines changed

1 file changed

+4
-67
lines changed

compiler/rustc_hir_typeck/src/typeck_root_ctxt.rs

Lines changed: 4 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,19 @@
11
use std::cell::{Cell, RefCell};
22
use std::ops::Deref;
33

4-
use rustc_data_structures::unord::{UnordMap, UnordSet};
4+
use rustc_data_structures::unord::UnordSet;
55
use rustc_hir::def_id::LocalDefId;
6-
use rustc_hir::{self as hir, HirId, HirIdMap, LangItem};
6+
use rustc_hir::{self as hir, HirId, HirIdMap};
77
use rustc_infer::infer::{InferCtxt, InferOk, OpaqueTypeStorageEntries, TyCtxtInferExt};
88
use rustc_middle::span_bug;
99
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt, TypingMode};
1010
use rustc_span::Span;
1111
use rustc_span::def_id::LocalDefIdMap;
12-
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt;
13-
use rustc_trait_selection::traits::{
14-
self, FulfillmentError, PredicateObligation, TraitEngine, TraitEngineExt as _,
15-
};
16-
use tracing::{debug, instrument};
12+
use rustc_trait_selection::traits::{self, FulfillmentError, TraitEngine, TraitEngineExt as _};
13+
use tracing::instrument;
1714

1815
use super::callee::DeferredCallResolution;
1916

20-
#[derive(Debug, Default, Copy, Clone)]
21-
pub(crate) struct InferVarInfo {
22-
/// This is true if we identified that this Ty (`?T`) is found in a `?T: Foo`
23-
/// obligation, where:
24-
///
25-
/// * `Foo` is not `Sized`
26-
/// * `(): Foo` may be satisfied
27-
pub self_in_trait: bool,
28-
/// This is true if we identified that this Ty (`?T`) is found in a `<_ as
29-
/// _>::AssocType = ?T`
30-
pub output: bool,
31-
}
32-
3317
/// Data shared between a "typeck root" and its nested bodies,
3418
/// e.g. closures defined within the function. For example:
3519
/// ```ignore (illustrative)
@@ -83,8 +67,6 @@ pub(crate) struct TypeckRootCtxt<'tcx> {
8367
/// we record that type variable here. This is later used to inform
8468
/// fallback. See the `fallback` module for details.
8569
pub(super) diverging_type_vars: RefCell<UnordSet<Ty<'tcx>>>,
86-
87-
pub(super) infer_var_info: RefCell<UnordMap<ty::TyVid, InferVarInfo>>,
8870
}
8971

9072
impl<'tcx> Deref for TypeckRootCtxt<'tcx> {
@@ -119,7 +101,6 @@ impl<'tcx> TypeckRootCtxt<'tcx> {
119101
deferred_asm_checks: RefCell::new(Vec::new()),
120102
deferred_repeat_expr_checks: RefCell::new(Vec::new()),
121103
diverging_type_vars: RefCell::new(Default::default()),
122-
infer_var_info: RefCell::new(Default::default()),
123104
}
124105
}
125106

@@ -129,8 +110,6 @@ impl<'tcx> TypeckRootCtxt<'tcx> {
129110
span_bug!(obligation.cause.span, "escaping bound vars in predicate {:?}", obligation);
130111
}
131112

132-
self.update_infer_var_info(&obligation);
133-
134113
self.fulfillment_cx.borrow_mut().register_predicate_obligation(self, obligation);
135114
}
136115

@@ -147,46 +126,4 @@ impl<'tcx> TypeckRootCtxt<'tcx> {
147126
self.register_predicates(infer_ok.obligations);
148127
infer_ok.value
149128
}
150-
151-
fn update_infer_var_info(&self, obligation: &PredicateObligation<'tcx>) {
152-
let infer_var_info = &mut self.infer_var_info.borrow_mut();
153-
154-
// (*) binder skipped
155-
if let ty::PredicateKind::Clause(ty::ClauseKind::Trait(tpred)) =
156-
obligation.predicate.kind().skip_binder()
157-
&& let Some(ty) =
158-
self.shallow_resolve(tpred.self_ty()).ty_vid().map(|t| self.root_var(t))
159-
&& !self.tcx.is_lang_item(tpred.trait_ref.def_id, LangItem::Sized)
160-
{
161-
let new_self_ty = self.tcx.types.unit;
162-
163-
// Then construct a new obligation with Self = () added
164-
// to the ParamEnv, and see if it holds.
165-
let o = obligation.with(
166-
self.tcx,
167-
obligation.predicate.kind().rebind(
168-
// (*) binder moved here
169-
ty::PredicateKind::Clause(ty::ClauseKind::Trait(
170-
tpred.with_replaced_self_ty(self.tcx, new_self_ty),
171-
)),
172-
),
173-
);
174-
// Don't report overflow errors. Otherwise equivalent to may_hold.
175-
if let Ok(result) = self.probe(|_| self.evaluate_obligation(&o))
176-
&& result.may_apply()
177-
{
178-
infer_var_info.entry(ty).or_default().self_in_trait = true;
179-
}
180-
}
181-
182-
if let ty::PredicateKind::Clause(ty::ClauseKind::Projection(predicate)) =
183-
obligation.predicate.kind().skip_binder()
184-
// If the projection predicate (Foo::Bar == X) has X as a non-TyVid,
185-
// we need to make it into one.
186-
&& let Some(vid) = predicate.term.as_type().and_then(|ty| ty.ty_vid())
187-
{
188-
debug!("infer_var_info: {:?}.output = true", vid);
189-
infer_var_info.entry(vid).or_default().output = true;
190-
}
191-
}
192129
}

0 commit comments

Comments
 (0)