Rename TypeckTables to TypeckResults.
This commit is contained in:
parent
8534be72fc
commit
1e6adad33f
222 changed files with 1439 additions and 1313 deletions
|
@ -80,7 +80,7 @@ where
|
|||
PpmTyped => {
|
||||
abort_on_err(tcx.analysis(LOCAL_CRATE), tcx.sess);
|
||||
|
||||
let annotation = TypedAnnotation { tcx, maybe_typeck_tables: Cell::new(None) };
|
||||
let annotation = TypedAnnotation { tcx, maybe_typeck_results: Cell::new(None) };
|
||||
tcx.dep_graph.with_ignore(|| f(&annotation, tcx.hir().krate()))
|
||||
}
|
||||
_ => panic!("Should use call_with_pp_support"),
|
||||
|
@ -305,16 +305,18 @@ impl<'a> pprust::PpAnn for HygieneAnnotation<'a> {
|
|||
|
||||
struct TypedAnnotation<'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
maybe_typeck_tables: Cell<Option<&'tcx ty::TypeckTables<'tcx>>>,
|
||||
maybe_typeck_results: Cell<Option<&'tcx ty::TypeckResults<'tcx>>>,
|
||||
}
|
||||
|
||||
impl<'tcx> TypedAnnotation<'tcx> {
|
||||
/// Gets the type-checking side-tables for the current body.
|
||||
/// Gets the type-checking results for the current body.
|
||||
/// As this will ICE if called outside bodies, only call when working with
|
||||
/// `Expr` or `Pat` nodes (they are guaranteed to be found only in bodies).
|
||||
#[track_caller]
|
||||
fn tables(&self) -> &'tcx ty::TypeckTables<'tcx> {
|
||||
self.maybe_typeck_tables.get().expect("`TypedAnnotation::tables` called outside of body")
|
||||
fn typeck_results(&self) -> &'tcx ty::TypeckResults<'tcx> {
|
||||
self.maybe_typeck_results
|
||||
.get()
|
||||
.expect("`TypedAnnotation::typeck_results` called outside of body")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -338,13 +340,13 @@ impl<'tcx> HirPrinterSupport<'tcx> for TypedAnnotation<'tcx> {
|
|||
|
||||
impl<'tcx> pprust_hir::PpAnn for TypedAnnotation<'tcx> {
|
||||
fn nested(&self, state: &mut pprust_hir::State<'_>, nested: pprust_hir::Nested) {
|
||||
let old_maybe_typeck_tables = self.maybe_typeck_tables.get();
|
||||
let old_maybe_typeck_results = self.maybe_typeck_results.get();
|
||||
if let pprust_hir::Nested::Body(id) = nested {
|
||||
self.maybe_typeck_tables.set(Some(self.tcx.body_tables(id)));
|
||||
self.maybe_typeck_results.set(Some(self.tcx.typeck_body(id)));
|
||||
}
|
||||
let pp_ann = &(&self.tcx.hir() as &dyn hir::intravisit::Map<'_>);
|
||||
pprust_hir::PpAnn::nested(pp_ann, state, nested);
|
||||
self.maybe_typeck_tables.set(old_maybe_typeck_tables);
|
||||
self.maybe_typeck_results.set(old_maybe_typeck_results);
|
||||
}
|
||||
fn pre(&self, s: &mut pprust_hir::State<'_>, node: pprust_hir::AnnNode<'_>) {
|
||||
if let pprust_hir::AnnNode::Expr(_) = node {
|
||||
|
@ -356,7 +358,7 @@ impl<'tcx> pprust_hir::PpAnn for TypedAnnotation<'tcx> {
|
|||
s.s.space();
|
||||
s.s.word("as");
|
||||
s.s.space();
|
||||
s.s.word(self.tables().expr_ty(expr).to_string());
|
||||
s.s.word(self.typeck_results().expr_ty(expr).to_string());
|
||||
s.pclose();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1571,7 +1571,7 @@ pub enum ExprKind<'hir> {
|
|||
/// To resolve the called method to a `DefId`, call [`type_dependent_def_id`] with
|
||||
/// the `hir_id` of the `MethodCall` node itself.
|
||||
///
|
||||
/// [`type_dependent_def_id`]: ../ty/struct.TypeckTables.html#method.type_dependent_def_id
|
||||
/// [`type_dependent_def_id`]: ../ty/struct.TypeckResults.html#method.type_dependent_def_id
|
||||
MethodCall(&'hir PathSegment<'hir>, Span, &'hir [Expr<'hir>], Span),
|
||||
/// A tuple (e.g., `(a, b, c, d)`).
|
||||
Tup(&'hir [Expr<'hir>]),
|
||||
|
@ -1659,7 +1659,7 @@ pub enum ExprKind<'hir> {
|
|||
///
|
||||
/// To resolve the path to a `DefId`, call [`qpath_res`].
|
||||
///
|
||||
/// [`qpath_res`]: ../rustc_middle/ty/struct.TypeckTables.html#method.qpath_res
|
||||
/// [`qpath_res`]: ../rustc_middle/ty/struct.TypeckResults.html#method.qpath_res
|
||||
#[derive(RustcEncodable, RustcDecodable, Debug, HashStable_Generic)]
|
||||
pub enum QPath<'hir> {
|
||||
/// Path to a definition, optionally "fully-qualified" with a `Self`
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
//! we will compare the fingerprint from the current and from the previous
|
||||
//! compilation session as appropriate:
|
||||
//!
|
||||
//! - `#[rustc_clean(cfg="rev2", except="typeck_tables_of")]` if we are
|
||||
//! - `#[rustc_clean(cfg="rev2", except="typeck")]` if we are
|
||||
//! in `#[cfg(rev2)]`, then the fingerprints associated with
|
||||
//! `DepNode::typeck_tables_of(X)` must be DIFFERENT (`X` is the `DefId` of the
|
||||
//! `DepNode::typeck(X)` must be DIFFERENT (`X` is the `DefId` of the
|
||||
//! current node).
|
||||
//! - `#[rustc_clean(cfg="rev2")]` same as above, except that the
|
||||
//! fingerprints must be the SAME (along with all other fingerprints).
|
||||
|
@ -48,7 +48,7 @@ const BASE_FN: &[&str] = &[
|
|||
label_strs::type_of,
|
||||
// And a big part of compilation (that we eventually want to cache) is type inference
|
||||
// information:
|
||||
label_strs::typeck_tables_of,
|
||||
label_strs::typeck,
|
||||
];
|
||||
|
||||
/// DepNodes for Hir, which is pretty much everything
|
||||
|
|
|
@ -624,8 +624,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
let scrut_expr = self.tcx.hir().expect_expr(scrut_hir_id);
|
||||
let scrut_ty = if let hir::ExprKind::Call(_, args) = &scrut_expr.kind {
|
||||
let arg_expr = args.first().expect("try desugaring call w/out arg");
|
||||
self.in_progress_tables
|
||||
.and_then(|tables| tables.borrow().expr_ty_opt(arg_expr))
|
||||
self.in_progress_typeck_results.and_then(|typeck_results| {
|
||||
typeck_results.borrow().expr_ty_opt(arg_expr)
|
||||
})
|
||||
} else {
|
||||
bug!("try desugaring w/out call expr as scrutinee");
|
||||
};
|
||||
|
@ -1683,9 +1684,11 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
let hir = &self.tcx.hir();
|
||||
// Attempt to obtain the span of the parameter so we can
|
||||
// suggest adding an explicit lifetime bound to it.
|
||||
let generics =
|
||||
self.in_progress_tables.map(|table| table.borrow().hir_owner).map(|table_owner| {
|
||||
let hir_id = hir.as_local_hir_id(table_owner);
|
||||
let generics = self
|
||||
.in_progress_typeck_results
|
||||
.map(|typeck_results| typeck_results.borrow().hir_owner)
|
||||
.map(|owner| {
|
||||
let hir_id = hir.as_local_hir_id(owner);
|
||||
let parent_id = hir.get_parent_item(hir_id);
|
||||
(
|
||||
// Parent item could be a `mod`, so we check the HIR before calling:
|
||||
|
@ -1698,7 +1701,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
} else {
|
||||
None
|
||||
},
|
||||
self.tcx.generics_of(table_owner.to_def_id()),
|
||||
self.tcx.generics_of(owner.to_def_id()),
|
||||
)
|
||||
});
|
||||
let type_param_span = match (generics, bound_kind) {
|
||||
|
|
|
@ -42,8 +42,10 @@ impl<'a, 'tcx> FindHirNodeVisitor<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn node_ty_contains_target(&mut self, hir_id: HirId) -> Option<Ty<'tcx>> {
|
||||
let ty_opt =
|
||||
self.infcx.in_progress_tables.and_then(|tables| tables.borrow().node_type_opt(hir_id));
|
||||
let ty_opt = self
|
||||
.infcx
|
||||
.in_progress_typeck_results
|
||||
.and_then(|typeck_results| typeck_results.borrow().node_type_opt(hir_id));
|
||||
match ty_opt {
|
||||
Some(ty) => {
|
||||
let ty = self.infcx.resolve_vars_if_possible(&ty);
|
||||
|
@ -123,8 +125,11 @@ impl<'a, 'tcx> Visitor<'tcx> for FindHirNodeVisitor<'a, 'tcx> {
|
|||
if let ExprKind::MethodCall(_, call_span, exprs, _) = expr.kind {
|
||||
if call_span == self.target_span
|
||||
&& Some(self.target)
|
||||
== self.infcx.in_progress_tables.and_then(|tables| {
|
||||
tables.borrow().node_type_opt(exprs.first().unwrap().hir_id).map(Into::into)
|
||||
== self.infcx.in_progress_typeck_results.and_then(|typeck_results| {
|
||||
typeck_results
|
||||
.borrow()
|
||||
.node_type_opt(exprs.first().unwrap().hir_id)
|
||||
.map(Into::into)
|
||||
})
|
||||
{
|
||||
self.found_exact_method_call = Some(&expr);
|
||||
|
@ -580,8 +585,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
e: &Expr<'_>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
) {
|
||||
if let (Some(tables), None) = (self.in_progress_tables, &segment.args) {
|
||||
let borrow = tables.borrow();
|
||||
if let (Some(typeck_results), None) = (self.in_progress_typeck_results, &segment.args) {
|
||||
let borrow = typeck_results.borrow();
|
||||
if let Some((DefKind::AssocFn, did)) = borrow.type_dependent_def(e.hir_id) {
|
||||
let generics = self.tcx.generics_of(did);
|
||||
if !generics.params.is_empty() {
|
||||
|
|
|
@ -283,11 +283,11 @@ impl<'tcx> InferCtxtInner<'tcx> {
|
|||
pub struct InferCtxt<'a, 'tcx> {
|
||||
pub tcx: TyCtxt<'tcx>,
|
||||
|
||||
/// During type-checking/inference of a body, `in_progress_tables`
|
||||
/// contains a reference to the tables being built up, which are
|
||||
/// During type-checking/inference of a body, `in_progress_typeck_results`
|
||||
/// contains a reference to the typeck results being built up, which are
|
||||
/// used for reading closure kinds/signatures as they are inferred,
|
||||
/// and for error reporting logic to read arbitrary node types.
|
||||
pub in_progress_tables: Option<&'a RefCell<ty::TypeckTables<'tcx>>>,
|
||||
pub in_progress_typeck_results: Option<&'a RefCell<ty::TypeckResults<'tcx>>>,
|
||||
|
||||
pub inner: RefCell<InferCtxtInner<'tcx>>,
|
||||
|
||||
|
@ -571,7 +571,7 @@ impl<'tcx> fmt::Display for FixupError<'tcx> {
|
|||
/// `F: for<'b, 'tcx> where 'tcx FnOnce(InferCtxt<'b, 'tcx>)`.
|
||||
pub struct InferCtxtBuilder<'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
fresh_tables: Option<RefCell<ty::TypeckTables<'tcx>>>,
|
||||
fresh_typeck_results: Option<RefCell<ty::TypeckResults<'tcx>>>,
|
||||
}
|
||||
|
||||
pub trait TyCtxtInferExt<'tcx> {
|
||||
|
@ -580,15 +580,15 @@ pub trait TyCtxtInferExt<'tcx> {
|
|||
|
||||
impl TyCtxtInferExt<'tcx> for TyCtxt<'tcx> {
|
||||
fn infer_ctxt(self) -> InferCtxtBuilder<'tcx> {
|
||||
InferCtxtBuilder { tcx: self, fresh_tables: None }
|
||||
InferCtxtBuilder { tcx: self, fresh_typeck_results: None }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> InferCtxtBuilder<'tcx> {
|
||||
/// Used only by `rustc_typeck` during body type-checking/inference,
|
||||
/// will initialize `in_progress_tables` with fresh `TypeckTables`.
|
||||
pub fn with_fresh_in_progress_tables(mut self, table_owner: LocalDefId) -> Self {
|
||||
self.fresh_tables = Some(RefCell::new(ty::TypeckTables::new(table_owner)));
|
||||
/// will initialize `in_progress_typeck_results` with fresh `TypeckResults`.
|
||||
pub fn with_fresh_in_progress_typeck_results(mut self, table_owner: LocalDefId) -> Self {
|
||||
self.fresh_typeck_results = Some(RefCell::new(ty::TypeckResults::new(table_owner)));
|
||||
self
|
||||
}
|
||||
|
||||
|
@ -616,11 +616,11 @@ impl<'tcx> InferCtxtBuilder<'tcx> {
|
|||
}
|
||||
|
||||
pub fn enter<R>(&mut self, f: impl for<'a> FnOnce(InferCtxt<'a, 'tcx>) -> R) -> R {
|
||||
let InferCtxtBuilder { tcx, ref fresh_tables } = *self;
|
||||
let in_progress_tables = fresh_tables.as_ref();
|
||||
let InferCtxtBuilder { tcx, ref fresh_typeck_results } = *self;
|
||||
let in_progress_typeck_results = fresh_typeck_results.as_ref();
|
||||
f(InferCtxt {
|
||||
tcx,
|
||||
in_progress_tables,
|
||||
in_progress_typeck_results,
|
||||
inner: RefCell::new(InferCtxtInner::new()),
|
||||
lexical_region_resolutions: RefCell::new(None),
|
||||
selection_cache: Default::default(),
|
||||
|
@ -667,7 +667,7 @@ pub struct CombinedSnapshot<'a, 'tcx> {
|
|||
region_constraints_snapshot: RegionSnapshot,
|
||||
universe: ty::UniverseIndex,
|
||||
was_in_snapshot: bool,
|
||||
_in_progress_tables: Option<Ref<'a, ty::TypeckTables<'tcx>>>,
|
||||
_in_progress_typeck_results: Option<Ref<'a, ty::TypeckResults<'tcx>>>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
|
@ -789,9 +789,11 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
region_constraints_snapshot: inner.unwrap_region_constraints().start_snapshot(),
|
||||
universe: self.universe(),
|
||||
was_in_snapshot: in_snapshot,
|
||||
// Borrow tables "in progress" (i.e., during typeck)
|
||||
// Borrow typeck results "in progress" (i.e., during typeck)
|
||||
// to ban writes from within a snapshot to them.
|
||||
_in_progress_tables: self.in_progress_tables.map(|tables| tables.borrow()),
|
||||
_in_progress_typeck_results: self
|
||||
.in_progress_typeck_results
|
||||
.map(|typeck_results| typeck_results.borrow()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -802,7 +804,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
region_constraints_snapshot,
|
||||
universe,
|
||||
was_in_snapshot,
|
||||
_in_progress_tables,
|
||||
_in_progress_typeck_results,
|
||||
} = snapshot;
|
||||
|
||||
self.in_snapshot.set(was_in_snapshot);
|
||||
|
@ -820,7 +822,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
region_constraints_snapshot: _,
|
||||
universe: _,
|
||||
was_in_snapshot,
|
||||
_in_progress_tables,
|
||||
_in_progress_typeck_results,
|
||||
} = snapshot;
|
||||
|
||||
self.in_snapshot.set(was_in_snapshot);
|
||||
|
|
|
@ -31,7 +31,7 @@ impl<'tcx> LateLintPass<'tcx> for ArrayIntoIter {
|
|||
|
||||
// Check if the method call actually calls the libcore
|
||||
// `IntoIterator::into_iter`.
|
||||
let def_id = cx.tables().type_dependent_def_id(expr.hir_id).unwrap();
|
||||
let def_id = cx.typeck_results().type_dependent_def_id(expr.hir_id).unwrap();
|
||||
match cx.tcx.trait_of_item(def_id) {
|
||||
Some(trait_id) if cx.tcx.is_diagnostic_item(sym::IntoIterator, trait_id) => {}
|
||||
_ => return,
|
||||
|
@ -45,7 +45,7 @@ impl<'tcx> LateLintPass<'tcx> for ArrayIntoIter {
|
|||
// `Box` is the only thing that values can be moved out of via
|
||||
// method call. `Box::new([1]).into_iter()` should trigger this
|
||||
// lint.
|
||||
let mut recv_ty = cx.tables().expr_ty(receiver_arg);
|
||||
let mut recv_ty = cx.typeck_results().expr_ty(receiver_arg);
|
||||
let mut num_box_derefs = 0;
|
||||
while recv_ty.is_box() {
|
||||
num_box_derefs += 1;
|
||||
|
@ -60,13 +60,13 @@ impl<'tcx> LateLintPass<'tcx> for ArrayIntoIter {
|
|||
// Make sure that there is an autoref coercion at the expected
|
||||
// position. The first `num_box_derefs` adjustments are the derefs
|
||||
// of the box.
|
||||
match cx.tables().expr_adjustments(receiver_arg).get(num_box_derefs) {
|
||||
match cx.typeck_results().expr_adjustments(receiver_arg).get(num_box_derefs) {
|
||||
Some(Adjustment { kind: Adjust::Borrow(_), .. }) => {}
|
||||
_ => return,
|
||||
}
|
||||
|
||||
// Emit lint diagnostic.
|
||||
let target = match cx.tables().expr_ty_adjusted(receiver_arg).kind {
|
||||
let target = match cx.typeck_results().expr_ty_adjusted(receiver_arg).kind {
|
||||
ty::Ref(_, ty::TyS { kind: ty::Array(..), .. }, _) => "[T; N]",
|
||||
ty::Ref(_, ty::TyS { kind: ty::Slice(..), .. }, _) => "[T]",
|
||||
|
||||
|
|
|
@ -144,7 +144,7 @@ impl<'tcx> LateLintPass<'tcx> for BoxPointers {
|
|||
}
|
||||
|
||||
fn check_expr(&mut self, cx: &LateContext<'_>, e: &hir::Expr<'_>) {
|
||||
let ty = cx.tables().node_type(e.hir_id);
|
||||
let ty = cx.typeck_results().node_type(e.hir_id);
|
||||
self.check_heap_type(cx, e.span, ty);
|
||||
}
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ impl<'tcx> LateLintPass<'tcx> for NonShorthandFieldPatterns {
|
|||
fn check_pat(&mut self, cx: &LateContext<'_>, pat: &hir::Pat<'_>) {
|
||||
if let PatKind::Struct(ref qpath, field_pats, _) = pat.kind {
|
||||
let variant = cx
|
||||
.tables()
|
||||
.typeck_results()
|
||||
.pat_ty(pat)
|
||||
.ty_adt_def()
|
||||
.expect("struct pattern type is not an ADT")
|
||||
|
@ -178,7 +178,7 @@ impl<'tcx> LateLintPass<'tcx> for NonShorthandFieldPatterns {
|
|||
}
|
||||
if let PatKind::Binding(binding_annot, _, ident, None) = fieldpat.pat.kind {
|
||||
if cx.tcx.find_field_index(ident, &variant)
|
||||
== Some(cx.tcx.field_index(fieldpat.hir_id, cx.tables()))
|
||||
== Some(cx.tcx.field_index(fieldpat.hir_id, cx.typeck_results()))
|
||||
{
|
||||
cx.struct_span_lint(NON_SHORTHAND_FIELD_PATTERNS, fieldpat.span, |lint| {
|
||||
let mut err = lint
|
||||
|
@ -909,7 +909,7 @@ impl<'tcx> LateLintPass<'tcx> for MutableTransmutes {
|
|||
if !def_id_is_transmute(cx, did) {
|
||||
return None;
|
||||
}
|
||||
let sig = cx.tables().node_type(expr.hir_id).fn_sig(cx.tcx);
|
||||
let sig = cx.typeck_results().node_type(expr.hir_id).fn_sig(cx.tcx);
|
||||
let from = sig.inputs().skip_binder()[0];
|
||||
let to = sig.output().skip_binder();
|
||||
return Some((from, to));
|
||||
|
@ -1901,7 +1901,7 @@ impl<'tcx> LateLintPass<'tcx> for InvalidValue {
|
|||
}
|
||||
} else if let hir::ExprKind::MethodCall(_, _, ref args, _) = expr.kind {
|
||||
// Find problematic calls to `MaybeUninit::assume_init`.
|
||||
let def_id = cx.tables().type_dependent_def_id(expr.hir_id)?;
|
||||
let def_id = cx.typeck_results().type_dependent_def_id(expr.hir_id)?;
|
||||
if cx.tcx.is_diagnostic_item(sym::assume_init, def_id) {
|
||||
// This is a call to *some* method named `assume_init`.
|
||||
// See if the `self` parameter is one of the dangerous constructors.
|
||||
|
@ -2020,7 +2020,7 @@ impl<'tcx> LateLintPass<'tcx> for InvalidValue {
|
|||
// This conjures an instance of a type out of nothing,
|
||||
// using zeroed or uninitialized memory.
|
||||
// We are extremely conservative with what we warn about.
|
||||
let conjured_ty = cx.tables().expr_ty(expr);
|
||||
let conjured_ty = cx.typeck_results().expr_ty(expr);
|
||||
if let Some((msg, span)) = ty_find_init_error(cx.tcx, conjured_ty, init) {
|
||||
cx.struct_span_lint(INVALID_VALUE, expr.span, |lint| {
|
||||
let mut err = lint.build(&format!(
|
||||
|
|
|
@ -431,11 +431,11 @@ pub struct LateContext<'tcx> {
|
|||
/// Current body, or `None` if outside a body.
|
||||
pub enclosing_body: Option<hir::BodyId>,
|
||||
|
||||
/// Type-checking side-tables for the current body. Access using the `tables`
|
||||
/// and `maybe_tables` methods, which handle querying the tables on demand.
|
||||
/// Type-checking results for the current body. Access using the `typeck_results`
|
||||
/// and `maybe_typeck_results` methods, which handle querying the typeck results on demand.
|
||||
// FIXME(eddyb) move all the code accessing internal fields like this,
|
||||
// to this module, to avoid exposing it to lint logic.
|
||||
pub(super) cached_typeck_tables: Cell<Option<&'tcx ty::TypeckTables<'tcx>>>,
|
||||
pub(super) cached_typeck_results: Cell<Option<&'tcx ty::TypeckResults<'tcx>>>,
|
||||
|
||||
/// Parameter environment for the item we are in.
|
||||
pub param_env: ty::ParamEnv<'tcx>,
|
||||
|
@ -677,35 +677,35 @@ impl LintContext for EarlyContext<'_> {
|
|||
}
|
||||
|
||||
impl<'tcx> LateContext<'tcx> {
|
||||
/// Gets the type-checking side-tables for the current body,
|
||||
/// Gets the type-checking results for the current body,
|
||||
/// or `None` if outside a body.
|
||||
pub fn maybe_typeck_tables(&self) -> Option<&'tcx ty::TypeckTables<'tcx>> {
|
||||
self.cached_typeck_tables.get().or_else(|| {
|
||||
pub fn maybe_typeck_results(&self) -> Option<&'tcx ty::TypeckResults<'tcx>> {
|
||||
self.cached_typeck_results.get().or_else(|| {
|
||||
self.enclosing_body.map(|body| {
|
||||
let tables = self.tcx.body_tables(body);
|
||||
self.cached_typeck_tables.set(Some(tables));
|
||||
tables
|
||||
let typeck_results = self.tcx.typeck_body(body);
|
||||
self.cached_typeck_results.set(Some(typeck_results));
|
||||
typeck_results
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/// Gets the type-checking side-tables for the current body.
|
||||
/// Gets the type-checking results for the current body.
|
||||
/// As this will ICE if called outside bodies, only call when working with
|
||||
/// `Expr` or `Pat` nodes (they are guaranteed to be found only in bodies).
|
||||
#[track_caller]
|
||||
pub fn tables(&self) -> &'tcx ty::TypeckTables<'tcx> {
|
||||
self.maybe_typeck_tables().expect("`LateContext::tables` called outside of body")
|
||||
pub fn typeck_results(&self) -> &'tcx ty::TypeckResults<'tcx> {
|
||||
self.maybe_typeck_results().expect("`LateContext::typeck_results` called outside of body")
|
||||
}
|
||||
|
||||
/// Returns the final resolution of a `QPath`, or `Res::Err` if unavailable.
|
||||
/// Unlike `.tables().qpath_res(qpath, id)`, this can be used even outside
|
||||
/// Unlike `.typeck_results().qpath_res(qpath, id)`, this can be used even outside
|
||||
/// bodies (e.g. for paths in `hir::Ty`), without any risk of ICE-ing.
|
||||
pub fn qpath_res(&self, qpath: &hir::QPath<'_>, id: hir::HirId) -> Res {
|
||||
match *qpath {
|
||||
hir::QPath::Resolved(_, ref path) => path.res,
|
||||
hir::QPath::TypeRelative(..) => self
|
||||
.maybe_typeck_tables()
|
||||
.and_then(|tables| tables.type_dependent_def(id))
|
||||
.maybe_typeck_results()
|
||||
.and_then(|typeck_results| typeck_results.type_dependent_def(id))
|
||||
.map_or(Res::Err, |(kind, def_id)| Res::Def(kind, def_id)),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,13 +105,13 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
|
|||
|
||||
fn visit_nested_body(&mut self, body_id: hir::BodyId) {
|
||||
let old_enclosing_body = self.context.enclosing_body.replace(body_id);
|
||||
let old_cached_typeck_tables = self.context.cached_typeck_tables.get();
|
||||
let old_cached_typeck_results = self.context.cached_typeck_results.get();
|
||||
|
||||
// HACK(eddyb) avoid trashing `cached_typeck_tables` when we're
|
||||
// HACK(eddyb) avoid trashing `cached_typeck_results` when we're
|
||||
// nested in `visit_fn`, which may have already resulted in them
|
||||
// being queried.
|
||||
if old_enclosing_body != Some(body_id) {
|
||||
self.context.cached_typeck_tables.set(None);
|
||||
self.context.cached_typeck_results.set(None);
|
||||
}
|
||||
|
||||
let body = self.context.tcx.hir().body(body_id);
|
||||
|
@ -120,7 +120,7 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
|
|||
|
||||
// See HACK comment above.
|
||||
if old_enclosing_body != Some(body_id) {
|
||||
self.context.cached_typeck_tables.set(old_cached_typeck_tables);
|
||||
self.context.cached_typeck_results.set(old_cached_typeck_results);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -191,16 +191,16 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
|
|||
span: Span,
|
||||
id: hir::HirId,
|
||||
) {
|
||||
// Wrap in tables here, not just in visit_nested_body,
|
||||
// Wrap in typeck results here, not just in visit_nested_body,
|
||||
// in order for `check_fn` to be able to use them.
|
||||
let old_enclosing_body = self.context.enclosing_body.replace(body_id);
|
||||
let old_cached_typeck_tables = self.context.cached_typeck_tables.take();
|
||||
let old_cached_typeck_results = self.context.cached_typeck_results.take();
|
||||
let body = self.context.tcx.hir().body(body_id);
|
||||
lint_callback!(self, check_fn, fk, decl, body, span, id);
|
||||
hir_visit::walk_fn(self, fk, decl, body_id, span, id);
|
||||
lint_callback!(self, check_fn_post, fk, decl, body, span, id);
|
||||
self.context.enclosing_body = old_enclosing_body;
|
||||
self.context.cached_typeck_tables.set(old_cached_typeck_tables);
|
||||
self.context.cached_typeck_results.set(old_cached_typeck_results);
|
||||
}
|
||||
|
||||
fn visit_variant_data(
|
||||
|
@ -375,7 +375,7 @@ fn late_lint_mod_pass<'tcx, T: LateLintPass<'tcx>>(
|
|||
let context = LateContext {
|
||||
tcx,
|
||||
enclosing_body: None,
|
||||
cached_typeck_tables: Cell::new(None),
|
||||
cached_typeck_results: Cell::new(None),
|
||||
param_env: ty::ParamEnv::empty(),
|
||||
access_levels,
|
||||
lint_store: unerased_lint_store(tcx),
|
||||
|
@ -423,7 +423,7 @@ fn late_lint_pass_crate<'tcx, T: LateLintPass<'tcx>>(tcx: TyCtxt<'tcx>, pass: T)
|
|||
let context = LateContext {
|
||||
tcx,
|
||||
enclosing_body: None,
|
||||
cached_typeck_tables: Cell::new(None),
|
||||
cached_typeck_results: Cell::new(None),
|
||||
param_env: ty::ParamEnv::empty(),
|
||||
access_levels,
|
||||
lint_store: unerased_lint_store(tcx),
|
||||
|
|
|
@ -168,7 +168,7 @@ fn report_bin_hex_error(
|
|||
repr_str, val, t, actually, t
|
||||
));
|
||||
if let Some(sugg_ty) =
|
||||
get_type_suggestion(&cx.tables().node_type(expr.hir_id), val, negative)
|
||||
get_type_suggestion(&cx.typeck_results().node_type(expr.hir_id), val, negative)
|
||||
{
|
||||
if let Some(pos) = repr_str.chars().position(|c| c == 'i' || c == 'u') {
|
||||
let (sans_suffix, _) = repr_str.split_at(pos);
|
||||
|
@ -302,7 +302,7 @@ fn lint_uint_literal<'tcx>(
|
|||
if let Node::Expr(par_e) = cx.tcx.hir().get(parent_id) {
|
||||
match par_e.kind {
|
||||
hir::ExprKind::Cast(..) => {
|
||||
if let ty::Char = cx.tables().expr_ty(par_e).kind {
|
||||
if let ty::Char = cx.typeck_results().expr_ty(par_e).kind {
|
||||
cx.struct_span_lint(OVERFLOWING_LITERALS, par_e.span, |lint| {
|
||||
lint.build("only `u8` can be cast into `char`")
|
||||
.span_suggestion(
|
||||
|
@ -353,7 +353,7 @@ fn lint_literal<'tcx>(
|
|||
e: &'tcx hir::Expr<'tcx>,
|
||||
lit: &hir::Lit,
|
||||
) {
|
||||
match cx.tables().node_type(e.hir_id).kind {
|
||||
match cx.typeck_results().node_type(e.hir_id).kind {
|
||||
ty::Int(t) => {
|
||||
match lit.node {
|
||||
ast::LitKind::Int(v, ast::LitIntType::Signed(_) | ast::LitIntType::Unsuffixed) => {
|
||||
|
@ -449,7 +449,7 @@ impl<'tcx> LateLintPass<'tcx> for TypeLimits {
|
|||
// Normalize the binop so that the literal is always on the RHS in
|
||||
// the comparison
|
||||
let norm_binop = if swap { rev_binop(binop) } else { binop };
|
||||
match cx.tables().node_type(expr.hir_id).kind {
|
||||
match cx.typeck_results().node_type(expr.hir_id).kind {
|
||||
ty::Int(int_ty) => {
|
||||
let (min, max) = int_ty_range(int_ty);
|
||||
let lit_val: i128 = match lit.kind {
|
||||
|
|
|
@ -46,7 +46,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
|
|||
return;
|
||||
}
|
||||
|
||||
let ty = cx.tables().expr_ty(&expr);
|
||||
let ty = cx.typeck_results().expr_ty(&expr);
|
||||
let type_permits_lack_of_use = check_must_use_ty(cx, ty, &expr, s.span, "", "", 1);
|
||||
|
||||
let mut fn_warned = false;
|
||||
|
@ -65,7 +65,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
|
|||
_ => None,
|
||||
}
|
||||
}
|
||||
hir::ExprKind::MethodCall(..) => cx.tables().type_dependent_def_id(expr.hir_id),
|
||||
hir::ExprKind::MethodCall(..) => cx.typeck_results().type_dependent_def_id(expr.hir_id),
|
||||
_ => None,
|
||||
};
|
||||
if let Some(def_id) = maybe_def_id {
|
||||
|
@ -950,7 +950,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedAllocation {
|
|||
_ => return,
|
||||
}
|
||||
|
||||
for adj in cx.tables().expr_adjustments(e) {
|
||||
for adj in cx.typeck_results().expr_adjustments(e) {
|
||||
if let adjustment::Adjust::Borrow(adjustment::AutoBorrow::Ref(_, m)) = adj.kind {
|
||||
cx.struct_span_lint(UNUSED_ALLOCATION, e.span, |lint| {
|
||||
let msg = match m {
|
||||
|
|
|
@ -1369,9 +1369,9 @@ impl EncodeContext<'tcx> {
|
|||
debug!("EncodeContext::encode_info_for_closure({:?})", def_id);
|
||||
|
||||
// NOTE(eddyb) `tcx.type_of(def_id)` isn't used because it's fully generic,
|
||||
// including on the signature, which is inferred in `typeck_tables_of.
|
||||
// including on the signature, which is inferred in `typeck.
|
||||
let hir_id = self.tcx.hir().as_local_hir_id(def_id);
|
||||
let ty = self.tcx.typeck_tables_of(def_id).node_type(hir_id);
|
||||
let ty = self.tcx.typeck(def_id).node_type(hir_id);
|
||||
|
||||
record!(self.tables.kind[def_id.to_def_id()] <- match ty.kind {
|
||||
ty::Generator(..) => {
|
||||
|
|
|
@ -40,7 +40,7 @@ macro_rules! arena_types {
|
|||
rustc_middle::mir::Promoted,
|
||||
rustc_middle::mir::Body<'_x>
|
||||
>;
|
||||
[decode] tables: rustc_middle::ty::TypeckTables<$tcx>, rustc_middle::ty::TypeckTables<'_x>;
|
||||
[decode] typeck_results: rustc_middle::ty::TypeckResults<$tcx>, rustc_middle::ty::TypeckResults<'_x>;
|
||||
[decode] borrowck_result:
|
||||
rustc_middle::mir::BorrowCheckResult<$tcx>,
|
||||
rustc_middle::mir::BorrowCheckResult<'_x>;
|
||||
|
|
|
@ -223,7 +223,7 @@ impl Debug for GeneratorLayout<'_> {
|
|||
#[derive(Debug, RustcEncodable, RustcDecodable, HashStable)]
|
||||
pub struct BorrowCheckResult<'tcx> {
|
||||
/// All the opaque types that are restricted to concrete types
|
||||
/// by this function. Unlike the value in `TypeckTables`, this has
|
||||
/// by this function. Unlike the value in `TypeckResults`, this has
|
||||
/// unerased regions.
|
||||
pub concrete_opaque_types: FxHashMap<DefId, ty::ResolvedOpaqueTy<'tcx>>,
|
||||
pub closure_requirements: Option<ClosureRegionRequirements<'tcx>>,
|
||||
|
|
|
@ -583,27 +583,27 @@ rustc_queries! {
|
|||
desc { "type-checking all item bodies" }
|
||||
}
|
||||
|
||||
query typeck_tables_of(key: LocalDefId) -> &'tcx ty::TypeckTables<'tcx> {
|
||||
query typeck(key: LocalDefId) -> &'tcx ty::TypeckResults<'tcx> {
|
||||
desc { |tcx| "type-checking `{}`", tcx.def_path_str(key.to_def_id()) }
|
||||
cache_on_disk_if { true }
|
||||
}
|
||||
query typeck_tables_of_const_arg(
|
||||
query typeck_const_arg(
|
||||
key: (LocalDefId, DefId)
|
||||
) -> &'tcx ty::TypeckTables<'tcx> {
|
||||
) -> &'tcx ty::TypeckResults<'tcx> {
|
||||
desc {
|
||||
|tcx| "type-checking the const argument `{}`",
|
||||
tcx.def_path_str(key.0.to_def_id()),
|
||||
}
|
||||
}
|
||||
query diagnostic_only_typeck_tables_of(key: LocalDefId) -> &'tcx ty::TypeckTables<'tcx> {
|
||||
query diagnostic_only_typeck(key: LocalDefId) -> &'tcx ty::TypeckResults<'tcx> {
|
||||
desc { |tcx| "type-checking `{}`", tcx.def_path_str(key.to_def_id()) }
|
||||
cache_on_disk_if { true }
|
||||
load_cached(tcx, id) {
|
||||
let typeck_tables: Option<ty::TypeckTables<'tcx>> = tcx
|
||||
let typeck_results: Option<ty::TypeckResults<'tcx>> = tcx
|
||||
.queries.on_disk_cache
|
||||
.try_load_query_result(tcx, id);
|
||||
|
||||
typeck_tables.map(|x| &*tcx.arena.alloc(x))
|
||||
typeck_results.map(|x| &*tcx.arena.alloc(x))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -616,7 +616,7 @@ rustc_queries! {
|
|||
}
|
||||
|
||||
TypeChecking {
|
||||
query has_typeck_tables(def_id: DefId) -> bool {
|
||||
query has_typeck_results(def_id: DefId) -> bool {
|
||||
desc { |tcx| "checking whether `{}` has a body", tcx.def_path_str(def_id) }
|
||||
}
|
||||
|
||||
|
|
|
@ -193,17 +193,17 @@ pub struct LocalTableInContext<'a, V> {
|
|||
}
|
||||
|
||||
/// Validate that the given HirId (respectively its `local_id` part) can be
|
||||
/// safely used as a key in the tables of a TypeckTable. For that to be
|
||||
/// safely used as a key in the maps of a TypeckResults. For that to be
|
||||
/// the case, the HirId must have the same `owner` as all the other IDs in
|
||||
/// this table (signified by `hir_owner`). Otherwise the HirId
|
||||
/// would be in a different frame of reference and using its `local_id`
|
||||
/// would result in lookup errors, or worse, in silently wrong data being
|
||||
/// stored/returned.
|
||||
fn validate_hir_id_for_typeck_tables(hir_owner: LocalDefId, hir_id: hir::HirId) {
|
||||
fn validate_hir_id_for_typeck_results(hir_owner: LocalDefId, hir_id: hir::HirId) {
|
||||
if hir_id.owner != hir_owner {
|
||||
ty::tls::with(|tcx| {
|
||||
bug!(
|
||||
"node {} with HirId::owner {:?} cannot be placed in TypeckTables with hir_owner {:?}",
|
||||
"node {} with HirId::owner {:?} cannot be placed in TypeckResults with hir_owner {:?}",
|
||||
tcx.hir().node_to_string(hir_id),
|
||||
hir_id.owner,
|
||||
hir_owner
|
||||
|
@ -214,12 +214,12 @@ fn validate_hir_id_for_typeck_tables(hir_owner: LocalDefId, hir_id: hir::HirId)
|
|||
|
||||
impl<'a, V> LocalTableInContext<'a, V> {
|
||||
pub fn contains_key(&self, id: hir::HirId) -> bool {
|
||||
validate_hir_id_for_typeck_tables(self.hir_owner, id);
|
||||
validate_hir_id_for_typeck_results(self.hir_owner, id);
|
||||
self.data.contains_key(&id.local_id)
|
||||
}
|
||||
|
||||
pub fn get(&self, id: hir::HirId) -> Option<&V> {
|
||||
validate_hir_id_for_typeck_tables(self.hir_owner, id);
|
||||
validate_hir_id_for_typeck_results(self.hir_owner, id);
|
||||
self.data.get(&id.local_id)
|
||||
}
|
||||
|
||||
|
@ -243,22 +243,22 @@ pub struct LocalTableInContextMut<'a, V> {
|
|||
|
||||
impl<'a, V> LocalTableInContextMut<'a, V> {
|
||||
pub fn get_mut(&mut self, id: hir::HirId) -> Option<&mut V> {
|
||||
validate_hir_id_for_typeck_tables(self.hir_owner, id);
|
||||
validate_hir_id_for_typeck_results(self.hir_owner, id);
|
||||
self.data.get_mut(&id.local_id)
|
||||
}
|
||||
|
||||
pub fn entry(&mut self, id: hir::HirId) -> Entry<'_, hir::ItemLocalId, V> {
|
||||
validate_hir_id_for_typeck_tables(self.hir_owner, id);
|
||||
validate_hir_id_for_typeck_results(self.hir_owner, id);
|
||||
self.data.entry(id.local_id)
|
||||
}
|
||||
|
||||
pub fn insert(&mut self, id: hir::HirId, val: V) -> Option<V> {
|
||||
validate_hir_id_for_typeck_tables(self.hir_owner, id);
|
||||
validate_hir_id_for_typeck_results(self.hir_owner, id);
|
||||
self.data.insert(id.local_id, val)
|
||||
}
|
||||
|
||||
pub fn remove(&mut self, id: hir::HirId) -> Option<V> {
|
||||
validate_hir_id_for_typeck_tables(self.hir_owner, id);
|
||||
validate_hir_id_for_typeck_results(self.hir_owner, id);
|
||||
self.data.remove(&id.local_id)
|
||||
}
|
||||
}
|
||||
|
@ -307,7 +307,7 @@ pub struct GeneratorInteriorTypeCause<'tcx> {
|
|||
}
|
||||
|
||||
#[derive(RustcEncodable, RustcDecodable, Debug)]
|
||||
pub struct TypeckTables<'tcx> {
|
||||
pub struct TypeckResults<'tcx> {
|
||||
/// The `HirId::owner` all `ItemLocalId`s in this table are relative to.
|
||||
pub hir_owner: LocalDefId,
|
||||
|
||||
|
@ -416,9 +416,9 @@ pub struct TypeckTables<'tcx> {
|
|||
pub generator_interior_types: Vec<GeneratorInteriorTypeCause<'tcx>>,
|
||||
}
|
||||
|
||||
impl<'tcx> TypeckTables<'tcx> {
|
||||
pub fn new(hir_owner: LocalDefId) -> TypeckTables<'tcx> {
|
||||
TypeckTables {
|
||||
impl<'tcx> TypeckResults<'tcx> {
|
||||
pub fn new(hir_owner: LocalDefId) -> TypeckResults<'tcx> {
|
||||
TypeckResults {
|
||||
hir_owner,
|
||||
type_dependent_defs: Default::default(),
|
||||
field_indices: Default::default(),
|
||||
|
@ -459,7 +459,7 @@ impl<'tcx> TypeckTables<'tcx> {
|
|||
}
|
||||
|
||||
pub fn type_dependent_def(&self, id: HirId) -> Option<(DefKind, DefId)> {
|
||||
validate_hir_id_for_typeck_tables(self.hir_owner, id);
|
||||
validate_hir_id_for_typeck_results(self.hir_owner, id);
|
||||
self.type_dependent_defs.get(&id.local_id).cloned().and_then(|r| r.ok())
|
||||
}
|
||||
|
||||
|
@ -506,7 +506,7 @@ impl<'tcx> TypeckTables<'tcx> {
|
|||
}
|
||||
|
||||
pub fn node_type_opt(&self, id: hir::HirId) -> Option<Ty<'tcx>> {
|
||||
validate_hir_id_for_typeck_tables(self.hir_owner, id);
|
||||
validate_hir_id_for_typeck_results(self.hir_owner, id);
|
||||
self.node_types.get(&id.local_id).cloned()
|
||||
}
|
||||
|
||||
|
@ -515,12 +515,12 @@ impl<'tcx> TypeckTables<'tcx> {
|
|||
}
|
||||
|
||||
pub fn node_substs(&self, id: hir::HirId) -> SubstsRef<'tcx> {
|
||||
validate_hir_id_for_typeck_tables(self.hir_owner, id);
|
||||
validate_hir_id_for_typeck_results(self.hir_owner, id);
|
||||
self.node_substs.get(&id.local_id).cloned().unwrap_or_else(|| InternalSubsts::empty())
|
||||
}
|
||||
|
||||
pub fn node_substs_opt(&self, id: hir::HirId) -> Option<SubstsRef<'tcx>> {
|
||||
validate_hir_id_for_typeck_tables(self.hir_owner, id);
|
||||
validate_hir_id_for_typeck_results(self.hir_owner, id);
|
||||
self.node_substs.get(&id.local_id).cloned()
|
||||
}
|
||||
|
||||
|
@ -563,7 +563,7 @@ impl<'tcx> TypeckTables<'tcx> {
|
|||
}
|
||||
|
||||
pub fn expr_adjustments(&self, expr: &hir::Expr<'_>) -> &[ty::adjustment::Adjustment<'tcx>] {
|
||||
validate_hir_id_for_typeck_tables(self.hir_owner, expr.hir_id);
|
||||
validate_hir_id_for_typeck_results(self.hir_owner, expr.hir_id);
|
||||
self.adjustments.get(&expr.hir_id.local_id).map_or(&[], |a| &a[..])
|
||||
}
|
||||
|
||||
|
@ -642,7 +642,7 @@ impl<'tcx> TypeckTables<'tcx> {
|
|||
}
|
||||
|
||||
pub fn is_coercion_cast(&self, hir_id: hir::HirId) -> bool {
|
||||
validate_hir_id_for_typeck_tables(self.hir_owner, hir_id);
|
||||
validate_hir_id_for_typeck_results(self.hir_owner, hir_id);
|
||||
self.coercion_casts.contains(&hir_id.local_id)
|
||||
}
|
||||
|
||||
|
@ -655,9 +655,9 @@ impl<'tcx> TypeckTables<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for TypeckTables<'tcx> {
|
||||
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for TypeckResults<'tcx> {
|
||||
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
|
||||
let ty::TypeckTables {
|
||||
let ty::TypeckResults {
|
||||
hir_owner,
|
||||
ref type_dependent_defs,
|
||||
ref field_indices,
|
||||
|
@ -980,14 +980,14 @@ pub struct GlobalCtxt<'tcx> {
|
|||
}
|
||||
|
||||
impl<'tcx> TyCtxt<'tcx> {
|
||||
pub fn typeck_tables_of_opt_const_arg(
|
||||
pub fn typeck_opt_const_arg(
|
||||
self,
|
||||
def: ty::WithOptConstParam<LocalDefId>,
|
||||
) -> &'tcx TypeckTables<'tcx> {
|
||||
) -> &'tcx TypeckResults<'tcx> {
|
||||
if let Some(param_did) = def.const_param_did {
|
||||
self.typeck_tables_of_const_arg((def.did, param_did))
|
||||
self.typeck_const_arg((def.did, param_did))
|
||||
} else {
|
||||
self.typeck_tables_of(def.did)
|
||||
self.typeck(def.did)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ pub use self::context::{
|
|||
UserType, UserTypeAnnotationIndex,
|
||||
};
|
||||
pub use self::context::{
|
||||
CtxtInterners, GeneratorInteriorTypeCause, GlobalCtxt, Lift, TypeckTables,
|
||||
CtxtInterners, GeneratorInteriorTypeCause, GlobalCtxt, Lift, TypeckResults,
|
||||
};
|
||||
|
||||
pub use self::instance::{Instance, InstanceDef};
|
||||
|
@ -1575,7 +1575,7 @@ pub type PlaceholderConst = Placeholder<BoundVar>;
|
|||
/// in case `did` is a const argument.
|
||||
///
|
||||
/// This is used to prevent cycle errors during typeck
|
||||
/// as `type_of(const_arg)` depends on `typeck_tables_of(owning_body)`
|
||||
/// as `type_of(const_arg)` depends on `typeck(owning_body)`
|
||||
/// which once again requires the type of its generic arguments.
|
||||
///
|
||||
/// Luckily we only need to deal with const arguments once we
|
||||
|
@ -2759,8 +2759,8 @@ pub enum ImplOverlapKind {
|
|||
}
|
||||
|
||||
impl<'tcx> TyCtxt<'tcx> {
|
||||
pub fn body_tables(self, body: hir::BodyId) -> &'tcx TypeckTables<'tcx> {
|
||||
self.typeck_tables_of(self.hir().body_owner_def_id(body))
|
||||
pub fn typeck_body(self, body: hir::BodyId) -> &'tcx TypeckResults<'tcx> {
|
||||
self.typeck(self.hir().body_owner_def_id(body))
|
||||
}
|
||||
|
||||
/// Returns an iterator of the `DefId`s for all body-owners in this
|
||||
|
@ -2807,8 +2807,8 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
is_associated_item.then(|| self.associated_item(def_id))
|
||||
}
|
||||
|
||||
pub fn field_index(self, hir_id: hir::HirId, tables: &TypeckTables<'_>) -> usize {
|
||||
tables.field_indices().get(hir_id).cloned().expect("no index for a field")
|
||||
pub fn field_index(self, hir_id: hir::HirId, typeck_results: &TypeckResults<'_>) -> usize {
|
||||
typeck_results.field_indices().get(hir_id).cloned().expect("no index for a field")
|
||||
}
|
||||
|
||||
pub fn find_field_index(self, ident: Ident, variant: &VariantDef) -> Option<usize> {
|
||||
|
|
|
@ -35,7 +35,7 @@ const TAG_INVALID_SPAN: u8 = 1;
|
|||
|
||||
/// Provides an interface to incremental compilation data cached from the
|
||||
/// previous compilation session. This data will eventually include the results
|
||||
/// of a few selected queries (like `typeck_tables_of` and `mir_optimized`) and
|
||||
/// of a few selected queries (like `typeck` and `mir_optimized`) and
|
||||
/// any diagnostics that have been emitted during a query.
|
||||
pub struct OnDiskCache<'sess> {
|
||||
// The complete cache data in serialized form.
|
||||
|
|
|
@ -471,8 +471,8 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
/// This is a significant `DefId` because, when we do
|
||||
/// type-checking, we type-check this fn item and all of its
|
||||
/// (transitive) closures together. Therefore, when we fetch the
|
||||
/// `typeck_tables_of` the closure, for example, we really wind up
|
||||
/// fetching the `typeck_tables_of` the enclosing fn item.
|
||||
/// `typeck` the closure, for example, we really wind up
|
||||
/// fetching the `typeck` the enclosing fn item.
|
||||
pub fn closure_base_def_id(self, def_id: DefId) -> DefId {
|
||||
let mut def_id = def_id;
|
||||
while self.is_closure(def_id) {
|
||||
|
|
|
@ -262,7 +262,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||
.ty;
|
||||
let needs_note = match ty.kind {
|
||||
ty::Closure(id, _) => {
|
||||
let tables = self.infcx.tcx.typeck_tables_of(id.expect_local());
|
||||
let tables = self.infcx.tcx.typeck(id.expect_local());
|
||||
let hir_id = self.infcx.tcx.hir().as_local_hir_id(id.expect_local());
|
||||
|
||||
tables.closure_kind_origins().get(hir_id).is_none()
|
||||
|
@ -966,12 +966,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||
.opt_name(fn_hir_id)
|
||||
.map(|name| format!("function `{}`", name))
|
||||
.unwrap_or_else(|| {
|
||||
match &self
|
||||
.infcx
|
||||
.tcx
|
||||
.typeck_tables_of(self.mir_def_id)
|
||||
.node_type(fn_hir_id)
|
||||
.kind
|
||||
match &self.infcx.tcx.typeck(self.mir_def_id).node_type(fn_hir_id).kind
|
||||
{
|
||||
ty::Closure(..) => "enclosing closure",
|
||||
ty::Generator(..) => "enclosing generator",
|
||||
|
|
|
@ -107,7 +107,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||
let hir_id = self.infcx.tcx.hir().as_local_hir_id(did);
|
||||
|
||||
if let Some((span, name)) =
|
||||
self.infcx.tcx.typeck_tables_of(did).closure_kind_origins().get(hir_id)
|
||||
self.infcx.tcx.typeck(did).closure_kind_origins().get(hir_id)
|
||||
{
|
||||
diag.span_note(
|
||||
*span,
|
||||
|
@ -130,7 +130,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||
let hir_id = self.infcx.tcx.hir().as_local_hir_id(did);
|
||||
|
||||
if let Some((span, name)) =
|
||||
self.infcx.tcx.typeck_tables_of(did).closure_kind_origins().get(hir_id)
|
||||
self.infcx.tcx.typeck(did).closure_kind_origins().get(hir_id)
|
||||
{
|
||||
diag.span_note(
|
||||
*span,
|
||||
|
|
|
@ -507,7 +507,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
.map(|(pos, _)| pos)
|
||||
.next();
|
||||
let def_id = hir.local_def_id(item_id);
|
||||
let tables = self.infcx.tcx.typeck_tables_of(def_id);
|
||||
let tables = self.infcx.tcx.typeck(def_id);
|
||||
if let Some(ty::FnDef(def_id, _)) =
|
||||
tables.node_type_opt(func.hir_id).as_ref().map(|ty| &ty.kind)
|
||||
{
|
||||
|
|
|
@ -150,7 +150,7 @@ fn do_mir_borrowck<'a, 'tcx>(
|
|||
}
|
||||
|
||||
// Gather the upvars of a closure, if any.
|
||||
let tables = tcx.typeck_tables_of_opt_const_arg(def);
|
||||
let tables = tcx.typeck_opt_const_arg(def);
|
||||
if let Some(ErrorReported) = tables.tainted_by_errors {
|
||||
infcx.set_tainted_by_errors();
|
||||
}
|
||||
|
|
|
@ -36,9 +36,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||
if !self.tcx().is_closure(self.mir_def_id.to_def_id()) {
|
||||
user_provided_sig = None;
|
||||
} else {
|
||||
let typeck_tables = self.tcx().typeck_tables_of(self.mir_def_id);
|
||||
let typeck_results = self.tcx().typeck(self.mir_def_id);
|
||||
user_provided_sig =
|
||||
match typeck_tables.user_provided_sigs.get(&self.mir_def_id.to_def_id()) {
|
||||
match typeck_results.user_provided_sigs.get(&self.mir_def_id.to_def_id()) {
|
||||
None => None,
|
||||
Some(user_provided_poly_sig) => {
|
||||
// Instantiate the canonicalized variables from
|
||||
|
|
|
@ -1239,7 +1239,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||
let tcx = infcx.tcx;
|
||||
let param_env = self.param_env;
|
||||
let body = self.body;
|
||||
let concrete_opaque_types = &tcx.typeck_tables_of(anon_owner_def_id).concrete_opaque_types;
|
||||
let concrete_opaque_types = &tcx.typeck(anon_owner_def_id).concrete_opaque_types;
|
||||
let mut opaque_type_values = Vec::new();
|
||||
|
||||
debug!("eq_opaque_type_and_type: mir_def_id={:?}", self.mir_def_id);
|
||||
|
|
|
@ -515,7 +515,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
|
|||
let defining_ty = if self.mir_def.did.to_def_id() == closure_base_def_id {
|
||||
tcx.type_of(closure_base_def_id)
|
||||
} else {
|
||||
let tables = tcx.typeck_tables_of(self.mir_def.did);
|
||||
let tables = tcx.typeck(self.mir_def.did);
|
||||
tables.node_type(self.mir_hir_id)
|
||||
};
|
||||
|
||||
|
|
|
@ -291,9 +291,8 @@ pub fn const_eval_raw_provider<'tcx>(
|
|||
let def = cid.instance.def.with_opt_param();
|
||||
|
||||
if let Some(def) = def.as_local() {
|
||||
if tcx.has_typeck_tables(def.did) {
|
||||
if let Some(error_reported) = tcx.typeck_tables_of_opt_const_arg(def).tainted_by_errors
|
||||
{
|
||||
if tcx.has_typeck_results(def.did) {
|
||||
if let Some(error_reported) = tcx.typeck_opt_const_arg(def).tainted_by_errors {
|
||||
return Err(ErrorHandled::Reported(error_reported));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -396,10 +396,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
// do not continue if typeck errors occurred (can only occur in local crate)
|
||||
let def = instance.with_opt_param();
|
||||
if let Some(def) = def.as_local() {
|
||||
if self.tcx.has_typeck_tables(def.did) {
|
||||
if let Some(error_reported) =
|
||||
self.tcx.typeck_tables_of_opt_const_arg(def).tainted_by_errors
|
||||
{
|
||||
if self.tcx.has_typeck_results(def.did) {
|
||||
if let Some(error_reported) = self.tcx.typeck_opt_const_arg(def).tainted_by_errors {
|
||||
throw_inval!(TypeckError(error_reported))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -922,7 +922,7 @@ where
|
|||
// FIXME: This should be an assert instead of an error, but if we transmute within an
|
||||
// array length computation, `typeck` may not have yet been run and errored out. In fact
|
||||
// most likey we *are* running `typeck` right now. Investigate whether we can bail out
|
||||
// on `typeck_tables().has_errors` at all const eval entry points.
|
||||
// on `typeck_results().has_errors` at all const eval entry points.
|
||||
debug!("Size mismatch when transmuting!\nsrc: {:#?}\ndest: {:#?}", src, dest);
|
||||
self.tcx.sess.delay_span_bug(
|
||||
self.cur_span(),
|
||||
|
|
|
@ -226,7 +226,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
|
|||
ty::Closure(def_id, _) | ty::Generator(def_id, _, _) => {
|
||||
let mut name = None;
|
||||
if let Some(def_id) = def_id.as_local() {
|
||||
let tables = self.ecx.tcx.typeck_tables_of(def_id);
|
||||
let tables = self.ecx.tcx.typeck(def_id);
|
||||
if let Some(upvars) = tables.closure_captures.get(&def_id.to_def_id()) {
|
||||
// Sometimes the index is beyond the number of upvars (seen
|
||||
// for a generator).
|
||||
|
|
|
@ -21,7 +21,10 @@ use rustc_target::spec::PanicStrategy;
|
|||
|
||||
use super::lints;
|
||||
|
||||
crate fn mir_built<'tcx>(tcx: TyCtxt<'tcx>, def: ty::WithOptConstParam<LocalDefId>) -> &'tcx ty::steal::Steal<Body<'tcx>> {
|
||||
crate fn mir_built<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
def: ty::WithOptConstParam<LocalDefId>,
|
||||
) -> &'tcx ty::steal::Steal<Body<'tcx>> {
|
||||
if def.const_param_did.is_none() {
|
||||
if let const_param_did @ Some(_) = tcx.opt_const_param_of(def.did) {
|
||||
return tcx.mir_built(ty::WithOptConstParam { const_param_did, ..def });
|
||||
|
@ -68,12 +71,12 @@ fn mir_build(tcx: TyCtxt<'_>, def: ty::WithOptConstParam<LocalDefId>) -> Body<'_
|
|||
|
||||
tcx.infer_ctxt().enter(|infcx| {
|
||||
let cx = Cx::new(&infcx, def, id);
|
||||
let body = if let Some(ErrorReported) = cx.tables().tainted_by_errors {
|
||||
let body = if let Some(ErrorReported) = cx.typeck_results().tainted_by_errors {
|
||||
build::construct_error(cx, body_id)
|
||||
} else if cx.body_owner_kind.is_fn_or_closure() {
|
||||
// fetch the fully liberated fn signature (that is, all bound
|
||||
// types/lifetimes replaced)
|
||||
let fn_sig = cx.tables().liberated_fn_sigs()[id];
|
||||
let fn_sig = cx.typeck_results().liberated_fn_sigs()[id];
|
||||
let fn_def_id = tcx.hir().local_def_id(id);
|
||||
|
||||
let safety = match fn_sig.unsafety {
|
||||
|
@ -92,7 +95,7 @@ fn mir_build(tcx: TyCtxt<'_>, def: ty::WithOptConstParam<LocalDefId>) -> Body<'_
|
|||
vec![ArgInfo(liberated_closure_env_ty(tcx, id, body_id), None, None, None)]
|
||||
}
|
||||
ty::Generator(..) => {
|
||||
let gen_ty = tcx.body_tables(body_id).node_type(id);
|
||||
let gen_ty = tcx.typeck_body(body_id).node_type(id);
|
||||
|
||||
// The resume argument may be missing, in that case we need to provide it here.
|
||||
// It will always be `()` in this case.
|
||||
|
@ -147,7 +150,7 @@ fn mir_build(tcx: TyCtxt<'_>, def: ty::WithOptConstParam<LocalDefId>) -> Body<'_
|
|||
let arguments = implicit_argument.into_iter().chain(explicit_arguments);
|
||||
|
||||
let (yield_ty, return_ty) = if body.generator_kind.is_some() {
|
||||
let gen_ty = tcx.body_tables(body_id).node_type(id);
|
||||
let gen_ty = tcx.typeck_body(body_id).node_type(id);
|
||||
let gen_sig = match gen_ty.kind {
|
||||
ty::Generator(_, gen_substs, ..) => gen_substs.as_generator().sig(),
|
||||
_ => span_bug!(tcx.hir().span(id), "generator w/o generator type: {:?}", ty),
|
||||
|
@ -182,7 +185,7 @@ fn mir_build(tcx: TyCtxt<'_>, def: ty::WithOptConstParam<LocalDefId>) -> Body<'_
|
|||
// place to be the type of the constant because NLL typeck will
|
||||
// equate them.
|
||||
|
||||
let return_ty = cx.tables().node_type(id);
|
||||
let return_ty = cx.typeck_results().node_type(id);
|
||||
|
||||
build::construct_const(cx, body_id, return_ty, return_ty_span)
|
||||
};
|
||||
|
@ -214,7 +217,7 @@ fn liberated_closure_env_ty(
|
|||
closure_expr_id: hir::HirId,
|
||||
body_id: hir::BodyId,
|
||||
) -> Ty<'_> {
|
||||
let closure_ty = tcx.body_tables(body_id).node_type(closure_expr_id);
|
||||
let closure_ty = tcx.typeck_body(body_id).node_type(closure_expr_id);
|
||||
|
||||
let (closure_def_id, closure_substs) = match closure_ty.kind {
|
||||
ty::Closure(closure_def_id, closure_substs) => (closure_def_id, closure_substs),
|
||||
|
@ -816,14 +819,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
|
||||
let tcx = self.hir.tcx();
|
||||
let tcx_hir = tcx.hir();
|
||||
let hir_tables = self.hir.tables();
|
||||
let hir_typeck_results = self.hir.typeck_results();
|
||||
|
||||
// In analyze_closure() in upvar.rs we gathered a list of upvars used by a
|
||||
// indexed closure and we stored in a map called closure_captures in TypeckTables
|
||||
// indexed closure and we stored in a map called closure_captures in TypeckResults
|
||||
// with the closure's DefId. Here, we run through that vec of UpvarIds for
|
||||
// the given closure and use the necessary information to create upvar
|
||||
// debuginfo and to fill `self.upvar_mutbls`.
|
||||
if let Some(upvars) = hir_tables.closure_captures.get(&fn_def_id) {
|
||||
if let Some(upvars) = hir_typeck_results.closure_captures.get(&fn_def_id) {
|
||||
let closure_env_arg = Local::new(1);
|
||||
let mut closure_env_projs = vec![];
|
||||
let mut closure_ty = self.local_decls[closure_env_arg].ty;
|
||||
|
@ -841,14 +844,16 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
self.upvar_mutbls = upvars_with_tys
|
||||
.enumerate()
|
||||
.map(|(i, ((&var_id, &upvar_id), ty))| {
|
||||
let capture = hir_tables.upvar_capture(upvar_id);
|
||||
let capture = hir_typeck_results.upvar_capture(upvar_id);
|
||||
|
||||
let mut mutability = Mutability::Not;
|
||||
let mut name = kw::Invalid;
|
||||
if let Some(Node::Binding(pat)) = tcx_hir.find(var_id) {
|
||||
if let hir::PatKind::Binding(_, _, ident, _) = pat.kind {
|
||||
name = ident.name;
|
||||
match hir_tables.extract_binding_mode(tcx.sess, pat.hir_id, pat.span) {
|
||||
match hir_typeck_results
|
||||
.extract_binding_mode(tcx.sess, pat.hir_id, pat.span)
|
||||
{
|
||||
Some(ty::BindByValue(hir::Mutability::Mut)) => {
|
||||
mutability = Mutability::Mut;
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ fn mirror_stmts<'a, 'tcx>(
|
|||
let mut pattern = cx.pattern_from_hir(&local.pat);
|
||||
|
||||
if let Some(ty) = &local.ty {
|
||||
if let Some(&user_ty) = cx.tables.user_provided_types().get(ty.hir_id) {
|
||||
if let Some(&user_ty) = cx.typeck_results.user_provided_types().get(ty.hir_id) {
|
||||
debug!("mirror_stmts: user_ty={:?}", user_ty);
|
||||
pattern = Pat {
|
||||
ty: pattern.ty,
|
||||
|
@ -105,7 +105,7 @@ crate fn to_expr_ref<'a, 'tcx>(
|
|||
cx: &mut Cx<'a, 'tcx>,
|
||||
block: &'tcx hir::Block<'tcx>,
|
||||
) -> ExprRef<'tcx> {
|
||||
let block_ty = cx.tables().node_type(block.hir_id);
|
||||
let block_ty = cx.typeck_results().node_type(block.hir_id);
|
||||
let temp_lifetime = cx.region_scope_tree.temporary_scope(block.hir_id.local_id);
|
||||
let expr = Expr {
|
||||
ty: block_ty,
|
||||
|
|
|
@ -27,7 +27,7 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr<'tcx> {
|
|||
let mut expr = make_mirror_unadjusted(cx, self);
|
||||
|
||||
// Now apply adjustments, if any.
|
||||
for adjustment in cx.tables().expr_adjustments(self) {
|
||||
for adjustment in cx.typeck_results().expr_adjustments(self) {
|
||||
debug!("make_mirror: expr={:?} applying adjustment={:?}", expr, adjustment);
|
||||
expr = apply_adjustment(cx, self, expr, adjustment);
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ fn make_mirror_unadjusted<'a, 'tcx>(
|
|||
cx: &mut Cx<'a, 'tcx>,
|
||||
expr: &'tcx hir::Expr<'tcx>,
|
||||
) -> Expr<'tcx> {
|
||||
let expr_ty = cx.tables().expr_ty(expr);
|
||||
let expr_ty = cx.typeck_results().expr_ty(expr);
|
||||
let temp_lifetime = cx.region_scope_tree.temporary_scope(expr.hir_id.local_id);
|
||||
|
||||
let kind = match expr.kind {
|
||||
|
@ -147,7 +147,7 @@ fn make_mirror_unadjusted<'a, 'tcx>(
|
|||
}
|
||||
|
||||
hir::ExprKind::Call(ref fun, ref args) => {
|
||||
if cx.tables().is_method_call(expr) {
|
||||
if cx.typeck_results().is_method_call(expr) {
|
||||
// The callee is something implementing Fn, FnMut, or FnOnce.
|
||||
// Find the actual method implementation being called and
|
||||
// build the appropriate UFCS call expression with the
|
||||
|
@ -157,7 +157,7 @@ fn make_mirror_unadjusted<'a, 'tcx>(
|
|||
|
||||
let method = method_callee(cx, expr, fun.span, None);
|
||||
|
||||
let arg_tys = args.iter().map(|e| cx.tables().expr_ty_adjusted(e));
|
||||
let arg_tys = args.iter().map(|e| cx.typeck_results().expr_ty_adjusted(e));
|
||||
let tupled_args = Expr {
|
||||
ty: cx.tcx.mk_tup(arg_tys),
|
||||
temp_lifetime,
|
||||
|
@ -187,8 +187,8 @@ fn make_mirror_unadjusted<'a, 'tcx>(
|
|||
None
|
||||
};
|
||||
if let Some((adt_def, index)) = adt_data {
|
||||
let substs = cx.tables().node_substs(fun.hir_id);
|
||||
let user_provided_types = cx.tables().user_provided_types();
|
||||
let substs = cx.typeck_results().node_substs(fun.hir_id);
|
||||
let user_provided_types = cx.typeck_results().user_provided_types();
|
||||
let user_ty = user_provided_types.get(fun.hir_id).copied().map(|mut u_ty| {
|
||||
if let UserType::TypeOf(ref mut did, _) = &mut u_ty.value {
|
||||
*did = adt_def.did;
|
||||
|
@ -212,7 +212,7 @@ fn make_mirror_unadjusted<'a, 'tcx>(
|
|||
}
|
||||
} else {
|
||||
ExprKind::Call {
|
||||
ty: cx.tables().node_type(fun.hir_id),
|
||||
ty: cx.typeck_results().node_type(fun.hir_id),
|
||||
fun: fun.to_ref(),
|
||||
args: args.to_ref(),
|
||||
from_hir_call: true,
|
||||
|
@ -237,7 +237,7 @@ fn make_mirror_unadjusted<'a, 'tcx>(
|
|||
}
|
||||
|
||||
hir::ExprKind::AssignOp(op, ref lhs, ref rhs) => {
|
||||
if cx.tables().is_method_call(expr) {
|
||||
if cx.typeck_results().is_method_call(expr) {
|
||||
overloaded_operator(cx, expr, vec![lhs.to_ref(), rhs.to_ref()])
|
||||
} else {
|
||||
ExprKind::AssignOp { op: bin_op(op.node), lhs: lhs.to_ref(), rhs: rhs.to_ref() }
|
||||
|
@ -250,7 +250,7 @@ fn make_mirror_unadjusted<'a, 'tcx>(
|
|||
},
|
||||
|
||||
hir::ExprKind::Binary(op, ref lhs, ref rhs) => {
|
||||
if cx.tables().is_method_call(expr) {
|
||||
if cx.typeck_results().is_method_call(expr) {
|
||||
overloaded_operator(cx, expr, vec![lhs.to_ref(), rhs.to_ref()])
|
||||
} else {
|
||||
// FIXME overflow
|
||||
|
@ -275,7 +275,7 @@ fn make_mirror_unadjusted<'a, 'tcx>(
|
|||
}
|
||||
|
||||
hir::ExprKind::Index(ref lhs, ref index) => {
|
||||
if cx.tables().is_method_call(expr) {
|
||||
if cx.typeck_results().is_method_call(expr) {
|
||||
overloaded_place(cx, expr, expr_ty, None, vec![lhs.to_ref(), index.to_ref()])
|
||||
} else {
|
||||
ExprKind::Index { lhs: lhs.to_ref(), index: index.to_ref() }
|
||||
|
@ -283,7 +283,7 @@ fn make_mirror_unadjusted<'a, 'tcx>(
|
|||
}
|
||||
|
||||
hir::ExprKind::Unary(hir::UnOp::UnDeref, ref arg) => {
|
||||
if cx.tables().is_method_call(expr) {
|
||||
if cx.typeck_results().is_method_call(expr) {
|
||||
overloaded_place(cx, expr, expr_ty, None, vec![arg.to_ref()])
|
||||
} else {
|
||||
ExprKind::Deref { arg: arg.to_ref() }
|
||||
|
@ -291,7 +291,7 @@ fn make_mirror_unadjusted<'a, 'tcx>(
|
|||
}
|
||||
|
||||
hir::ExprKind::Unary(hir::UnOp::UnNot, ref arg) => {
|
||||
if cx.tables().is_method_call(expr) {
|
||||
if cx.typeck_results().is_method_call(expr) {
|
||||
overloaded_operator(cx, expr, vec![arg.to_ref()])
|
||||
} else {
|
||||
ExprKind::Unary { op: UnOp::Not, arg: arg.to_ref() }
|
||||
|
@ -299,7 +299,7 @@ fn make_mirror_unadjusted<'a, 'tcx>(
|
|||
}
|
||||
|
||||
hir::ExprKind::Unary(hir::UnOp::UnNeg, ref arg) => {
|
||||
if cx.tables().is_method_call(expr) {
|
||||
if cx.typeck_results().is_method_call(expr) {
|
||||
overloaded_operator(cx, expr, vec![arg.to_ref()])
|
||||
} else {
|
||||
if let hir::ExprKind::Lit(ref lit) = arg.kind {
|
||||
|
@ -316,7 +316,7 @@ fn make_mirror_unadjusted<'a, 'tcx>(
|
|||
hir::ExprKind::Struct(ref qpath, ref fields, ref base) => match expr_ty.kind {
|
||||
ty::Adt(adt, substs) => match adt.adt_kind() {
|
||||
AdtKind::Struct | AdtKind::Union => {
|
||||
let user_provided_types = cx.tables().user_provided_types();
|
||||
let user_provided_types = cx.typeck_results().user_provided_types();
|
||||
let user_ty = user_provided_types.get(expr.hir_id).copied();
|
||||
debug!("make_mirror_unadjusted: (struct/union) user_ty={:?}", user_ty);
|
||||
ExprKind::Adt {
|
||||
|
@ -327,18 +327,18 @@ fn make_mirror_unadjusted<'a, 'tcx>(
|
|||
fields: field_refs(cx, fields),
|
||||
base: base.as_ref().map(|base| FruInfo {
|
||||
base: base.to_ref(),
|
||||
field_types: cx.tables().fru_field_types()[expr.hir_id].clone(),
|
||||
field_types: cx.typeck_results().fru_field_types()[expr.hir_id].clone(),
|
||||
}),
|
||||
}
|
||||
}
|
||||
AdtKind::Enum => {
|
||||
let res = cx.tables().qpath_res(qpath, expr.hir_id);
|
||||
let res = cx.typeck_results().qpath_res(qpath, expr.hir_id);
|
||||
match res {
|
||||
Res::Def(DefKind::Variant, variant_id) => {
|
||||
assert!(base.is_none());
|
||||
|
||||
let index = adt.variant_index_with_id(variant_id);
|
||||
let user_provided_types = cx.tables().user_provided_types();
|
||||
let user_provided_types = cx.typeck_results().user_provided_types();
|
||||
let user_ty = user_provided_types.get(expr.hir_id).copied();
|
||||
debug!("make_mirror_unadjusted: (variant) user_ty={:?}", user_ty);
|
||||
ExprKind::Adt {
|
||||
|
@ -362,7 +362,7 @@ fn make_mirror_unadjusted<'a, 'tcx>(
|
|||
},
|
||||
|
||||
hir::ExprKind::Closure(..) => {
|
||||
let closure_ty = cx.tables().expr_ty(expr);
|
||||
let closure_ty = cx.typeck_results().expr_ty(expr);
|
||||
let (def_id, substs, movability) = match closure_ty.kind {
|
||||
ty::Closure(def_id, substs) => (def_id, UpvarSubsts::Closure(substs), None),
|
||||
ty::Generator(def_id, substs, movability) => {
|
||||
|
@ -384,7 +384,7 @@ fn make_mirror_unadjusted<'a, 'tcx>(
|
|||
}
|
||||
|
||||
hir::ExprKind::Path(ref qpath) => {
|
||||
let res = cx.tables().qpath_res(qpath, expr.hir_id);
|
||||
let res = cx.typeck_results().qpath_res(qpath, expr.hir_id);
|
||||
convert_path_expr(cx, expr, res)
|
||||
}
|
||||
|
||||
|
@ -433,11 +433,11 @@ fn make_mirror_unadjusted<'a, 'tcx>(
|
|||
};
|
||||
let temp_lifetime =
|
||||
cx.region_scope_tree.temporary_scope(expr.hir_id.local_id);
|
||||
let res = cx.tables().qpath_res(qpath, expr.hir_id);
|
||||
let res = cx.typeck_results().qpath_res(qpath, expr.hir_id);
|
||||
let ty;
|
||||
match res {
|
||||
Res::Def(DefKind::Fn, _) | Res::Def(DefKind::AssocFn, _) => {
|
||||
ty = cx.tables().node_type(expr.hir_id);
|
||||
ty = cx.typeck_results().node_type(expr.hir_id);
|
||||
let user_ty = user_substs_applied_to_res(cx, expr.hir_id, res);
|
||||
InlineAsmOperand::SymFn {
|
||||
expr: Expr {
|
||||
|
@ -523,11 +523,11 @@ fn make_mirror_unadjusted<'a, 'tcx>(
|
|||
}
|
||||
hir::ExprKind::Field(ref source, ..) => ExprKind::Field {
|
||||
lhs: source.to_ref(),
|
||||
name: Field::new(cx.tcx.field_index(expr.hir_id, cx.tables)),
|
||||
name: Field::new(cx.tcx.field_index(expr.hir_id, cx.typeck_results)),
|
||||
},
|
||||
hir::ExprKind::Cast(ref source, ref cast_ty) => {
|
||||
// Check for a user-given type annotation on this `cast`
|
||||
let user_provided_types = cx.tables.user_provided_types();
|
||||
let user_provided_types = cx.typeck_results.user_provided_types();
|
||||
let user_ty = user_provided_types.get(cast_ty.hir_id);
|
||||
|
||||
debug!(
|
||||
|
@ -537,10 +537,10 @@ fn make_mirror_unadjusted<'a, 'tcx>(
|
|||
|
||||
// Check to see if this cast is a "coercion cast", where the cast is actually done
|
||||
// using a coercion (or is a no-op).
|
||||
let cast = if cx.tables().is_coercion_cast(source.hir_id) {
|
||||
let cast = if cx.typeck_results().is_coercion_cast(source.hir_id) {
|
||||
// Convert the lexpr to a vexpr.
|
||||
ExprKind::Use { source: source.to_ref() }
|
||||
} else if cx.tables().expr_ty(source).is_region_ptr() {
|
||||
} else if cx.typeck_results().expr_ty(source).is_region_ptr() {
|
||||
// Special cased so that we can type check that the element
|
||||
// type of the source matches the pointed to type of the
|
||||
// destination.
|
||||
|
@ -558,9 +558,9 @@ fn make_mirror_unadjusted<'a, 'tcx>(
|
|||
// The correct solution would be to add symbolic computations to miri,
|
||||
// so we wouldn't have to compute and store the actual value
|
||||
let var = if let hir::ExprKind::Path(ref qpath) = source.kind {
|
||||
let res = cx.tables().qpath_res(qpath, source.hir_id);
|
||||
cx.tables().node_type(source.hir_id).ty_adt_def().and_then(
|
||||
|adt_def| match res {
|
||||
let res = cx.typeck_results().qpath_res(qpath, source.hir_id);
|
||||
cx.typeck_results().node_type(source.hir_id).ty_adt_def().and_then(|adt_def| {
|
||||
match res {
|
||||
Res::Def(
|
||||
DefKind::Ctor(CtorOf::Variant, CtorKind::Const),
|
||||
variant_ctor_id,
|
||||
|
@ -573,8 +573,8 @@ fn make_mirror_unadjusted<'a, 'tcx>(
|
|||
Some((d, o, ty))
|
||||
}
|
||||
_ => None,
|
||||
},
|
||||
)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
@ -634,7 +634,7 @@ fn make_mirror_unadjusted<'a, 'tcx>(
|
|||
}
|
||||
}
|
||||
hir::ExprKind::Type(ref source, ref ty) => {
|
||||
let user_provided_types = cx.tables.user_provided_types();
|
||||
let user_provided_types = cx.typeck_results.user_provided_types();
|
||||
let user_ty = user_provided_types.get(ty.hir_id).copied();
|
||||
debug!("make_mirror_unadjusted: (type) user_ty={:?}", user_ty);
|
||||
if source.is_syntactic_place_expr() {
|
||||
|
@ -670,7 +670,7 @@ fn user_substs_applied_to_res<'tcx>(
|
|||
| Res::Def(DefKind::Ctor(_, CtorKind::Fn), _)
|
||||
| Res::Def(DefKind::Const, _)
|
||||
| Res::Def(DefKind::AssocConst, _) => {
|
||||
cx.tables().user_provided_types().get(hir_id).copied()
|
||||
cx.typeck_results().user_provided_types().get(hir_id).copied()
|
||||
}
|
||||
|
||||
// A unit struct/variant which is used as a value (e.g.,
|
||||
|
@ -701,12 +701,12 @@ fn method_callee<'a, 'tcx>(
|
|||
Some((def_id, substs)) => (def_id, substs, None),
|
||||
None => {
|
||||
let (kind, def_id) = cx
|
||||
.tables()
|
||||
.typeck_results()
|
||||
.type_dependent_def(expr.hir_id)
|
||||
.unwrap_or_else(|| span_bug!(expr.span, "no type-dependent def for method callee"));
|
||||
let user_ty = user_substs_applied_to_res(cx, expr.hir_id, Res::Def(kind, def_id));
|
||||
debug!("method_callee: user_ty={:?}", user_ty);
|
||||
(def_id, cx.tables().node_substs(expr.hir_id), user_ty)
|
||||
(def_id, cx.typeck_results().node_substs(expr.hir_id), user_ty)
|
||||
}
|
||||
};
|
||||
let ty = cx.tcx().mk_fn_def(def_id, substs);
|
||||
|
@ -765,7 +765,7 @@ fn convert_path_expr<'a, 'tcx>(
|
|||
expr: &'tcx hir::Expr<'tcx>,
|
||||
res: Res,
|
||||
) -> ExprKind<'tcx> {
|
||||
let substs = cx.tables().node_substs(expr.hir_id);
|
||||
let substs = cx.typeck_results().node_substs(expr.hir_id);
|
||||
match res {
|
||||
// A regular function, constructor function or a constant.
|
||||
Res::Def(DefKind::Fn, _)
|
||||
|
@ -775,7 +775,7 @@ fn convert_path_expr<'a, 'tcx>(
|
|||
let user_ty = user_substs_applied_to_res(cx, expr.hir_id, res);
|
||||
debug!("convert_path_expr: user_ty={:?}", user_ty);
|
||||
ExprKind::Literal {
|
||||
literal: ty::Const::zero_sized(cx.tcx, cx.tables().node_type(expr.hir_id)),
|
||||
literal: ty::Const::zero_sized(cx.tcx, cx.typeck_results().node_type(expr.hir_id)),
|
||||
user_ty,
|
||||
}
|
||||
}
|
||||
|
@ -790,7 +790,9 @@ fn convert_path_expr<'a, 'tcx>(
|
|||
let name = cx.tcx.hir().name(hir_id);
|
||||
let val = ty::ConstKind::Param(ty::ParamConst::new(index, name));
|
||||
ExprKind::Literal {
|
||||
literal: cx.tcx.mk_const(ty::Const { val, ty: cx.tables().node_type(expr.hir_id) }),
|
||||
literal: cx
|
||||
.tcx
|
||||
.mk_const(ty::Const { val, ty: cx.typeck_results().node_type(expr.hir_id) }),
|
||||
user_ty: None,
|
||||
}
|
||||
}
|
||||
|
@ -805,17 +807,17 @@ fn convert_path_expr<'a, 'tcx>(
|
|||
substs,
|
||||
None,
|
||||
),
|
||||
ty: cx.tables().node_type(expr.hir_id),
|
||||
ty: cx.typeck_results().node_type(expr.hir_id),
|
||||
}),
|
||||
user_ty,
|
||||
}
|
||||
}
|
||||
|
||||
Res::Def(DefKind::Ctor(_, CtorKind::Const), def_id) => {
|
||||
let user_provided_types = cx.tables.user_provided_types();
|
||||
let user_provided_types = cx.typeck_results.user_provided_types();
|
||||
let user_provided_type = user_provided_types.get(expr.hir_id).copied();
|
||||
debug!("convert_path_expr: user_provided_type={:?}", user_provided_type);
|
||||
let ty = cx.tables().node_type(expr.hir_id);
|
||||
let ty = cx.typeck_results().node_type(expr.hir_id);
|
||||
match ty.kind {
|
||||
// A unit struct/variant which is used as a value.
|
||||
// We return a completely different ExprKind here to account for this special case.
|
||||
|
@ -860,7 +862,7 @@ fn convert_var<'tcx>(
|
|||
var_hir_id: hir::HirId,
|
||||
) -> ExprKind<'tcx> {
|
||||
let upvar_index = cx
|
||||
.tables()
|
||||
.typeck_results()
|
||||
.closure_captures
|
||||
.get(&cx.body_owner)
|
||||
.and_then(|upvars| upvars.get_full(&var_hir_id).map(|(i, _, _)| i));
|
||||
|
@ -881,11 +883,11 @@ fn convert_var<'tcx>(
|
|||
var_path: ty::UpvarPath { hir_id: var_hir_id },
|
||||
closure_expr_id: closure_def_id.expect_local(),
|
||||
};
|
||||
let var_ty = cx.tables().node_type(var_hir_id);
|
||||
let var_ty = cx.typeck_results().node_type(var_hir_id);
|
||||
|
||||
// FIXME free regions in closures are not right
|
||||
let closure_ty = cx
|
||||
.tables()
|
||||
.typeck_results()
|
||||
.node_type(cx.tcx.hir().local_def_id_to_hir_id(upvar_id.closure_expr_id));
|
||||
|
||||
// FIXME we're just hard-coding the idea that the
|
||||
|
@ -956,7 +958,7 @@ fn convert_var<'tcx>(
|
|||
|
||||
// ...but the upvar might be an `&T` or `&mut T` capture, at which
|
||||
// point we need an implicit deref
|
||||
match cx.tables().upvar_capture(upvar_id) {
|
||||
match cx.typeck_results().upvar_capture(upvar_id) {
|
||||
ty::UpvarCapture::ByValue => field_kind,
|
||||
ty::UpvarCapture::ByRef(borrow) => ExprKind::Deref {
|
||||
arg: Expr {
|
||||
|
@ -1018,7 +1020,7 @@ fn overloaded_place<'a, 'tcx>(
|
|||
// line up (this is because `*x` and `x[y]` represent places):
|
||||
|
||||
let recv_ty = match args[0] {
|
||||
ExprRef::Hair(e) => cx.tables().expr_ty_adjusted(e),
|
||||
ExprRef::Hair(e) => cx.typeck_results().expr_ty_adjusted(e),
|
||||
ExprRef::Mirror(ref e) => e.ty,
|
||||
};
|
||||
|
||||
|
@ -1062,9 +1064,9 @@ fn capture_upvar<'tcx>(
|
|||
var_path: ty::UpvarPath { hir_id: var_hir_id },
|
||||
closure_expr_id: cx.tcx.hir().local_def_id(closure_expr.hir_id),
|
||||
};
|
||||
let upvar_capture = cx.tables().upvar_capture(upvar_id);
|
||||
let upvar_capture = cx.typeck_results().upvar_capture(upvar_id);
|
||||
let temp_lifetime = cx.region_scope_tree.temporary_scope(closure_expr.hir_id.local_id);
|
||||
let var_ty = cx.tables().node_type(var_hir_id);
|
||||
let var_ty = cx.typeck_results().node_type(var_hir_id);
|
||||
let captured_var = Expr {
|
||||
temp_lifetime,
|
||||
ty: var_ty,
|
||||
|
@ -1098,7 +1100,7 @@ fn field_refs<'a, 'tcx>(
|
|||
fields
|
||||
.iter()
|
||||
.map(|field| FieldExprRef {
|
||||
name: Field::new(cx.tcx.field_index(field.hir_id, cx.tables)),
|
||||
name: Field::new(cx.tcx.field_index(field.hir_id, cx.typeck_results)),
|
||||
expr: field.expr.to_ref(),
|
||||
})
|
||||
.collect()
|
||||
|
|
|
@ -33,7 +33,7 @@ crate struct Cx<'a, 'tcx> {
|
|||
crate identity_substs: &'tcx InternalSubsts<'tcx>,
|
||||
|
||||
crate region_scope_tree: &'tcx region::ScopeTree,
|
||||
crate tables: &'a ty::TypeckTables<'tcx>,
|
||||
crate typeck_results: &'a ty::TypeckResults<'tcx>,
|
||||
|
||||
/// This is `Constness::Const` if we are compiling a `static`,
|
||||
/// `const`, or the body of a `const fn`.
|
||||
|
@ -56,7 +56,7 @@ impl<'a, 'tcx> Cx<'a, 'tcx> {
|
|||
src_id: hir::HirId,
|
||||
) -> Cx<'a, 'tcx> {
|
||||
let tcx = infcx.tcx;
|
||||
let tables = tcx.typeck_tables_of_opt_const_arg(def);
|
||||
let typeck_results = tcx.typeck_opt_const_arg(def);
|
||||
let body_owner_kind = tcx.hir().body_owner_kind(src_id);
|
||||
|
||||
let constness = match body_owner_kind {
|
||||
|
@ -84,7 +84,7 @@ impl<'a, 'tcx> Cx<'a, 'tcx> {
|
|||
param_env: tcx.param_env(def.did),
|
||||
identity_substs: InternalSubsts::identity_for_item(tcx, def.did.to_def_id()),
|
||||
region_scope_tree: tcx.region_scope_tree(def.did),
|
||||
tables,
|
||||
typeck_results,
|
||||
constness,
|
||||
body_owner: def.did.to_def_id(),
|
||||
body_owner_kind,
|
||||
|
@ -153,7 +153,7 @@ impl<'a, 'tcx> Cx<'a, 'tcx> {
|
|||
Node::Pat(p) | Node::Binding(p) => p,
|
||||
node => bug!("pattern became {:?}", node),
|
||||
};
|
||||
Pat::from_hir(self.tcx, self.param_env, self.tables(), p)
|
||||
Pat::from_hir(self.tcx, self.param_env, self.typeck_results(), p)
|
||||
}
|
||||
|
||||
crate fn trait_method(
|
||||
|
@ -191,8 +191,8 @@ impl<'a, 'tcx> Cx<'a, 'tcx> {
|
|||
self.tcx
|
||||
}
|
||||
|
||||
crate fn tables(&self) -> &'a ty::TypeckTables<'tcx> {
|
||||
self.tables
|
||||
crate fn typeck_results(&self) -> &'a ty::TypeckResults<'tcx> {
|
||||
self.typeck_results
|
||||
}
|
||||
|
||||
crate fn check_overflow(&self) -> bool {
|
||||
|
@ -209,8 +209,8 @@ impl<'tcx> UserAnnotatedTyHelpers<'tcx> for Cx<'_, 'tcx> {
|
|||
self.tcx()
|
||||
}
|
||||
|
||||
fn tables(&self) -> &ty::TypeckTables<'tcx> {
|
||||
self.tables()
|
||||
fn typeck_results(&self) -> &ty::TypeckResults<'tcx> {
|
||||
self.typeck_results()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ crate fn check_match(tcx: TyCtxt<'_>, def_id: DefId) {
|
|||
|
||||
let mut visitor = MatchVisitor {
|
||||
tcx,
|
||||
tables: tcx.body_tables(body_id),
|
||||
typeck_results: tcx.typeck_body(body_id),
|
||||
param_env: tcx.param_env(def_id),
|
||||
pattern_arena: TypedArena::default(),
|
||||
};
|
||||
|
@ -41,7 +41,7 @@ fn create_e0004(sess: &Session, sp: Span, error_message: String) -> DiagnosticBu
|
|||
|
||||
struct MatchVisitor<'a, 'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
tables: &'a ty::TypeckTables<'tcx>,
|
||||
typeck_results: &'a ty::TypeckResults<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
pattern_arena: TypedArena<super::Pat<'tcx>>,
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ impl<'tcx> MatchVisitor<'_, 'tcx> {
|
|||
pat: &'tcx hir::Pat<'tcx>,
|
||||
have_errors: &mut bool,
|
||||
) -> (&'p super::Pat<'tcx>, Ty<'tcx>) {
|
||||
let mut patcx = PatCtxt::new(self.tcx, self.param_env, self.tables);
|
||||
let mut patcx = PatCtxt::new(self.tcx, self.param_env, self.typeck_results);
|
||||
patcx.include_lint_checks();
|
||||
let pattern = patcx.lower_pattern(pat);
|
||||
let pattern_ty = pattern.ty;
|
||||
|
@ -190,7 +190,7 @@ impl<'tcx> MatchVisitor<'_, 'tcx> {
|
|||
// Fifth, check if the match is exhaustive.
|
||||
// Note: An empty match isn't the same as an empty matrix for diagnostics purposes,
|
||||
// since an empty matrix can occur when there are arms, if those arms all have guards.
|
||||
let scrut_ty = self.tables.expr_ty_adjusted(scrut);
|
||||
let scrut_ty = self.typeck_results.expr_ty_adjusted(scrut);
|
||||
let is_empty_match = inlined_arms.is_empty();
|
||||
check_exhaustive(&mut cx, scrut_ty, scrut.span, &matrix, scrut.hir_id, is_empty_match);
|
||||
}
|
||||
|
@ -286,9 +286,9 @@ fn check_for_bindings_named_same_as_variants(cx: &MatchVisitor<'_, '_>, pat: &Pa
|
|||
pat.walk_always(|p| {
|
||||
if let hir::PatKind::Binding(_, _, ident, None) = p.kind {
|
||||
if let Some(ty::BindByValue(hir::Mutability::Not)) =
|
||||
cx.tables.extract_binding_mode(cx.tcx.sess, p.hir_id, p.span)
|
||||
cx.typeck_results.extract_binding_mode(cx.tcx.sess, p.hir_id, p.span)
|
||||
{
|
||||
let pat_ty = cx.tables.pat_ty(p).peel_refs();
|
||||
let pat_ty = cx.typeck_results.pat_ty(p).peel_refs();
|
||||
if let ty::Adt(edef, _) = pat_ty.kind {
|
||||
if edef.is_enum()
|
||||
&& edef.variants.iter().any(|variant| {
|
||||
|
@ -598,18 +598,20 @@ fn maybe_point_at_variant(ty: Ty<'_>, patterns: &[super::Pat<'_>]) -> Vec<Span>
|
|||
|
||||
/// Check if a by-value binding is by-value. That is, check if the binding's type is not `Copy`.
|
||||
fn is_binding_by_move(cx: &MatchVisitor<'_, '_>, hir_id: HirId, span: Span) -> bool {
|
||||
!cx.tables.node_type(hir_id).is_copy_modulo_regions(cx.tcx.at(span), cx.param_env)
|
||||
!cx.typeck_results.node_type(hir_id).is_copy_modulo_regions(cx.tcx.at(span), cx.param_env)
|
||||
}
|
||||
|
||||
/// Check the legality of legality of by-move bindings.
|
||||
fn check_legality_of_move_bindings(cx: &mut MatchVisitor<'_, '_>, has_guard: bool, pat: &Pat<'_>) {
|
||||
let sess = cx.tcx.sess;
|
||||
let tables = cx.tables;
|
||||
let typeck_results = cx.typeck_results;
|
||||
|
||||
// Find all by-ref spans.
|
||||
let mut by_ref_spans = Vec::new();
|
||||
pat.each_binding(|_, hir_id, span, _| {
|
||||
if let Some(ty::BindByReference(_)) = tables.extract_binding_mode(sess, hir_id, span) {
|
||||
if let Some(ty::BindByReference(_)) =
|
||||
typeck_results.extract_binding_mode(sess, hir_id, span)
|
||||
{
|
||||
by_ref_spans.push(span);
|
||||
}
|
||||
});
|
||||
|
@ -630,7 +632,9 @@ fn check_legality_of_move_bindings(cx: &mut MatchVisitor<'_, '_>, has_guard: boo
|
|||
};
|
||||
pat.walk_always(|p| {
|
||||
if let hir::PatKind::Binding(.., sub) = &p.kind {
|
||||
if let Some(ty::BindByValue(_)) = tables.extract_binding_mode(sess, p.hir_id, p.span) {
|
||||
if let Some(ty::BindByValue(_)) =
|
||||
typeck_results.extract_binding_mode(sess, p.hir_id, p.span)
|
||||
{
|
||||
if is_binding_by_move(cx, p.hir_id, p.span) {
|
||||
check_move(p, sub.as_deref());
|
||||
}
|
||||
|
@ -674,16 +678,16 @@ fn check_borrow_conflicts_in_at_patterns(cx: &MatchVisitor<'_, '_>, pat: &Pat<'_
|
|||
};
|
||||
let binding_span = pat.span.with_hi(name.span.hi());
|
||||
|
||||
let tables = cx.tables;
|
||||
let typeck_results = cx.typeck_results;
|
||||
let sess = cx.tcx.sess;
|
||||
|
||||
// Get the binding move, extract the mutability if by-ref.
|
||||
let mut_outer = match tables.extract_binding_mode(sess, pat.hir_id, pat.span) {
|
||||
let mut_outer = match typeck_results.extract_binding_mode(sess, pat.hir_id, pat.span) {
|
||||
Some(ty::BindByValue(_)) if is_binding_by_move(cx, pat.hir_id, pat.span) => {
|
||||
// We have `x @ pat` where `x` is by-move. Reject all borrows in `pat`.
|
||||
let mut conflicts_ref = Vec::new();
|
||||
sub.each_binding(|_, hir_id, span, _| {
|
||||
match tables.extract_binding_mode(sess, hir_id, span) {
|
||||
match typeck_results.extract_binding_mode(sess, hir_id, span) {
|
||||
Some(ty::BindByValue(_)) | None => {}
|
||||
Some(ty::BindByReference(_)) => conflicts_ref.push(span),
|
||||
}
|
||||
|
@ -692,7 +696,7 @@ fn check_borrow_conflicts_in_at_patterns(cx: &MatchVisitor<'_, '_>, pat: &Pat<'_
|
|||
let occurs_because = format!(
|
||||
"move occurs because `{}` has type `{}` which does not implement the `Copy` trait",
|
||||
name,
|
||||
tables.node_type(pat.hir_id),
|
||||
typeck_results.node_type(pat.hir_id),
|
||||
);
|
||||
sess.struct_span_err(pat.span, "borrow of moved value")
|
||||
.span_label(binding_span, format!("value moved into `{}` here", name))
|
||||
|
@ -712,7 +716,7 @@ fn check_borrow_conflicts_in_at_patterns(cx: &MatchVisitor<'_, '_>, pat: &Pat<'_
|
|||
let mut conflicts_mut_mut = Vec::new();
|
||||
let mut conflicts_mut_ref = Vec::new();
|
||||
sub.each_binding(|_, hir_id, span, name| {
|
||||
match tables.extract_binding_mode(sess, hir_id, span) {
|
||||
match typeck_results.extract_binding_mode(sess, hir_id, span) {
|
||||
Some(ty::BindByReference(mut_inner)) => match (mut_outer, mut_inner) {
|
||||
(Mutability::Not, Mutability::Not) => {} // Both sides are `ref`.
|
||||
(Mutability::Mut, Mutability::Mut) => conflicts_mut_mut.push((span, name)), // 2x `ref mut`.
|
||||
|
|
|
@ -349,7 +349,7 @@ impl<'tcx> fmt::Display for Pat<'tcx> {
|
|||
crate struct PatCtxt<'a, 'tcx> {
|
||||
crate tcx: TyCtxt<'tcx>,
|
||||
crate param_env: ty::ParamEnv<'tcx>,
|
||||
crate tables: &'a ty::TypeckTables<'tcx>,
|
||||
crate typeck_results: &'a ty::TypeckResults<'tcx>,
|
||||
crate errors: Vec<PatternError>,
|
||||
include_lint_checks: bool,
|
||||
}
|
||||
|
@ -358,10 +358,10 @@ impl<'a, 'tcx> Pat<'tcx> {
|
|||
crate fn from_hir(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
tables: &'a ty::TypeckTables<'tcx>,
|
||||
typeck_results: &'a ty::TypeckResults<'tcx>,
|
||||
pat: &'tcx hir::Pat<'tcx>,
|
||||
) -> Self {
|
||||
let mut pcx = PatCtxt::new(tcx, param_env, tables);
|
||||
let mut pcx = PatCtxt::new(tcx, param_env, typeck_results);
|
||||
let result = pcx.lower_pattern(pat);
|
||||
if !pcx.errors.is_empty() {
|
||||
let msg = format!("encountered errors lowering pattern: {:?}", pcx.errors);
|
||||
|
@ -376,9 +376,9 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
|||
crate fn new(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
tables: &'a ty::TypeckTables<'tcx>,
|
||||
typeck_results: &'a ty::TypeckResults<'tcx>,
|
||||
) -> Self {
|
||||
PatCtxt { tcx, param_env, tables, errors: vec![], include_lint_checks: false }
|
||||
PatCtxt { tcx, param_env, typeck_results, errors: vec![], include_lint_checks: false }
|
||||
}
|
||||
|
||||
crate fn include_lint_checks(&mut self) -> &mut Self {
|
||||
|
@ -407,7 +407,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
|||
// adjustments in *reverse order* (last-in-first-out, so that the last `Deref` inserted
|
||||
// gets the least-dereferenced type).
|
||||
let unadjusted_pat = self.lower_pattern_unadjusted(pat);
|
||||
self.tables.pat_adjustments().get(pat.hir_id).unwrap_or(&vec![]).iter().rev().fold(
|
||||
self.typeck_results.pat_adjustments().get(pat.hir_id).unwrap_or(&vec![]).iter().rev().fold(
|
||||
unadjusted_pat,
|
||||
|pat, ref_ty| {
|
||||
debug!("{:?}: wrapping pattern with type {:?}", pat, ref_ty);
|
||||
|
@ -507,7 +507,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn lower_pattern_unadjusted(&mut self, pat: &'tcx hir::Pat<'tcx>) -> Pat<'tcx> {
|
||||
let mut ty = self.tables.node_type(pat.hir_id);
|
||||
let mut ty = self.typeck_results.node_type(pat.hir_id);
|
||||
|
||||
if let ty::Error(_) = ty.kind {
|
||||
// Avoid ICEs (e.g., #50577 and #50585).
|
||||
|
@ -573,8 +573,11 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
|||
}
|
||||
|
||||
hir::PatKind::Binding(_, id, ident, ref sub) => {
|
||||
let bm =
|
||||
*self.tables.pat_binding_modes().get(pat.hir_id).expect("missing binding mode");
|
||||
let bm = *self
|
||||
.typeck_results
|
||||
.pat_binding_modes()
|
||||
.get(pat.hir_id)
|
||||
.expect("missing binding mode");
|
||||
let (mutability, mode) = match bm {
|
||||
ty::BindByValue(mutbl) => (mutbl, BindingMode::ByValue),
|
||||
ty::BindByReference(hir::Mutability::Mut) => (
|
||||
|
@ -609,7 +612,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
|||
}
|
||||
|
||||
hir::PatKind::TupleStruct(ref qpath, ref pats, ddpos) => {
|
||||
let res = self.tables.qpath_res(qpath, pat.hir_id);
|
||||
let res = self.typeck_results.qpath_res(qpath, pat.hir_id);
|
||||
let adt_def = match ty.kind {
|
||||
ty::Adt(adt_def, _) => adt_def,
|
||||
_ => span_bug!(pat.span, "tuple struct pattern not applied to an ADT {:?}", ty),
|
||||
|
@ -620,11 +623,11 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
|||
}
|
||||
|
||||
hir::PatKind::Struct(ref qpath, ref fields, _) => {
|
||||
let res = self.tables.qpath_res(qpath, pat.hir_id);
|
||||
let res = self.typeck_results.qpath_res(qpath, pat.hir_id);
|
||||
let subpatterns = fields
|
||||
.iter()
|
||||
.map(|field| FieldPat {
|
||||
field: Field::new(self.tcx.field_index(field.hir_id, self.tables)),
|
||||
field: Field::new(self.tcx.field_index(field.hir_id, self.typeck_results)),
|
||||
pattern: self.lower_pattern(&field.pat),
|
||||
})
|
||||
.collect();
|
||||
|
@ -764,8 +767,8 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
|||
/// it to `const_to_pat`. Any other path (like enum variants without fields)
|
||||
/// is converted to the corresponding pattern via `lower_variant_or_leaf`.
|
||||
fn lower_path(&mut self, qpath: &hir::QPath<'_>, id: hir::HirId, span: Span) -> Pat<'tcx> {
|
||||
let ty = self.tables.node_type(id);
|
||||
let res = self.tables.qpath_res(qpath, id);
|
||||
let ty = self.typeck_results.node_type(id);
|
||||
let res = self.typeck_results.qpath_res(qpath, id);
|
||||
|
||||
let pat_from_kind = |kind| Pat { span, ty, kind: Box::new(kind) };
|
||||
|
||||
|
@ -779,7 +782,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
|||
// Use `Reveal::All` here because patterns are always monomorphic even if their function
|
||||
// isn't.
|
||||
let param_env_reveal_all = self.param_env.with_reveal_all();
|
||||
let substs = self.tables.node_substs(id);
|
||||
let substs = self.typeck_results.node_substs(id);
|
||||
let instance = match ty::Instance::resolve(self.tcx, param_env_reveal_all, def_id, substs) {
|
||||
Ok(Some(i)) => i,
|
||||
Ok(None) => {
|
||||
|
@ -806,7 +809,8 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
|||
|
||||
match self.tcx.const_eval_instance(param_env_reveal_all, instance, Some(span)) {
|
||||
Ok(value) => {
|
||||
let const_ = ty::Const::from_value(self.tcx, value, self.tables.node_type(id));
|
||||
let const_ =
|
||||
ty::Const::from_value(self.tcx, value, self.typeck_results.node_type(id));
|
||||
|
||||
let pattern = self.const_to_pat(&const_, id, span, mir_structural_match_violation);
|
||||
|
||||
|
@ -814,7 +818,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
|||
return pattern;
|
||||
}
|
||||
|
||||
let user_provided_types = self.tables().user_provided_types();
|
||||
let user_provided_types = self.typeck_results().user_provided_types();
|
||||
if let Some(u_ty) = user_provided_types.get(id) {
|
||||
let user_ty = PatTyProj::from_user_type(*u_ty);
|
||||
Pat {
|
||||
|
@ -862,7 +866,8 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
|||
_ => span_bug!(expr.span, "not a literal: {:?}", expr),
|
||||
};
|
||||
|
||||
let lit_input = LitToConstInput { lit: &lit.node, ty: self.tables.expr_ty(expr), neg };
|
||||
let lit_input =
|
||||
LitToConstInput { lit: &lit.node, ty: self.typeck_results.expr_ty(expr), neg };
|
||||
match self.tcx.at(expr.span).lit_to_const(lit_input) {
|
||||
Ok(val) => *self.const_to_pat(val, expr.hir_id, lit.span, false).kind,
|
||||
Err(LitToConstError::UnparseableFloat) => {
|
||||
|
@ -881,8 +886,8 @@ impl<'tcx> UserAnnotatedTyHelpers<'tcx> for PatCtxt<'_, 'tcx> {
|
|||
self.tcx
|
||||
}
|
||||
|
||||
fn tables(&self) -> &ty::TypeckTables<'tcx> {
|
||||
self.tables
|
||||
fn typeck_results(&self) -> &ty::TypeckResults<'tcx> {
|
||||
self.typeck_results
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ use rustc_middle::ty::{self, CanonicalUserType, TyCtxt, UserType};
|
|||
crate trait UserAnnotatedTyHelpers<'tcx> {
|
||||
fn tcx(&self) -> TyCtxt<'tcx>;
|
||||
|
||||
fn tables(&self) -> &ty::TypeckTables<'tcx>;
|
||||
fn typeck_results(&self) -> &ty::TypeckResults<'tcx>;
|
||||
|
||||
/// Looks up the type associated with this hir-id and applies the
|
||||
/// user-given substitutions; the hir-id must map to a suitable
|
||||
|
@ -13,10 +13,10 @@ crate trait UserAnnotatedTyHelpers<'tcx> {
|
|||
&self,
|
||||
hir_id: hir::HirId,
|
||||
) -> Option<CanonicalUserType<'tcx>> {
|
||||
let user_provided_types = self.tables().user_provided_types();
|
||||
let user_provided_types = self.typeck_results().user_provided_types();
|
||||
let mut user_ty = *user_provided_types.get(hir_id)?;
|
||||
debug!("user_subts_applied_to_ty_of_hir_id: user_ty={:?}", user_ty);
|
||||
let ty = self.tables().node_type(hir_id);
|
||||
let ty = self.typeck_results().node_type(hir_id);
|
||||
match ty.kind {
|
||||
ty::Adt(adt_def, ..) => {
|
||||
if let UserType::TypeOf(ref mut did, _) = &mut user_ty.value {
|
||||
|
|
|
@ -40,7 +40,7 @@ fn should_explore(tcx: TyCtxt<'_>, hir_id: hir::HirId) -> bool {
|
|||
struct MarkSymbolVisitor<'tcx> {
|
||||
worklist: Vec<hir::HirId>,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
maybe_typeck_tables: Option<&'tcx ty::TypeckTables<'tcx>>,
|
||||
maybe_typeck_results: Option<&'tcx ty::TypeckResults<'tcx>>,
|
||||
live_symbols: FxHashSet<hir::HirId>,
|
||||
repr_has_repr_c: bool,
|
||||
in_pat: bool,
|
||||
|
@ -51,12 +51,13 @@ struct MarkSymbolVisitor<'tcx> {
|
|||
}
|
||||
|
||||
impl<'tcx> MarkSymbolVisitor<'tcx> {
|
||||
/// Gets the type-checking side-tables for the current body.
|
||||
/// Gets the type-checking results for the current body.
|
||||
/// As this will ICE if called outside bodies, only call when working with
|
||||
/// `Expr` or `Pat` nodes (they are guaranteed to be found only in bodies).
|
||||
#[track_caller]
|
||||
fn tables(&self) -> &'tcx ty::TypeckTables<'tcx> {
|
||||
self.maybe_typeck_tables.expect("`MarkSymbolVisitor::tables` called outside of body")
|
||||
fn typeck_results(&self) -> &'tcx ty::TypeckResults<'tcx> {
|
||||
self.maybe_typeck_results
|
||||
.expect("`MarkSymbolVisitor::typeck_results` called outside of body")
|
||||
}
|
||||
|
||||
fn check_def_id(&mut self, def_id: DefId) {
|
||||
|
@ -115,7 +116,7 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
|
|||
}
|
||||
|
||||
fn lookup_and_handle_method(&mut self, id: hir::HirId) {
|
||||
if let Some(def_id) = self.tables().type_dependent_def_id(id) {
|
||||
if let Some(def_id) = self.typeck_results().type_dependent_def_id(id) {
|
||||
self.check_def_id(def_id);
|
||||
} else {
|
||||
bug!("no type-dependent def for method");
|
||||
|
@ -123,9 +124,9 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
|
|||
}
|
||||
|
||||
fn handle_field_access(&mut self, lhs: &hir::Expr<'_>, hir_id: hir::HirId) {
|
||||
match self.tables().expr_ty_adjusted(lhs).kind {
|
||||
match self.typeck_results().expr_ty_adjusted(lhs).kind {
|
||||
ty::Adt(def, _) => {
|
||||
let index = self.tcx.field_index(hir_id, self.tables());
|
||||
let index = self.tcx.field_index(hir_id, self.typeck_results());
|
||||
self.insert_def_id(def.non_enum_variant().fields[index].did);
|
||||
}
|
||||
ty::Tuple(..) => {}
|
||||
|
@ -139,7 +140,7 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
|
|||
res: Res,
|
||||
pats: &[hir::FieldPat<'_>],
|
||||
) {
|
||||
let variant = match self.tables().node_type(lhs.hir_id).kind {
|
||||
let variant = match self.typeck_results().node_type(lhs.hir_id).kind {
|
||||
ty::Adt(adt, _) => adt.variant_of_res(res),
|
||||
_ => span_bug!(lhs.span, "non-ADT in struct pattern"),
|
||||
};
|
||||
|
@ -147,7 +148,7 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
|
|||
if let PatKind::Wild = pat.pat.kind {
|
||||
continue;
|
||||
}
|
||||
let index = self.tcx.field_index(pat.hir_id, self.tables());
|
||||
let index = self.tcx.field_index(pat.hir_id, self.typeck_results());
|
||||
self.insert_def_id(variant.fields[index].did);
|
||||
}
|
||||
}
|
||||
|
@ -212,7 +213,7 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
|
|||
fn mark_as_used_if_union(&mut self, adt: &ty::AdtDef, fields: &[hir::Field<'_>]) {
|
||||
if adt.is_union() && adt.non_enum_variant().fields.len() > 1 && adt.did.is_local() {
|
||||
for field in fields {
|
||||
let index = self.tcx.field_index(field.hir_id, self.tables());
|
||||
let index = self.tcx.field_index(field.hir_id, self.typeck_results());
|
||||
self.insert_def_id(adt.non_enum_variant().fields[index].did);
|
||||
}
|
||||
}
|
||||
|
@ -227,10 +228,11 @@ impl<'tcx> Visitor<'tcx> for MarkSymbolVisitor<'tcx> {
|
|||
}
|
||||
|
||||
fn visit_nested_body(&mut self, body: hir::BodyId) {
|
||||
let old_maybe_typeck_tables = self.maybe_typeck_tables.replace(self.tcx.body_tables(body));
|
||||
let old_maybe_typeck_results =
|
||||
self.maybe_typeck_results.replace(self.tcx.typeck_body(body));
|
||||
let body = self.tcx.hir().body(body);
|
||||
self.visit_body(body);
|
||||
self.maybe_typeck_tables = old_maybe_typeck_tables;
|
||||
self.maybe_typeck_results = old_maybe_typeck_results;
|
||||
}
|
||||
|
||||
fn visit_variant_data(
|
||||
|
@ -255,7 +257,7 @@ impl<'tcx> Visitor<'tcx> for MarkSymbolVisitor<'tcx> {
|
|||
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) {
|
||||
match expr.kind {
|
||||
hir::ExprKind::Path(ref qpath @ hir::QPath::TypeRelative(..)) => {
|
||||
let res = self.tables().qpath_res(qpath, expr.hir_id);
|
||||
let res = self.typeck_results().qpath_res(qpath, expr.hir_id);
|
||||
self.handle_res(res);
|
||||
}
|
||||
hir::ExprKind::MethodCall(..) => {
|
||||
|
@ -265,9 +267,9 @@ impl<'tcx> Visitor<'tcx> for MarkSymbolVisitor<'tcx> {
|
|||
self.handle_field_access(&lhs, expr.hir_id);
|
||||
}
|
||||
hir::ExprKind::Struct(ref qpath, ref fields, _) => {
|
||||
let res = self.tables().qpath_res(qpath, expr.hir_id);
|
||||
let res = self.typeck_results().qpath_res(qpath, expr.hir_id);
|
||||
self.handle_res(res);
|
||||
if let ty::Adt(ref adt, _) = self.tables().expr_ty(expr).kind {
|
||||
if let ty::Adt(ref adt, _) = self.typeck_results().expr_ty(expr).kind {
|
||||
self.mark_as_used_if_union(adt, fields);
|
||||
}
|
||||
}
|
||||
|
@ -290,11 +292,11 @@ impl<'tcx> Visitor<'tcx> for MarkSymbolVisitor<'tcx> {
|
|||
fn visit_pat(&mut self, pat: &'tcx hir::Pat<'tcx>) {
|
||||
match pat.kind {
|
||||
PatKind::Struct(ref path, ref fields, _) => {
|
||||
let res = self.tables().qpath_res(path, pat.hir_id);
|
||||
let res = self.typeck_results().qpath_res(path, pat.hir_id);
|
||||
self.handle_field_pattern_match(pat, res, fields);
|
||||
}
|
||||
PatKind::Path(ref qpath) => {
|
||||
let res = self.tables().qpath_res(qpath, pat.hir_id);
|
||||
let res = self.typeck_results().qpath_res(qpath, pat.hir_id);
|
||||
self.handle_res(res);
|
||||
}
|
||||
_ => (),
|
||||
|
@ -480,7 +482,7 @@ fn find_live<'tcx>(
|
|||
let mut symbol_visitor = MarkSymbolVisitor {
|
||||
worklist,
|
||||
tcx,
|
||||
maybe_typeck_tables: None,
|
||||
maybe_typeck_results: None,
|
||||
live_symbols: Default::default(),
|
||||
repr_has_repr_c: false,
|
||||
in_pat: false,
|
||||
|
|
|
@ -28,7 +28,7 @@ struct ItemVisitor<'tcx> {
|
|||
|
||||
struct ExprVisitor<'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
tables: &'tcx ty::TypeckTables<'tcx>,
|
||||
typeck_results: &'tcx ty::TypeckResults<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
}
|
||||
|
||||
|
@ -142,7 +142,7 @@ impl ExprVisitor<'tcx> {
|
|||
tied_input: Option<(&hir::Expr<'tcx>, Option<InlineAsmType>)>,
|
||||
) -> Option<InlineAsmType> {
|
||||
// Check the type against the allowed types for inline asm.
|
||||
let ty = self.tables.expr_ty_adjusted(expr);
|
||||
let ty = self.typeck_results.expr_ty_adjusted(expr);
|
||||
let asm_ty_isize = match self.tcx.sess.target.ptr_width {
|
||||
16 => InlineAsmType::I16,
|
||||
32 => InlineAsmType::I32,
|
||||
|
@ -236,7 +236,7 @@ impl ExprVisitor<'tcx> {
|
|||
let mut err = self.tcx.sess.struct_span_err(vec![in_expr.span, expr.span], msg);
|
||||
err.span_label(
|
||||
in_expr.span,
|
||||
&format!("type `{}`", self.tables.expr_ty_adjusted(in_expr)),
|
||||
&format!("type `{}`", self.typeck_results.expr_ty_adjusted(in_expr)),
|
||||
);
|
||||
err.span_label(expr.span, &format!("type `{}`", ty));
|
||||
err.note(
|
||||
|
@ -373,7 +373,7 @@ impl ExprVisitor<'tcx> {
|
|||
}
|
||||
}
|
||||
hir::InlineAsmOperand::Const { ref expr } => {
|
||||
let ty = self.tables.expr_ty_adjusted(expr);
|
||||
let ty = self.typeck_results.expr_ty_adjusted(expr);
|
||||
match ty.kind {
|
||||
ty::Int(_) | ty::Uint(_) | ty::Float(_) => {}
|
||||
_ => {
|
||||
|
@ -400,8 +400,8 @@ impl Visitor<'tcx> for ItemVisitor<'tcx> {
|
|||
let owner_def_id = self.tcx.hir().body_owner_def_id(body_id);
|
||||
let body = self.tcx.hir().body(body_id);
|
||||
let param_env = self.tcx.param_env(owner_def_id.to_def_id());
|
||||
let tables = self.tcx.typeck_tables_of(owner_def_id);
|
||||
ExprVisitor { tcx: self.tcx, param_env, tables }.visit_body(body);
|
||||
let typeck_results = self.tcx.typeck(owner_def_id);
|
||||
ExprVisitor { tcx: self.tcx, param_env, typeck_results }.visit_body(body);
|
||||
self.visit_body(body);
|
||||
}
|
||||
}
|
||||
|
@ -416,10 +416,10 @@ impl Visitor<'tcx> for ExprVisitor<'tcx> {
|
|||
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) {
|
||||
match expr.kind {
|
||||
hir::ExprKind::Path(ref qpath) => {
|
||||
let res = self.tables.qpath_res(qpath, expr.hir_id);
|
||||
let res = self.typeck_results.qpath_res(qpath, expr.hir_id);
|
||||
if let Res::Def(DefKind::Fn, did) = res {
|
||||
if self.def_id_is_transmute(did) {
|
||||
let typ = self.tables.node_type(expr.hir_id);
|
||||
let typ = self.typeck_results.node_type(expr.hir_id);
|
||||
let sig = typ.fn_sig(self.tcx);
|
||||
let from = sig.inputs().skip_binder()[0];
|
||||
let to = sig.output().skip_binder();
|
||||
|
|
|
@ -650,7 +650,7 @@ const ACC_USE: u32 = 4;
|
|||
|
||||
struct Liveness<'a, 'tcx> {
|
||||
ir: &'a mut IrMaps<'tcx>,
|
||||
tables: &'a ty::TypeckTables<'tcx>,
|
||||
typeck_results: &'a ty::TypeckResults<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
s: Specials,
|
||||
successors: Vec<LiveNode>,
|
||||
|
@ -670,7 +670,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
exit_ln: ir.add_live_node(ExitNode),
|
||||
};
|
||||
|
||||
let tables = ir.tcx.typeck_tables_of(def_id);
|
||||
let typeck_results = ir.tcx.typeck(def_id);
|
||||
let param_env = ir.tcx.param_env(def_id);
|
||||
|
||||
let num_live_nodes = ir.num_live_nodes;
|
||||
|
@ -678,7 +678,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
|
||||
Liveness {
|
||||
ir,
|
||||
tables,
|
||||
typeck_results,
|
||||
param_env,
|
||||
s: specials,
|
||||
successors: vec![invalid_node(); num_live_nodes],
|
||||
|
@ -939,7 +939,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
var_path: ty::UpvarPath { hir_id: var_hir_id },
|
||||
closure_expr_id: self.ir.body_owner,
|
||||
};
|
||||
match self.tables.upvar_capture(upvar_id) {
|
||||
match self.typeck_results.upvar_capture(upvar_id) {
|
||||
ty::UpvarCapture::ByRef(_) => {
|
||||
let var = self.variable(var_hir_id, upvar.span);
|
||||
self.acc(self.s.exit_ln, var, ACC_READ | ACC_USE);
|
||||
|
@ -956,7 +956,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
FnKind::Closure(..) => {}
|
||||
}
|
||||
|
||||
let ty = self.tables.node_type(id);
|
||||
let ty = self.typeck_results.node_type(id);
|
||||
match ty.kind {
|
||||
ty::Closure(_def_id, substs) => match substs.as_closure().kind() {
|
||||
ty::ClosureKind::Fn => {}
|
||||
|
@ -1151,7 +1151,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
|
||||
hir::ExprKind::AssignOp(_, ref l, ref r) => {
|
||||
// an overloaded assign op is like a method call
|
||||
if self.tables.is_method_call(expr) {
|
||||
if self.typeck_results.is_method_call(expr) {
|
||||
let succ = self.propagate_through_expr(&l, succ);
|
||||
self.propagate_through_expr(&r, succ)
|
||||
} else {
|
||||
|
@ -1178,7 +1178,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
let m = self.ir.tcx.parent_module(expr.hir_id).to_def_id();
|
||||
let succ = if self.ir.tcx.is_ty_uninhabited_from(
|
||||
m,
|
||||
self.tables.expr_ty(expr),
|
||||
self.typeck_results.expr_ty(expr),
|
||||
self.param_env,
|
||||
) {
|
||||
self.s.exit_ln
|
||||
|
@ -1193,7 +1193,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
let m = self.ir.tcx.parent_module(expr.hir_id).to_def_id();
|
||||
let succ = if self.ir.tcx.is_ty_uninhabited_from(
|
||||
m,
|
||||
self.tables.expr_ty(expr),
|
||||
self.typeck_results.expr_ty(expr),
|
||||
self.param_env,
|
||||
) {
|
||||
self.s.exit_ln
|
||||
|
@ -1497,7 +1497,7 @@ fn check_expr<'tcx>(this: &mut Liveness<'_, 'tcx>, expr: &'tcx Expr<'tcx>) {
|
|||
}
|
||||
|
||||
hir::ExprKind::AssignOp(_, ref l, _) => {
|
||||
if !this.tables.is_method_call(expr) {
|
||||
if !this.typeck_results.is_method_call(expr) {
|
||||
this.check_place(&l);
|
||||
}
|
||||
}
|
||||
|
@ -1607,7 +1607,7 @@ impl<'tcx> Liveness<'_, 'tcx> {
|
|||
var_path: ty::UpvarPath { hir_id: var_hir_id },
|
||||
closure_expr_id: self.ir.body_owner,
|
||||
};
|
||||
match self.tables.upvar_capture(upvar_id) {
|
||||
match self.typeck_results.upvar_capture(upvar_id) {
|
||||
ty::UpvarCapture::ByValue => {}
|
||||
ty::UpvarCapture::ByRef(..) => continue,
|
||||
};
|
||||
|
|
|
@ -63,7 +63,7 @@ fn method_might_be_inlined(
|
|||
struct ReachableContext<'tcx> {
|
||||
// The type context.
|
||||
tcx: TyCtxt<'tcx>,
|
||||
maybe_typeck_tables: Option<&'tcx ty::TypeckTables<'tcx>>,
|
||||
maybe_typeck_results: Option<&'tcx ty::TypeckResults<'tcx>>,
|
||||
// The set of items which must be exported in the linkage sense.
|
||||
reachable_symbols: HirIdSet,
|
||||
// A worklist of item IDs. Each item ID in this worklist will be inlined
|
||||
|
@ -81,17 +81,20 @@ impl<'tcx> Visitor<'tcx> for ReachableContext<'tcx> {
|
|||
}
|
||||
|
||||
fn visit_nested_body(&mut self, body: hir::BodyId) {
|
||||
let old_maybe_typeck_tables = self.maybe_typeck_tables.replace(self.tcx.body_tables(body));
|
||||
let old_maybe_typeck_results =
|
||||
self.maybe_typeck_results.replace(self.tcx.typeck_body(body));
|
||||
let body = self.tcx.hir().body(body);
|
||||
self.visit_body(body);
|
||||
self.maybe_typeck_tables = old_maybe_typeck_tables;
|
||||
self.maybe_typeck_results = old_maybe_typeck_results;
|
||||
}
|
||||
|
||||
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) {
|
||||
let res = match expr.kind {
|
||||
hir::ExprKind::Path(ref qpath) => Some(self.tables().qpath_res(qpath, expr.hir_id)),
|
||||
hir::ExprKind::Path(ref qpath) => {
|
||||
Some(self.typeck_results().qpath_res(qpath, expr.hir_id))
|
||||
}
|
||||
hir::ExprKind::MethodCall(..) => self
|
||||
.tables()
|
||||
.typeck_results()
|
||||
.type_dependent_def(expr.hir_id)
|
||||
.map(|(kind, def_id)| Res::Def(kind, def_id)),
|
||||
_ => None,
|
||||
|
@ -133,12 +136,13 @@ impl<'tcx> Visitor<'tcx> for ReachableContext<'tcx> {
|
|||
}
|
||||
|
||||
impl<'tcx> ReachableContext<'tcx> {
|
||||
/// Gets the type-checking side-tables for the current body.
|
||||
/// Gets the type-checking results for the current body.
|
||||
/// As this will ICE if called outside bodies, only call when working with
|
||||
/// `Expr` or `Pat` nodes (they are guaranteed to be found only in bodies).
|
||||
#[track_caller]
|
||||
fn tables(&self) -> &'tcx ty::TypeckTables<'tcx> {
|
||||
self.maybe_typeck_tables.expect("`ReachableContext::tables` called outside of body")
|
||||
fn typeck_results(&self) -> &'tcx ty::TypeckResults<'tcx> {
|
||||
self.maybe_typeck_results
|
||||
.expect("`ReachableContext::typeck_results` called outside of body")
|
||||
}
|
||||
|
||||
// Returns true if the given def ID represents a local item that is
|
||||
|
@ -388,7 +392,7 @@ fn reachable_set<'tcx>(tcx: TyCtxt<'tcx>, crate_num: CrateNum) -> &'tcx HirIdSet
|
|||
});
|
||||
let mut reachable_context = ReachableContext {
|
||||
tcx,
|
||||
maybe_typeck_tables: None,
|
||||
maybe_typeck_results: None,
|
||||
reachable_symbols: Default::default(),
|
||||
worklist: Vec::new(),
|
||||
any_library,
|
||||
|
|
|
@ -1021,17 +1021,18 @@ impl DefIdVisitor<'tcx> for ReachEverythingInTheInterfaceVisitor<'_, 'tcx> {
|
|||
|
||||
struct NamePrivacyVisitor<'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
maybe_typeck_tables: Option<&'tcx ty::TypeckTables<'tcx>>,
|
||||
maybe_typeck_results: Option<&'tcx ty::TypeckResults<'tcx>>,
|
||||
current_item: Option<hir::HirId>,
|
||||
}
|
||||
|
||||
impl<'tcx> NamePrivacyVisitor<'tcx> {
|
||||
/// Gets the type-checking side-tables for the current body.
|
||||
/// Gets the type-checking results for the current body.
|
||||
/// As this will ICE if called outside bodies, only call when working with
|
||||
/// `Expr` or `Pat` nodes (they are guaranteed to be found only in bodies).
|
||||
#[track_caller]
|
||||
fn tables(&self) -> &'tcx ty::TypeckTables<'tcx> {
|
||||
self.maybe_typeck_tables.expect("`NamePrivacyVisitor::tables` called outside of body")
|
||||
fn typeck_results(&self) -> &'tcx ty::TypeckResults<'tcx> {
|
||||
self.maybe_typeck_results
|
||||
.expect("`NamePrivacyVisitor::typeck_results` called outside of body")
|
||||
}
|
||||
|
||||
// Checks that a field in a struct constructor (expression or pattern) is accessible.
|
||||
|
@ -1084,10 +1085,11 @@ impl<'tcx> Visitor<'tcx> for NamePrivacyVisitor<'tcx> {
|
|||
}
|
||||
|
||||
fn visit_nested_body(&mut self, body: hir::BodyId) {
|
||||
let old_maybe_typeck_tables = self.maybe_typeck_tables.replace(self.tcx.body_tables(body));
|
||||
let old_maybe_typeck_results =
|
||||
self.maybe_typeck_results.replace(self.tcx.typeck_body(body));
|
||||
let body = self.tcx.hir().body(body);
|
||||
self.visit_body(body);
|
||||
self.maybe_typeck_tables = old_maybe_typeck_tables;
|
||||
self.maybe_typeck_results = old_maybe_typeck_results;
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
|
||||
|
@ -1098,17 +1100,17 @@ impl<'tcx> Visitor<'tcx> for NamePrivacyVisitor<'tcx> {
|
|||
|
||||
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) {
|
||||
if let hir::ExprKind::Struct(ref qpath, fields, ref base) = expr.kind {
|
||||
let res = self.tables().qpath_res(qpath, expr.hir_id);
|
||||
let adt = self.tables().expr_ty(expr).ty_adt_def().unwrap();
|
||||
let res = self.typeck_results().qpath_res(qpath, expr.hir_id);
|
||||
let adt = self.typeck_results().expr_ty(expr).ty_adt_def().unwrap();
|
||||
let variant = adt.variant_of_res(res);
|
||||
if let Some(ref base) = *base {
|
||||
// If the expression uses FRU we need to make sure all the unmentioned fields
|
||||
// are checked for privacy (RFC 736). Rather than computing the set of
|
||||
// unmentioned fields, just check them all.
|
||||
for (vf_index, variant_field) in variant.fields.iter().enumerate() {
|
||||
let field = fields
|
||||
.iter()
|
||||
.find(|f| self.tcx.field_index(f.hir_id, self.tables()) == vf_index);
|
||||
let field = fields.iter().find(|f| {
|
||||
self.tcx.field_index(f.hir_id, self.typeck_results()) == vf_index
|
||||
});
|
||||
let (use_ctxt, span) = match field {
|
||||
Some(field) => (field.ident.span, field.span),
|
||||
None => (base.span, base.span),
|
||||
|
@ -1118,7 +1120,7 @@ impl<'tcx> Visitor<'tcx> for NamePrivacyVisitor<'tcx> {
|
|||
} else {
|
||||
for field in fields {
|
||||
let use_ctxt = field.ident.span;
|
||||
let index = self.tcx.field_index(field.hir_id, self.tables());
|
||||
let index = self.tcx.field_index(field.hir_id, self.typeck_results());
|
||||
self.check_field(use_ctxt, field.span, adt, &variant.fields[index], false);
|
||||
}
|
||||
}
|
||||
|
@ -1129,12 +1131,12 @@ impl<'tcx> Visitor<'tcx> for NamePrivacyVisitor<'tcx> {
|
|||
|
||||
fn visit_pat(&mut self, pat: &'tcx hir::Pat<'tcx>) {
|
||||
if let PatKind::Struct(ref qpath, fields, _) = pat.kind {
|
||||
let res = self.tables().qpath_res(qpath, pat.hir_id);
|
||||
let adt = self.tables().pat_ty(pat).ty_adt_def().unwrap();
|
||||
let res = self.typeck_results().qpath_res(qpath, pat.hir_id);
|
||||
let adt = self.typeck_results().pat_ty(pat).ty_adt_def().unwrap();
|
||||
let variant = adt.variant_of_res(res);
|
||||
for field in fields {
|
||||
let use_ctxt = field.ident.span;
|
||||
let index = self.tcx.field_index(field.hir_id, self.tables());
|
||||
let index = self.tcx.field_index(field.hir_id, self.typeck_results());
|
||||
self.check_field(use_ctxt, field.span, adt, &variant.fields[index], false);
|
||||
}
|
||||
}
|
||||
|
@ -1151,18 +1153,19 @@ impl<'tcx> Visitor<'tcx> for NamePrivacyVisitor<'tcx> {
|
|||
|
||||
struct TypePrivacyVisitor<'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
maybe_typeck_tables: Option<&'tcx ty::TypeckTables<'tcx>>,
|
||||
maybe_typeck_results: Option<&'tcx ty::TypeckResults<'tcx>>,
|
||||
current_item: LocalDefId,
|
||||
span: Span,
|
||||
}
|
||||
|
||||
impl<'tcx> TypePrivacyVisitor<'tcx> {
|
||||
/// Gets the type-checking side-tables for the current body.
|
||||
/// Gets the type-checking results for the current body.
|
||||
/// As this will ICE if called outside bodies, only call when working with
|
||||
/// `Expr` or `Pat` nodes (they are guaranteed to be found only in bodies).
|
||||
#[track_caller]
|
||||
fn tables(&self) -> &'tcx ty::TypeckTables<'tcx> {
|
||||
self.maybe_typeck_tables.expect("`TypePrivacyVisitor::tables` called outside of body")
|
||||
fn typeck_results(&self) -> &'tcx ty::TypeckResults<'tcx> {
|
||||
self.maybe_typeck_results
|
||||
.expect("`TypePrivacyVisitor::typeck_results` called outside of body")
|
||||
}
|
||||
|
||||
fn item_is_accessible(&self, did: DefId) -> bool {
|
||||
|
@ -1174,11 +1177,11 @@ impl<'tcx> TypePrivacyVisitor<'tcx> {
|
|||
// Take node-id of an expression or pattern and check its type for privacy.
|
||||
fn check_expr_pat_type(&mut self, id: hir::HirId, span: Span) -> bool {
|
||||
self.span = span;
|
||||
let tables = self.tables();
|
||||
if self.visit(tables.node_type(id)) || self.visit(tables.node_substs(id)) {
|
||||
let typeck_results = self.typeck_results();
|
||||
if self.visit(typeck_results.node_type(id)) || self.visit(typeck_results.node_substs(id)) {
|
||||
return true;
|
||||
}
|
||||
if let Some(adjustments) = tables.adjustments().get(id) {
|
||||
if let Some(adjustments) = typeck_results.adjustments().get(id) {
|
||||
for adjustment in adjustments {
|
||||
if self.visit(adjustment.target) {
|
||||
return true;
|
||||
|
@ -1216,17 +1219,18 @@ impl<'tcx> Visitor<'tcx> for TypePrivacyVisitor<'tcx> {
|
|||
}
|
||||
|
||||
fn visit_nested_body(&mut self, body: hir::BodyId) {
|
||||
let old_maybe_typeck_tables = self.maybe_typeck_tables.replace(self.tcx.body_tables(body));
|
||||
let old_maybe_typeck_results =
|
||||
self.maybe_typeck_results.replace(self.tcx.typeck_body(body));
|
||||
let body = self.tcx.hir().body(body);
|
||||
self.visit_body(body);
|
||||
self.maybe_typeck_tables = old_maybe_typeck_tables;
|
||||
self.maybe_typeck_results = old_maybe_typeck_results;
|
||||
}
|
||||
|
||||
fn visit_ty(&mut self, hir_ty: &'tcx hir::Ty<'tcx>) {
|
||||
self.span = hir_ty.span;
|
||||
if let Some(tables) = self.maybe_typeck_tables {
|
||||
if let Some(typeck_results) = self.maybe_typeck_results {
|
||||
// Types in bodies.
|
||||
if self.visit(tables.node_type(hir_ty.hir_id)) {
|
||||
if self.visit(typeck_results.node_type(hir_ty.hir_id)) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
@ -1243,7 +1247,7 @@ impl<'tcx> Visitor<'tcx> for TypePrivacyVisitor<'tcx> {
|
|||
|
||||
fn visit_trait_ref(&mut self, trait_ref: &'tcx hir::TraitRef<'tcx>) {
|
||||
self.span = trait_ref.path.span;
|
||||
if self.maybe_typeck_tables.is_none() {
|
||||
if self.maybe_typeck_results.is_none() {
|
||||
// Avoid calling `hir_trait_to_predicates` in bodies, it will ICE.
|
||||
// The traits' privacy in bodies is already checked as a part of trait object types.
|
||||
let bounds = rustc_typeck::hir_trait_to_predicates(
|
||||
|
@ -1289,7 +1293,7 @@ impl<'tcx> Visitor<'tcx> for TypePrivacyVisitor<'tcx> {
|
|||
hir::ExprKind::MethodCall(_, span, _, _) => {
|
||||
// Method calls have to be checked specially.
|
||||
self.span = span;
|
||||
if let Some(def_id) = self.tables().type_dependent_def_id(expr.hir_id) {
|
||||
if let Some(def_id) = self.typeck_results().type_dependent_def_id(expr.hir_id) {
|
||||
if self.visit(self.tcx.type_of(def_id)) {
|
||||
return;
|
||||
}
|
||||
|
@ -1317,9 +1321,9 @@ impl<'tcx> Visitor<'tcx> for TypePrivacyVisitor<'tcx> {
|
|||
Res::Def(kind, def_id) => Some((kind, def_id)),
|
||||
_ => None,
|
||||
},
|
||||
hir::QPath::TypeRelative(..) => {
|
||||
self.maybe_typeck_tables.and_then(|tables| tables.type_dependent_def(id))
|
||||
}
|
||||
hir::QPath::TypeRelative(..) => self
|
||||
.maybe_typeck_results
|
||||
.and_then(|typeck_results| typeck_results.type_dependent_def(id)),
|
||||
};
|
||||
let def = def.filter(|(kind, _)| match kind {
|
||||
DefKind::AssocFn | DefKind::AssocConst | DefKind::AssocTy | DefKind::Static => true,
|
||||
|
@ -1375,9 +1379,9 @@ impl<'tcx> Visitor<'tcx> for TypePrivacyVisitor<'tcx> {
|
|||
fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
|
||||
let orig_current_item =
|
||||
mem::replace(&mut self.current_item, self.tcx.hir().local_def_id(item.hir_id));
|
||||
let old_maybe_typeck_tables = self.maybe_typeck_tables.take();
|
||||
let old_maybe_typeck_results = self.maybe_typeck_results.take();
|
||||
intravisit::walk_item(self, item);
|
||||
self.maybe_typeck_tables = old_maybe_typeck_tables;
|
||||
self.maybe_typeck_results = old_maybe_typeck_results;
|
||||
self.current_item = orig_current_item;
|
||||
}
|
||||
}
|
||||
|
@ -2040,7 +2044,7 @@ pub fn provide(providers: &mut Providers) {
|
|||
|
||||
fn check_mod_privacy(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
|
||||
// Check privacy of names not checked in previous compilation stages.
|
||||
let mut visitor = NamePrivacyVisitor { tcx, maybe_typeck_tables: None, current_item: None };
|
||||
let mut visitor = NamePrivacyVisitor { tcx, maybe_typeck_results: None, current_item: None };
|
||||
let (module, span, hir_id) = tcx.hir().get_module(module_def_id);
|
||||
|
||||
intravisit::walk_mod(&mut visitor, module, hir_id);
|
||||
|
@ -2048,7 +2052,7 @@ fn check_mod_privacy(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
|
|||
// Check privacy of explicitly written types and traits as well as
|
||||
// inferred types of expressions and patterns.
|
||||
let mut visitor =
|
||||
TypePrivacyVisitor { tcx, maybe_typeck_tables: None, current_item: module_def_id, span };
|
||||
TypePrivacyVisitor { tcx, maybe_typeck_results: None, current_item: module_def_id, span };
|
||||
intravisit::walk_mod(&mut visitor, module, hir_id);
|
||||
}
|
||||
|
||||
|
|
|
@ -104,20 +104,20 @@ impl<'tcx> DumpVisitor<'tcx> {
|
|||
self.dumper.analysis()
|
||||
}
|
||||
|
||||
fn nest_tables<F>(&mut self, item_def_id: LocalDefId, f: F)
|
||||
fn nest_typeck_results<F>(&mut self, item_def_id: LocalDefId, f: F)
|
||||
where
|
||||
F: FnOnce(&mut Self),
|
||||
{
|
||||
let tables = if self.tcx.has_typeck_tables(item_def_id) {
|
||||
Some(self.tcx.typeck_tables_of(item_def_id))
|
||||
let typeck_results = if self.tcx.has_typeck_results(item_def_id) {
|
||||
Some(self.tcx.typeck(item_def_id))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let old_maybe_typeck_tables = self.save_ctxt.maybe_typeck_tables;
|
||||
self.save_ctxt.maybe_typeck_tables = tables;
|
||||
let old_maybe_typeck_results = self.save_ctxt.maybe_typeck_results;
|
||||
self.save_ctxt.maybe_typeck_results = typeck_results;
|
||||
f(self);
|
||||
self.save_ctxt.maybe_typeck_tables = old_maybe_typeck_tables;
|
||||
self.save_ctxt.maybe_typeck_results = old_maybe_typeck_results;
|
||||
}
|
||||
|
||||
fn span_from_span(&self, span: Span) -> SpanData {
|
||||
|
@ -226,7 +226,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
|||
collector.visit_pat(&arg.pat);
|
||||
|
||||
for (hir_id, ident, ..) in collector.collected_idents {
|
||||
let typ = match self.save_ctxt.tables().node_type_opt(hir_id) {
|
||||
let typ = match self.save_ctxt.typeck_results().node_type_opt(hir_id) {
|
||||
Some(s) => s.to_string(),
|
||||
None => continue,
|
||||
};
|
||||
|
@ -269,7 +269,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
|||
debug!("process_method: {}:{}", hir_id, ident);
|
||||
|
||||
let map = &self.tcx.hir();
|
||||
self.nest_tables(map.local_def_id(hir_id), |v| {
|
||||
self.nest_typeck_results(map.local_def_id(hir_id), |v| {
|
||||
if let Some(mut method_data) = v.save_ctxt.get_method_data(hir_id, ident, span) {
|
||||
if let Some(body) = body {
|
||||
v.process_formals(map.body(body).params, &method_data.qualname);
|
||||
|
@ -363,7 +363,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
|||
body: hir::BodyId,
|
||||
) {
|
||||
let map = &self.tcx.hir();
|
||||
self.nest_tables(map.local_def_id(item.hir_id), |v| {
|
||||
self.nest_typeck_results(map.local_def_id(item.hir_id), |v| {
|
||||
let body = map.body(body);
|
||||
if let Some(fn_data) = v.save_ctxt.get_item_data(item) {
|
||||
down_cast_data!(fn_data, DefData, item.span);
|
||||
|
@ -391,7 +391,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
|||
typ: &'tcx hir::Ty<'tcx>,
|
||||
expr: &'tcx hir::Expr<'tcx>,
|
||||
) {
|
||||
self.nest_tables(self.tcx.hir().local_def_id(item.hir_id), |v| {
|
||||
self.nest_typeck_results(self.tcx.hir().local_def_id(item.hir_id), |v| {
|
||||
if let Some(var_data) = v.save_ctxt.get_item_data(item) {
|
||||
down_cast_data!(var_data, DefData, item.span);
|
||||
v.dumper.dump_def(&access_from!(v.save_ctxt, item, item.hir_id), var_data);
|
||||
|
@ -438,7 +438,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
|||
}
|
||||
|
||||
// walk type and init value
|
||||
self.nest_tables(self.tcx.hir().local_def_id(hir_id), |v| {
|
||||
self.nest_typeck_results(self.tcx.hir().local_def_id(hir_id), |v| {
|
||||
v.visit_ty(typ);
|
||||
if let Some(expr) = expr {
|
||||
v.visit_expr(expr);
|
||||
|
@ -508,7 +508,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
|||
);
|
||||
}
|
||||
|
||||
self.nest_tables(self.tcx.hir().local_def_id(item.hir_id), |v| {
|
||||
self.nest_typeck_results(self.tcx.hir().local_def_id(item.hir_id), |v| {
|
||||
for field in def.fields() {
|
||||
v.process_struct_field_def(field, item.hir_id);
|
||||
v.visit_ty(&field.ty);
|
||||
|
@ -641,7 +641,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
|||
}
|
||||
|
||||
let map = &self.tcx.hir();
|
||||
self.nest_tables(map.local_def_id(item.hir_id), |v| {
|
||||
self.nest_typeck_results(map.local_def_id(item.hir_id), |v| {
|
||||
v.visit_ty(&typ);
|
||||
if let &Some(ref trait_ref) = trait_ref {
|
||||
v.process_path(trait_ref.hir_ref_id, &hir::QPath::Resolved(None, &trait_ref.path));
|
||||
|
@ -859,7 +859,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
|||
match p.kind {
|
||||
hir::PatKind::Struct(ref _path, fields, _) => {
|
||||
// FIXME do something with _path?
|
||||
let adt = match self.save_ctxt.tables().node_type_opt(p.hir_id) {
|
||||
let adt = match self.save_ctxt.typeck_results().node_type_opt(p.hir_id) {
|
||||
Some(ty) if ty.ty_adt_def().is_some() => ty.ty_adt_def().unwrap(),
|
||||
_ => {
|
||||
intravisit::walk_pat(self, p);
|
||||
|
@ -900,7 +900,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
|||
Res::Local(hir_id) => {
|
||||
let typ = self
|
||||
.save_ctxt
|
||||
.tables()
|
||||
.typeck_results()
|
||||
.node_type_opt(hir_id)
|
||||
.map(|t| t.to_string())
|
||||
.unwrap_or_default();
|
||||
|
@ -1375,13 +1375,15 @@ impl<'tcx> Visitor<'tcx> for DumpVisitor<'tcx> {
|
|||
hir::TyKind::Array(ref ty, ref anon_const) => {
|
||||
self.visit_ty(ty);
|
||||
let map = self.tcx.hir();
|
||||
self.nest_tables(self.tcx.hir().local_def_id(anon_const.hir_id), |v| {
|
||||
self.nest_typeck_results(self.tcx.hir().local_def_id(anon_const.hir_id), |v| {
|
||||
v.visit_expr(&map.body(anon_const.body).value)
|
||||
});
|
||||
}
|
||||
hir::TyKind::OpaqueDef(item_id, _) => {
|
||||
let item = self.tcx.hir().item(item_id.id);
|
||||
self.nest_tables(self.tcx.hir().local_def_id(item_id.id), |v| v.visit_item(item));
|
||||
self.nest_typeck_results(self.tcx.hir().local_def_id(item_id.id), |v| {
|
||||
v.visit_item(item)
|
||||
});
|
||||
}
|
||||
_ => intravisit::walk_ty(self, t),
|
||||
}
|
||||
|
@ -1393,7 +1395,7 @@ impl<'tcx> Visitor<'tcx> for DumpVisitor<'tcx> {
|
|||
match ex.kind {
|
||||
hir::ExprKind::Struct(ref path, ref fields, ref base) => {
|
||||
let hir_expr = self.save_ctxt.tcx.hir().expect_expr(ex.hir_id);
|
||||
let adt = match self.save_ctxt.tables().expr_ty_opt(&hir_expr) {
|
||||
let adt = match self.save_ctxt.typeck_results().expr_ty_opt(&hir_expr) {
|
||||
Some(ty) if ty.ty_adt_def().is_some() => ty.ty_adt_def().unwrap(),
|
||||
_ => {
|
||||
intravisit::walk_expr(self, ex);
|
||||
|
@ -1430,7 +1432,7 @@ impl<'tcx> Visitor<'tcx> for DumpVisitor<'tcx> {
|
|||
|
||||
// walk the body
|
||||
let map = self.tcx.hir();
|
||||
self.nest_tables(self.tcx.hir().local_def_id(ex.hir_id), |v| {
|
||||
self.nest_typeck_results(self.tcx.hir().local_def_id(ex.hir_id), |v| {
|
||||
let body = map.body(body);
|
||||
v.process_formals(body.params, &id);
|
||||
v.visit_expr(&body.value)
|
||||
|
@ -1439,7 +1441,7 @@ impl<'tcx> Visitor<'tcx> for DumpVisitor<'tcx> {
|
|||
hir::ExprKind::Repeat(ref expr, ref anon_const) => {
|
||||
self.visit_expr(expr);
|
||||
let map = self.tcx.hir();
|
||||
self.nest_tables(self.tcx.hir().local_def_id(anon_const.hir_id), |v| {
|
||||
self.nest_typeck_results(self.tcx.hir().local_def_id(anon_const.hir_id), |v| {
|
||||
v.visit_expr(&map.body(anon_const.body).value)
|
||||
});
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ use log::{debug, error, info};
|
|||
|
||||
pub struct SaveContext<'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
maybe_typeck_tables: Option<&'tcx ty::TypeckTables<'tcx>>,
|
||||
maybe_typeck_results: Option<&'tcx ty::TypeckResults<'tcx>>,
|
||||
access_levels: &'tcx AccessLevels,
|
||||
span_utils: SpanUtils<'tcx>,
|
||||
config: Config,
|
||||
|
@ -65,12 +65,12 @@ pub enum Data {
|
|||
}
|
||||
|
||||
impl<'tcx> SaveContext<'tcx> {
|
||||
/// Gets the type-checking side-tables for the current body.
|
||||
/// Gets the type-checking results for the current body.
|
||||
/// As this will ICE if called outside bodies, only call when working with
|
||||
/// `Expr` or `Pat` nodes (they are guaranteed to be found only in bodies).
|
||||
#[track_caller]
|
||||
fn tables(&self) -> &'tcx ty::TypeckTables<'tcx> {
|
||||
self.maybe_typeck_tables.expect("`SaveContext::tables` called outside of body")
|
||||
fn typeck_results(&self) -> &'tcx ty::TypeckResults<'tcx> {
|
||||
self.maybe_typeck_results.expect("`SaveContext::typeck_results` called outside of body")
|
||||
}
|
||||
|
||||
fn span_from_span(&self, span: Span) -> SpanData {
|
||||
|
@ -483,7 +483,7 @@ impl<'tcx> SaveContext<'tcx> {
|
|||
None => {
|
||||
debug!("could not find container for method {} at {:?}", hir_id, span);
|
||||
// This is not necessarily a bug, if there was a compilation error,
|
||||
// the tables we need might not exist.
|
||||
// the typeck results we need might not exist.
|
||||
return None;
|
||||
}
|
||||
},
|
||||
|
@ -524,13 +524,13 @@ impl<'tcx> SaveContext<'tcx> {
|
|||
}
|
||||
|
||||
pub fn get_expr_data(&self, expr: &hir::Expr<'_>) -> Option<Data> {
|
||||
let ty = self.tables().expr_ty_adjusted_opt(expr)?;
|
||||
let ty = self.typeck_results().expr_ty_adjusted_opt(expr)?;
|
||||
if matches!(ty.kind, ty::Error(_)) {
|
||||
return None;
|
||||
}
|
||||
match expr.kind {
|
||||
hir::ExprKind::Field(ref sub_ex, ident) => {
|
||||
match self.tables().expr_ty_adjusted(&sub_ex).kind {
|
||||
match self.typeck_results().expr_ty_adjusted(&sub_ex).kind {
|
||||
ty::Adt(def, _) if !def.is_enum() => {
|
||||
let variant = &def.non_enum_variant();
|
||||
filter!(self.span_utils, ident.span);
|
||||
|
@ -575,7 +575,7 @@ impl<'tcx> SaveContext<'tcx> {
|
|||
}
|
||||
}
|
||||
hir::ExprKind::MethodCall(ref seg, ..) => {
|
||||
let method_id = match self.tables().type_dependent_def_id(expr.hir_id) {
|
||||
let method_id = match self.typeck_results().type_dependent_def_id(expr.hir_id) {
|
||||
Some(id) => id,
|
||||
None => {
|
||||
debug!("could not resolve method id for {:?}", expr);
|
||||
|
@ -624,7 +624,7 @@ impl<'tcx> SaveContext<'tcx> {
|
|||
},
|
||||
|
||||
Node::Expr(&hir::Expr { kind: hir::ExprKind::Struct(ref qpath, ..), .. }) => {
|
||||
self.tables().qpath_res(qpath, hir_id)
|
||||
self.typeck_results().qpath_res(qpath, hir_id)
|
||||
}
|
||||
|
||||
Node::Expr(&hir::Expr { kind: hir::ExprKind::Path(ref qpath), .. })
|
||||
|
@ -638,8 +638,8 @@ impl<'tcx> SaveContext<'tcx> {
|
|||
| Node::Ty(&hir::Ty { kind: hir::TyKind::Path(ref qpath), .. }) => match qpath {
|
||||
hir::QPath::Resolved(_, path) => path.res,
|
||||
hir::QPath::TypeRelative(..) => self
|
||||
.maybe_typeck_tables
|
||||
.map_or(Res::Err, |tables| tables.qpath_res(qpath, hir_id)),
|
||||
.maybe_typeck_results
|
||||
.map_or(Res::Err, |typeck_results| typeck_results.qpath_res(qpath, hir_id)),
|
||||
},
|
||||
|
||||
Node::Binding(&hir::Pat {
|
||||
|
@ -1010,7 +1010,7 @@ pub fn process_crate<'l, 'tcx, H: SaveHandler>(
|
|||
|
||||
let save_ctxt = SaveContext {
|
||||
tcx,
|
||||
maybe_typeck_tables: None,
|
||||
maybe_typeck_results: None,
|
||||
access_levels: &access_levels,
|
||||
span_utils: SpanUtils::new(&tcx.sess),
|
||||
config: find_config(config),
|
||||
|
|
|
@ -593,9 +593,9 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
|
||||
// Additional context information explaining why the closure only implements
|
||||
// a particular trait.
|
||||
if let Some(tables) = self.in_progress_tables {
|
||||
let tables = tables.borrow();
|
||||
match (found_kind, tables.closure_kind_origins().get(hir_id)) {
|
||||
if let Some(typeck_results) = self.in_progress_typeck_results {
|
||||
let typeck_results = typeck_results.borrow();
|
||||
match (found_kind, typeck_results.closure_kind_origins().get(hir_id)) {
|
||||
(ty::ClosureKind::FnOnce, Some((span, name))) => {
|
||||
err.span_label(
|
||||
*span,
|
||||
|
|
|
@ -18,7 +18,7 @@ use rustc_middle::ty::{
|
|||
self, suggest_constraining_type_param, AdtKind, DefIdTree, Infer, InferTy, ToPredicate, Ty,
|
||||
TyCtxt, TypeFoldable, WithConstness,
|
||||
};
|
||||
use rustc_middle::ty::{TypeAndMut, TypeckTables};
|
||||
use rustc_middle::ty::{TypeAndMut, TypeckResults};
|
||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||
use rustc_span::{MultiSpan, Span, DUMMY_SP};
|
||||
use std::fmt;
|
||||
|
@ -145,7 +145,7 @@ pub trait InferCtxtExt<'tcx> {
|
|||
outer_generator: Option<DefId>,
|
||||
trait_ref: ty::TraitRef<'tcx>,
|
||||
target_ty: Ty<'tcx>,
|
||||
tables: &ty::TypeckTables<'tcx>,
|
||||
typeck_results: &ty::TypeckResults<'tcx>,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
next_code: Option<&ObligationCauseCode<'tcx>>,
|
||||
);
|
||||
|
@ -968,12 +968,12 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
let mut visitor = ReturnsVisitor::default();
|
||||
visitor.visit_body(&body);
|
||||
|
||||
let tables = self.in_progress_tables.map(|t| t.borrow()).unwrap();
|
||||
let typeck_results = self.in_progress_typeck_results.map(|t| t.borrow()).unwrap();
|
||||
|
||||
let mut ret_types = visitor
|
||||
.returns
|
||||
.iter()
|
||||
.filter_map(|expr| tables.node_type_opt(expr.hir_id))
|
||||
.filter_map(|expr| typeck_results.node_type_opt(expr.hir_id))
|
||||
.map(|ty| self.resolve_vars_if_possible(&ty));
|
||||
let (last_ty, all_returns_have_same_type, only_never_return) = ret_types.clone().fold(
|
||||
(None, true, true),
|
||||
|
@ -1000,7 +1000,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
},
|
||||
);
|
||||
let all_returns_conform_to_trait =
|
||||
if let Some(ty_ret_ty) = tables.node_type_opt(ret_ty.hir_id) {
|
||||
if let Some(ty_ret_ty) = typeck_results.node_type_opt(ret_ty.hir_id) {
|
||||
match ty_ret_ty.kind {
|
||||
ty::Dynamic(predicates, _) => {
|
||||
let cause = ObligationCause::misc(ret_ty.span, ret_ty.hir_id);
|
||||
|
@ -1128,9 +1128,9 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
// Point at all the `return`s in the function as they have failed trait bounds.
|
||||
let mut visitor = ReturnsVisitor::default();
|
||||
visitor.visit_body(&body);
|
||||
let tables = self.in_progress_tables.map(|t| t.borrow()).unwrap();
|
||||
let typeck_results = self.in_progress_typeck_results.map(|t| t.borrow()).unwrap();
|
||||
for expr in &visitor.returns {
|
||||
if let Some(returned_ty) = tables.node_type_opt(expr.hir_id) {
|
||||
if let Some(returned_ty) = typeck_results.node_type_opt(expr.hir_id) {
|
||||
let ty = self.resolve_vars_if_possible(&returned_ty);
|
||||
err.span_label(expr.span, &format!("this returned value is of type `{}`", ty));
|
||||
}
|
||||
|
@ -1360,25 +1360,25 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
return false;
|
||||
}
|
||||
|
||||
// Get the tables from the infcx if the generator is the function we are
|
||||
// Get the typeck results from the infcx if the generator is the function we are
|
||||
// currently type-checking; otherwise, get them by performing a query.
|
||||
// This is needed to avoid cycles.
|
||||
let in_progress_tables = self.in_progress_tables.map(|t| t.borrow());
|
||||
let in_progress_typeck_results = self.in_progress_typeck_results.map(|t| t.borrow());
|
||||
let generator_did_root = self.tcx.closure_base_def_id(generator_did);
|
||||
debug!(
|
||||
"maybe_note_obligation_cause_for_async_await: generator_did={:?} \
|
||||
generator_did_root={:?} in_progress_tables.hir_owner={:?} span={:?}",
|
||||
generator_did_root={:?} in_progress_typeck_results.hir_owner={:?} span={:?}",
|
||||
generator_did,
|
||||
generator_did_root,
|
||||
in_progress_tables.as_ref().map(|t| t.hir_owner),
|
||||
in_progress_typeck_results.as_ref().map(|t| t.hir_owner),
|
||||
span
|
||||
);
|
||||
let query_tables;
|
||||
let tables: &TypeckTables<'tcx> = match &in_progress_tables {
|
||||
let query_typeck_results;
|
||||
let typeck_results: &TypeckResults<'tcx> = match &in_progress_typeck_results {
|
||||
Some(t) if t.hir_owner.to_def_id() == generator_did_root => t,
|
||||
_ => {
|
||||
query_tables = self.tcx.typeck_tables_of(generator_did.expect_local());
|
||||
&query_tables
|
||||
query_typeck_results = self.tcx.typeck(generator_did.expect_local());
|
||||
&query_typeck_results
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1425,7 +1425,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
|
||||
if let Some(upvars) = self.tcx.upvars_mentioned(generator_did) {
|
||||
interior_or_upvar_span = upvars.iter().find_map(|(upvar_id, upvar)| {
|
||||
let upvar_ty = tables.node_type(*upvar_id);
|
||||
let upvar_ty = typeck_results.node_type(*upvar_id);
|
||||
let upvar_ty = self.resolve_vars_if_possible(&upvar_ty);
|
||||
if ty_matches(&upvar_ty) {
|
||||
Some(GeneratorInteriorOrUpvar::Upvar(upvar.span))
|
||||
|
@ -1435,7 +1435,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
});
|
||||
};
|
||||
|
||||
tables
|
||||
typeck_results
|
||||
.generator_interior_types
|
||||
.iter()
|
||||
.find(|ty::GeneratorInteriorTypeCause { ty, .. }| ty_matches(ty))
|
||||
|
@ -1446,7 +1446,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
.into_iter()
|
||||
.map(|id| hir.expect_expr(id))
|
||||
.find(|await_expr| {
|
||||
let ty = tables.expr_ty_adjusted(&await_expr);
|
||||
let ty = typeck_results.expr_ty_adjusted(&await_expr);
|
||||
debug!(
|
||||
"maybe_note_obligation_cause_for_async_await: await_expr={:?}",
|
||||
await_expr
|
||||
|
@ -1464,7 +1464,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
debug!(
|
||||
"maybe_note_obligation_cause_for_async_await: interior_or_upvar={:?} \
|
||||
generator_interior_types={:?}",
|
||||
interior_or_upvar_span, tables.generator_interior_types
|
||||
interior_or_upvar_span, typeck_results.generator_interior_types
|
||||
);
|
||||
if let Some(interior_or_upvar_span) = interior_or_upvar_span {
|
||||
self.note_obligation_cause_for_async_await(
|
||||
|
@ -1475,7 +1475,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
outer_generator,
|
||||
trait_ref,
|
||||
target_ty,
|
||||
tables,
|
||||
typeck_results,
|
||||
obligation,
|
||||
next_code,
|
||||
);
|
||||
|
@ -1496,7 +1496,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
outer_generator: Option<DefId>,
|
||||
trait_ref: ty::TraitRef<'tcx>,
|
||||
target_ty: Ty<'tcx>,
|
||||
tables: &ty::TypeckTables<'tcx>,
|
||||
typeck_results: &ty::TypeckResults<'tcx>,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
next_code: Option<&ObligationCauseCode<'tcx>>,
|
||||
) {
|
||||
|
@ -1613,7 +1613,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
// Look at the last interior type to get a span for the `.await`.
|
||||
debug!(
|
||||
"note_obligation_cause_for_async_await generator_interior_types: {:#?}",
|
||||
tables.generator_interior_types
|
||||
typeck_results.generator_interior_types
|
||||
);
|
||||
explain_yield(interior_span, yield_span, scope_span);
|
||||
}
|
||||
|
@ -1634,7 +1634,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
// ^^^^^^^ a temporary `&T` created inside this method call due to `&self`
|
||||
// ```
|
||||
//
|
||||
let is_region_borrow = tables
|
||||
let is_region_borrow = typeck_results
|
||||
.expr_adjustments(expr)
|
||||
.iter()
|
||||
.any(|adj| adj.is_region_borrow());
|
||||
|
@ -1651,7 +1651,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
_ => false,
|
||||
};
|
||||
|
||||
if (tables.is_method_call(e) && is_region_borrow)
|
||||
if (typeck_results.is_method_call(e) && is_region_borrow)
|
||||
|| is_raw_borrow_inside_fn_like_call
|
||||
{
|
||||
err.span_help(
|
||||
|
|
|
@ -337,7 +337,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let mut inner_callee_path = None;
|
||||
let def = match callee.kind {
|
||||
hir::ExprKind::Path(ref qpath) => {
|
||||
self.tables.borrow().qpath_res(qpath, callee.hir_id)
|
||||
self.typeck_results.borrow().qpath_res(qpath, callee.hir_id)
|
||||
}
|
||||
hir::ExprKind::Call(ref inner_callee, _) => {
|
||||
// If the call spans more than one line and the callee kind is
|
||||
|
@ -355,7 +355,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
}
|
||||
if let hir::ExprKind::Path(ref inner_qpath) = inner_callee.kind {
|
||||
inner_callee_path = Some(inner_qpath);
|
||||
self.tables.borrow().qpath_res(inner_qpath, inner_callee.hir_id)
|
||||
self.typeck_results
|
||||
.borrow()
|
||||
.qpath_res(inner_qpath, inner_callee.hir_id)
|
||||
} else {
|
||||
Res::Err
|
||||
}
|
||||
|
|
|
@ -566,7 +566,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
|||
Ok(()) => {
|
||||
self.trivial_cast_lint(fcx);
|
||||
debug!(" -> CoercionCast");
|
||||
fcx.tables.borrow_mut().set_coercion_cast(self.expr.hir_id.local_id);
|
||||
fcx.typeck_results.borrow_mut().set_coercion_cast(self.expr.hir_id.local_id);
|
||||
}
|
||||
Err(ty::error::TypeError::ObjectUnsafeCoercion(did)) => {
|
||||
self.report_object_unsafe_cast(&fcx, did);
|
||||
|
|
|
@ -416,7 +416,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// Up till this point, we have ignored the annotations that the user
|
||||
// gave. This function will check that they unify successfully.
|
||||
// Along the way, it also writes out entries for types that the user
|
||||
// wrote into our tables, which are then later used by the privacy
|
||||
// wrote into our typeck results, which are then later used by the privacy
|
||||
// check.
|
||||
match self.check_supplied_sig_against_expectation(expr_def_id, decl, body, &closure_sigs) {
|
||||
Ok(infer_ok) => self.register_infer_ok_obligations(infer_ok),
|
||||
|
@ -588,7 +588,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
debug!("supplied_sig_of_closure: result={:?}", result);
|
||||
|
||||
let c_result = self.inh.infcx.canonicalize_response(&result);
|
||||
self.tables.borrow_mut().user_provided_sigs.insert(expr_def_id, c_result);
|
||||
self.typeck_results.borrow_mut().user_provided_sigs.insert(expr_def_id, c_result);
|
||||
|
||||
result
|
||||
}
|
||||
|
|
|
@ -1000,7 +1000,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// First try to coerce the new expression to the type of the previous ones,
|
||||
// but only if the new expression has no coercion already applied to it.
|
||||
let mut first_error = None;
|
||||
if !self.tables.borrow().adjustments().contains_key(new.hir_id) {
|
||||
if !self.typeck_results.borrow().adjustments().contains_key(new.hir_id) {
|
||||
let result = self.commit_if_ok(|_| coerce.coerce(new_ty, prev_ty));
|
||||
match result {
|
||||
Ok(ok) => {
|
||||
|
@ -1021,7 +1021,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// previous expressions, other than noop reborrows (ignoring lifetimes).
|
||||
for expr in exprs {
|
||||
let expr = expr.as_coercion_site();
|
||||
let noop = match self.tables.borrow().expr_adjustments(expr) {
|
||||
let noop = match self.typeck_results.borrow().expr_adjustments(expr) {
|
||||
&[Adjustment { kind: Adjust::Deref(_), .. }, Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(_, mutbl_adj)), .. }] =>
|
||||
{
|
||||
match self.node_ty(expr.hir_id).kind {
|
||||
|
|
|
@ -320,7 +320,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
_ => return None,
|
||||
};
|
||||
|
||||
let self_ty = self.tables.borrow().node_type(method_expr[0].hir_id);
|
||||
let self_ty = self.typeck_results.borrow().node_type(method_expr[0].hir_id);
|
||||
let self_ty = format!("{:?}", self_ty);
|
||||
let name = method_path.ident.name;
|
||||
let is_as_ref_able = (self_ty.starts_with("&std::option::Option")
|
||||
|
@ -466,10 +466,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let clone_trait = self.tcx.require_lang_item(CloneTraitLangItem, Some(sp));
|
||||
if let ([arg], Some(true), sym::clone) = (
|
||||
&args[..],
|
||||
self.tables.borrow().type_dependent_def_id(expr.hir_id).map(|did| {
|
||||
let ai = self.tcx.associated_item(did);
|
||||
ai.container == ty::TraitContainer(clone_trait)
|
||||
}),
|
||||
self.typeck_results.borrow().type_dependent_def_id(expr.hir_id).map(
|
||||
|did| {
|
||||
let ai = self.tcx.associated_item(did);
|
||||
ai.container == ty::TraitContainer(clone_trait)
|
||||
},
|
||||
),
|
||||
segment.ident.name,
|
||||
) {
|
||||
// If this expression had a clone call when suggesting borrowing
|
||||
|
|
|
@ -68,7 +68,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// coercions from ! to `expected`.
|
||||
if ty.is_never() {
|
||||
assert!(
|
||||
!self.tables.borrow().adjustments().contains_key(expr.hir_id),
|
||||
!self.typeck_results.borrow().adjustments().contains_key(expr.hir_id),
|
||||
"expression with never type wound up being adjusted"
|
||||
);
|
||||
let adj_ty = self.next_diverging_ty_var(TypeVariableOrigin {
|
||||
|
@ -430,7 +430,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// This is maybe too permissive, since it allows
|
||||
// `let u = &raw const Box::new((1,)).0`, which creates an
|
||||
// immediately dangling raw pointer.
|
||||
self.tables.borrow().adjustments().get(base.hir_id).map_or(false, |x| {
|
||||
self.typeck_results.borrow().adjustments().get(base.hir_id).map_or(false, |x| {
|
||||
x.iter().any(|adj| if let Adjust::Deref(_) = adj.kind { true } else { false })
|
||||
})
|
||||
});
|
||||
|
@ -509,7 +509,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
|
||||
// We always require that the type provided as the value for
|
||||
// a type parameter outlives the moment of instantiation.
|
||||
let substs = self.tables.borrow().node_substs(expr.hir_id);
|
||||
let substs = self.typeck_results.borrow().node_substs(expr.hir_id);
|
||||
self.add_wf_bounds(substs, expr);
|
||||
|
||||
ty
|
||||
|
@ -1123,7 +1123,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
})
|
||||
.collect();
|
||||
|
||||
self.tables
|
||||
self.typeck_results
|
||||
.borrow_mut()
|
||||
.fru_field_types_mut()
|
||||
.insert(expr.hir_id, fru_field_types);
|
||||
|
|
|
@ -190,8 +190,8 @@ pub fn resolve_interior<'a, 'tcx>(
|
|||
let type_list = fcx.tcx.mk_type_list(type_causes.iter().map(|cause| cause.ty));
|
||||
let witness = fcx.tcx.mk_generator_witness(ty::Binder::bind(type_list));
|
||||
|
||||
// Store the generator types and spans into the tables for this generator.
|
||||
visitor.fcx.inh.tables.borrow_mut().generator_interior_types = type_causes;
|
||||
// Store the generator types and spans into the typeck results for this generator.
|
||||
visitor.fcx.inh.typeck_results.borrow_mut().generator_interior_types = type_causes;
|
||||
|
||||
debug!(
|
||||
"types in generator after region replacement {:?}, span = {:?}",
|
||||
|
@ -222,7 +222,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> {
|
|||
|
||||
if let PatKind::Binding(..) = pat.kind {
|
||||
let scope = self.region_scope_tree.var_scope(pat.hir_id.local_id);
|
||||
let ty = self.fcx.tables.borrow().pat_ty(pat);
|
||||
let ty = self.fcx.typeck_results.borrow().pat_ty(pat);
|
||||
self.record(ty, Some(scope), None, pat.span);
|
||||
}
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> {
|
|||
match &expr.kind {
|
||||
ExprKind::Call(callee, args) => match &callee.kind {
|
||||
ExprKind::Path(qpath) => {
|
||||
let res = self.fcx.tables.borrow().qpath_res(qpath, callee.hir_id);
|
||||
let res = self.fcx.typeck_results.borrow().qpath_res(qpath, callee.hir_id);
|
||||
match res {
|
||||
// Direct calls never need to keep the callee `ty::FnDef`
|
||||
// ZST in a temporary, so skip its type, just in case it
|
||||
|
@ -263,7 +263,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> {
|
|||
|
||||
// If there are adjustments, then record the final type --
|
||||
// this is the actual value that is being produced.
|
||||
if let Some(adjusted_ty) = self.fcx.tables.borrow().expr_ty_adjusted_opt(expr) {
|
||||
if let Some(adjusted_ty) = self.fcx.typeck_results.borrow().expr_ty_adjusted_opt(expr) {
|
||||
self.record(adjusted_ty, scope, Some(expr), expr.span);
|
||||
}
|
||||
|
||||
|
@ -291,7 +291,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> {
|
|||
//
|
||||
// The type table might not have information for this expression
|
||||
// if it is in a malformed scope. (#66387)
|
||||
if let Some(ty) = self.fcx.tables.borrow().expr_ty_opt(expr) {
|
||||
if let Some(ty) = self.fcx.typeck_results.borrow().expr_ty_opt(expr) {
|
||||
self.record(ty, scope, Some(expr), expr.span);
|
||||
} else {
|
||||
self.fcx.tcx.sess.delay_span_bug(expr.span, "no type for node");
|
||||
|
|
|
@ -131,7 +131,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
|
|||
pick: &probe::Pick<'tcx>,
|
||||
) -> Ty<'tcx> {
|
||||
// Commit the autoderefs by calling `autoderef` again, but this
|
||||
// time writing the results into the various tables.
|
||||
// time writing the results into the various typeck results.
|
||||
let mut autoderef = self.autoderef(self.span, unadjusted_self_ty);
|
||||
let (_, n) = match autoderef.nth(pick.autoderefs) {
|
||||
Some(n) => n,
|
||||
|
|
|
@ -195,7 +195,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
|
||||
for import_id in &pick.import_ids {
|
||||
debug!("used_trait_import: {:?}", import_id);
|
||||
Lrc::get_mut(&mut self.tables.borrow_mut().used_trait_imports)
|
||||
Lrc::get_mut(&mut self.typeck_results.borrow_mut().used_trait_imports)
|
||||
.unwrap()
|
||||
.insert(*import_id);
|
||||
}
|
||||
|
@ -456,8 +456,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
)?;
|
||||
debug!("resolve_ufcs: pick={:?}", pick);
|
||||
{
|
||||
let mut tables = self.tables.borrow_mut();
|
||||
let used_trait_imports = Lrc::get_mut(&mut tables.used_trait_imports).unwrap();
|
||||
let mut typeck_results = self.typeck_results.borrow_mut();
|
||||
let used_trait_imports = Lrc::get_mut(&mut typeck_results.used_trait_imports).unwrap();
|
||||
for import_id in pick.import_ids {
|
||||
debug!("resolve_ufcs: used_trait_import: {:?}", import_id);
|
||||
used_trait_imports.insert(import_id);
|
||||
|
|
|
@ -1043,7 +1043,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
};
|
||||
// Obtain the span for `param` and use it for a structured suggestion.
|
||||
let mut suggested = false;
|
||||
if let (Some(ref param), Some(ref table)) = (param_type, self.in_progress_tables) {
|
||||
if let (Some(ref param), Some(ref table)) =
|
||||
(param_type, self.in_progress_typeck_results)
|
||||
{
|
||||
let table_owner = table.borrow().hir_owner;
|
||||
let generics = self.tcx.generics_of(table_owner.to_def_id());
|
||||
let type_param = generics.type_param(param, self.tcx);
|
||||
|
|
|
@ -51,7 +51,7 @@ and `fcx.expr_ty()` / `fcx.node_ty()` to write/obtain the types of
|
|||
nodes within the function.
|
||||
|
||||
The types of top-level items, which never contain unbound type
|
||||
variables, are stored directly into the `tcx` tables.
|
||||
variables, are stored directly into the `tcx` typeck_results.
|
||||
|
||||
N.B., a type variable is not the same thing as a type parameter. A
|
||||
type variable is rather an "instance" of a type parameter: that is,
|
||||
|
@ -182,24 +182,28 @@ pub struct LocalTy<'tcx> {
|
|||
revealed_ty: Ty<'tcx>,
|
||||
}
|
||||
|
||||
/// A wrapper for `InferCtxt`'s `in_progress_tables` field.
|
||||
/// A wrapper for `InferCtxt`'s `in_progress_typeck_results` field.
|
||||
#[derive(Copy, Clone)]
|
||||
struct MaybeInProgressTables<'a, 'tcx> {
|
||||
maybe_tables: Option<&'a RefCell<ty::TypeckTables<'tcx>>>,
|
||||
maybe_typeck_results: Option<&'a RefCell<ty::TypeckResults<'tcx>>>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> MaybeInProgressTables<'a, 'tcx> {
|
||||
fn borrow(self) -> Ref<'a, ty::TypeckTables<'tcx>> {
|
||||
match self.maybe_tables {
|
||||
Some(tables) => tables.borrow(),
|
||||
None => bug!("MaybeInProgressTables: inh/fcx.tables.borrow() with no tables"),
|
||||
fn borrow(self) -> Ref<'a, ty::TypeckResults<'tcx>> {
|
||||
match self.maybe_typeck_results {
|
||||
Some(typeck_results) => typeck_results.borrow(),
|
||||
None => bug!(
|
||||
"MaybeInProgressTables: inh/fcx.typeck_results.borrow() with no typeck results"
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
fn borrow_mut(self) -> RefMut<'a, ty::TypeckTables<'tcx>> {
|
||||
match self.maybe_tables {
|
||||
Some(tables) => tables.borrow_mut(),
|
||||
None => bug!("MaybeInProgressTables: inh/fcx.tables.borrow_mut() with no tables"),
|
||||
fn borrow_mut(self) -> RefMut<'a, ty::TypeckResults<'tcx>> {
|
||||
match self.maybe_typeck_results {
|
||||
Some(typeck_results) => typeck_results.borrow_mut(),
|
||||
None => bug!(
|
||||
"MaybeInProgressTables: inh/fcx.typeck_results.borrow_mut() with no typeck results"
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -216,7 +220,7 @@ impl<'a, 'tcx> MaybeInProgressTables<'a, 'tcx> {
|
|||
pub struct Inherited<'a, 'tcx> {
|
||||
infcx: InferCtxt<'a, 'tcx>,
|
||||
|
||||
tables: MaybeInProgressTables<'a, 'tcx>,
|
||||
typeck_results: MaybeInProgressTables<'a, 'tcx>,
|
||||
|
||||
locals: RefCell<HirIdMap<LocalTy<'tcx>>>,
|
||||
|
||||
|
@ -645,7 +649,7 @@ impl Inherited<'_, 'tcx> {
|
|||
let hir_owner = tcx.hir().local_def_id_to_hir_id(def_id).owner;
|
||||
|
||||
InheritedBuilder {
|
||||
infcx: tcx.infer_ctxt().with_fresh_in_progress_tables(hir_owner),
|
||||
infcx: tcx.infer_ctxt().with_fresh_in_progress_typeck_results(hir_owner),
|
||||
def_id,
|
||||
}
|
||||
}
|
||||
|
@ -668,7 +672,9 @@ impl Inherited<'a, 'tcx> {
|
|||
let body_id = tcx.hir().maybe_body_owned_by(item_id);
|
||||
|
||||
Inherited {
|
||||
tables: MaybeInProgressTables { maybe_tables: infcx.in_progress_tables },
|
||||
typeck_results: MaybeInProgressTables {
|
||||
maybe_typeck_results: infcx.in_progress_typeck_results,
|
||||
},
|
||||
infcx,
|
||||
fulfillment_cx: RefCell::new(TraitEngine::new(tcx)),
|
||||
locals: RefCell::new(Default::default()),
|
||||
|
@ -744,7 +750,7 @@ fn check_mod_item_types(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
|
|||
fn typeck_item_bodies(tcx: TyCtxt<'_>, crate_num: CrateNum) {
|
||||
debug_assert!(crate_num == LOCAL_CRATE);
|
||||
tcx.par_body_owners(|body_owner_def_id| {
|
||||
tcx.ensure().typeck_tables_of(body_owner_def_id);
|
||||
tcx.ensure().typeck(body_owner_def_id);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -764,10 +770,10 @@ pub fn provide(providers: &mut Providers) {
|
|||
method::provide(providers);
|
||||
*providers = Providers {
|
||||
typeck_item_bodies,
|
||||
typeck_tables_of_const_arg,
|
||||
typeck_tables_of,
|
||||
diagnostic_only_typeck_tables_of,
|
||||
has_typeck_tables,
|
||||
typeck_const_arg,
|
||||
typeck,
|
||||
diagnostic_only_typeck,
|
||||
has_typeck_results,
|
||||
adt_destructor,
|
||||
used_trait_imports,
|
||||
check_item_well_formed,
|
||||
|
@ -787,10 +793,10 @@ fn adt_destructor(tcx: TyCtxt<'_>, def_id: DefId) -> Option<ty::Destructor> {
|
|||
/// it's body-id, fn-header and fn-decl (if any). Otherwise,
|
||||
/// returns `None`.
|
||||
///
|
||||
/// If this function returns `Some`, then `typeck_tables(def_id)` will
|
||||
/// succeed; if it returns `None`, then `typeck_tables(def_id)` may or
|
||||
/// If this function returns `Some`, then `typeck_results(def_id)` will
|
||||
/// succeed; if it returns `None`, then `typeck_results(def_id)` may or
|
||||
/// may not succeed. In some cases where this function returns `None`
|
||||
/// (notably closures), `typeck_tables(def_id)` would wind up
|
||||
/// (notably closures), `typeck_results(def_id)` would wind up
|
||||
/// redirecting to the owning function.
|
||||
fn primary_body_of(
|
||||
tcx: TyCtxt<'_>,
|
||||
|
@ -825,12 +831,12 @@ fn primary_body_of(
|
|||
}
|
||||
}
|
||||
|
||||
fn has_typeck_tables(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
|
||||
// Closures' tables come from their outermost function,
|
||||
fn has_typeck_results(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
|
||||
// Closures' typeck results come from their outermost function,
|
||||
// as they are part of the same "inference environment".
|
||||
let outer_def_id = tcx.closure_base_def_id(def_id);
|
||||
if outer_def_id != def_id {
|
||||
return tcx.has_typeck_tables(outer_def_id);
|
||||
return tcx.has_typeck_results(outer_def_id);
|
||||
}
|
||||
|
||||
if let Some(def_id) = def_id.as_local() {
|
||||
|
@ -842,7 +848,7 @@ fn has_typeck_tables(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
|
|||
}
|
||||
|
||||
fn used_trait_imports(tcx: TyCtxt<'_>, def_id: LocalDefId) -> &FxHashSet<LocalDefId> {
|
||||
&*tcx.typeck_tables_of(def_id).used_trait_imports
|
||||
&*tcx.typeck(def_id).used_trait_imports
|
||||
}
|
||||
|
||||
/// Inspects the substs of opaque types, replacing any inference variables
|
||||
|
@ -956,46 +962,43 @@ where
|
|||
val.fold_with(&mut FixupFolder { tcx })
|
||||
}
|
||||
|
||||
fn typeck_tables_of_const_arg<'tcx>(
|
||||
fn typeck_const_arg<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
(did, param_did): (LocalDefId, DefId),
|
||||
) -> &ty::TypeckTables<'tcx> {
|
||||
) -> &ty::TypeckResults<'tcx> {
|
||||
let fallback = move || tcx.type_of(param_did);
|
||||
typeck_tables_of_with_fallback(tcx, did, fallback)
|
||||
typeck_with_fallback(tcx, did, fallback)
|
||||
}
|
||||
|
||||
fn typeck_tables_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &ty::TypeckTables<'tcx> {
|
||||
fn typeck<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &ty::TypeckResults<'tcx> {
|
||||
if let Some(param_did) = tcx.opt_const_param_of(def_id) {
|
||||
tcx.typeck_tables_of_const_arg((def_id, param_did))
|
||||
tcx.typeck_const_arg((def_id, param_did))
|
||||
} else {
|
||||
let fallback = move || tcx.type_of(def_id.to_def_id());
|
||||
typeck_tables_of_with_fallback(tcx, def_id, fallback)
|
||||
typeck_with_fallback(tcx, def_id, fallback)
|
||||
}
|
||||
}
|
||||
|
||||
/// Used only to get `TypeckTables` for type inference during error recovery.
|
||||
/// Used only to get `TypeckResults` for type inference during error recovery.
|
||||
/// Currently only used for type inference of `static`s and `const`s to avoid type cycle errors.
|
||||
fn diagnostic_only_typeck_tables_of<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
def_id: LocalDefId,
|
||||
) -> &ty::TypeckTables<'tcx> {
|
||||
fn diagnostic_only_typeck<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &ty::TypeckResults<'tcx> {
|
||||
let fallback = move || {
|
||||
let span = tcx.hir().span(tcx.hir().as_local_hir_id(def_id));
|
||||
tcx.ty_error_with_message(span, "diagnostic only typeck table used")
|
||||
};
|
||||
typeck_tables_of_with_fallback(tcx, def_id, fallback)
|
||||
typeck_with_fallback(tcx, def_id, fallback)
|
||||
}
|
||||
|
||||
fn typeck_tables_of_with_fallback<'tcx>(
|
||||
fn typeck_with_fallback<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
def_id: LocalDefId,
|
||||
fallback: impl Fn() -> Ty<'tcx> + 'tcx,
|
||||
) -> &'tcx ty::TypeckTables<'tcx> {
|
||||
// Closures' tables come from their outermost function,
|
||||
) -> &'tcx ty::TypeckResults<'tcx> {
|
||||
// Closures' typeck results come from their outermost function,
|
||||
// as they are part of the same "inference environment".
|
||||
let outer_def_id = tcx.closure_base_def_id(def_id.to_def_id()).expect_local();
|
||||
if outer_def_id != def_id {
|
||||
return tcx.typeck_tables_of(outer_def_id);
|
||||
return tcx.typeck(outer_def_id);
|
||||
}
|
||||
|
||||
let id = tcx.hir().as_local_hir_id(def_id);
|
||||
|
@ -1007,7 +1010,7 @@ fn typeck_tables_of_with_fallback<'tcx>(
|
|||
});
|
||||
let body = tcx.hir().body(body_id);
|
||||
|
||||
let tables = Inherited::build(tcx, def_id).enter(|inh| {
|
||||
let typeck_results = Inherited::build(tcx, def_id).enter(|inh| {
|
||||
let param_env = tcx.param_env(def_id);
|
||||
let fcx = if let (Some(header), Some(decl)) = (fn_header, fn_decl) {
|
||||
let fn_sig = if crate::collect::get_infer_ret_ty(&decl.output).is_some() {
|
||||
|
@ -1137,11 +1140,11 @@ fn typeck_tables_of_with_fallback<'tcx>(
|
|||
fcx.resolve_type_vars_in_body(body)
|
||||
});
|
||||
|
||||
// Consistency check our TypeckTables instance can hold all ItemLocalIds
|
||||
// Consistency check our TypeckResults instance can hold all ItemLocalIds
|
||||
// it will need to hold.
|
||||
assert_eq!(tables.hir_owner, id.owner);
|
||||
assert_eq!(typeck_results.hir_owner, id.owner);
|
||||
|
||||
tables
|
||||
typeck_results
|
||||
}
|
||||
|
||||
fn check_abi(tcx: TyCtxt<'_>, span: Span, abi: Abi) {
|
||||
|
@ -1214,7 +1217,11 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> {
|
|||
"visit_local: ty.hir_id={:?} o_ty={:?} revealed_ty={:?} c_ty={:?}",
|
||||
ty.hir_id, o_ty, revealed_ty, c_ty
|
||||
);
|
||||
self.fcx.tables.borrow_mut().user_provided_types_mut().insert(ty.hir_id, c_ty);
|
||||
self.fcx
|
||||
.typeck_results
|
||||
.borrow_mut()
|
||||
.user_provided_types_mut()
|
||||
.insert(ty.hir_id, c_ty);
|
||||
|
||||
Some(LocalTy { decl_ty: o_ty, revealed_ty })
|
||||
}
|
||||
|
@ -1369,7 +1376,7 @@ fn check_fn<'a, 'tcx>(
|
|||
fcx.write_ty(param.hir_id, param_ty);
|
||||
}
|
||||
|
||||
inherited.tables.borrow_mut().liberated_fn_sigs_mut().insert(fn_id, fn_sig);
|
||||
inherited.typeck_results.borrow_mut().liberated_fn_sigs_mut().insert(fn_id, fn_sig);
|
||||
|
||||
if let ty::Dynamic(..) = declared_ret_ty.kind {
|
||||
// FIXME: We need to verify that the return type is `Sized` after the return expression has
|
||||
|
@ -1758,17 +1765,17 @@ fn opaque_type_cycle_error(tcx: TyCtxt<'tcx>, def_id: LocalDefId, span: Span) {
|
|||
|
||||
let mut label = false;
|
||||
if let Some((hir_id, visitor)) = get_owner_return_paths(tcx, def_id) {
|
||||
let tables = tcx.typeck_tables_of(tcx.hir().local_def_id(hir_id));
|
||||
let typeck_results = tcx.typeck(tcx.hir().local_def_id(hir_id));
|
||||
if visitor
|
||||
.returns
|
||||
.iter()
|
||||
.filter_map(|expr| tables.node_type_opt(expr.hir_id))
|
||||
.filter_map(|expr| typeck_results.node_type_opt(expr.hir_id))
|
||||
.all(|ty| matches!(ty.kind, ty::Never))
|
||||
{
|
||||
let spans = visitor
|
||||
.returns
|
||||
.iter()
|
||||
.filter(|expr| tables.node_type_opt(expr.hir_id).is_some())
|
||||
.filter(|expr| typeck_results.node_type_opt(expr.hir_id).is_some())
|
||||
.map(|expr| expr.span)
|
||||
.collect::<Vec<Span>>();
|
||||
let span_len = spans.len();
|
||||
|
@ -1791,7 +1798,7 @@ fn opaque_type_cycle_error(tcx: TyCtxt<'tcx>, def_id: LocalDefId, span: Span) {
|
|||
for (sp, ty) in visitor
|
||||
.returns
|
||||
.iter()
|
||||
.filter_map(|e| tables.node_type_opt(e.hir_id).map(|t| (e.span, t)))
|
||||
.filter_map(|e| typeck_results.node_type_opt(e.hir_id).map(|t| (e.span, t)))
|
||||
.filter(|(_, ty)| !matches!(ty.kind, ty::Never))
|
||||
{
|
||||
struct VisitTypes(Vec<DefId>);
|
||||
|
@ -1861,9 +1868,9 @@ fn binding_opaque_type_cycle_error(
|
|||
..
|
||||
}) => {
|
||||
let hir_id = tcx.hir().as_local_hir_id(def_id);
|
||||
let tables =
|
||||
tcx.typeck_tables_of(tcx.hir().local_def_id(tcx.hir().get_parent_item(hir_id)));
|
||||
if let Some(ty) = tables.node_type_opt(expr.hir_id) {
|
||||
let typeck_results =
|
||||
tcx.typeck(tcx.hir().local_def_id(tcx.hir().get_parent_item(hir_id)));
|
||||
if let Some(ty) = typeck_results.node_type_opt(expr.hir_id) {
|
||||
err.span_label(
|
||||
expr.span,
|
||||
&format!(
|
||||
|
@ -1931,11 +1938,11 @@ pub fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, it: &'tcx hir::Item<'tcx>) {
|
|||
// Consts can play a role in type-checking, so they are included here.
|
||||
hir::ItemKind::Static(..) => {
|
||||
let def_id = tcx.hir().local_def_id(it.hir_id);
|
||||
tcx.ensure().typeck_tables_of(def_id);
|
||||
tcx.ensure().typeck(def_id);
|
||||
maybe_check_static_with_link_section(tcx, def_id, it.span);
|
||||
}
|
||||
hir::ItemKind::Const(..) => {
|
||||
tcx.ensure().typeck_tables_of(tcx.hir().local_def_id(it.hir_id));
|
||||
tcx.ensure().typeck(tcx.hir().local_def_id(it.hir_id));
|
||||
}
|
||||
hir::ItemKind::Enum(ref enum_definition, _) => {
|
||||
check_enum(tcx, it.span, &enum_definition.variants, it.hir_id);
|
||||
|
@ -2843,7 +2850,7 @@ pub fn check_enum<'tcx>(
|
|||
|
||||
for v in vs {
|
||||
if let Some(ref e) = v.disr_expr {
|
||||
tcx.ensure().typeck_tables_of(tcx.hir().local_def_id(e.hir_id));
|
||||
tcx.ensure().typeck(tcx.hir().local_def_id(e.hir_id));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3212,7 +3219,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
self.resolve_vars_if_possible(&ty),
|
||||
self.tag()
|
||||
);
|
||||
self.tables.borrow_mut().node_types_mut().insert(id, ty);
|
||||
self.typeck_results.borrow_mut().node_types_mut().insert(id, ty);
|
||||
|
||||
if ty.references_error() {
|
||||
self.has_errors.set(true);
|
||||
|
@ -3221,11 +3228,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
}
|
||||
|
||||
pub fn write_field_index(&self, hir_id: hir::HirId, index: usize) {
|
||||
self.tables.borrow_mut().field_indices_mut().insert(hir_id, index);
|
||||
self.typeck_results.borrow_mut().field_indices_mut().insert(hir_id, index);
|
||||
}
|
||||
|
||||
fn write_resolution(&self, hir_id: hir::HirId, r: Result<(DefKind, DefId), ErrorReported>) {
|
||||
self.tables.borrow_mut().type_dependent_defs_mut().insert(hir_id, r);
|
||||
self.typeck_results.borrow_mut().type_dependent_defs_mut().insert(hir_id, r);
|
||||
}
|
||||
|
||||
pub fn write_method_call(&self, hir_id: hir::HirId, method: MethodCallee<'tcx>) {
|
||||
|
@ -3279,7 +3286,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
if !substs.is_noop() {
|
||||
debug!("write_substs({:?}, {:?}) in fcx {}", node_id, substs, self.tag());
|
||||
|
||||
self.tables.borrow_mut().node_substs_mut().insert(node_id, substs);
|
||||
self.typeck_results.borrow_mut().node_substs_mut().insert(node_id, substs);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3330,7 +3337,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
);
|
||||
|
||||
if !canonical_user_type_annotation.is_identity() {
|
||||
self.tables
|
||||
self.typeck_results
|
||||
.borrow_mut()
|
||||
.user_provided_types_mut()
|
||||
.insert(hir_id, canonical_user_type_annotation);
|
||||
|
@ -3353,7 +3360,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
})
|
||||
});
|
||||
|
||||
match self.tables.borrow_mut().adjustments_mut().entry(expr.hir_id) {
|
||||
match self.typeck_results.borrow_mut().adjustments_mut().entry(expr.hir_id) {
|
||||
Entry::Vacant(entry) => {
|
||||
entry.insert(adj);
|
||||
}
|
||||
|
@ -3538,7 +3545,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
if Self::can_contain_user_lifetime_bounds(ty) {
|
||||
let c_ty = self.infcx.canonicalize_response(&UserType::Ty(ty));
|
||||
debug!("to_ty_saving_user_provided_ty: c_ty={:?}", c_ty);
|
||||
self.tables.borrow_mut().user_provided_types_mut().insert(ast_ty.hir_id, c_ty);
|
||||
self.typeck_results.borrow_mut().user_provided_types_mut().insert(ast_ty.hir_id, c_ty);
|
||||
}
|
||||
|
||||
ty
|
||||
|
@ -3588,7 +3595,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
}
|
||||
|
||||
pub fn node_ty(&self, id: hir::HirId) -> Ty<'tcx> {
|
||||
match self.tables.borrow().node_types().get(id) {
|
||||
match self.typeck_results.borrow().node_types().get(id) {
|
||||
Some(&t) => t,
|
||||
None if self.is_tainted_by_errors() => self.tcx.ty_error(),
|
||||
None => {
|
||||
|
@ -4527,7 +4534,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
}
|
||||
QPath::TypeRelative(ref qself, ref segment) => (self.to_ty(qself), qself, segment),
|
||||
};
|
||||
if let Some(&cached_result) = self.tables.borrow().type_dependent_defs().get(hir_id) {
|
||||
if let Some(&cached_result) = self.typeck_results.borrow().type_dependent_defs().get(hir_id)
|
||||
{
|
||||
// Return directly on cache hit. This is useful to avoid doubly reporting
|
||||
// errors with default match binding modes. See #44614.
|
||||
let def =
|
||||
|
@ -4701,8 +4709,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let arm_spans: Vec<Span> = arms
|
||||
.iter()
|
||||
.filter_map(|arm| {
|
||||
self.in_progress_tables
|
||||
.and_then(|tables| tables.borrow().node_type_opt(arm.body.hir_id))
|
||||
self.in_progress_typeck_results
|
||||
.and_then(|typeck_results| {
|
||||
typeck_results.borrow().node_type_opt(arm.body.hir_id)
|
||||
})
|
||||
.and_then(|arm_ty| {
|
||||
if arm_ty.is_never() {
|
||||
None
|
||||
|
|
|
@ -240,7 +240,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// some cases applied on the RHS, on top of which we need
|
||||
// to autoref, which is not allowed by apply_adjustments.
|
||||
// self.apply_adjustments(rhs_expr, vec![autoref]);
|
||||
self.tables
|
||||
self.typeck_results
|
||||
.borrow_mut()
|
||||
.adjustments_mut()
|
||||
.entry(rhs_expr.hir_id)
|
||||
|
@ -496,14 +496,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
err.span_label(span, ty.to_string());
|
||||
if let FnDef(def_id, _) = ty.kind {
|
||||
let source_map = self.tcx.sess.source_map();
|
||||
if !self.tcx.has_typeck_tables(def_id) {
|
||||
if !self.tcx.has_typeck_results(def_id) {
|
||||
return false;
|
||||
}
|
||||
// We're emitting a suggestion, so we can just ignore regions
|
||||
let fn_sig = self.tcx.fn_sig(def_id).skip_binder();
|
||||
|
||||
let other_ty = if let FnDef(def_id, _) = other_ty.kind {
|
||||
if !self.tcx.has_typeck_tables(def_id) {
|
||||
if !self.tcx.has_typeck_results(def_id) {
|
||||
return false;
|
||||
}
|
||||
// We're emitting a suggestion, so we can just ignore regions
|
||||
|
|
|
@ -363,7 +363,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
|
||||
if !pat_adjustments.is_empty() {
|
||||
debug!("default binding mode is now {:?}", def_bm);
|
||||
self.inh.tables.borrow_mut().pat_adjustments_mut().insert(pat.hir_id, pat_adjustments);
|
||||
self.inh
|
||||
.typeck_results
|
||||
.borrow_mut()
|
||||
.pat_adjustments_mut()
|
||||
.insert(pat.hir_id, pat_adjustments);
|
||||
}
|
||||
|
||||
(expected, def_bm)
|
||||
|
@ -534,7 +538,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
_ => BindingMode::convert(ba),
|
||||
};
|
||||
// ...and store it in a side table:
|
||||
self.inh.tables.borrow_mut().pat_binding_modes_mut().insert(pat.hir_id, bm);
|
||||
self.inh.typeck_results.borrow_mut().pat_binding_modes_mut().insert(pat.hir_id, bm);
|
||||
|
||||
debug!("check_pat_ident: pat.hir_id={:?} bm={:?}", pat.hir_id, bm);
|
||||
|
||||
|
|
|
@ -221,9 +221,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let mut source = self.node_ty(expr.hir_id);
|
||||
// Do not mutate adjustments in place, but rather take them,
|
||||
// and replace them after mutating them, to avoid having the
|
||||
// tables borrowed during (`deref_mut`) method resolution.
|
||||
// typeck results borrowed during (`deref_mut`) method resolution.
|
||||
let previous_adjustments =
|
||||
self.tables.borrow_mut().adjustments_mut().remove(expr.hir_id);
|
||||
self.typeck_results.borrow_mut().adjustments_mut().remove(expr.hir_id);
|
||||
if let Some(mut adjustments) = previous_adjustments {
|
||||
for adjustment in &mut adjustments {
|
||||
if let Adjust::Deref(Some(ref mut deref)) = adjustment.kind {
|
||||
|
@ -241,14 +241,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
}
|
||||
source = adjustment.target;
|
||||
}
|
||||
self.tables.borrow_mut().adjustments_mut().insert(expr.hir_id, adjustments);
|
||||
self.typeck_results.borrow_mut().adjustments_mut().insert(expr.hir_id, adjustments);
|
||||
}
|
||||
|
||||
match expr.kind {
|
||||
hir::ExprKind::Index(ref base_expr, ref index_expr) => {
|
||||
// We need to get the final type in case dereferences were needed for the trait
|
||||
// to apply (#72002).
|
||||
let index_expr_ty = self.tables.borrow().expr_ty_adjusted(index_expr);
|
||||
let index_expr_ty = self.typeck_results.borrow().expr_ty_adjusted(index_expr);
|
||||
self.convert_place_op_to_mutable(
|
||||
PlaceOp::Index,
|
||||
expr,
|
||||
|
@ -272,14 +272,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
arg_tys: &[Ty<'tcx>],
|
||||
) {
|
||||
debug!("convert_place_op_to_mutable({:?}, {:?}, {:?}, {:?})", op, expr, base_expr, arg_tys);
|
||||
if !self.tables.borrow().is_method_call(expr) {
|
||||
if !self.typeck_results.borrow().is_method_call(expr) {
|
||||
debug!("convert_place_op_to_mutable - builtin, nothing to do");
|
||||
return;
|
||||
}
|
||||
|
||||
// Need to deref because overloaded place ops take self by-reference.
|
||||
let base_ty = self
|
||||
.tables
|
||||
.typeck_results
|
||||
.borrow()
|
||||
.expr_ty_adjusted(base_expr)
|
||||
.builtin_deref(false)
|
||||
|
@ -306,7 +306,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// region and mutability.
|
||||
let base_expr_ty = self.node_ty(base_expr.hir_id);
|
||||
if let Some(adjustments) =
|
||||
self.tables.borrow_mut().adjustments_mut().get_mut(base_expr.hir_id)
|
||||
self.typeck_results.borrow_mut().adjustments_mut().get_mut(base_expr.hir_id)
|
||||
{
|
||||
let mut source = base_expr_ty;
|
||||
for adjustment in &mut adjustments[..] {
|
||||
|
|
|
@ -263,7 +263,7 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> {
|
|||
self.body_owner = self.tcx.hir().body_owner_def_id(body_id);
|
||||
|
||||
let fn_sig = {
|
||||
match self.tables.borrow().liberated_fn_sigs().get(id) {
|
||||
match self.typeck_results.borrow().liberated_fn_sigs().get(id) {
|
||||
Some(f) => *f,
|
||||
None => {
|
||||
bug!("No fn-sig entry for id={:?}", id);
|
||||
|
@ -433,7 +433,7 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> {
|
|||
&self.infcx,
|
||||
self.outlives_environment.param_env,
|
||||
self.body_owner,
|
||||
&self.tables.borrow(),
|
||||
&self.typeck_results.borrow(),
|
||||
))
|
||||
}
|
||||
|
||||
|
@ -447,8 +447,8 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> {
|
|||
|
||||
let mut place = self.with_mc(|mc| mc.cat_expr_unadjusted(expr))?;
|
||||
|
||||
let tables = self.tables.borrow();
|
||||
let adjustments = tables.expr_adjustments(&expr);
|
||||
let typeck_results = self.typeck_results.borrow();
|
||||
let adjustments = typeck_results.expr_adjustments(&expr);
|
||||
if adjustments.is_empty() {
|
||||
return Ok(place);
|
||||
}
|
||||
|
@ -580,7 +580,7 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> {
|
|||
// `ref x` pattern
|
||||
if let PatKind::Binding(..) = kind {
|
||||
if let Some(ty::BindByReference(mutbl)) =
|
||||
mc.tables.extract_binding_mode(self.tcx.sess, *hir_id, *span)
|
||||
mc.typeck_results.extract_binding_mode(self.tcx.sess, *hir_id, *span)
|
||||
{
|
||||
self.link_region_from_node_type(*span, *hir_id, mutbl, &sub_cmt);
|
||||
}
|
||||
|
@ -773,7 +773,7 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> {
|
|||
debug!("link_upvar_region(borrorw_region={:?}, upvar_id={:?}", borrow_region, upvar_id);
|
||||
// A by-reference upvar can't be borrowed for longer than the
|
||||
// upvar is borrowed from the environment.
|
||||
match self.tables.borrow().upvar_capture(upvar_id) {
|
||||
match self.typeck_results.borrow().upvar_capture(upvar_id) {
|
||||
ty::UpvarCapture::ByRef(upvar_borrow) => {
|
||||
self.sub_regions(
|
||||
infer::ReborrowUpvar(span, upvar_id),
|
||||
|
|
|
@ -135,13 +135,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
}
|
||||
};
|
||||
|
||||
self.tables.borrow_mut().upvar_capture_map.insert(upvar_id, capture_kind);
|
||||
self.typeck_results.borrow_mut().upvar_capture_map.insert(upvar_id, capture_kind);
|
||||
}
|
||||
// Add the vector of upvars to the map keyed with the closure id.
|
||||
// This gives us an easier access to them without having to call
|
||||
// tcx.upvars again..
|
||||
if !closure_captures.is_empty() {
|
||||
self.tables.borrow_mut().closure_captures.insert(closure_def_id, closure_captures);
|
||||
self.typeck_results
|
||||
.borrow_mut()
|
||||
.closure_captures
|
||||
.insert(closure_def_id, closure_captures);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -159,7 +162,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
&self.infcx,
|
||||
body_owner_def_id,
|
||||
self.param_env,
|
||||
&self.tables.borrow(),
|
||||
&self.typeck_results.borrow(),
|
||||
)
|
||||
.consume_body(body);
|
||||
|
||||
|
@ -172,11 +175,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
|
||||
// If we have an origin, store it.
|
||||
if let Some(origin) = delegate.current_origin {
|
||||
self.tables.borrow_mut().closure_kind_origins_mut().insert(closure_hir_id, origin);
|
||||
self.typeck_results
|
||||
.borrow_mut()
|
||||
.closure_kind_origins_mut()
|
||||
.insert(closure_hir_id, origin);
|
||||
}
|
||||
}
|
||||
|
||||
self.tables.borrow_mut().upvar_capture_map.extend(delegate.adjust_upvar_captures);
|
||||
self.typeck_results.borrow_mut().upvar_capture_map.extend(delegate.adjust_upvar_captures);
|
||||
|
||||
// Now that we've analyzed the closure, we know how each
|
||||
// variable is borrowed, and we know what traits the closure
|
||||
|
@ -227,7 +233,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
var_path: ty::UpvarPath { hir_id: var_hir_id },
|
||||
closure_expr_id: closure_def_id,
|
||||
};
|
||||
let capture = self.tables.borrow().upvar_capture(upvar_id);
|
||||
let capture = self.typeck_results.borrow().upvar_capture(upvar_id);
|
||||
|
||||
debug!("var_id={:?} upvar_ty={:?} capture={:?}", var_hir_id, upvar_ty, capture);
|
||||
|
||||
|
@ -392,7 +398,7 @@ impl<'a, 'tcx> InferBorrowKind<'a, 'tcx> {
|
|||
.adjust_upvar_captures
|
||||
.get(&upvar_id)
|
||||
.copied()
|
||||
.unwrap_or_else(|| self.fcx.tables.borrow().upvar_capture(upvar_id));
|
||||
.unwrap_or_else(|| self.fcx.typeck_results.borrow().upvar_capture(upvar_id));
|
||||
debug!(
|
||||
"adjust_upvar_borrow_kind(upvar_id={:?}, upvar_capture={:?}, kind={:?})",
|
||||
upvar_id, upvar_capture, kind
|
||||
|
|
|
@ -23,10 +23,10 @@ use std::mem;
|
|||
|
||||
// During type inference, partially inferred types are
|
||||
// represented using Type variables (ty::Infer). These don't appear in
|
||||
// the final TypeckTables since all of the types should have been
|
||||
// inferred once typeck_tables_of is done.
|
||||
// the final TypeckResults since all of the types should have been
|
||||
// inferred once typeck is done.
|
||||
// When type inference is running however, having to update the typeck
|
||||
// tables every time a new type is inferred would be unreasonably slow,
|
||||
// typeck results every time a new type is inferred would be unreasonably slow,
|
||||
// so instead all of the replacement happens at the end in
|
||||
// resolve_type_vars_in_body, which creates a new TypeTables which
|
||||
// doesn't contain any inference types.
|
||||
|
@ -34,7 +34,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
pub fn resolve_type_vars_in_body(
|
||||
&self,
|
||||
body: &'tcx hir::Body<'tcx>,
|
||||
) -> &'tcx ty::TypeckTables<'tcx> {
|
||||
) -> &'tcx ty::TypeckResults<'tcx> {
|
||||
let item_id = self.tcx.hir().body_owner(body.id());
|
||||
let item_def_id = self.tcx.hir().local_def_id(item_id);
|
||||
|
||||
|
@ -65,36 +65,39 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
wbcx.visit_user_provided_sigs();
|
||||
wbcx.visit_generator_interior_types();
|
||||
|
||||
let used_trait_imports = mem::take(&mut self.tables.borrow_mut().used_trait_imports);
|
||||
let used_trait_imports =
|
||||
mem::take(&mut self.typeck_results.borrow_mut().used_trait_imports);
|
||||
debug!("used_trait_imports({:?}) = {:?}", item_def_id, used_trait_imports);
|
||||
wbcx.tables.used_trait_imports = used_trait_imports;
|
||||
wbcx.typeck_results.used_trait_imports = used_trait_imports;
|
||||
|
||||
wbcx.tables.closure_captures =
|
||||
mem::replace(&mut self.tables.borrow_mut().closure_captures, Default::default());
|
||||
wbcx.typeck_results.closure_captures = mem::replace(
|
||||
&mut self.typeck_results.borrow_mut().closure_captures,
|
||||
Default::default(),
|
||||
);
|
||||
|
||||
if self.is_tainted_by_errors() {
|
||||
// FIXME(eddyb) keep track of `ErrorReported` from where the error was emitted.
|
||||
wbcx.tables.tainted_by_errors = Some(ErrorReported);
|
||||
wbcx.typeck_results.tainted_by_errors = Some(ErrorReported);
|
||||
}
|
||||
|
||||
debug!("writeback: tables for {:?} are {:#?}", item_def_id, wbcx.tables);
|
||||
debug!("writeback: typeck results for {:?} are {:#?}", item_def_id, wbcx.typeck_results);
|
||||
|
||||
self.tcx.arena.alloc(wbcx.tables)
|
||||
self.tcx.arena.alloc(wbcx.typeck_results)
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// The Writeback context. This visitor walks the AST, checking the
|
||||
// fn-specific tables to find references to types or regions. It
|
||||
// fn-specific typeck results to find references to types or regions. It
|
||||
// resolves those regions to remove inference variables and writes the
|
||||
// final result back into the master tables in the tcx. Here and
|
||||
// final result back into the master typeck results in the tcx. Here and
|
||||
// there, it applies a few ad-hoc checks that were not convenient to
|
||||
// do elsewhere.
|
||||
|
||||
struct WritebackCx<'cx, 'tcx> {
|
||||
fcx: &'cx FnCtxt<'cx, 'tcx>,
|
||||
|
||||
tables: ty::TypeckTables<'tcx>,
|
||||
typeck_results: ty::TypeckResults<'tcx>,
|
||||
|
||||
body: &'tcx hir::Body<'tcx>,
|
||||
|
||||
|
@ -109,17 +112,22 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
|||
) -> WritebackCx<'cx, 'tcx> {
|
||||
let owner = body.id().hir_id.owner;
|
||||
|
||||
WritebackCx { fcx, tables: ty::TypeckTables::new(owner), body, rustc_dump_user_substs }
|
||||
WritebackCx {
|
||||
fcx,
|
||||
typeck_results: ty::TypeckResults::new(owner),
|
||||
body,
|
||||
rustc_dump_user_substs,
|
||||
}
|
||||
}
|
||||
|
||||
fn tcx(&self) -> TyCtxt<'tcx> {
|
||||
self.fcx.tcx
|
||||
}
|
||||
|
||||
fn write_ty_to_tables(&mut self, hir_id: hir::HirId, ty: Ty<'tcx>) {
|
||||
debug!("write_ty_to_tables({:?}, {:?})", hir_id, ty);
|
||||
fn write_ty_to_typeck_results(&mut self, hir_id: hir::HirId, ty: Ty<'tcx>) {
|
||||
debug!("write_ty_to_typeck_results({:?}, {:?})", hir_id, ty);
|
||||
assert!(!ty.needs_infer() && !ty.has_placeholders() && !ty.has_free_regions());
|
||||
self.tables.node_types_mut().insert(hir_id, ty);
|
||||
self.typeck_results.node_types_mut().insert(hir_id, ty);
|
||||
}
|
||||
|
||||
// Hacky hack: During type-checking, we treat *all* operators
|
||||
|
@ -133,9 +141,9 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
|||
let inner_ty = self.fcx.resolve_vars_if_possible(&inner_ty);
|
||||
|
||||
if inner_ty.is_scalar() {
|
||||
let mut tables = self.fcx.tables.borrow_mut();
|
||||
tables.type_dependent_defs_mut().remove(e.hir_id);
|
||||
tables.node_substs_mut().remove(e.hir_id);
|
||||
let mut typeck_results = self.fcx.typeck_results.borrow_mut();
|
||||
typeck_results.type_dependent_defs_mut().remove(e.hir_id);
|
||||
typeck_results.node_substs_mut().remove(e.hir_id);
|
||||
}
|
||||
}
|
||||
hir::ExprKind::Binary(ref op, ref lhs, ref rhs)
|
||||
|
@ -147,14 +155,14 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
|||
let rhs_ty = self.fcx.resolve_vars_if_possible(&rhs_ty);
|
||||
|
||||
if lhs_ty.is_scalar() && rhs_ty.is_scalar() {
|
||||
let mut tables = self.fcx.tables.borrow_mut();
|
||||
tables.type_dependent_defs_mut().remove(e.hir_id);
|
||||
tables.node_substs_mut().remove(e.hir_id);
|
||||
let mut typeck_results = self.fcx.typeck_results.borrow_mut();
|
||||
typeck_results.type_dependent_defs_mut().remove(e.hir_id);
|
||||
typeck_results.node_substs_mut().remove(e.hir_id);
|
||||
|
||||
match e.kind {
|
||||
hir::ExprKind::Binary(..) => {
|
||||
if !op.node.is_by_value() {
|
||||
let mut adjustments = tables.adjustments_mut();
|
||||
let mut adjustments = typeck_results.adjustments_mut();
|
||||
if let Some(a) = adjustments.get_mut(lhs.hir_id) {
|
||||
a.pop();
|
||||
}
|
||||
|
@ -164,7 +172,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
|||
}
|
||||
}
|
||||
hir::ExprKind::AssignOp(..) => {
|
||||
if let Some(a) = tables.adjustments_mut().get_mut(lhs.hir_id) {
|
||||
if let Some(a) = typeck_results.adjustments_mut().get_mut(lhs.hir_id) {
|
||||
a.pop();
|
||||
}
|
||||
}
|
||||
|
@ -182,10 +190,10 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
|||
// usize-ish
|
||||
fn fix_index_builtin_expr(&mut self, e: &hir::Expr<'_>) {
|
||||
if let hir::ExprKind::Index(ref base, ref index) = e.kind {
|
||||
let mut tables = self.fcx.tables.borrow_mut();
|
||||
let mut typeck_results = self.fcx.typeck_results.borrow_mut();
|
||||
|
||||
// All valid indexing looks like this; might encounter non-valid indexes at this point.
|
||||
let base_ty = tables.expr_ty_adjusted_opt(&base).map(|t| &t.kind);
|
||||
let base_ty = typeck_results.expr_ty_adjusted_opt(&base).map(|t| &t.kind);
|
||||
if base_ty.is_none() {
|
||||
// When encountering `return [0][0]` outside of a `fn` body we can encounter a base
|
||||
// that isn't in the type table. We assume more relevant errors have already been
|
||||
|
@ -193,7 +201,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
|||
self.tcx().sess.delay_span_bug(e.span, &format!("bad base: `{:?}`", base));
|
||||
}
|
||||
if let Some(ty::Ref(_, base_ty, _)) = base_ty {
|
||||
let index_ty = tables.expr_ty_adjusted_opt(&index).unwrap_or_else(|| {
|
||||
let index_ty = typeck_results.expr_ty_adjusted_opt(&index).unwrap_or_else(|| {
|
||||
// When encountering `return [0][0]` outside of a `fn` body we would attempt
|
||||
// to access an unexistend index. We assume that more relevant errors will
|
||||
// already have been emitted, so we only gate on this with an ICE if no
|
||||
|
@ -207,10 +215,10 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
|||
|
||||
if base_ty.builtin_index().is_some() && index_ty == self.fcx.tcx.types.usize {
|
||||
// Remove the method call record
|
||||
tables.type_dependent_defs_mut().remove(e.hir_id);
|
||||
tables.node_substs_mut().remove(e.hir_id);
|
||||
typeck_results.type_dependent_defs_mut().remove(e.hir_id);
|
||||
typeck_results.node_substs_mut().remove(e.hir_id);
|
||||
|
||||
if let Some(a) = tables.adjustments_mut().get_mut(base.hir_id) {
|
||||
if let Some(a) = typeck_results.adjustments_mut().get_mut(base.hir_id) {
|
||||
// Discard the need for a mutable borrow
|
||||
|
||||
// Extra adjustment made when indexing causes a drop
|
||||
|
@ -237,7 +245,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
|||
// This is the master code which walks the AST. It delegates most of
|
||||
// the heavy lifting to the generic visit and resolve functions
|
||||
// below. In general, a function is made into a `visitor` if it must
|
||||
// traffic in node-ids or update tables in the type context etc.
|
||||
// traffic in node-ids or update typeck results in the type context etc.
|
||||
|
||||
impl<'cx, 'tcx> Visitor<'tcx> for WritebackCx<'cx, 'tcx> {
|
||||
type Map = intravisit::ErasedMap<'tcx>;
|
||||
|
@ -283,9 +291,11 @@ impl<'cx, 'tcx> Visitor<'tcx> for WritebackCx<'cx, 'tcx> {
|
|||
fn visit_pat(&mut self, p: &'tcx hir::Pat<'tcx>) {
|
||||
match p.kind {
|
||||
hir::PatKind::Binding(..) => {
|
||||
let tables = self.fcx.tables.borrow();
|
||||
if let Some(bm) = tables.extract_binding_mode(self.tcx().sess, p.hir_id, p.span) {
|
||||
self.tables.pat_binding_modes_mut().insert(p.hir_id, bm);
|
||||
let typeck_results = self.fcx.typeck_results.borrow();
|
||||
if let Some(bm) =
|
||||
typeck_results.extract_binding_mode(self.tcx().sess, p.hir_id, p.span)
|
||||
{
|
||||
self.typeck_results.pat_binding_modes_mut().insert(p.hir_id, bm);
|
||||
}
|
||||
}
|
||||
hir::PatKind::Struct(_, fields, _) => {
|
||||
|
@ -306,20 +316,20 @@ impl<'cx, 'tcx> Visitor<'tcx> for WritebackCx<'cx, 'tcx> {
|
|||
intravisit::walk_local(self, l);
|
||||
let var_ty = self.fcx.local_ty(l.span, l.hir_id).decl_ty;
|
||||
let var_ty = self.resolve(&var_ty, &l.span);
|
||||
self.write_ty_to_tables(l.hir_id, var_ty);
|
||||
self.write_ty_to_typeck_results(l.hir_id, var_ty);
|
||||
}
|
||||
|
||||
fn visit_ty(&mut self, hir_ty: &'tcx hir::Ty<'tcx>) {
|
||||
intravisit::walk_ty(self, hir_ty);
|
||||
let ty = self.fcx.node_ty(hir_ty.hir_id);
|
||||
let ty = self.resolve(&ty, &hir_ty.span);
|
||||
self.write_ty_to_tables(hir_ty.hir_id, ty);
|
||||
self.write_ty_to_typeck_results(hir_ty.hir_id, ty);
|
||||
}
|
||||
}
|
||||
|
||||
impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
||||
fn visit_upvar_capture_map(&mut self) {
|
||||
for (upvar_id, upvar_capture) in self.fcx.tables.borrow().upvar_capture_map.iter() {
|
||||
for (upvar_id, upvar_capture) in self.fcx.typeck_results.borrow().upvar_capture_map.iter() {
|
||||
let new_upvar_capture = match *upvar_capture {
|
||||
ty::UpvarCapture::ByValue => ty::UpvarCapture::ByValue,
|
||||
ty::UpvarCapture::ByRef(ref upvar_borrow) => {
|
||||
|
@ -330,38 +340,38 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
|||
}
|
||||
};
|
||||
debug!("Upvar capture for {:?} resolved to {:?}", upvar_id, new_upvar_capture);
|
||||
self.tables.upvar_capture_map.insert(*upvar_id, new_upvar_capture);
|
||||
self.typeck_results.upvar_capture_map.insert(*upvar_id, new_upvar_capture);
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_closures(&mut self) {
|
||||
let fcx_tables = self.fcx.tables.borrow();
|
||||
assert_eq!(fcx_tables.hir_owner, self.tables.hir_owner);
|
||||
let common_hir_owner = fcx_tables.hir_owner;
|
||||
let fcx_typeck_results = self.fcx.typeck_results.borrow();
|
||||
assert_eq!(fcx_typeck_results.hir_owner, self.typeck_results.hir_owner);
|
||||
let common_hir_owner = fcx_typeck_results.hir_owner;
|
||||
|
||||
for (&id, &origin) in fcx_tables.closure_kind_origins().iter() {
|
||||
for (&id, &origin) in fcx_typeck_results.closure_kind_origins().iter() {
|
||||
let hir_id = hir::HirId { owner: common_hir_owner, local_id: id };
|
||||
self.tables.closure_kind_origins_mut().insert(hir_id, origin);
|
||||
self.typeck_results.closure_kind_origins_mut().insert(hir_id, origin);
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_coercion_casts(&mut self) {
|
||||
let fcx_tables = self.fcx.tables.borrow();
|
||||
let fcx_coercion_casts = fcx_tables.coercion_casts();
|
||||
assert_eq!(fcx_tables.hir_owner, self.tables.hir_owner);
|
||||
let fcx_typeck_results = self.fcx.typeck_results.borrow();
|
||||
let fcx_coercion_casts = fcx_typeck_results.coercion_casts();
|
||||
assert_eq!(fcx_typeck_results.hir_owner, self.typeck_results.hir_owner);
|
||||
|
||||
for local_id in fcx_coercion_casts {
|
||||
self.tables.set_coercion_cast(*local_id);
|
||||
self.typeck_results.set_coercion_cast(*local_id);
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_user_provided_tys(&mut self) {
|
||||
let fcx_tables = self.fcx.tables.borrow();
|
||||
assert_eq!(fcx_tables.hir_owner, self.tables.hir_owner);
|
||||
let common_hir_owner = fcx_tables.hir_owner;
|
||||
let fcx_typeck_results = self.fcx.typeck_results.borrow();
|
||||
assert_eq!(fcx_typeck_results.hir_owner, self.typeck_results.hir_owner);
|
||||
let common_hir_owner = fcx_typeck_results.hir_owner;
|
||||
|
||||
let mut errors_buffer = Vec::new();
|
||||
for (&local_id, c_ty) in fcx_tables.user_provided_types().iter() {
|
||||
for (&local_id, c_ty) in fcx_typeck_results.user_provided_types().iter() {
|
||||
let hir_id = hir::HirId { owner: common_hir_owner, local_id };
|
||||
|
||||
if cfg!(debug_assertions) && c_ty.needs_infer() {
|
||||
|
@ -372,7 +382,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
|||
);
|
||||
};
|
||||
|
||||
self.tables.user_provided_types_mut().insert(hir_id, *c_ty);
|
||||
self.typeck_results.user_provided_types_mut().insert(hir_id, *c_ty);
|
||||
|
||||
if let ty::UserType::TypeOf(_, user_substs) = c_ty.value {
|
||||
if self.rustc_dump_user_substs {
|
||||
|
@ -398,10 +408,10 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
|||
}
|
||||
|
||||
fn visit_user_provided_sigs(&mut self) {
|
||||
let fcx_tables = self.fcx.tables.borrow();
|
||||
assert_eq!(fcx_tables.hir_owner, self.tables.hir_owner);
|
||||
let fcx_typeck_results = self.fcx.typeck_results.borrow();
|
||||
assert_eq!(fcx_typeck_results.hir_owner, self.typeck_results.hir_owner);
|
||||
|
||||
for (&def_id, c_sig) in fcx_tables.user_provided_sigs.iter() {
|
||||
for (&def_id, c_sig) in fcx_typeck_results.user_provided_sigs.iter() {
|
||||
if cfg!(debug_assertions) && c_sig.needs_infer() {
|
||||
span_bug!(
|
||||
self.fcx.tcx.hir().span_if_local(def_id).unwrap(),
|
||||
|
@ -410,14 +420,15 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
|||
);
|
||||
};
|
||||
|
||||
self.tables.user_provided_sigs.insert(def_id, *c_sig);
|
||||
self.typeck_results.user_provided_sigs.insert(def_id, *c_sig);
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_generator_interior_types(&mut self) {
|
||||
let fcx_tables = self.fcx.tables.borrow();
|
||||
assert_eq!(fcx_tables.hir_owner, self.tables.hir_owner);
|
||||
self.tables.generator_interior_types = fcx_tables.generator_interior_types.clone();
|
||||
let fcx_typeck_results = self.fcx.typeck_results.borrow();
|
||||
assert_eq!(fcx_typeck_results.hir_owner, self.typeck_results.hir_owner);
|
||||
self.typeck_results.generator_interior_types =
|
||||
fcx_typeck_results.generator_interior_types.clone();
|
||||
}
|
||||
|
||||
fn visit_opaque_types(&mut self, span: Span) {
|
||||
|
@ -472,7 +483,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
|||
substs: opaque_defn.substs,
|
||||
};
|
||||
|
||||
let old = self.tables.concrete_opaque_types.insert(def_id, new);
|
||||
let old = self.typeck_results.concrete_opaque_types.insert(def_id, new);
|
||||
if let Some(old) = old {
|
||||
if old.concrete_type != definition_ty || old.substs != opaque_defn.substs {
|
||||
span_bug!(
|
||||
|
@ -494,15 +505,18 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
|||
}
|
||||
|
||||
fn visit_field_id(&mut self, hir_id: hir::HirId) {
|
||||
if let Some(index) = self.fcx.tables.borrow_mut().field_indices_mut().remove(hir_id) {
|
||||
self.tables.field_indices_mut().insert(hir_id, index);
|
||||
if let Some(index) = self.fcx.typeck_results.borrow_mut().field_indices_mut().remove(hir_id)
|
||||
{
|
||||
self.typeck_results.field_indices_mut().insert(hir_id, index);
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_node_id(&mut self, span: Span, hir_id: hir::HirId) {
|
||||
// Export associated path extensions and method resolutions.
|
||||
if let Some(def) = self.fcx.tables.borrow_mut().type_dependent_defs_mut().remove(hir_id) {
|
||||
self.tables.type_dependent_defs_mut().insert(hir_id, def);
|
||||
if let Some(def) =
|
||||
self.fcx.typeck_results.borrow_mut().type_dependent_defs_mut().remove(hir_id)
|
||||
{
|
||||
self.typeck_results.type_dependent_defs_mut().insert(hir_id, def);
|
||||
}
|
||||
|
||||
// Resolve any borrowings for the node with id `node_id`
|
||||
|
@ -511,20 +525,20 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
|||
// Resolve the type of the node with id `node_id`
|
||||
let n_ty = self.fcx.node_ty(hir_id);
|
||||
let n_ty = self.resolve(&n_ty, &span);
|
||||
self.write_ty_to_tables(hir_id, n_ty);
|
||||
self.write_ty_to_typeck_results(hir_id, n_ty);
|
||||
debug!("node {:?} has type {:?}", hir_id, n_ty);
|
||||
|
||||
// Resolve any substitutions
|
||||
if let Some(substs) = self.fcx.tables.borrow().node_substs_opt(hir_id) {
|
||||
if let Some(substs) = self.fcx.typeck_results.borrow().node_substs_opt(hir_id) {
|
||||
let substs = self.resolve(&substs, &span);
|
||||
debug!("write_substs_to_tcx({:?}, {:?})", hir_id, substs);
|
||||
assert!(!substs.needs_infer() && !substs.has_placeholders());
|
||||
self.tables.node_substs_mut().insert(hir_id, substs);
|
||||
self.typeck_results.node_substs_mut().insert(hir_id, substs);
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_adjustments(&mut self, span: Span, hir_id: hir::HirId) {
|
||||
let adjustment = self.fcx.tables.borrow_mut().adjustments_mut().remove(hir_id);
|
||||
let adjustment = self.fcx.typeck_results.borrow_mut().adjustments_mut().remove(hir_id);
|
||||
match adjustment {
|
||||
None => {
|
||||
debug!("no adjustments for node {:?}", hir_id);
|
||||
|
@ -533,13 +547,13 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
|||
Some(adjustment) => {
|
||||
let resolved_adjustment = self.resolve(&adjustment, &span);
|
||||
debug!("adjustments for node {:?}: {:?}", hir_id, resolved_adjustment);
|
||||
self.tables.adjustments_mut().insert(hir_id, resolved_adjustment);
|
||||
self.typeck_results.adjustments_mut().insert(hir_id, resolved_adjustment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_pat_adjustments(&mut self, span: Span, hir_id: hir::HirId) {
|
||||
let adjustment = self.fcx.tables.borrow_mut().pat_adjustments_mut().remove(hir_id);
|
||||
let adjustment = self.fcx.typeck_results.borrow_mut().pat_adjustments_mut().remove(hir_id);
|
||||
match adjustment {
|
||||
None => {
|
||||
debug!("no pat_adjustments for node {:?}", hir_id);
|
||||
|
@ -548,32 +562,32 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
|||
Some(adjustment) => {
|
||||
let resolved_adjustment = self.resolve(&adjustment, &span);
|
||||
debug!("pat_adjustments for node {:?}: {:?}", hir_id, resolved_adjustment);
|
||||
self.tables.pat_adjustments_mut().insert(hir_id, resolved_adjustment);
|
||||
self.typeck_results.pat_adjustments_mut().insert(hir_id, resolved_adjustment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_liberated_fn_sigs(&mut self) {
|
||||
let fcx_tables = self.fcx.tables.borrow();
|
||||
assert_eq!(fcx_tables.hir_owner, self.tables.hir_owner);
|
||||
let common_hir_owner = fcx_tables.hir_owner;
|
||||
let fcx_typeck_results = self.fcx.typeck_results.borrow();
|
||||
assert_eq!(fcx_typeck_results.hir_owner, self.typeck_results.hir_owner);
|
||||
let common_hir_owner = fcx_typeck_results.hir_owner;
|
||||
|
||||
for (&local_id, fn_sig) in fcx_tables.liberated_fn_sigs().iter() {
|
||||
for (&local_id, fn_sig) in fcx_typeck_results.liberated_fn_sigs().iter() {
|
||||
let hir_id = hir::HirId { owner: common_hir_owner, local_id };
|
||||
let fn_sig = self.resolve(fn_sig, &hir_id);
|
||||
self.tables.liberated_fn_sigs_mut().insert(hir_id, fn_sig);
|
||||
self.typeck_results.liberated_fn_sigs_mut().insert(hir_id, fn_sig);
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_fru_field_types(&mut self) {
|
||||
let fcx_tables = self.fcx.tables.borrow();
|
||||
assert_eq!(fcx_tables.hir_owner, self.tables.hir_owner);
|
||||
let common_hir_owner = fcx_tables.hir_owner;
|
||||
let fcx_typeck_results = self.fcx.typeck_results.borrow();
|
||||
assert_eq!(fcx_typeck_results.hir_owner, self.typeck_results.hir_owner);
|
||||
let common_hir_owner = fcx_typeck_results.hir_owner;
|
||||
|
||||
for (&local_id, ftys) in fcx_tables.fru_field_types().iter() {
|
||||
for (&local_id, ftys) in fcx_typeck_results.fru_field_types().iter() {
|
||||
let hir_id = hir::HirId { owner: common_hir_owner, local_id };
|
||||
let ftys = self.resolve(ftys, &hir_id);
|
||||
self.tables.fru_field_types_mut().insert(hir_id, ftys);
|
||||
self.typeck_results.fru_field_types_mut().insert(hir_id, ftys);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -588,11 +602,11 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
|||
}
|
||||
|
||||
// We may have introduced e.g. `ty::Error`, if inference failed, make sure
|
||||
// to mark the `TypeckTables` as tainted in that case, so that downstream
|
||||
// users of the tables don't produce extra errors, or worse, ICEs.
|
||||
// to mark the `TypeckResults` as tainted in that case, so that downstream
|
||||
// users of the typeck results don't produce extra errors, or worse, ICEs.
|
||||
if resolver.replaced_with_error {
|
||||
// FIXME(eddyb) keep track of `ErrorReported` from where the error was emitted.
|
||||
self.tables.tainted_by_errors = Some(ErrorReported);
|
||||
self.typeck_results.tainted_by_errors = Some(ErrorReported);
|
||||
}
|
||||
|
||||
x
|
||||
|
|
|
@ -1515,7 +1515,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
|
|||
| Item(hir::Item { kind: ItemKind::Fn(sig, generics, _), ident, .. }) => {
|
||||
match get_infer_ret_ty(&sig.decl.output) {
|
||||
Some(ty) => {
|
||||
let fn_sig = tcx.typeck_tables_of(def_id).liberated_fn_sigs()[hir_id];
|
||||
let fn_sig = tcx.typeck(def_id).liberated_fn_sigs()[hir_id];
|
||||
let mut visitor = PlaceholderHirTyCollector::default();
|
||||
visitor.visit_ty(ty);
|
||||
let mut diag = bad_placeholder_type(tcx, visitor.0);
|
||||
|
|
|
@ -36,7 +36,7 @@ pub(super) fn opt_const_param_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<
|
|||
..
|
||||
}) => {
|
||||
let body_owner = tcx.hir().local_def_id(tcx.hir().enclosing_body_owner(hir_id));
|
||||
let tables = tcx.typeck_tables_of(body_owner);
|
||||
let tables = tcx.typeck(body_owner);
|
||||
// This may fail in case the method/path does not actually exist.
|
||||
// As there is no relevant param for `def_id`, we simply return
|
||||
// `None` here.
|
||||
|
@ -76,7 +76,7 @@ pub(super) fn opt_const_param_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<
|
|||
}) => {
|
||||
let body_owner =
|
||||
tcx.hir().local_def_id(tcx.hir().enclosing_body_owner(hir_id));
|
||||
let _tables = tcx.typeck_tables_of(body_owner);
|
||||
let _tables = tcx.typeck(body_owner);
|
||||
&*path
|
||||
}
|
||||
_ => span_bug!(DUMMY_SP, "unexpected const parent path {:?}", parent_node),
|
||||
|
@ -222,12 +222,12 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
|
|||
tcx.sess.delay_span_bug(
|
||||
DUMMY_SP,
|
||||
&format!(
|
||||
"owner {:?} has no opaque type for {:?} in its tables",
|
||||
"owner {:?} has no opaque type for {:?} in its typeck results",
|
||||
owner, def_id,
|
||||
),
|
||||
);
|
||||
if let Some(ErrorReported) =
|
||||
tcx.typeck_tables_of(owner.expect_local()).tainted_by_errors
|
||||
tcx.typeck(owner.expect_local()).tainted_by_errors
|
||||
{
|
||||
// Some error in the
|
||||
// owner fn prevented us from populating
|
||||
|
@ -411,16 +411,16 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> {
|
|||
impl ConstraintLocator<'_> {
|
||||
fn check(&mut self, def_id: LocalDefId) {
|
||||
// Don't try to check items that cannot possibly constrain the type.
|
||||
if !self.tcx.has_typeck_tables(def_id) {
|
||||
if !self.tcx.has_typeck_results(def_id) {
|
||||
debug!(
|
||||
"find_opaque_ty_constraints: no constraint for `{:?}` at `{:?}`: no tables",
|
||||
"find_opaque_ty_constraints: no constraint for `{:?}` at `{:?}`: no typeck results",
|
||||
self.def_id, def_id,
|
||||
);
|
||||
return;
|
||||
}
|
||||
// Calling `mir_borrowck` can lead to cycle errors through
|
||||
// const-checking, avoid calling it if we don't have to.
|
||||
if !self.tcx.typeck_tables_of(def_id).concrete_opaque_types.contains_key(&self.def_id) {
|
||||
if !self.tcx.typeck(def_id).concrete_opaque_types.contains_key(&self.def_id) {
|
||||
debug!(
|
||||
"find_opaque_ty_constraints: no constraint for `{:?}` at `{:?}`",
|
||||
self.def_id, def_id,
|
||||
|
@ -604,8 +604,8 @@ fn let_position_impl_trait_type(tcx: TyCtxt<'_>, opaque_ty_id: LocalDefId) -> Ty
|
|||
|
||||
let opaque_ty_def_id = opaque_ty_id.to_def_id();
|
||||
|
||||
let owner_tables = tcx.typeck_tables_of(scope_def_id);
|
||||
let concrete_ty = owner_tables
|
||||
let owner_typeck_results = tcx.typeck(scope_def_id);
|
||||
let concrete_ty = owner_typeck_results
|
||||
.concrete_opaque_types
|
||||
.get(&opaque_ty_def_id)
|
||||
.map(|opaque| opaque.concrete_type)
|
||||
|
@ -613,11 +613,11 @@ fn let_position_impl_trait_type(tcx: TyCtxt<'_>, opaque_ty_id: LocalDefId) -> Ty
|
|||
tcx.sess.delay_span_bug(
|
||||
DUMMY_SP,
|
||||
&format!(
|
||||
"owner {:?} has no opaque type for {:?} in its tables",
|
||||
"owner {:?} has no opaque type for {:?} in its typeck results",
|
||||
scope_def_id, opaque_ty_id
|
||||
),
|
||||
);
|
||||
if let Some(ErrorReported) = owner_tables.tainted_by_errors {
|
||||
if let Some(ErrorReported) = owner_typeck_results.tainted_by_errors {
|
||||
// Some error in the owner fn prevented us from populating the
|
||||
// `concrete_opaque_types` table.
|
||||
tcx.ty_error()
|
||||
|
@ -649,7 +649,7 @@ fn infer_placeholder_type(
|
|||
span: Span,
|
||||
item_ident: Ident,
|
||||
) -> Ty<'_> {
|
||||
let ty = tcx.diagnostic_only_typeck_tables_of(def_id).node_type(body_id.hir_id);
|
||||
let ty = tcx.diagnostic_only_typeck(def_id).node_type(body_id.hir_id);
|
||||
|
||||
// If this came from a free `const` or `static mut?` item,
|
||||
// then the user may have written e.g. `const A = 42;`.
|
||||
|
|
|
@ -82,16 +82,16 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
|||
///
|
||||
/// - `delegate` -- who receives the callbacks
|
||||
/// - `param_env` --- parameter environment for trait lookups (esp. pertaining to `Copy`)
|
||||
/// - `tables` --- typeck results for the code being analyzed
|
||||
/// - `typeck_results` --- typeck results for the code being analyzed
|
||||
pub fn new(
|
||||
delegate: &'a mut (dyn Delegate<'tcx> + 'a),
|
||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
||||
body_owner: LocalDefId,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
tables: &'a ty::TypeckTables<'tcx>,
|
||||
typeck_results: &'a ty::TypeckResults<'tcx>,
|
||||
) -> Self {
|
||||
ExprUseVisitor {
|
||||
mc: mc::MemCategorizationContext::new(infcx, param_env, body_owner, tables),
|
||||
mc: mc::MemCategorizationContext::new(infcx, param_env, body_owner, typeck_results),
|
||||
delegate,
|
||||
}
|
||||
}
|
||||
|
@ -296,7 +296,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
|||
}
|
||||
|
||||
hir::ExprKind::AssignOp(_, ref lhs, ref rhs) => {
|
||||
if self.mc.tables.is_method_call(expr) {
|
||||
if self.mc.typeck_results.is_method_call(expr) {
|
||||
self.consume_expr(lhs);
|
||||
} else {
|
||||
self.mutate_expr(lhs);
|
||||
|
@ -390,9 +390,9 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
|||
ty::Adt(adt, substs) if adt.is_struct() => {
|
||||
// Consume those fields of the with expression that are needed.
|
||||
for (f_index, with_field) in adt.non_enum_variant().fields.iter().enumerate() {
|
||||
let is_mentioned = fields
|
||||
.iter()
|
||||
.any(|f| self.tcx().field_index(f.hir_id, self.mc.tables) == f_index);
|
||||
let is_mentioned = fields.iter().any(|f| {
|
||||
self.tcx().field_index(f.hir_id, self.mc.typeck_results) == f_index
|
||||
});
|
||||
if !is_mentioned {
|
||||
let field_place = self.mc.cat_projection(
|
||||
&*with_expr,
|
||||
|
@ -424,7 +424,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
|||
// consumed or borrowed as part of the automatic adjustment
|
||||
// process.
|
||||
fn walk_adjustment(&mut self, expr: &hir::Expr<'_>) {
|
||||
let adjustments = self.mc.tables.expr_adjustments(expr);
|
||||
let adjustments = self.mc.typeck_results.expr_adjustments(expr);
|
||||
let mut place_with_id = return_if_err!(self.mc.cat_expr_unadjusted(expr));
|
||||
for adjustment in adjustments {
|
||||
debug!("walk_adjustment expr={:?} adj={:?}", expr, adjustment);
|
||||
|
@ -508,7 +508,9 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
|||
return_if_err!(mc.cat_pattern(discr_place.clone(), pat, |place, pat| {
|
||||
if let PatKind::Binding(_, canonical_id, ..) = pat.kind {
|
||||
debug!("walk_pat: binding place={:?} pat={:?}", place, pat,);
|
||||
if let Some(bm) = mc.tables.extract_binding_mode(tcx.sess, pat.hir_id, pat.span) {
|
||||
if let Some(bm) =
|
||||
mc.typeck_results.extract_binding_mode(tcx.sess, pat.hir_id, pat.span)
|
||||
{
|
||||
debug!("walk_pat: pat.hir_id={:?} bm={:?}", pat.hir_id, bm);
|
||||
|
||||
// pat_ty: the type of the binding being produced.
|
||||
|
@ -549,7 +551,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
|||
var_path: ty::UpvarPath { hir_id: var_id },
|
||||
closure_expr_id: closure_def_id,
|
||||
};
|
||||
let upvar_capture = self.mc.tables.upvar_capture(upvar_id);
|
||||
let upvar_capture = self.mc.typeck_results.upvar_capture(upvar_id);
|
||||
let captured_place = return_if_err!(self.cat_captured_var(
|
||||
closure_expr.hir_id,
|
||||
fn_decl_span,
|
||||
|
|
|
@ -199,7 +199,7 @@ impl HirNode for hir::Pat<'_> {
|
|||
|
||||
#[derive(Clone)]
|
||||
crate struct MemCategorizationContext<'a, 'tcx> {
|
||||
crate tables: &'a ty::TypeckTables<'tcx>,
|
||||
crate typeck_results: &'a ty::TypeckResults<'tcx>,
|
||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
body_owner: LocalDefId,
|
||||
|
@ -214,10 +214,10 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
|||
infcx: &'a InferCtxt<'a, 'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
body_owner: LocalDefId,
|
||||
tables: &'a ty::TypeckTables<'tcx>,
|
||||
typeck_results: &'a ty::TypeckResults<'tcx>,
|
||||
) -> MemCategorizationContext<'a, 'tcx> {
|
||||
MemCategorizationContext {
|
||||
tables,
|
||||
typeck_results,
|
||||
infcx,
|
||||
param_env,
|
||||
body_owner,
|
||||
|
@ -272,15 +272,15 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
|||
}
|
||||
|
||||
crate fn node_ty(&self, hir_id: hir::HirId) -> McResult<Ty<'tcx>> {
|
||||
self.resolve_type_vars_or_error(hir_id, self.tables.node_type_opt(hir_id))
|
||||
self.resolve_type_vars_or_error(hir_id, self.typeck_results.node_type_opt(hir_id))
|
||||
}
|
||||
|
||||
fn expr_ty(&self, expr: &hir::Expr<'_>) -> McResult<Ty<'tcx>> {
|
||||
self.resolve_type_vars_or_error(expr.hir_id, self.tables.expr_ty_opt(expr))
|
||||
self.resolve_type_vars_or_error(expr.hir_id, self.typeck_results.expr_ty_opt(expr))
|
||||
}
|
||||
|
||||
crate fn expr_ty_adjusted(&self, expr: &hir::Expr<'_>) -> McResult<Ty<'tcx>> {
|
||||
self.resolve_type_vars_or_error(expr.hir_id, self.tables.expr_ty_adjusted_opt(expr))
|
||||
self.resolve_type_vars_or_error(expr.hir_id, self.typeck_results.expr_ty_adjusted_opt(expr))
|
||||
}
|
||||
|
||||
/// Returns the type of value that this pattern matches against.
|
||||
|
@ -298,7 +298,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
|||
// that these are never attached to binding patterns, so
|
||||
// actually this is somewhat "disjoint" from the code below
|
||||
// that aims to account for `ref x`.
|
||||
if let Some(vec) = self.tables.pat_adjustments().get(pat.hir_id) {
|
||||
if let Some(vec) = self.typeck_results.pat_adjustments().get(pat.hir_id) {
|
||||
if let Some(first_ty) = vec.first() {
|
||||
debug!("pat_ty(pat={:?}) found adjusted ty `{:?}`", pat, first_ty);
|
||||
return Ok(first_ty);
|
||||
|
@ -317,8 +317,11 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
|||
// and if so, figures out what the type *being borrowed* is.
|
||||
let ret_ty = match pat.kind {
|
||||
PatKind::Binding(..) => {
|
||||
let bm =
|
||||
*self.tables.pat_binding_modes().get(pat.hir_id).expect("missing binding mode");
|
||||
let bm = *self
|
||||
.typeck_results
|
||||
.pat_binding_modes()
|
||||
.get(pat.hir_id)
|
||||
.expect("missing binding mode");
|
||||
|
||||
if let ty::BindByReference(_) = bm {
|
||||
// a bind-by-ref means that the base_ty will be the type of the ident itself,
|
||||
|
@ -358,7 +361,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
helper(self, expr, self.tables.expr_adjustments(expr))
|
||||
helper(self, expr, self.typeck_results.expr_adjustments(expr))
|
||||
}
|
||||
|
||||
crate fn cat_expr_adjusted(
|
||||
|
@ -410,7 +413,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
|||
let expr_ty = self.expr_ty(expr)?;
|
||||
match expr.kind {
|
||||
hir::ExprKind::Unary(hir::UnOp::UnDeref, ref e_base) => {
|
||||
if self.tables.is_method_call(expr) {
|
||||
if self.typeck_results.is_method_call(expr) {
|
||||
self.cat_overloaded_place(expr, e_base)
|
||||
} else {
|
||||
let base = self.cat_expr(&e_base)?;
|
||||
|
@ -423,7 +426,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
|||
debug!("cat_expr(cat_field): id={} expr={:?} base={:?}", expr.hir_id, expr, base);
|
||||
|
||||
let field_idx = self
|
||||
.tables
|
||||
.typeck_results
|
||||
.field_indices()
|
||||
.get(expr.hir_id)
|
||||
.cloned()
|
||||
|
@ -438,7 +441,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
|||
}
|
||||
|
||||
hir::ExprKind::Index(ref base, _) => {
|
||||
if self.tables.is_method_call(expr) {
|
||||
if self.typeck_results.is_method_call(expr) {
|
||||
// If this is an index implemented by a method call, then it
|
||||
// will include an implicit deref of the result.
|
||||
// The call to index() returns a `&T` value, which
|
||||
|
@ -452,7 +455,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
|||
}
|
||||
|
||||
hir::ExprKind::Path(ref qpath) => {
|
||||
let res = self.tables.qpath_res(qpath, expr.hir_id);
|
||||
let res = self.typeck_results.qpath_res(qpath, expr.hir_id);
|
||||
self.cat_res(expr.hir_id, expr.span, expr_ty, res)
|
||||
}
|
||||
|
||||
|
@ -646,8 +649,8 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
|||
pat_hir_id: hir::HirId,
|
||||
span: Span,
|
||||
) -> McResult<VariantIdx> {
|
||||
let res = self.tables.qpath_res(qpath, pat_hir_id);
|
||||
let ty = self.tables.node_type(pat_hir_id);
|
||||
let res = self.typeck_results.qpath_res(qpath, pat_hir_id);
|
||||
let ty = self.typeck_results.node_type(pat_hir_id);
|
||||
let adt_def = match ty.kind {
|
||||
ty::Adt(adt_def, _) => adt_def,
|
||||
_ => {
|
||||
|
@ -682,7 +685,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
|||
variant_index: VariantIdx,
|
||||
span: Span,
|
||||
) -> McResult<usize> {
|
||||
let ty = self.tables.node_type(pat_hir_id);
|
||||
let ty = self.typeck_results.node_type(pat_hir_id);
|
||||
match ty.kind {
|
||||
ty::Adt(adt_def, _) => Ok(adt_def.variants[variant_index].fields.len()),
|
||||
_ => {
|
||||
|
@ -697,7 +700,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
|||
/// Returns the total number of fields in a tuple used within a Tuple pattern.
|
||||
/// Here `pat_hir_id` is the HirId of the pattern itself.
|
||||
fn total_fields_in_tuple(&self, pat_hir_id: hir::HirId, span: Span) -> McResult<usize> {
|
||||
let ty = self.tables.node_type(pat_hir_id);
|
||||
let ty = self.typeck_results.node_type(pat_hir_id);
|
||||
match ty.kind {
|
||||
ty::Tuple(substs) => Ok(substs.len()),
|
||||
_ => {
|
||||
|
@ -758,7 +761,9 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
|||
// Then we see that to get the same result, we must start with
|
||||
// `deref { deref { place_foo }}` instead of `place_foo` since the pattern is now `Some(x,)`
|
||||
// and not `&&Some(x,)`, even though its assigned type is that of `&&Some(x,)`.
|
||||
for _ in 0..self.tables.pat_adjustments().get(pat.hir_id).map(|v| v.len()).unwrap_or(0) {
|
||||
for _ in
|
||||
0..self.typeck_results.pat_adjustments().get(pat.hir_id).map(|v| v.len()).unwrap_or(0)
|
||||
{
|
||||
debug!("cat_pattern: applying adjustment to place_with_id={:?}", place_with_id);
|
||||
place_with_id = self.cat_deref(pat, place_with_id)?;
|
||||
}
|
||||
|
@ -813,7 +818,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
|||
for fp in field_pats {
|
||||
let field_ty = self.pat_ty_adjusted(&fp.pat)?;
|
||||
let field_index = self
|
||||
.tables
|
||||
.typeck_results
|
||||
.field_indices()
|
||||
.get(fp.hir_id)
|
||||
.cloned()
|
||||
|
|
|
@ -380,9 +380,9 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
|
|||
override_queries: Some(|_sess, providers, _external_providers| {
|
||||
// Most lints will require typechecking, so just don't run them.
|
||||
providers.lint_mod = |_, _| {};
|
||||
// Prevent `rustc_typeck::check_crate` from calling `typeck_tables_of` on all bodies.
|
||||
// Prevent `rustc_typeck::check_crate` from calling `typeck` on all bodies.
|
||||
providers.typeck_item_bodies = |_, _| {};
|
||||
// hack so that `used_trait_imports` won't try to call typeck_tables_of
|
||||
// hack so that `used_trait_imports` won't try to call typeck
|
||||
providers.used_trait_imports = |_, _| {
|
||||
lazy_static! {
|
||||
static ref EMPTY_SET: FxHashSet<LocalDefId> = FxHashSet::default();
|
||||
|
@ -390,20 +390,20 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
|
|||
&EMPTY_SET
|
||||
};
|
||||
// In case typeck does end up being called, don't ICE in case there were name resolution errors
|
||||
providers.typeck_tables_of = move |tcx, def_id| {
|
||||
providers.typeck = move |tcx, def_id| {
|
||||
// Closures' tables come from their outermost function,
|
||||
// as they are part of the same "inference environment".
|
||||
// This avoids emitting errors for the parent twice (see similar code in `typeck_tables_of_with_fallback`)
|
||||
// This avoids emitting errors for the parent twice (see similar code in `typeck_with_fallback`)
|
||||
let outer_def_id = tcx.closure_base_def_id(def_id.to_def_id()).expect_local();
|
||||
if outer_def_id != def_id {
|
||||
return tcx.typeck_tables_of(outer_def_id);
|
||||
return tcx.typeck(outer_def_id);
|
||||
}
|
||||
|
||||
let hir = tcx.hir();
|
||||
let body = hir.body(hir.body_owned_by(hir.as_local_hir_id(def_id)));
|
||||
debug!("visiting body for {:?}", def_id);
|
||||
EmitIgnoredResolutionErrors::new(tcx).visit_body(body);
|
||||
(rustc_interface::DEFAULT_QUERY_PROVIDERS.typeck_tables_of)(tcx, def_id)
|
||||
(rustc_interface::DEFAULT_QUERY_PROVIDERS.typeck)(tcx, def_id)
|
||||
};
|
||||
}),
|
||||
registry: rustc_driver::diagnostics_registry(),
|
||||
|
|
|
@ -24,7 +24,7 @@ extern crate point;
|
|||
pub mod fn_calls_methods_in_same_impl {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn check() {
|
||||
let x = Point { x: 2.0, y: 2.0 };
|
||||
x.distance_from_origin();
|
||||
|
@ -35,7 +35,7 @@ pub mod fn_calls_methods_in_same_impl {
|
|||
pub mod fn_calls_free_fn {
|
||||
use point::{self, Point};
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn check() {
|
||||
let x = Point { x: 2.0, y: 2.0 };
|
||||
point::distance_squared(&x);
|
||||
|
@ -46,7 +46,7 @@ pub mod fn_calls_free_fn {
|
|||
pub mod fn_make_struct {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn make_origin() -> Point {
|
||||
Point { x: 2.0, y: 2.0 }
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ pub mod fn_make_struct {
|
|||
pub mod fn_read_field {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn get_x(p: Point) -> f32 {
|
||||
p.x
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ pub mod fn_read_field {
|
|||
pub mod fn_write_field {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn inc_x(p: &mut Point) {
|
||||
p.x += 1.0;
|
||||
}
|
||||
|
|
|
@ -6,12 +6,12 @@
|
|||
|
||||
extern crate a;
|
||||
|
||||
#[rustc_dirty(label="typeck_tables_of", cfg="rpass2")]
|
||||
#[rustc_dirty(label="typeck", cfg="rpass2")]
|
||||
pub fn call_function0() {
|
||||
a::function0(77);
|
||||
}
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="rpass2")]
|
||||
#[rustc_clean(label="typeck", cfg="rpass2")]
|
||||
pub fn call_function1() {
|
||||
a::function1(77);
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ pub mod point {
|
|||
pub mod fn_with_type_in_sig {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_dirty(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_dirty(label="typeck", cfg="cfail2")]
|
||||
pub fn boop(p: Option<&Point>) -> f32 {
|
||||
p.map(|p| p.total()).unwrap_or(0.0)
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ pub mod fn_with_type_in_sig {
|
|||
pub mod call_fn_with_type_in_sig {
|
||||
use fn_with_type_in_sig;
|
||||
|
||||
#[rustc_dirty(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_dirty(label="typeck", cfg="cfail2")]
|
||||
pub fn bip() -> f32 {
|
||||
fn_with_type_in_sig::boop(None)
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ pub mod call_fn_with_type_in_sig {
|
|||
pub mod fn_with_type_in_body {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_dirty(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_dirty(label="typeck", cfg="cfail2")]
|
||||
pub fn boop() -> f32 {
|
||||
Point::origin().total()
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ pub mod fn_with_type_in_body {
|
|||
pub mod call_fn_with_type_in_body {
|
||||
use fn_with_type_in_body;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn bip() -> f32 {
|
||||
fn_with_type_in_body::boop()
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ pub mod call_fn_with_type_in_body {
|
|||
pub mod fn_make_struct {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_dirty(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_dirty(label="typeck", cfg="cfail2")]
|
||||
pub fn make_origin(p: Point) -> Point {
|
||||
Point { ..p }
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ pub mod fn_make_struct {
|
|||
pub mod fn_read_field {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_dirty(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_dirty(label="typeck", cfg="cfail2")]
|
||||
pub fn get_x(p: Point) -> f32 {
|
||||
p.x
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ pub mod fn_read_field {
|
|||
pub mod fn_write_field {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_dirty(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_dirty(label="typeck", cfg="cfail2")]
|
||||
pub fn inc_x(p: &mut Point) {
|
||||
p.x += 1.0;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ extern crate a;
|
|||
use a::A;
|
||||
use b::B;
|
||||
|
||||
//? #[rustc_clean(label="typeck_tables_of", cfg="rpass2")]
|
||||
//? #[rustc_clean(label="typeck", cfg="rpass2")]
|
||||
pub fn main() {
|
||||
A + B;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ pub mod point {
|
|||
pub mod fn_calls_methods_in_same_impl {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn check() {
|
||||
let x = Point { x: 2.0, y: 2.0 };
|
||||
x.distance_from_origin();
|
||||
|
@ -62,7 +62,7 @@ pub mod fn_calls_methods_in_same_impl {
|
|||
pub mod fn_calls_methods_in_another_impl {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn check() {
|
||||
let mut x = Point { x: 2.0, y: 2.0 };
|
||||
x.translate(3.0, 3.0);
|
||||
|
@ -73,7 +73,7 @@ pub mod fn_calls_methods_in_another_impl {
|
|||
pub mod fn_make_struct {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn make_origin() -> Point {
|
||||
Point { x: 2.0, y: 2.0 }
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ pub mod fn_make_struct {
|
|||
pub mod fn_read_field {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn get_x(p: Point) -> f32 {
|
||||
p.x
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ pub mod fn_read_field {
|
|||
pub mod fn_write_field {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn inc_x(p: &mut Point) {
|
||||
p.x += 1.0;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ extern crate point;
|
|||
pub mod fn_calls_methods_in_same_impl {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn check() {
|
||||
let x = Point { x: 2.0, y: 2.0 };
|
||||
x.distance_from_origin();
|
||||
|
@ -34,7 +34,7 @@ pub mod fn_calls_methods_in_same_impl {
|
|||
pub mod fn_calls_methods_in_another_impl {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn check() {
|
||||
let mut x = Point { x: 2.0, y: 2.0 };
|
||||
x.translate(3.0, 3.0);
|
||||
|
@ -45,7 +45,7 @@ pub mod fn_calls_methods_in_another_impl {
|
|||
pub mod fn_make_struct {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn make_origin() -> Point {
|
||||
Point { x: 2.0, y: 2.0 }
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ pub mod fn_make_struct {
|
|||
pub mod fn_read_field {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn get_x(p: Point) -> f32 {
|
||||
p.x
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ pub mod fn_read_field {
|
|||
pub mod fn_write_field {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn inc_x(p: &mut Point) {
|
||||
p.x += 1.0;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ pub mod point {
|
|||
pub mod fn_calls_methods_in_same_impl {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn check() {
|
||||
let x = Point { x: 2.0, y: 2.0 };
|
||||
x.distance_from_origin();
|
||||
|
@ -62,7 +62,7 @@ pub mod fn_calls_methods_in_same_impl {
|
|||
pub mod fn_calls_methods_in_another_impl {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn check() {
|
||||
let mut x = Point { x: 2.0, y: 2.0 };
|
||||
x.translate(3.0, 3.0);
|
||||
|
@ -73,7 +73,7 @@ pub mod fn_calls_methods_in_another_impl {
|
|||
pub mod fn_make_struct {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn make_origin() -> Point {
|
||||
Point { x: 2.0, y: 2.0 }
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ pub mod fn_make_struct {
|
|||
pub mod fn_read_field {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn get_x(p: Point) -> f32 {
|
||||
p.x
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ pub mod fn_read_field {
|
|||
pub mod fn_write_field {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn inc_x(p: &mut Point) {
|
||||
p.x += 1.0;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ extern crate point;
|
|||
pub mod fn_calls_methods_in_same_impl {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn check() {
|
||||
let x = Point { x: 2.0, y: 2.0 };
|
||||
x.distance_from_origin();
|
||||
|
@ -35,7 +35,7 @@ pub mod fn_calls_methods_in_same_impl {
|
|||
pub mod fn_calls_methods_in_another_impl {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn dirty() {
|
||||
let mut x = Point { x: 2.0, y: 2.0 };
|
||||
x.translate(3.0, 3.0);
|
||||
|
@ -46,7 +46,7 @@ pub mod fn_calls_methods_in_another_impl {
|
|||
pub mod fn_make_struct {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn make_origin() -> Point {
|
||||
Point { x: 2.0, y: 2.0 }
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ pub mod fn_make_struct {
|
|||
pub mod fn_read_field {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn get_x(p: Point) -> f32 {
|
||||
p.x
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ pub mod fn_read_field {
|
|||
pub mod fn_write_field {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn inc_x(p: &mut Point) {
|
||||
p.x += 1.0;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ pub mod point {
|
|||
pub mod fn_calls_changed_method {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn check() {
|
||||
let p = Point { x: 2.0, y: 2.0 };
|
||||
p.distance_from_origin();
|
||||
|
@ -53,7 +53,7 @@ pub mod fn_calls_changed_method {
|
|||
pub mod fn_calls_another_method {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn check() {
|
||||
let p = Point { x: 2.0, y: 2.0 };
|
||||
p.x();
|
||||
|
@ -64,7 +64,7 @@ pub mod fn_calls_another_method {
|
|||
pub mod fn_make_struct {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn make_origin() -> Point {
|
||||
Point { x: 2.0, y: 2.0 }
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ pub mod fn_make_struct {
|
|||
pub mod fn_read_field {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn get_x(p: Point) -> f32 {
|
||||
p.x
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ pub mod fn_read_field {
|
|||
pub mod fn_write_field {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn inc_x(p: &mut Point) {
|
||||
p.x += 1.0;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ pub mod point {
|
|||
pub mod fn_calls_changed_method {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_dirty(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_dirty(label="typeck", cfg="cfail2")]
|
||||
pub fn check() {
|
||||
let p = Point { x: 2.0, y: 2.0 };
|
||||
p.distance_from_point(None);
|
||||
|
@ -63,7 +63,7 @@ pub mod fn_calls_changed_method {
|
|||
pub mod fn_calls_another_method {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn check() {
|
||||
let p = Point { x: 2.0, y: 2.0 };
|
||||
p.x();
|
||||
|
@ -74,7 +74,7 @@ pub mod fn_calls_another_method {
|
|||
pub mod fn_make_struct {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn make_origin() -> Point {
|
||||
Point { x: 2.0, y: 2.0 }
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ pub mod fn_make_struct {
|
|||
pub mod fn_read_field {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn get_x(p: Point) -> f32 {
|
||||
p.x
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ pub mod fn_read_field {
|
|||
pub mod fn_write_field {
|
||||
use point::Point;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn inc_x(p: &mut Point) {
|
||||
p.x += 1.0;
|
||||
}
|
||||
|
|
|
@ -25,16 +25,16 @@ mod x {
|
|||
mod y {
|
||||
use x;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn y() {
|
||||
//[cfail2]~^ ERROR `typeck_tables_of(y::y)` should be clean but is not
|
||||
//[cfail2]~^ ERROR `typeck(y::y)` should be clean but is not
|
||||
x::x();
|
||||
}
|
||||
}
|
||||
|
||||
mod z {
|
||||
#[rustc_dirty(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_dirty(label="typeck", cfg="cfail2")]
|
||||
pub fn z() {
|
||||
//[cfail2]~^ ERROR `typeck_tables_of(z::z)` should be dirty but is not
|
||||
//[cfail2]~^ ERROR `typeck(z::z)` should be dirty but is not
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ pub fn change_callee_function() {
|
|||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck_tables_of")]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn change_callee_function() {
|
||||
callee2(1, 2)
|
||||
|
@ -81,7 +81,7 @@ pub fn change_callee_method() {
|
|||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck_tables_of")]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn change_callee_method() {
|
||||
let s = Struct;
|
||||
|
@ -115,7 +115,7 @@ pub fn change_ufcs_callee_method() {
|
|||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck_tables_of")]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn change_ufcs_callee_method() {
|
||||
let s = Struct;
|
||||
|
@ -149,7 +149,7 @@ pub fn change_to_ufcs() {
|
|||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck_tables_of")]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
// One might think this would be expanded in the hir_owner_nodes/Mir, but it actually
|
||||
// results in slightly different hir_owner/Mir.
|
||||
|
@ -171,7 +171,7 @@ pub mod change_ufcs_callee_indirectly {
|
|||
#[cfg(not(cfail1))]
|
||||
use super::Struct2 as Struct;
|
||||
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck_tables_of")]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ pub fn add_parameter() {
|
|||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir, typeck_tables_of")]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir, typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn add_parameter() {
|
||||
let x = 0u32;
|
||||
|
@ -53,7 +53,7 @@ pub fn change_parameter_pattern() {
|
|||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, typeck_tables_of")]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn change_parameter_pattern() {
|
||||
let _ = |(x,): (u32,)| x;
|
||||
|
@ -84,7 +84,7 @@ pub fn add_type_ascription_to_parameter() {
|
|||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg = "cfail2", except = "hir_owner_nodes, typeck_tables_of")]
|
||||
#[rustc_clean(cfg = "cfail2", except = "hir_owner_nodes, typeck")]
|
||||
#[rustc_clean(cfg = "cfail3")]
|
||||
pub fn add_type_ascription_to_parameter() {
|
||||
let closure = |x: u32| x + 1u32;
|
||||
|
@ -101,7 +101,7 @@ pub fn change_parameter_type() {
|
|||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir, typeck_tables_of")]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir, typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn change_parameter_type() {
|
||||
let closure = |x: u16| (x as u64) + 1;
|
||||
|
|
|
@ -57,7 +57,7 @@ pub fn change_field_order_struct_like() -> Enum {
|
|||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck_tables_of")]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
// FIXME(michaelwoerister):Interesting. I would have thought that that changes the MIR. And it
|
||||
// would if it were not all constants
|
||||
|
@ -96,7 +96,7 @@ pub fn change_constructor_path_struct_like() {
|
|||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck_tables_of")]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn change_constructor_path_struct_like() {
|
||||
let _ = Enum2::Struct {
|
||||
|
@ -140,7 +140,7 @@ pub mod change_constructor_path_indirectly_struct_like {
|
|||
#[rustc_clean(
|
||||
cfg="cfail2",
|
||||
except="fn_sig,hir_owner,hir_owner_nodes,optimized_mir,\
|
||||
typeck_tables_of"
|
||||
typeck"
|
||||
)]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn function() -> TheEnum {
|
||||
|
@ -197,7 +197,7 @@ pub fn change_constructor_path_tuple_like() {
|
|||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(
|
||||
cfg="cfail2",
|
||||
except="hir_owner_nodes,optimized_mir,typeck_tables_of"
|
||||
except="hir_owner_nodes,optimized_mir,typeck"
|
||||
)]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn change_constructor_path_tuple_like() {
|
||||
|
@ -215,7 +215,7 @@ pub fn change_constructor_variant_tuple_like() {
|
|||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(
|
||||
cfg="cfail2",
|
||||
except="hir_owner_nodes,optimized_mir,typeck_tables_of"
|
||||
except="hir_owner_nodes,optimized_mir,typeck"
|
||||
)]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn change_constructor_variant_tuple_like() {
|
||||
|
@ -233,7 +233,7 @@ pub mod change_constructor_path_indirectly_tuple_like {
|
|||
#[rustc_clean(
|
||||
cfg="cfail2",
|
||||
except="fn_sig,hir_owner,hir_owner_nodes,optimized_mir,\
|
||||
typeck_tables_of"
|
||||
typeck"
|
||||
)]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn function() -> TheEnum {
|
||||
|
@ -251,7 +251,7 @@ pub mod change_constructor_variant_indirectly_tuple_like {
|
|||
#[cfg(not(cfail1))]
|
||||
use super::Enum2::Tuple2 as Variant;
|
||||
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck_tables_of")]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn function() -> Enum2 {
|
||||
Variant(0, 1, 2)
|
||||
|
@ -278,7 +278,7 @@ pub fn change_constructor_path_c_like() {
|
|||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck_tables_of")]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn change_constructor_path_c_like() {
|
||||
let _x = Clike2::B;
|
||||
|
@ -310,7 +310,7 @@ pub mod change_constructor_path_indirectly_c_like {
|
|||
#[rustc_clean(
|
||||
cfg="cfail2",
|
||||
except="fn_sig,hir_owner,hir_owner_nodes,optimized_mir,\
|
||||
typeck_tables_of"
|
||||
typeck"
|
||||
)]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn function() -> TheEnum {
|
||||
|
|
|
@ -71,7 +71,7 @@ pub fn change_iteration_variable_pattern() {
|
|||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir, typeck_tables_of")]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir, typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn change_iteration_variable_pattern() {
|
||||
let mut _x = 0;
|
||||
|
@ -116,7 +116,7 @@ pub fn add_break() {
|
|||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir, typeck_tables_of")]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir, typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn add_break() {
|
||||
let mut _x = 0;
|
||||
|
|
|
@ -22,7 +22,7 @@ pub fn add_parameter() {}
|
|||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(
|
||||
cfg = "cfail2",
|
||||
except = "hir_owner, hir_owner_nodes, optimized_mir, typeck_tables_of, fn_sig"
|
||||
except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
|
||||
)]
|
||||
#[rustc_clean(cfg = "cfail3")]
|
||||
pub fn add_parameter(p: i32) {}
|
||||
|
@ -45,7 +45,7 @@ pub fn type_of_parameter(p: i32) {}
|
|||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(
|
||||
cfg = "cfail2",
|
||||
except = "hir_owner, hir_owner_nodes, optimized_mir, typeck_tables_of, fn_sig"
|
||||
except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
|
||||
)]
|
||||
#[rustc_clean(cfg = "cfail3")]
|
||||
pub fn type_of_parameter(p: i64) {}
|
||||
|
@ -58,7 +58,7 @@ pub fn type_of_parameter_ref(p: &i32) {}
|
|||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(
|
||||
cfg = "cfail2",
|
||||
except = "hir_owner, hir_owner_nodes, optimized_mir, typeck_tables_of, fn_sig"
|
||||
except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
|
||||
)]
|
||||
#[rustc_clean(cfg = "cfail3")]
|
||||
pub fn type_of_parameter_ref(p: &mut i32) {}
|
||||
|
@ -71,7 +71,7 @@ pub fn order_of_parameters(p1: i32, p2: i64) {}
|
|||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(
|
||||
cfg = "cfail2",
|
||||
except = "hir_owner, hir_owner_nodes, optimized_mir, typeck_tables_of, fn_sig"
|
||||
except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
|
||||
)]
|
||||
#[rustc_clean(cfg = "cfail3")]
|
||||
pub fn order_of_parameters(p2: i64, p1: i32) {}
|
||||
|
@ -84,7 +84,7 @@ pub fn make_unsafe() {}
|
|||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(
|
||||
cfg = "cfail2",
|
||||
except = "hir_owner, hir_owner_nodes, optimized_mir, typeck_tables_of, fn_sig"
|
||||
except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
|
||||
)]
|
||||
#[rustc_clean(cfg = "cfail3")]
|
||||
pub unsafe fn make_unsafe() {}
|
||||
|
@ -95,7 +95,7 @@ pub unsafe fn make_unsafe() {}
|
|||
pub fn make_extern() {}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, typeck_tables_of, fn_sig")]
|
||||
#[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, typeck, fn_sig")]
|
||||
#[rustc_clean(cfg = "cfail3")]
|
||||
pub extern "C" fn make_extern() {}
|
||||
|
||||
|
@ -241,7 +241,7 @@ pub fn return_impl_trait() -> i32 {
|
|||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, typeck_tables_of, fn_sig")]
|
||||
#[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, typeck, fn_sig")]
|
||||
#[rustc_clean(cfg = "cfail3")]
|
||||
pub fn return_impl_trait() -> impl Clone {
|
||||
0
|
||||
|
@ -274,7 +274,7 @@ pub mod change_return_type_indirectly {
|
|||
|
||||
#[rustc_clean(
|
||||
cfg = "cfail2",
|
||||
except = "hir_owner, hir_owner_nodes, optimized_mir, typeck_tables_of, fn_sig"
|
||||
except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
|
||||
)]
|
||||
#[rustc_clean(cfg = "cfail3")]
|
||||
pub fn indirect_return_type() -> ReturnType {
|
||||
|
@ -292,7 +292,7 @@ pub mod change_parameter_type_indirectly {
|
|||
|
||||
#[rustc_clean(
|
||||
cfg = "cfail2",
|
||||
except = "hir_owner, hir_owner_nodes, optimized_mir, typeck_tables_of, fn_sig"
|
||||
except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
|
||||
)]
|
||||
#[rustc_clean(cfg = "cfail3")]
|
||||
pub fn indirect_parameter_type(p: ParameterType) {}
|
||||
|
|
|
@ -25,7 +25,7 @@ pub fn change_condition(x: bool) -> u32 {
|
|||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck_tables_of")]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn change_condition(x: bool) -> u32 {
|
||||
if !x {
|
||||
|
@ -120,7 +120,7 @@ pub fn change_condition_if_let(x: Option<u32>) -> u32 {
|
|||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck_tables_of")]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn change_condition_if_let(x: Option<u32>) -> u32 {
|
||||
if let Some(_) = x {
|
||||
|
@ -143,7 +143,7 @@ pub fn change_then_branch_if_let(x: Option<u32>) -> u32 {
|
|||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck_tables_of")]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn change_then_branch_if_let(x: Option<u32>) -> u32 {
|
||||
if let Some(x) = x {
|
||||
|
|
|
@ -44,7 +44,7 @@ impl Foo {
|
|||
impl Foo {
|
||||
#[rustc_clean(
|
||||
cfg="cfail2",
|
||||
except="hir_owner_nodes,optimized_mir,promoted_mir,typeck_tables_of"
|
||||
except="hir_owner_nodes,optimized_mir,promoted_mir,typeck"
|
||||
)]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn method_body() {
|
||||
|
@ -68,7 +68,7 @@ impl Foo {
|
|||
impl Foo {
|
||||
#[rustc_clean(
|
||||
cfg="cfail2",
|
||||
except="hir_owner_nodes,optimized_mir,promoted_mir,typeck_tables_of"
|
||||
except="hir_owner_nodes,optimized_mir,promoted_mir,typeck"
|
||||
)]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
#[inline]
|
||||
|
@ -120,7 +120,7 @@ impl Foo {
|
|||
impl Foo {
|
||||
#[rustc_clean(
|
||||
cfg="cfail2",
|
||||
except="hir_owner,hir_owner_nodes,fn_sig,typeck_tables_of,optimized_mir"
|
||||
except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir"
|
||||
)]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn method_selfmutness(&mut self) { }
|
||||
|
@ -160,7 +160,7 @@ impl Foo {
|
|||
impl Foo {
|
||||
#[rustc_clean(
|
||||
cfg="cfail2",
|
||||
except="hir_owner,hir_owner_nodes,fn_sig,typeck_tables_of,optimized_mir"
|
||||
except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir"
|
||||
)]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn add_method_parameter(&self, _: i32) { }
|
||||
|
@ -197,7 +197,7 @@ impl Foo {
|
|||
impl Foo {
|
||||
#[rustc_clean(
|
||||
cfg="cfail2",
|
||||
except="hir_owner,hir_owner_nodes,fn_sig,optimized_mir,typeck_tables_of")]
|
||||
except="hir_owner,hir_owner_nodes,fn_sig,optimized_mir,typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn change_method_return_type(&self) -> u8 { 0 }
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ impl Foo {
|
|||
impl Foo {
|
||||
#[rustc_clean(
|
||||
cfg="cfail2",
|
||||
except="hir_owner,hir_owner_nodes,fn_sig,typeck_tables_of,optimized_mir"
|
||||
except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir"
|
||||
)]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub unsafe fn make_method_unsafe(&self) { }
|
||||
|
@ -269,7 +269,7 @@ impl Foo {
|
|||
#[rustc_clean(cfg="cfail2")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
impl Foo {
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,fn_sig,typeck_tables_of")]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,fn_sig,typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub extern fn make_method_extern(&self) { }
|
||||
}
|
||||
|
@ -286,7 +286,7 @@ impl Foo {
|
|||
#[rustc_clean(cfg="cfail2")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
impl Foo {
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,fn_sig,typeck_tables_of")]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,fn_sig,typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub extern "system" fn change_method_calling_convention(&self) { }
|
||||
}
|
||||
|
@ -303,15 +303,15 @@ impl Foo {
|
|||
#[rustc_clean(cfg="cfail2")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
impl Foo {
|
||||
// Warning: Note that `typeck_tables_of` are coming up clean here.
|
||||
// Warning: Note that `typeck` are coming up clean here.
|
||||
// The addition or removal of lifetime parameters that don't
|
||||
// appear in the arguments or fn body in any way does not, in
|
||||
// fact, affect the `typeck_tables_of` in any semantic way (at least
|
||||
// fact, affect the `typeck` in any semantic way (at least
|
||||
// as of this writing). **However,** altering the order of
|
||||
// lowering **can** cause it appear to affect the `typeck_tables_of`:
|
||||
// lowering **can** cause it appear to affect the `typeck`:
|
||||
// if we lower generics before the body, then the `HirId` for
|
||||
// things in the body will be affected. So if you start to see
|
||||
// `typeck_tables_of` appear dirty, that might be the cause. -nmatsakis
|
||||
// `typeck` appear dirty, that might be the cause. -nmatsakis
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn add_lifetime_parameter_to_method<'a>(&self) { }
|
||||
|
@ -329,14 +329,14 @@ impl Foo {
|
|||
#[rustc_clean(cfg="cfail2")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
impl Foo {
|
||||
// Warning: Note that `typeck_tables_of` are coming up clean here.
|
||||
// Warning: Note that `typeck` are coming up clean here.
|
||||
// The addition or removal of type parameters that don't appear in
|
||||
// the arguments or fn body in any way does not, in fact, affect
|
||||
// the `typeck_tables_of` in any semantic way (at least as of this
|
||||
// the `typeck` in any semantic way (at least as of this
|
||||
// writing). **However,** altering the order of lowering **can**
|
||||
// cause it appear to affect the `typeck_tables_of`: if we lower
|
||||
// cause it appear to affect the `typeck`: if we lower
|
||||
// generics before the body, then the `HirId` for things in the
|
||||
// body will be affected. So if you start to see `typeck_tables_of`
|
||||
// body will be affected. So if you start to see `typeck`
|
||||
// appear dirty, that might be the cause. -nmatsakis
|
||||
#[rustc_clean(
|
||||
cfg="cfail2",
|
||||
|
@ -378,14 +378,14 @@ impl Foo {
|
|||
#[rustc_clean(cfg="cfail2")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
impl Foo {
|
||||
// Warning: Note that `typeck_tables_of` are coming up clean here.
|
||||
// Warning: Note that `typeck` are coming up clean here.
|
||||
// The addition or removal of bounds that don't appear in the
|
||||
// arguments or fn body in any way does not, in fact, affect the
|
||||
// `typeck_tables_of` in any semantic way (at least as of this
|
||||
// `typeck` in any semantic way (at least as of this
|
||||
// writing). **However,** altering the order of lowering **can**
|
||||
// cause it appear to affect the `typeck_tables_of`: if we lower
|
||||
// cause it appear to affect the `typeck`: if we lower
|
||||
// generics before the body, then the `HirId` for things in the
|
||||
// body will be affected. So if you start to see `typeck_tables_of`
|
||||
// body will be affected. So if you start to see `typeck`
|
||||
// appear dirty, that might be the cause. -nmatsakis
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,\
|
||||
type_of")]
|
||||
|
@ -405,14 +405,14 @@ impl Foo {
|
|||
#[rustc_clean(cfg="cfail2")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
impl Foo {
|
||||
// Warning: Note that `typeck_tables_of` are coming up clean here.
|
||||
// Warning: Note that `typeck` are coming up clean here.
|
||||
// The addition or removal of bounds that don't appear in the
|
||||
// arguments or fn body in any way does not, in fact, affect the
|
||||
// `typeck_tables_of` in any semantic way (at least as of this
|
||||
// `typeck` in any semantic way (at least as of this
|
||||
// writing). **However,** altering the order of lowering **can**
|
||||
// cause it appear to affect the `typeck_tables_of`: if we lower
|
||||
// cause it appear to affect the `typeck`: if we lower
|
||||
// generics before the body, then the `HirId` for things in the
|
||||
// body will be affected. So if you start to see `typeck_tables_of`
|
||||
// body will be affected. So if you start to see `typeck`
|
||||
// appear dirty, that might be the cause. -nmatsakis
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,predicates_of")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
|
@ -453,7 +453,7 @@ impl Bar<u32> {
|
|||
impl<T> Bar<T> {
|
||||
#[rustc_clean(
|
||||
cfg="cfail2",
|
||||
except="generics_of,fn_sig,typeck_tables_of,type_of,optimized_mir"
|
||||
except="generics_of,fn_sig,typeck,type_of,optimized_mir"
|
||||
)]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn add_type_parameter_to_impl(&self) { }
|
||||
|
@ -471,7 +471,7 @@ impl Bar<u32> {
|
|||
#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
impl Bar<u64> {
|
||||
#[rustc_clean(cfg="cfail2", except="fn_sig,optimized_mir,typeck_tables_of")]
|
||||
#[rustc_clean(cfg="cfail2", except="fn_sig,optimized_mir,typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn change_impl_self_type(&self) { }
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ pub fn add_type() {
|
|||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2",
|
||||
except="hir_owner_nodes,typeck_tables_of")]
|
||||
except="hir_owner_nodes,typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn add_type() {
|
||||
let _x: u32 = 2u32;
|
||||
|
@ -54,7 +54,7 @@ pub fn change_type() {
|
|||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2",
|
||||
except="hir_owner_nodes,typeck_tables_of,optimized_mir")]
|
||||
except="hir_owner_nodes,typeck,optimized_mir")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn change_type() {
|
||||
let _x: u8 = 2;
|
||||
|
@ -70,7 +70,7 @@ pub fn change_mutability_of_reference_type() {
|
|||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2",
|
||||
except="hir_owner_nodes,typeck_tables_of,optimized_mir")]
|
||||
except="hir_owner_nodes,typeck,optimized_mir")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn change_mutability_of_reference_type() {
|
||||
let _x: &mut u64;
|
||||
|
@ -86,7 +86,7 @@ pub fn change_mutability_of_slot() {
|
|||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2",
|
||||
except="hir_owner_nodes,typeck_tables_of,optimized_mir")]
|
||||
except="hir_owner_nodes,typeck,optimized_mir")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn change_mutability_of_slot() {
|
||||
let _x: u64 = 0;
|
||||
|
@ -102,7 +102,7 @@ pub fn change_simple_binding_to_pattern() {
|
|||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2",
|
||||
except="hir_owner_nodes,typeck_tables_of,optimized_mir")]
|
||||
except="hir_owner_nodes,typeck,optimized_mir")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn change_simple_binding_to_pattern() {
|
||||
let (_a, _b) = (0u8, 'x');
|
||||
|
@ -134,7 +134,7 @@ pub fn add_ref_in_pattern() {
|
|||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2",
|
||||
except="hir_owner_nodes,typeck_tables_of,optimized_mir")]
|
||||
except="hir_owner_nodes,typeck,optimized_mir")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn add_ref_in_pattern() {
|
||||
let (ref _a, _b) = (1u8, 'y');
|
||||
|
@ -150,7 +150,7 @@ pub fn add_amp_in_pattern() {
|
|||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2",
|
||||
except="hir_owner_nodes,typeck_tables_of,optimized_mir")]
|
||||
except="hir_owner_nodes,typeck,optimized_mir")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn add_amp_in_pattern() {
|
||||
let (&_a, _b) = (&1u8, 'y');
|
||||
|
@ -166,7 +166,7 @@ pub fn change_mutability_of_binding_in_pattern() {
|
|||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2",
|
||||
except="hir_owner_nodes,typeck_tables_of,optimized_mir")]
|
||||
except="hir_owner_nodes,typeck,optimized_mir")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn change_mutability_of_binding_in_pattern() {
|
||||
let (mut _a, _b) = (99u8, 'q');
|
||||
|
@ -182,7 +182,7 @@ pub fn add_initializer() {
|
|||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2",
|
||||
except="hir_owner_nodes,typeck_tables_of,optimized_mir")]
|
||||
except="hir_owner_nodes,typeck,optimized_mir")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn add_initializer() {
|
||||
let _x: i16 = 3i16;
|
||||
|
|
|
@ -47,7 +47,7 @@ pub fn add_break() {
|
|||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir, typeck_tables_of")]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir, typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn add_break() {
|
||||
let mut _x = 0;
|
||||
|
@ -118,7 +118,7 @@ pub fn change_break_label() {
|
|||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir, typeck_tables_of")]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir, typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn change_break_label() {
|
||||
let mut _x = 0;
|
||||
|
@ -168,7 +168,7 @@ pub fn change_continue_label() {
|
|||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, typeck_tables_of")]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn change_continue_label() {
|
||||
let mut _x = 0;
|
||||
|
@ -193,7 +193,7 @@ pub fn change_continue_to_break() {
|
|||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir, typeck_tables_of")]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir, typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn change_continue_to_break() {
|
||||
let mut _x = 0;
|
||||
|
|
|
@ -26,7 +26,7 @@ pub fn add_arm(x: u32) -> u32 {
|
|||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2",
|
||||
except="hir_owner_nodes,optimized_mir,typeck_tables_of")]
|
||||
except="hir_owner_nodes,optimized_mir,typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn add_arm(x: u32) -> u32 {
|
||||
match x {
|
||||
|
@ -75,7 +75,7 @@ pub fn add_guard_clause(x: u32, y: bool) -> u32 {
|
|||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2",
|
||||
except="hir_owner_nodes,optimized_mir,typeck_tables_of")]
|
||||
except="hir_owner_nodes,optimized_mir,typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn add_guard_clause(x: u32, y: bool) -> u32 {
|
||||
match x {
|
||||
|
@ -99,7 +99,7 @@ pub fn change_guard_clause(x: u32, y: bool) -> u32 {
|
|||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2",
|
||||
except="hir_owner_nodes,optimized_mir,typeck_tables_of")]
|
||||
except="hir_owner_nodes,optimized_mir,typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn change_guard_clause(x: u32, y: bool) -> u32 {
|
||||
match x {
|
||||
|
@ -123,7 +123,7 @@ pub fn add_at_binding(x: u32) -> u32 {
|
|||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2",
|
||||
except="hir_owner_nodes,optimized_mir,typeck_tables_of")]
|
||||
except="hir_owner_nodes,optimized_mir,typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn add_at_binding(x: u32) -> u32 {
|
||||
match x {
|
||||
|
@ -170,7 +170,7 @@ pub fn change_simple_name_to_pattern(x: u32) -> u32 {
|
|||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2",
|
||||
except="hir_owner_nodes,optimized_mir,typeck_tables_of")]
|
||||
except="hir_owner_nodes,optimized_mir,typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn change_simple_name_to_pattern(x: u32) -> u32 {
|
||||
match (x, x & 1) {
|
||||
|
@ -216,7 +216,7 @@ pub fn change_mutability_of_binding_in_pattern(x: u32) -> u32 {
|
|||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2",
|
||||
except="hir_owner_nodes,optimized_mir,typeck_tables_of")]
|
||||
except="hir_owner_nodes,optimized_mir,typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn change_mutability_of_binding_in_pattern(x: u32) -> u32 {
|
||||
match (x, x & 1) {
|
||||
|
@ -238,7 +238,7 @@ pub fn add_ref_to_binding_in_pattern(x: u32) -> u32 {
|
|||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2",
|
||||
except="hir_owner_nodes,optimized_mir,typeck_tables_of")]
|
||||
except="hir_owner_nodes,optimized_mir,typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn add_ref_to_binding_in_pattern(x: u32) -> u32 {
|
||||
match (x, x & 1) {
|
||||
|
@ -260,7 +260,7 @@ pub fn add_amp_to_binding_in_pattern(x: u32) -> u32 {
|
|||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2",
|
||||
except="hir_owner_nodes,optimized_mir,typeck_tables_of")]
|
||||
except="hir_owner_nodes,optimized_mir,typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn add_amp_to_binding_in_pattern(x: u32) -> u32 {
|
||||
match (&x, x & 1) {
|
||||
|
@ -307,7 +307,7 @@ pub fn add_alternative_to_arm(x: u32) -> u32 {
|
|||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2",
|
||||
except="hir_owner_nodes,optimized_mir,typeck_tables_of")]
|
||||
except="hir_owner_nodes,optimized_mir,typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn add_alternative_to_arm(x: u32) -> u32 {
|
||||
match x {
|
||||
|
|
|
@ -54,7 +54,7 @@ pub fn change_field_order_regular_struct() -> RegularStruct {
|
|||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck_tables_of")]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn change_field_order_regular_struct() -> RegularStruct {
|
||||
RegularStruct {
|
||||
|
@ -82,7 +82,7 @@ pub fn add_field_regular_struct() -> RegularStruct {
|
|||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck_tables_of")]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn add_field_regular_struct() -> RegularStruct {
|
||||
let struct1 = RegularStruct {
|
||||
|
@ -117,7 +117,7 @@ pub fn change_field_label_regular_struct() -> RegularStruct {
|
|||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck_tables_of")]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn change_field_label_regular_struct() -> RegularStruct {
|
||||
let struct1 = RegularStruct {
|
||||
|
@ -152,7 +152,7 @@ pub fn change_constructor_path_regular_struct() {
|
|||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck_tables_of")]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn change_constructor_path_regular_struct() {
|
||||
let _ = RegularStruct2 {
|
||||
|
@ -173,7 +173,7 @@ pub mod change_constructor_path_indirectly_regular_struct {
|
|||
|
||||
#[rustc_clean(
|
||||
cfg="cfail2",
|
||||
except="fn_sig,hir_owner,hir_owner_nodes,optimized_mir,typeck_tables_of"
|
||||
except="fn_sig,hir_owner,hir_owner_nodes,optimized_mir,typeck"
|
||||
)]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn function() -> Struct {
|
||||
|
@ -213,7 +213,7 @@ pub fn change_constructor_path_tuple_struct() {
|
|||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck_tables_of")]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn change_constructor_path_tuple_struct() {
|
||||
let _ = TupleStruct2(0, 1, 2);
|
||||
|
@ -230,7 +230,7 @@ pub mod change_constructor_path_indirectly_tuple_struct {
|
|||
|
||||
#[rustc_clean(
|
||||
cfg="cfail2",
|
||||
except="fn_sig,hir_owner,hir_owner_nodes,optimized_mir,typeck_tables_of"
|
||||
except="fn_sig,hir_owner,hir_owner_nodes,optimized_mir,typeck"
|
||||
)]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn function() -> Struct {
|
||||
|
|
|
@ -368,7 +368,7 @@ pub fn type_cast(a: u8) -> u64 {
|
|||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(except="hir_owner_nodes,optimized_mir,typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(except="hir_owner_nodes,optimized_mir,typeck", cfg="cfail2")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn type_cast(a: u8) -> u64 {
|
||||
let b = a as u32;
|
||||
|
|
|
@ -70,7 +70,7 @@ pub fn add_break() {
|
|||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, typeck_tables_of")]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn add_break() {
|
||||
let mut _x = 0;
|
||||
|
|
|
@ -70,7 +70,7 @@ pub fn add_break() {
|
|||
}
|
||||
|
||||
#[cfg(not(cfail1))]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir, typeck_tables_of")]
|
||||
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir, typeck")]
|
||||
#[rustc_clean(cfg="cfail3")]
|
||||
pub fn add_break() {
|
||||
let mut _x = 0;
|
||||
|
|
|
@ -21,7 +21,7 @@ mod x {
|
|||
mod y {
|
||||
use x;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="rpass2")]
|
||||
#[rustc_clean(label="typeck", cfg="rpass2")]
|
||||
pub fn yyyy() {
|
||||
x::xxxx();
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ mod y {
|
|||
mod z {
|
||||
use y;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="rpass2")]
|
||||
#[rustc_clean(label="typeck", cfg="rpass2")]
|
||||
pub fn z() {
|
||||
y::yyyy();
|
||||
}
|
||||
|
|
|
@ -28,14 +28,14 @@ mod mod3 {
|
|||
|
||||
#[rustc_clean(label="hir_owner", cfg="rpass2")]
|
||||
#[rustc_clean(label="hir_owner_nodes", cfg="rpass2")]
|
||||
#[rustc_dirty(label="typeck_tables_of", cfg="rpass2")]
|
||||
#[rustc_dirty(label="typeck", cfg="rpass2")]
|
||||
fn bar() {
|
||||
().method();
|
||||
}
|
||||
|
||||
#[rustc_clean(label="hir_owner", cfg="rpass2")]
|
||||
#[rustc_clean(label="hir_owner_nodes", cfg="rpass2")]
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="rpass2")]
|
||||
#[rustc_clean(label="typeck", cfg="rpass2")]
|
||||
fn baz() {
|
||||
22; // no method call, traits in scope don't matter
|
||||
}
|
||||
|
|
|
@ -12,15 +12,15 @@
|
|||
|
||||
extern crate a;
|
||||
|
||||
#[rustc_dirty(label="typeck_tables_of", cfg="rpass2")]
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="rpass3")]
|
||||
#[rustc_dirty(label="typeck", cfg="rpass2")]
|
||||
#[rustc_clean(label="typeck", cfg="rpass3")]
|
||||
pub fn use_X() -> u32 {
|
||||
let x: a::X = 22;
|
||||
x as u32
|
||||
}
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="rpass2")]
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="rpass3")]
|
||||
#[rustc_clean(label="typeck", cfg="rpass2")]
|
||||
#[rustc_clean(label="typeck", cfg="rpass3")]
|
||||
pub fn use_Y() {
|
||||
let x: a::Y = 'c';
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ pub mod x {
|
|||
pub mod y {
|
||||
use x;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
#[rustc_clean(label="optimized_mir", cfg="cfail2")]
|
||||
pub fn y() {
|
||||
x::x();
|
||||
|
@ -38,7 +38,7 @@ pub mod y {
|
|||
pub mod z {
|
||||
use y;
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
#[rustc_clean(label="optimized_mir", cfg="cfail2")]
|
||||
pub fn z() {
|
||||
y::y();
|
||||
|
|
|
@ -21,17 +21,17 @@ pub struct Y {
|
|||
pub y: char
|
||||
}
|
||||
|
||||
#[rustc_dirty(label="typeck_tables_of", cfg="rpass2")]
|
||||
#[rustc_dirty(label="typeck", cfg="rpass2")]
|
||||
pub fn use_X(x: X) -> u32 {
|
||||
x.x as u32
|
||||
}
|
||||
|
||||
#[rustc_dirty(label="typeck_tables_of", cfg="rpass2")]
|
||||
#[rustc_dirty(label="typeck", cfg="rpass2")]
|
||||
pub fn use_EmbedX(embed: EmbedX) -> u32 {
|
||||
embed.x.x as u32
|
||||
}
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="rpass2")]
|
||||
#[rustc_clean(label="typeck", cfg="rpass2")]
|
||||
pub fn use_Y() {
|
||||
let x: Y = Y { y: 'c' };
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ pub struct Y {
|
|||
pub y: char
|
||||
}
|
||||
|
||||
#[rustc_dirty(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_dirty(label="typeck", cfg="cfail2")]
|
||||
pub fn use_X() -> u32 {
|
||||
let x: X = X { x: 22 };
|
||||
//[cfail2]~^ ERROR struct `X` has no field named `x`
|
||||
|
@ -32,13 +32,13 @@ pub fn use_X() -> u32 {
|
|||
//[cfail2]~^ ERROR no field `x` on type `X`
|
||||
}
|
||||
|
||||
#[rustc_dirty(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_dirty(label="typeck", cfg="cfail2")]
|
||||
pub fn use_EmbedX(embed: EmbedX) -> u32 {
|
||||
embed.x.x as u32
|
||||
//[cfail2]~^ ERROR no field `x` on type `X`
|
||||
}
|
||||
|
||||
#[rustc_clean(label="typeck_tables_of", cfg="cfail2")]
|
||||
#[rustc_clean(label="typeck", cfg="cfail2")]
|
||||
pub fn use_Y() {
|
||||
let x: Y = Y { y: 'c' };
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue