diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index 6a34a310f735a..2864e46cadcf9 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -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>>, + maybe_typeck_results: Cell>>, } 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(); } } diff --git a/src/librustc_hir/hir.rs b/src/librustc_hir/hir.rs index 9204f778a24b9..f56522406b0a7 100644 --- a/src/librustc_hir/hir.rs +++ b/src/librustc_hir/hir.rs @@ -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` diff --git a/src/librustc_incremental/persist/dirty_clean.rs b/src/librustc_incremental/persist/dirty_clean.rs index 0f558f59a12c8..d48810f1cf103 100644 --- a/src/librustc_incremental/persist/dirty_clean.rs +++ b/src/librustc_incremental/persist/dirty_clean.rs @@ -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 diff --git a/src/librustc_infer/infer/error_reporting/mod.rs b/src/librustc_infer/infer/error_reporting/mod.rs index b1ea222370742..633589db2704c 100644 --- a/src/librustc_infer/infer/error_reporting/mod.rs +++ b/src/librustc_infer/infer/error_reporting/mod.rs @@ -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) { diff --git a/src/librustc_infer/infer/error_reporting/need_type_info.rs b/src/librustc_infer/infer/error_reporting/need_type_info.rs index 1687bcc155636..bf087dfacfa43 100644 --- a/src/librustc_infer/infer/error_reporting/need_type_info.rs +++ b/src/librustc_infer/infer/error_reporting/need_type_info.rs @@ -42,8 +42,10 @@ impl<'a, 'tcx> FindHirNodeVisitor<'a, 'tcx> { } fn node_ty_contains_target(&mut self, hir_id: HirId) -> Option> { - 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() { diff --git a/src/librustc_infer/infer/mod.rs b/src/librustc_infer/infer/mod.rs index 00503a6992875..37883fcb07468 100644 --- a/src/librustc_infer/infer/mod.rs +++ b/src/librustc_infer/infer/mod.rs @@ -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>>, + pub in_progress_typeck_results: Option<&'a RefCell>>, pub inner: RefCell>, @@ -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>>, + fresh_typeck_results: Option>>, } 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(&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>>, + _in_progress_typeck_results: Option>>, } 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); diff --git a/src/librustc_lint/array_into_iter.rs b/src/librustc_lint/array_into_iter.rs index 31faad3368fdb..9d74ad3b2f558 100644 --- a/src/librustc_lint/array_into_iter.rs +++ b/src/librustc_lint/array_into_iter.rs @@ -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]", diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 75e8d1cebdb8a..69b564c573d6a 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -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!( diff --git a/src/librustc_lint/context.rs b/src/librustc_lint/context.rs index 65fd938a11351..84f5ea7bcda85 100644 --- a/src/librustc_lint/context.rs +++ b/src/librustc_lint/context.rs @@ -431,11 +431,11 @@ pub struct LateContext<'tcx> { /// Current body, or `None` if outside a body. pub enclosing_body: Option, - /// 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>>, + pub(super) cached_typeck_results: Cell>>, /// 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)), } } diff --git a/src/librustc_lint/late.rs b/src/librustc_lint/late.rs index 5feb17af24f7c..f43c197d2d201 100644 --- a/src/librustc_lint/late.rs +++ b/src/librustc_lint/late.rs @@ -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), diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 46741fcf2ba0c..8c82765c45d43 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -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 { diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index 2431f7ba54b36..6d6c7b24101ca 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -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 { diff --git a/src/librustc_metadata/rmeta/encoder.rs b/src/librustc_metadata/rmeta/encoder.rs index 5f44bcc1b5409..a8c46d3e32e6a 100644 --- a/src/librustc_metadata/rmeta/encoder.rs +++ b/src/librustc_metadata/rmeta/encoder.rs @@ -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(..) => { diff --git a/src/librustc_middle/arena.rs b/src/librustc_middle/arena.rs index c5b66c1b13be5..f2259e5e9f857 100644 --- a/src/librustc_middle/arena.rs +++ b/src/librustc_middle/arena.rs @@ -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>; diff --git a/src/librustc_middle/mir/query.rs b/src/librustc_middle/mir/query.rs index b311f8344bb6d..402a5c421a7b5 100644 --- a/src/librustc_middle/mir/query.rs +++ b/src/librustc_middle/mir/query.rs @@ -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>, pub closure_requirements: Option>, diff --git a/src/librustc_middle/query/mod.rs b/src/librustc_middle/query/mod.rs index 40ff25cf3b134..4dd8723bd72a1 100644 --- a/src/librustc_middle/query/mod.rs +++ b/src/librustc_middle/query/mod.rs @@ -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> = tcx + let typeck_results: Option> = 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) } } diff --git a/src/librustc_middle/ty/context.rs b/src/librustc_middle/ty/context.rs index bb5dd53a7e669..3dd57eea2348f 100644 --- a/src/librustc_middle/ty/context.rs +++ b/src/librustc_middle/ty/context.rs @@ -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 { - 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 { - 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>, } -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> { - 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> { - 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> for TypeckTables<'tcx> { +impl<'a, 'tcx> HashStable> 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, - ) -> &'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) } } diff --git a/src/librustc_middle/ty/mod.rs b/src/librustc_middle/ty/mod.rs index b3cfcc0f4c2a8..21745977b04b1 100644 --- a/src/librustc_middle/ty/mod.rs +++ b/src/librustc_middle/ty/mod.rs @@ -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; /// 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 { diff --git a/src/librustc_middle/ty/query/on_disk_cache.rs b/src/librustc_middle/ty/query/on_disk_cache.rs index c84a7c38d0a0e..1ba305e63fb9c 100644 --- a/src/librustc_middle/ty/query/on_disk_cache.rs +++ b/src/librustc_middle/ty/query/on_disk_cache.rs @@ -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. diff --git a/src/librustc_middle/ty/util.rs b/src/librustc_middle/ty/util.rs index 67ad7ee708267..adba45facc9b4 100644 --- a/src/librustc_middle/ty/util.rs +++ b/src/librustc_middle/ty/util.rs @@ -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) { diff --git a/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs b/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs index 17846055f6c96..8e7c97c4a1bac 100644 --- a/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs +++ b/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs @@ -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", diff --git a/src/librustc_mir/borrow_check/diagnostics/mod.rs b/src/librustc_mir/borrow_check/diagnostics/mod.rs index e94952e1c543c..d8f6abd92f6b8 100644 --- a/src/librustc_mir/borrow_check/diagnostics/mod.rs +++ b/src/librustc_mir/borrow_check/diagnostics/mod.rs @@ -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, diff --git a/src/librustc_mir/borrow_check/diagnostics/mutability_errors.rs b/src/librustc_mir/borrow_check/diagnostics/mutability_errors.rs index b4bc89e827daa..ef0fe71abecb2 100644 --- a/src/librustc_mir/borrow_check/diagnostics/mutability_errors.rs +++ b/src/librustc_mir/borrow_check/diagnostics/mutability_errors.rs @@ -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) { diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index d8d988717b824..1972b7149d569 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -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(); } diff --git a/src/librustc_mir/borrow_check/type_check/input_output.rs b/src/librustc_mir/borrow_check/type_check/input_output.rs index 8cebd3679345f..4846ef06a8b6a 100644 --- a/src/librustc_mir/borrow_check/type_check/input_output.rs +++ b/src/librustc_mir/borrow_check/type_check/input_output.rs @@ -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 diff --git a/src/librustc_mir/borrow_check/type_check/mod.rs b/src/librustc_mir/borrow_check/type_check/mod.rs index 7b84737fa77a4..bede9b22bbb0a 100644 --- a/src/librustc_mir/borrow_check/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/type_check/mod.rs @@ -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); diff --git a/src/librustc_mir/borrow_check/universal_regions.rs b/src/librustc_mir/borrow_check/universal_regions.rs index 55d817b3f1ce3..c5aa5c5ebc7f2 100644 --- a/src/librustc_mir/borrow_check/universal_regions.rs +++ b/src/librustc_mir/borrow_check/universal_regions.rs @@ -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) }; diff --git a/src/librustc_mir/const_eval/eval_queries.rs b/src/librustc_mir/const_eval/eval_queries.rs index cec7f1bcb9d9b..dc3e01f3d1561 100644 --- a/src/librustc_mir/const_eval/eval_queries.rs +++ b/src/librustc_mir/const_eval/eval_queries.rs @@ -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)); } } diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index c59b7c98e982b..ba462ec35eacf 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -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)) } } diff --git a/src/librustc_mir/interpret/place.rs b/src/librustc_mir/interpret/place.rs index 3868150c6bd28..270be98606454 100644 --- a/src/librustc_mir/interpret/place.rs +++ b/src/librustc_mir/interpret/place.rs @@ -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(), diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs index f95ac309424d0..84f39ac8955b6 100644 --- a/src/librustc_mir/interpret/validity.rs +++ b/src/librustc_mir/interpret/validity.rs @@ -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). diff --git a/src/librustc_mir_build/build/mod.rs b/src/librustc_mir_build/build/mod.rs index 21a5ea0aae305..eb47195c06278 100644 --- a/src/librustc_mir_build/build/mod.rs +++ b/src/librustc_mir_build/build/mod.rs @@ -21,7 +21,10 @@ use rustc_target::spec::PanicStrategy; use super::lints; -crate fn mir_built<'tcx>(tcx: TyCtxt<'tcx>, def: ty::WithOptConstParam) -> &'tcx ty::steal::Steal> { +crate fn mir_built<'tcx>( + tcx: TyCtxt<'tcx>, + def: ty::WithOptConstParam, +) -> &'tcx ty::steal::Steal> { 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) -> 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) -> 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) -> 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) -> 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; } diff --git a/src/librustc_mir_build/hair/cx/block.rs b/src/librustc_mir_build/hair/cx/block.rs index c7b53024666d9..a5381781d1d80 100644 --- a/src/librustc_mir_build/hair/cx/block.rs +++ b/src/librustc_mir_build/hair/cx/block.rs @@ -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, diff --git a/src/librustc_mir_build/hair/cx/expr.rs b/src/librustc_mir_build/hair/cx/expr.rs index 89ad8a1b3370c..6e1d8a8fc4012 100644 --- a/src/librustc_mir_build/hair/cx/expr.rs +++ b/src/librustc_mir_build/hair/cx/expr.rs @@ -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() diff --git a/src/librustc_mir_build/hair/cx/mod.rs b/src/librustc_mir_build/hair/cx/mod.rs index 12d1c637fb006..2694cde14fde7 100644 --- a/src/librustc_mir_build/hair/cx/mod.rs +++ b/src/librustc_mir_build/hair/cx/mod.rs @@ -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() } } diff --git a/src/librustc_mir_build/hair/pattern/check_match.rs b/src/librustc_mir_build/hair/pattern/check_match.rs index 2ae20f551be41..744f319205f94 100644 --- a/src/librustc_mir_build/hair/pattern/check_match.rs +++ b/src/librustc_mir_build/hair/pattern/check_match.rs @@ -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>, } @@ -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 /// 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`. diff --git a/src/librustc_mir_build/hair/pattern/mod.rs b/src/librustc_mir_build/hair/pattern/mod.rs index 5c30b2a448c6d..4fa23906a3568 100644 --- a/src/librustc_mir_build/hair/pattern/mod.rs +++ b/src/librustc_mir_build/hair/pattern/mod.rs @@ -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, 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 } } diff --git a/src/librustc_mir_build/hair/util.rs b/src/librustc_mir_build/hair/util.rs index 0ea0d5d1b0c19..7de60ddda41a3 100644 --- a/src/librustc_mir_build/hair/util.rs +++ b/src/librustc_mir_build/hair/util.rs @@ -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> { - 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 { diff --git a/src/librustc_passes/dead.rs b/src/librustc_passes/dead.rs index 87348894a5ad9..ab75c8ebf4c89 100644 --- a/src/librustc_passes/dead.rs +++ b/src/librustc_passes/dead.rs @@ -40,7 +40,7 @@ fn should_explore(tcx: TyCtxt<'_>, hir_id: hir::HirId) -> bool { struct MarkSymbolVisitor<'tcx> { worklist: Vec, tcx: TyCtxt<'tcx>, - maybe_typeck_tables: Option<&'tcx ty::TypeckTables<'tcx>>, + maybe_typeck_results: Option<&'tcx ty::TypeckResults<'tcx>>, live_symbols: FxHashSet, 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, diff --git a/src/librustc_passes/intrinsicck.rs b/src/librustc_passes/intrinsicck.rs index 25edfad86e8ec..931a8cb5f7d02 100644 --- a/src/librustc_passes/intrinsicck.rs +++ b/src/librustc_passes/intrinsicck.rs @@ -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)>, ) -> Option { // 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(); diff --git a/src/librustc_passes/liveness.rs b/src/librustc_passes/liveness.rs index 3675a987644da..45193c4556962 100644 --- a/src/librustc_passes/liveness.rs +++ b/src/librustc_passes/liveness.rs @@ -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, @@ -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, }; diff --git a/src/librustc_passes/reachable.rs b/src/librustc_passes/reachable.rs index c46f4856cfe3a..c71dbdf515aa9 100644 --- a/src/librustc_passes/reachable.rs +++ b/src/librustc_passes/reachable.rs @@ -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, diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 2c5cbed2192ef..7d60e027287ac 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -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, } 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); } diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index bd3724449fabf..5aa676e3fce8e 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -104,20 +104,20 @@ impl<'tcx> DumpVisitor<'tcx> { self.dumper.analysis() } - fn nest_tables(&mut self, item_def_id: LocalDefId, f: F) + fn nest_typeck_results(&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) }); } diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index e29bc9f078ddb..912ea6f5003ee 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -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 { - 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), diff --git a/src/librustc_trait_selection/traits/error_reporting/mod.rs b/src/librustc_trait_selection/traits/error_reporting/mod.rs index a9b045cee6087..112de68466084 100644 --- a/src/librustc_trait_selection/traits/error_reporting/mod.rs +++ b/src/librustc_trait_selection/traits/error_reporting/mod.rs @@ -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, diff --git a/src/librustc_trait_selection/traits/error_reporting/suggestions.rs b/src/librustc_trait_selection/traits/error_reporting/suggestions.rs index 2c6589eb2bdf9..0a6fb72ca51ea 100644 --- a/src/librustc_trait_selection/traits/error_reporting/suggestions.rs +++ b/src/librustc_trait_selection/traits/error_reporting/suggestions.rs @@ -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, 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, 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( diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index 9930a60032734..4ba64035ca44a 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -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 } diff --git a/src/librustc_typeck/check/cast.rs b/src/librustc_typeck/check/cast.rs index 8948e5a3e00db..a877df68326d6 100644 --- a/src/librustc_typeck/check/cast.rs +++ b/src/librustc_typeck/check/cast.rs @@ -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); diff --git a/src/librustc_typeck/check/closure.rs b/src/librustc_typeck/check/closure.rs index fce2b18b782fb..8b18e759026b1 100644 --- a/src/librustc_typeck/check/closure.rs +++ b/src/librustc_typeck/check/closure.rs @@ -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 } diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index e6b3224050e9b..5cf2e2d64100c 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -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 { diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index f575548ddd638..be83ab259c2ec 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -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 diff --git a/src/librustc_typeck/check/expr.rs b/src/librustc_typeck/check/expr.rs index b29f66312ef2e..63c100d5fad4f 100644 --- a/src/librustc_typeck/check/expr.rs +++ b/src/librustc_typeck/check/expr.rs @@ -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); diff --git a/src/librustc_typeck/check/generator_interior.rs b/src/librustc_typeck/check/generator_interior.rs index ce376a08ea604..c5004e4ce119b 100644 --- a/src/librustc_typeck/check/generator_interior.rs +++ b/src/librustc_typeck/check/generator_interior.rs @@ -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"); diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index 0ca85b5165ea0..96248e18aaf87 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -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, diff --git a/src/librustc_typeck/check/method/mod.rs b/src/librustc_typeck/check/method/mod.rs index b1799c6eef336..64dce3e1738e3 100644 --- a/src/librustc_typeck/check/method/mod.rs +++ b/src/librustc_typeck/check/method/mod.rs @@ -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); diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index f6ebf8b56bd4c..b9f1f8064c861 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -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); diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 9a8d78940ba0d..04e02704296de 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -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>>, + maybe_typeck_results: Option<&'a RefCell>>, } 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>>, @@ -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 { /// 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 { - &*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::>(); 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); @@ -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 = 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 diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index b61aa73bb0184..41aac3569d115 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -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 diff --git a/src/librustc_typeck/check/pat.rs b/src/librustc_typeck/check/pat.rs index 18fc37df88652..42170bc199cbc 100644 --- a/src/librustc_typeck/check/pat.rs +++ b/src/librustc_typeck/check/pat.rs @@ -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); diff --git a/src/librustc_typeck/check/place_op.rs b/src/librustc_typeck/check/place_op.rs index b7c8f310a1414..1246875092355 100644 --- a/src/librustc_typeck/check/place_op.rs +++ b/src/librustc_typeck/check/place_op.rs @@ -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[..] { diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index 199f49ca323e0..d8d904a15f39c 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -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), diff --git a/src/librustc_typeck/check/upvar.rs b/src/librustc_typeck/check/upvar.rs index 0f3133e0695f1..ffaf9ef7c9fc2 100644 --- a/src/librustc_typeck/check/upvar.rs +++ b/src/librustc_typeck/check/upvar.rs @@ -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 diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index fa17696e02b30..82ee48f0b5346 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -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 diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 17212187e6a01..ec534aa925d4f 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -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); diff --git a/src/librustc_typeck/collect/type_of.rs b/src/librustc_typeck/collect/type_of.rs index c265fadb82f94..8c9cd50a17d6a 100644 --- a/src/librustc_typeck/collect/type_of.rs +++ b/src/librustc_typeck/collect/type_of.rs @@ -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;`. diff --git a/src/librustc_typeck/expr_use_visitor.rs b/src/librustc_typeck/expr_use_visitor.rs index 1be32729b1ee5..e5bd34ff148af 100644 --- a/src/librustc_typeck/expr_use_visitor.rs +++ b/src/librustc_typeck/expr_use_visitor.rs @@ -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, diff --git a/src/librustc_typeck/mem_categorization.rs b/src/librustc_typeck/mem_categorization.rs index 70fe2c2cda512..2d7ae14d7d5a3 100644 --- a/src/librustc_typeck/mem_categorization.rs +++ b/src/librustc_typeck/mem_categorization.rs @@ -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> { - 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> { - 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> { - 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 { - 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 { - 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 { - 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() diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 6a52974534f8b..bbe2555d56c26 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -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 = 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(), diff --git a/src/test/incremental/add_private_fn_at_krate_root_cc/struct_point.rs b/src/test/incremental/add_private_fn_at_krate_root_cc/struct_point.rs index 34f30548c5a81..2af72f0e98764 100644 --- a/src/test/incremental/add_private_fn_at_krate_root_cc/struct_point.rs +++ b/src/test/incremental/add_private_fn_at_krate_root_cc/struct_point.rs @@ -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; } diff --git a/src/test/incremental/callee_caller_cross_crate/b.rs b/src/test/incremental/callee_caller_cross_crate/b.rs index b49731b26e78f..0245374007985 100644 --- a/src/test/incremental/callee_caller_cross_crate/b.rs +++ b/src/test/incremental/callee_caller_cross_crate/b.rs @@ -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); } diff --git a/src/test/incremental/change_add_field/struct_point.rs b/src/test/incremental/change_add_field/struct_point.rs index 662aa53533134..89699bce209f0 100644 --- a/src/test/incremental/change_add_field/struct_point.rs +++ b/src/test/incremental/change_add_field/struct_point.rs @@ -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; } diff --git a/src/test/incremental/change_crate_order/main.rs b/src/test/incremental/change_crate_order/main.rs index c167cf6e035d6..7448b54dd079c 100644 --- a/src/test/incremental/change_crate_order/main.rs +++ b/src/test/incremental/change_crate_order/main.rs @@ -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; } diff --git a/src/test/incremental/change_private_fn/struct_point.rs b/src/test/incremental/change_private_fn/struct_point.rs index 722e62ef11ded..ba4bf4e7b7d20 100644 --- a/src/test/incremental/change_private_fn/struct_point.rs +++ b/src/test/incremental/change_private_fn/struct_point.rs @@ -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; } diff --git a/src/test/incremental/change_private_fn_cc/struct_point.rs b/src/test/incremental/change_private_fn_cc/struct_point.rs index 384441d6d0c71..5072ef609e2cc 100644 --- a/src/test/incremental/change_private_fn_cc/struct_point.rs +++ b/src/test/incremental/change_private_fn_cc/struct_point.rs @@ -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; } diff --git a/src/test/incremental/change_private_impl_method/struct_point.rs b/src/test/incremental/change_private_impl_method/struct_point.rs index ec5899f3119d8..5c024ed91a3bf 100644 --- a/src/test/incremental/change_private_impl_method/struct_point.rs +++ b/src/test/incremental/change_private_impl_method/struct_point.rs @@ -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; } diff --git a/src/test/incremental/change_private_impl_method_cc/struct_point.rs b/src/test/incremental/change_private_impl_method_cc/struct_point.rs index f0e78f8d0a483..2aeecfc89d5c0 100644 --- a/src/test/incremental/change_private_impl_method_cc/struct_point.rs +++ b/src/test/incremental/change_private_impl_method_cc/struct_point.rs @@ -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; } diff --git a/src/test/incremental/change_pub_inherent_method_body/struct_point.rs b/src/test/incremental/change_pub_inherent_method_body/struct_point.rs index 641d20ed6cc8a..c944901e34542 100644 --- a/src/test/incremental/change_pub_inherent_method_body/struct_point.rs +++ b/src/test/incremental/change_pub_inherent_method_body/struct_point.rs @@ -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; } diff --git a/src/test/incremental/change_pub_inherent_method_sig/struct_point.rs b/src/test/incremental/change_pub_inherent_method_sig/struct_point.rs index 9b8f9517bf149..4a5aac682f5aa 100644 --- a/src/test/incremental/change_pub_inherent_method_sig/struct_point.rs +++ b/src/test/incremental/change_pub_inherent_method_sig/struct_point.rs @@ -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; } diff --git a/src/test/incremental/dirty_clean.rs b/src/test/incremental/dirty_clean.rs index b9a1846b37d44..2a1056df4ceca 100644 --- a/src/test/incremental/dirty_clean.rs +++ b/src/test/incremental/dirty_clean.rs @@ -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 } } diff --git a/src/test/incremental/hashes/call_expressions.rs b/src/test/incremental/hashes/call_expressions.rs index 73d5bcf21a2b0..d4511cee75bb9 100644 --- a/src/test/incremental/hashes/call_expressions.rs +++ b/src/test/incremental/hashes/call_expressions.rs @@ -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")] diff --git a/src/test/incremental/hashes/closure_expressions.rs b/src/test/incremental/hashes/closure_expressions.rs index a4a3ba779c017..7372cbc915608 100644 --- a/src/test/incremental/hashes/closure_expressions.rs +++ b/src/test/incremental/hashes/closure_expressions.rs @@ -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; diff --git a/src/test/incremental/hashes/enum_constructors.rs b/src/test/incremental/hashes/enum_constructors.rs index 398866bef79ae..4161c6a6bfcde 100644 --- a/src/test/incremental/hashes/enum_constructors.rs +++ b/src/test/incremental/hashes/enum_constructors.rs @@ -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 { diff --git a/src/test/incremental/hashes/for_loops.rs b/src/test/incremental/hashes/for_loops.rs index 18ba48e7b4be3..e1460503d2d94 100644 --- a/src/test/incremental/hashes/for_loops.rs +++ b/src/test/incremental/hashes/for_loops.rs @@ -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; diff --git a/src/test/incremental/hashes/function_interfaces.rs b/src/test/incremental/hashes/function_interfaces.rs index 2690b0bd6ed3d..706cbcf4caf34 100644 --- a/src/test/incremental/hashes/function_interfaces.rs +++ b/src/test/incremental/hashes/function_interfaces.rs @@ -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) {} diff --git a/src/test/incremental/hashes/if_expressions.rs b/src/test/incremental/hashes/if_expressions.rs index 8faa91e465be1..59af1fc09c2de 100644 --- a/src/test/incremental/hashes/if_expressions.rs +++ b/src/test/incremental/hashes/if_expressions.rs @@ -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 { } #[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 { if let Some(_) = x { @@ -143,7 +143,7 @@ pub fn change_then_branch_if_let(x: Option) -> 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 { if let Some(x) = x { diff --git a/src/test/incremental/hashes/inherent_impls.rs b/src/test/incremental/hashes/inherent_impls.rs index 4244e0c238688..fcd12ad30ebc9 100644 --- a/src/test/incremental/hashes/inherent_impls.rs +++ b/src/test/incremental/hashes/inherent_impls.rs @@ -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 { impl Bar { #[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 { #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")] #[rustc_clean(cfg="cfail3")] impl Bar { - #[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) { } } diff --git a/src/test/incremental/hashes/let_expressions.rs b/src/test/incremental/hashes/let_expressions.rs index b833e621a91b1..918e72582d697 100644 --- a/src/test/incremental/hashes/let_expressions.rs +++ b/src/test/incremental/hashes/let_expressions.rs @@ -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; diff --git a/src/test/incremental/hashes/loop_expressions.rs b/src/test/incremental/hashes/loop_expressions.rs index 4196fd68cb096..178def016a25f 100644 --- a/src/test/incremental/hashes/loop_expressions.rs +++ b/src/test/incremental/hashes/loop_expressions.rs @@ -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; diff --git a/src/test/incremental/hashes/match_expressions.rs b/src/test/incremental/hashes/match_expressions.rs index 1e19401479687..969f930f57bdf 100644 --- a/src/test/incremental/hashes/match_expressions.rs +++ b/src/test/incremental/hashes/match_expressions.rs @@ -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 { diff --git a/src/test/incremental/hashes/struct_constructors.rs b/src/test/incremental/hashes/struct_constructors.rs index 9e8f5ce77bc64..edec03d4f057e 100644 --- a/src/test/incremental/hashes/struct_constructors.rs +++ b/src/test/incremental/hashes/struct_constructors.rs @@ -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 { diff --git a/src/test/incremental/hashes/unary_and_binary_exprs.rs b/src/test/incremental/hashes/unary_and_binary_exprs.rs index 325dd56b7410f..687580ec8afb2 100644 --- a/src/test/incremental/hashes/unary_and_binary_exprs.rs +++ b/src/test/incremental/hashes/unary_and_binary_exprs.rs @@ -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; diff --git a/src/test/incremental/hashes/while_let_loops.rs b/src/test/incremental/hashes/while_let_loops.rs index 6608ad9c41a93..290f1b66a7369 100644 --- a/src/test/incremental/hashes/while_let_loops.rs +++ b/src/test/incremental/hashes/while_let_loops.rs @@ -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; diff --git a/src/test/incremental/hashes/while_loops.rs b/src/test/incremental/hashes/while_loops.rs index 0ecb0d79ae67e..1049dabacf2e1 100644 --- a/src/test/incremental/hashes/while_loops.rs +++ b/src/test/incremental/hashes/while_loops.rs @@ -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; diff --git a/src/test/incremental/hello_world.rs b/src/test/incremental/hello_world.rs index e4d8c56752c78..4c60d7bd9d526 100644 --- a/src/test/incremental/hello_world.rs +++ b/src/test/incremental/hello_world.rs @@ -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(); } diff --git a/src/test/incremental/ich_method_call_trait_scope.rs b/src/test/incremental/ich_method_call_trait_scope.rs index 847bce7ef90b0..6d7d446cb7c55 100644 --- a/src/test/incremental/ich_method_call_trait_scope.rs +++ b/src/test/incremental/ich_method_call_trait_scope.rs @@ -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 } diff --git a/src/test/incremental/rlib_cross_crate/b.rs b/src/test/incremental/rlib_cross_crate/b.rs index 81b84ba741dc8..73846712b5960 100644 --- a/src/test/incremental/rlib_cross_crate/b.rs +++ b/src/test/incremental/rlib_cross_crate/b.rs @@ -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'; } diff --git a/src/test/incremental/string_constant.rs b/src/test/incremental/string_constant.rs index cc35f3bdf299b..2fc725294313b 100644 --- a/src/test/incremental/string_constant.rs +++ b/src/test/incremental/string_constant.rs @@ -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(); diff --git a/src/test/incremental/struct_add_field.rs b/src/test/incremental/struct_add_field.rs index d2e1e7decf54e..4c29f196f67c9 100644 --- a/src/test/incremental/struct_add_field.rs +++ b/src/test/incremental/struct_add_field.rs @@ -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' }; } diff --git a/src/test/incremental/struct_change_field_name.rs b/src/test/incremental/struct_change_field_name.rs index 68356f703bcf8..ee88fbdf59275 100644 --- a/src/test/incremental/struct_change_field_name.rs +++ b/src/test/incremental/struct_change_field_name.rs @@ -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' }; } diff --git a/src/test/incremental/struct_change_field_type.rs b/src/test/incremental/struct_change_field_type.rs index 308ec84fa72ef..b60b4b311eeb3 100644 --- a/src/test/incremental/struct_change_field_type.rs +++ b/src/test/incremental/struct_change_field_type.rs @@ -24,19 +24,19 @@ pub struct Y { pub y: char } -#[rustc_dirty(label="typeck_tables_of", cfg="rpass2")] +#[rustc_dirty(label="typeck", cfg="rpass2")] pub fn use_X() -> u32 { let x: X = X { x: 22 }; x.x as u32 } -#[rustc_dirty(label="typeck_tables_of", cfg="rpass2")] +#[rustc_dirty(label="typeck", cfg="rpass2")] pub fn use_EmbedX(x: EmbedX) -> u32 { let x: X = X { x: 22 }; 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' }; } diff --git a/src/test/incremental/struct_change_field_type_cross_crate/b.rs b/src/test/incremental/struct_change_field_type_cross_crate/b.rs index 9d84c2cf773b8..0221d510eaba7 100644 --- a/src/test/incremental/struct_change_field_type_cross_crate/b.rs +++ b/src/test/incremental/struct_change_field_type_cross_crate/b.rs @@ -8,18 +8,18 @@ extern crate a; use a::*; -#[rustc_dirty(label="typeck_tables_of", cfg="rpass2")] +#[rustc_dirty(label="typeck", cfg="rpass2")] pub fn use_X() -> u32 { let x: X = X { x: 22 }; 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' }; } diff --git a/src/test/incremental/struct_change_nothing.rs b/src/test/incremental/struct_change_nothing.rs index bbded1da21619..3ab90e966fb6d 100644 --- a/src/test/incremental/struct_change_nothing.rs +++ b/src/test/incremental/struct_change_nothing.rs @@ -24,19 +24,19 @@ pub struct Y { pub y: char } -#[rustc_clean(label="typeck_tables_of", cfg="rpass2")] +#[rustc_clean(label="typeck", cfg="rpass2")] pub fn use_X() -> u32 { let x: X = X { x: 22 }; x.x as u32 } -#[rustc_clean(label="typeck_tables_of", cfg="rpass2")] +#[rustc_clean(label="typeck", cfg="rpass2")] pub fn use_EmbedX(x: EmbedX) -> u32 { let x: X = X { x: 22 }; 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' }; } diff --git a/src/test/incremental/struct_remove_field.rs b/src/test/incremental/struct_remove_field.rs index 4c4028bbe5bdd..f6017b1b1c3a6 100644 --- a/src/test/incremental/struct_remove_field.rs +++ b/src/test/incremental/struct_remove_field.rs @@ -25,17 +25,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' }; } diff --git a/src/test/incremental/type_alias_cross_crate/b.rs b/src/test/incremental/type_alias_cross_crate/b.rs index cef2e4bab12d7..05c926fdded7c 100644 --- a/src/test/incremental/type_alias_cross_crate/b.rs +++ b/src/test/incremental/type_alias_cross_crate/b.rs @@ -6,15 +6,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'; } diff --git a/src/test/ui/dep-graph/dep-graph-assoc-type-codegen.rs b/src/test/ui/dep-graph/dep-graph-assoc-type-codegen.rs index bcf7e3e6608ea..0d11d933af04e 100644 --- a/src/test/ui/dep-graph/dep-graph-assoc-type-codegen.rs +++ b/src/test/ui/dep-graph/dep-graph-assoc-type-codegen.rs @@ -25,7 +25,7 @@ mod x { mod y { use Foo; - #[rustc_then_this_would_need(typeck_tables_of)] //~ ERROR OK + #[rustc_then_this_would_need(typeck)] //~ ERROR OK pub fn use_char_assoc() { // Careful here: in the representation, ::T gets // normalized away, so at a certain point we had no edge to diff --git a/src/test/ui/dep-graph/dep-graph-assoc-type-codegen.stderr b/src/test/ui/dep-graph/dep-graph-assoc-type-codegen.stderr index a603d71596ba6..4e659648e9edc 100644 --- a/src/test/ui/dep-graph/dep-graph-assoc-type-codegen.stderr +++ b/src/test/ui/dep-graph/dep-graph-assoc-type-codegen.stderr @@ -1,8 +1,8 @@ error: OK --> $DIR/dep-graph-assoc-type-codegen.rs:28:5 | -LL | #[rustc_then_this_would_need(typeck_tables_of)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(typeck)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/dep-graph/dep-graph-caller-callee.rs b/src/test/ui/dep-graph/dep-graph-caller-callee.rs index 18b4252a06b84..b12c635d2e733 100644 --- a/src/test/ui/dep-graph/dep-graph-caller-callee.rs +++ b/src/test/ui/dep-graph/dep-graph-caller-callee.rs @@ -17,7 +17,7 @@ mod y { use x; // These dependencies SHOULD exist: - #[rustc_then_this_would_need(typeck_tables_of)] //~ ERROR OK + #[rustc_then_this_would_need(typeck)] //~ ERROR OK pub fn y() { x::x(); } @@ -28,7 +28,7 @@ mod z { // These are expected to yield errors, because changes to `x` // affect the BODY of `y`, but not its signature. - #[rustc_then_this_would_need(typeck_tables_of)] //~ ERROR no path + #[rustc_then_this_would_need(typeck)] //~ ERROR no path pub fn z() { y::y(); } diff --git a/src/test/ui/dep-graph/dep-graph-caller-callee.stderr b/src/test/ui/dep-graph/dep-graph-caller-callee.stderr index de041e600672d..164c474183ad0 100644 --- a/src/test/ui/dep-graph/dep-graph-caller-callee.stderr +++ b/src/test/ui/dep-graph/dep-graph-caller-callee.stderr @@ -1,14 +1,14 @@ error: OK --> $DIR/dep-graph-caller-callee.rs:20:5 | -LL | #[rustc_then_this_would_need(typeck_tables_of)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(typeck)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: no path from `x::x` to `typeck_tables_of` +error: no path from `x::x` to `typeck` --> $DIR/dep-graph-caller-callee.rs:31:5 | -LL | #[rustc_then_this_would_need(typeck_tables_of)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(typeck)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/dep-graph/dep-graph-struct-signature.rs b/src/test/ui/dep-graph/dep-graph-struct-signature.rs index 8b78d39ecae33..7ef6fac48c3a6 100644 --- a/src/test/ui/dep-graph/dep-graph-struct-signature.rs +++ b/src/test/ui/dep-graph/dep-graph-struct-signature.rs @@ -33,11 +33,11 @@ mod signatures { } #[rustc_then_this_would_need(fn_sig)] //~ ERROR OK - #[rustc_then_this_would_need(typeck_tables_of)] //~ ERROR OK + #[rustc_then_this_would_need(typeck)] //~ ERROR OK fn some_fn(x: WillChange) { } #[rustc_then_this_would_need(fn_sig)] //~ ERROR OK - #[rustc_then_this_would_need(typeck_tables_of)] //~ ERROR OK + #[rustc_then_this_would_need(typeck)] //~ ERROR OK fn new_foo(x: u32, y: u32) -> WillChange { WillChange { x: x, y: y } } @@ -45,14 +45,14 @@ mod signatures { #[rustc_then_this_would_need(type_of)] //~ ERROR OK impl WillChange { #[rustc_then_this_would_need(fn_sig)] //~ ERROR OK - #[rustc_then_this_would_need(typeck_tables_of)] //~ ERROR OK + #[rustc_then_this_would_need(typeck)] //~ ERROR OK fn new(x: u32, y: u32) -> WillChange { loop { } } } #[rustc_then_this_would_need(type_of)] //~ ERROR OK impl WillChange { #[rustc_then_this_would_need(fn_sig)] //~ ERROR OK - #[rustc_then_this_would_need(typeck_tables_of)] //~ ERROR OK + #[rustc_then_this_would_need(typeck)] //~ ERROR OK fn method(&self, x: u32) { } } @@ -81,6 +81,6 @@ mod invalid_signatures { fn b(x: WontChange) { } #[rustc_then_this_would_need(fn_sig)] //~ ERROR no path from `WillChange` - #[rustc_then_this_would_need(typeck_tables_of)] //~ ERROR no path from `WillChange` + #[rustc_then_this_would_need(typeck)] //~ ERROR no path from `WillChange` fn c(x: u32) { } } diff --git a/src/test/ui/dep-graph/dep-graph-struct-signature.stderr b/src/test/ui/dep-graph/dep-graph-struct-signature.stderr index 2e00e5a2cbd2f..9d1644a00d002 100644 --- a/src/test/ui/dep-graph/dep-graph-struct-signature.stderr +++ b/src/test/ui/dep-graph/dep-graph-struct-signature.stderr @@ -25,8 +25,8 @@ LL | #[rustc_then_this_would_need(fn_sig)] error: OK --> $DIR/dep-graph-struct-signature.rs:36:5 | -LL | #[rustc_then_this_would_need(typeck_tables_of)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(typeck)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK --> $DIR/dep-graph-struct-signature.rs:39:5 @@ -37,8 +37,8 @@ LL | #[rustc_then_this_would_need(fn_sig)] error: OK --> $DIR/dep-graph-struct-signature.rs:40:5 | -LL | #[rustc_then_this_would_need(typeck_tables_of)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(typeck)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK --> $DIR/dep-graph-struct-signature.rs:45:5 @@ -88,11 +88,11 @@ error: no path from `WillChange` to `fn_sig` LL | #[rustc_then_this_would_need(fn_sig)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: no path from `WillChange` to `typeck_tables_of` +error: no path from `WillChange` to `typeck` --> $DIR/dep-graph-struct-signature.rs:84:5 | -LL | #[rustc_then_this_would_need(typeck_tables_of)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(typeck)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK --> $DIR/dep-graph-struct-signature.rs:31:9 @@ -115,8 +115,8 @@ LL | #[rustc_then_this_would_need(fn_sig)] error: OK --> $DIR/dep-graph-struct-signature.rs:48:9 | -LL | #[rustc_then_this_would_need(typeck_tables_of)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(typeck)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK --> $DIR/dep-graph-struct-signature.rs:54:9 @@ -127,8 +127,8 @@ LL | #[rustc_then_this_would_need(fn_sig)] error: OK --> $DIR/dep-graph-struct-signature.rs:55:9 | -LL | #[rustc_then_this_would_need(typeck_tables_of)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(typeck)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 22 previous errors diff --git a/src/test/ui/dep-graph/dep-graph-trait-impl-two-traits-same-method.rs b/src/test/ui/dep-graph/dep-graph-trait-impl-two-traits-same-method.rs index 38622a754ddb2..1b3bf5a3933fe 100644 --- a/src/test/ui/dep-graph/dep-graph-trait-impl-two-traits-same-method.rs +++ b/src/test/ui/dep-graph/dep-graph-trait-impl-two-traits-same-method.rs @@ -29,7 +29,7 @@ mod x { mod y { use {Foo, Bar}; - #[rustc_then_this_would_need(typeck_tables_of)] //~ ERROR OK + #[rustc_then_this_would_need(typeck)] //~ ERROR OK pub fn with_char() { char::method('a'); } @@ -38,7 +38,7 @@ mod y { mod z { use y; - #[rustc_then_this_would_need(typeck_tables_of)] //~ ERROR no path + #[rustc_then_this_would_need(typeck)] //~ ERROR no path pub fn z() { y::with_char(); } diff --git a/src/test/ui/dep-graph/dep-graph-trait-impl-two-traits-same-method.stderr b/src/test/ui/dep-graph/dep-graph-trait-impl-two-traits-same-method.stderr index 3384fd7b4acf5..ae3d725e1c051 100644 --- a/src/test/ui/dep-graph/dep-graph-trait-impl-two-traits-same-method.stderr +++ b/src/test/ui/dep-graph/dep-graph-trait-impl-two-traits-same-method.stderr @@ -1,14 +1,14 @@ error: OK --> $DIR/dep-graph-trait-impl-two-traits-same-method.rs:32:5 | -LL | #[rustc_then_this_would_need(typeck_tables_of)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(typeck)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: no path from `x::` to `typeck_tables_of` +error: no path from `x::` to `typeck` --> $DIR/dep-graph-trait-impl-two-traits-same-method.rs:41:5 | -LL | #[rustc_then_this_would_need(typeck_tables_of)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(typeck)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/dep-graph/dep-graph-trait-impl-two-traits.rs b/src/test/ui/dep-graph/dep-graph-trait-impl-two-traits.rs index 82306b6539c15..ebfe8ccc3dfaf 100644 --- a/src/test/ui/dep-graph/dep-graph-trait-impl-two-traits.rs +++ b/src/test/ui/dep-graph/dep-graph-trait-impl-two-traits.rs @@ -28,7 +28,7 @@ mod x { mod y { use {Foo, Bar}; - #[rustc_then_this_would_need(typeck_tables_of)] //~ ERROR no path + #[rustc_then_this_would_need(typeck)] //~ ERROR no path pub fn call_bar() { char::bar('a'); } @@ -37,7 +37,7 @@ mod y { mod z { use y; - #[rustc_then_this_would_need(typeck_tables_of)] //~ ERROR no path + #[rustc_then_this_would_need(typeck)] //~ ERROR no path pub fn z() { y::call_bar(); } diff --git a/src/test/ui/dep-graph/dep-graph-trait-impl-two-traits.stderr b/src/test/ui/dep-graph/dep-graph-trait-impl-two-traits.stderr index d8a1f05dcaa79..4823927477fe0 100644 --- a/src/test/ui/dep-graph/dep-graph-trait-impl-two-traits.stderr +++ b/src/test/ui/dep-graph/dep-graph-trait-impl-two-traits.stderr @@ -1,14 +1,14 @@ -error: no path from `x::` to `typeck_tables_of` +error: no path from `x::` to `typeck` --> $DIR/dep-graph-trait-impl-two-traits.rs:31:5 | -LL | #[rustc_then_this_would_need(typeck_tables_of)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(typeck)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: no path from `x::` to `typeck_tables_of` +error: no path from `x::` to `typeck` --> $DIR/dep-graph-trait-impl-two-traits.rs:40:5 | -LL | #[rustc_then_this_would_need(typeck_tables_of)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(typeck)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/dep-graph/dep-graph-trait-impl.rs b/src/test/ui/dep-graph/dep-graph-trait-impl.rs index e4483b9f71ddb..9dd201e2a1fbc 100644 --- a/src/test/ui/dep-graph/dep-graph-trait-impl.rs +++ b/src/test/ui/dep-graph/dep-graph-trait-impl.rs @@ -24,22 +24,22 @@ mod x { mod y { use Foo; - #[rustc_then_this_would_need(typeck_tables_of)] //~ ERROR OK + #[rustc_then_this_would_need(typeck)] //~ ERROR OK pub fn with_char() { char::method('a'); } - #[rustc_then_this_would_need(typeck_tables_of)] //~ ERROR OK + #[rustc_then_this_would_need(typeck)] //~ ERROR OK pub fn take_foo_with_char() { take_foo::('a'); } - #[rustc_then_this_would_need(typeck_tables_of)] //~ ERROR OK + #[rustc_then_this_would_need(typeck)] //~ ERROR OK pub fn with_u32() { u32::method(22); } - #[rustc_then_this_would_need(typeck_tables_of)] //~ ERROR OK + #[rustc_then_this_would_need(typeck)] //~ ERROR OK pub fn take_foo_with_u32() { take_foo::(22); } @@ -52,7 +52,7 @@ mod z { // These are expected to yield errors, because changes to `x` // affect the BODY of `y`, but not its signature. - #[rustc_then_this_would_need(typeck_tables_of)] //~ ERROR no path + #[rustc_then_this_would_need(typeck)] //~ ERROR no path pub fn z() { y::with_char(); y::with_u32(); diff --git a/src/test/ui/dep-graph/dep-graph-trait-impl.stderr b/src/test/ui/dep-graph/dep-graph-trait-impl.stderr index ca9676a9478e4..f8ead80894276 100644 --- a/src/test/ui/dep-graph/dep-graph-trait-impl.stderr +++ b/src/test/ui/dep-graph/dep-graph-trait-impl.stderr @@ -1,32 +1,32 @@ error: OK --> $DIR/dep-graph-trait-impl.rs:27:5 | -LL | #[rustc_then_this_would_need(typeck_tables_of)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(typeck)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK --> $DIR/dep-graph-trait-impl.rs:32:5 | -LL | #[rustc_then_this_would_need(typeck_tables_of)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(typeck)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK --> $DIR/dep-graph-trait-impl.rs:37:5 | -LL | #[rustc_then_this_would_need(typeck_tables_of)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(typeck)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK --> $DIR/dep-graph-trait-impl.rs:42:5 | -LL | #[rustc_then_this_would_need(typeck_tables_of)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(typeck)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: no path from `x::` to `typeck_tables_of` +error: no path from `x::` to `typeck` --> $DIR/dep-graph-trait-impl.rs:55:5 | -LL | #[rustc_then_this_would_need(typeck_tables_of)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(typeck)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 5 previous errors diff --git a/src/test/ui/dep-graph/dep-graph-type-alias.rs b/src/test/ui/dep-graph/dep-graph-type-alias.rs index 2d4a18f2818b5..c9151ce79c5f6 100644 --- a/src/test/ui/dep-graph/dep-graph-type-alias.rs +++ b/src/test/ui/dep-graph/dep-graph-type-alias.rs @@ -41,7 +41,7 @@ struct SomeType; #[rustc_then_this_would_need(type_of)] //~ ERROR no path impl SomeType { #[rustc_then_this_would_need(fn_sig)] //~ ERROR OK - #[rustc_then_this_would_need(typeck_tables_of)] //~ ERROR OK + #[rustc_then_this_would_need(typeck)] //~ ERROR OK fn method(&self, _: TypeAlias) {} } @@ -49,7 +49,7 @@ impl SomeType { type TypeAlias2 = TypeAlias; #[rustc_then_this_would_need(fn_sig)] //~ ERROR OK -#[rustc_then_this_would_need(typeck_tables_of)] //~ ERROR OK +#[rustc_then_this_would_need(typeck)] //~ ERROR OK fn function(_: TypeAlias) { } diff --git a/src/test/ui/dep-graph/dep-graph-type-alias.stderr b/src/test/ui/dep-graph/dep-graph-type-alias.stderr index 393e4badc1608..9baaf746fc210 100644 --- a/src/test/ui/dep-graph/dep-graph-type-alias.stderr +++ b/src/test/ui/dep-graph/dep-graph-type-alias.stderr @@ -49,8 +49,8 @@ LL | #[rustc_then_this_would_need(fn_sig)] error: OK --> $DIR/dep-graph-type-alias.rs:52:1 | -LL | #[rustc_then_this_would_need(typeck_tables_of)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(typeck)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: OK --> $DIR/dep-graph-type-alias.rs:35:5 @@ -67,8 +67,8 @@ LL | #[rustc_then_this_would_need(fn_sig)] error: OK --> $DIR/dep-graph-type-alias.rs:44:5 | -LL | #[rustc_then_this_would_need(typeck_tables_of)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_then_this_would_need(typeck)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 12 previous errors diff --git a/src/tools/clippy/clippy_lints/src/arithmetic.rs b/src/tools/clippy/clippy_lints/src/arithmetic.rs index da60856fac932..e84481f9b5385 100644 --- a/src/tools/clippy/clippy_lints/src/arithmetic.rs +++ b/src/tools/clippy/clippy_lints/src/arithmetic.rs @@ -86,7 +86,7 @@ impl<'tcx> LateLintPass<'tcx> for Arithmetic { _ => (), } - let (l_ty, r_ty) = (cx.tables().expr_ty(l), cx.tables().expr_ty(r)); + let (l_ty, r_ty) = (cx.typeck_results().expr_ty(l), cx.typeck_results().expr_ty(r)); if l_ty.peel_refs().is_integral() && r_ty.peel_refs().is_integral() { span_lint(cx, INTEGER_ARITHMETIC, expr.span, "integer arithmetic detected"); self.expr_span = Some(expr.span); @@ -96,8 +96,8 @@ impl<'tcx> LateLintPass<'tcx> for Arithmetic { } }, hir::ExprKind::Unary(hir::UnOp::UnNeg, arg) => { - let ty = cx.tables().expr_ty(arg); - if constant_simple(cx, cx.tables(), expr).is_none() { + let ty = cx.typeck_results().expr_ty(arg); + if constant_simple(cx, cx.typeck_results(), expr).is_none() { if ty.is_integral() { span_lint(cx, INTEGER_ARITHMETIC, expr.span, "integer arithmetic detected"); self.expr_span = Some(expr.span); diff --git a/src/tools/clippy/clippy_lints/src/assertions_on_constants.rs b/src/tools/clippy/clippy_lints/src/assertions_on_constants.rs index cffe8d94e2797..982d5ecf8d02f 100644 --- a/src/tools/clippy/clippy_lints/src/assertions_on_constants.rs +++ b/src/tools/clippy/clippy_lints/src/assertions_on_constants.rs @@ -72,7 +72,7 @@ impl<'tcx> LateLintPass<'tcx> for AssertionsOnConstants { } if_chain! { if let ExprKind::Unary(_, ref lit) = e.kind; - if let Some((Constant::Bool(is_true), _)) = constant(cx, cx.tables(), lit); + if let Some((Constant::Bool(is_true), _)) = constant(cx, cx.typeck_results(), lit); if is_true; then { lint_true(true); @@ -121,7 +121,7 @@ fn match_assert_with_message<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) if let ExprKind::DropTemps(ref expr) = expr.kind; if let ExprKind::Unary(UnOp::UnNot, ref expr) = expr.kind; // bind the first argument of the `assert!` macro - if let Some((Constant::Bool(is_true), _)) = constant(cx, cx.tables(), expr); + if let Some((Constant::Bool(is_true), _)) = constant(cx, cx.typeck_results(), expr); // arm 1 pattern if let PatKind::Lit(ref lit_expr) = arms[0].pat.kind; if let ExprKind::Lit(ref lit) = lit_expr.kind; diff --git a/src/tools/clippy/clippy_lints/src/assign_ops.rs b/src/tools/clippy/clippy_lints/src/assign_ops.rs index bc6e868823f77..dab1e96e282f0 100644 --- a/src/tools/clippy/clippy_lints/src/assign_ops.rs +++ b/src/tools/clippy/clippy_lints/src/assign_ops.rs @@ -82,8 +82,8 @@ impl<'tcx> LateLintPass<'tcx> for AssignOps { hir::ExprKind::Assign(assignee, e, _) => { if let hir::ExprKind::Binary(op, l, r) = &e.kind { let lint = |assignee: &hir::Expr<'_>, rhs: &hir::Expr<'_>| { - let ty = cx.tables().expr_ty(assignee); - let rty = cx.tables().expr_ty(rhs); + let ty = cx.typeck_results().expr_ty(assignee); + let rty = cx.typeck_results().expr_ty(rhs); macro_rules! ops { ($op:expr, $cx:expr, @@ -167,7 +167,7 @@ impl<'tcx> LateLintPass<'tcx> for AssignOps { // a = b commutative_op a // Limited to primitive type as these ops are know to be commutative if SpanlessEq::new(cx).ignore_fn().eq_expr(assignee, r) - && cx.tables().expr_ty(assignee).is_primitive_ty() + && cx.typeck_results().expr_ty(assignee).is_primitive_ty() { match op.node { hir::BinOpKind::Add diff --git a/src/tools/clippy/clippy_lints/src/atomic_ordering.rs b/src/tools/clippy/clippy_lints/src/atomic_ordering.rs index efd3f0f671cdd..277fe350055ec 100644 --- a/src/tools/clippy/clippy_lints/src/atomic_ordering.rs +++ b/src/tools/clippy/clippy_lints/src/atomic_ordering.rs @@ -53,7 +53,7 @@ const ATOMIC_TYPES: [&str; 12] = [ ]; fn type_is_atomic(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { - if let ty::Adt(&ty::AdtDef { did, .. }, _) = cx.tables().expr_ty(expr).kind { + if let ty::Adt(&ty::AdtDef { did, .. }, _) = cx.typeck_results().expr_ty(expr).kind { ATOMIC_TYPES .iter() .any(|ty| match_def_path(cx, did, &["core", "sync", "atomic", ty])) diff --git a/src/tools/clippy/clippy_lints/src/attrs.rs b/src/tools/clippy/clippy_lints/src/attrs.rs index c29432bf93384..27a7fa8862237 100644 --- a/src/tools/clippy/clippy_lints/src/attrs.rs +++ b/src/tools/clippy/clippy_lints/src/attrs.rs @@ -461,7 +461,7 @@ fn check_clippy_lint_names(cx: &LateContext<'_>, ident: &str, items: &[NestedMet fn is_relevant_item(cx: &LateContext<'_>, item: &Item<'_>) -> bool { if let ItemKind::Fn(_, _, eid) = item.kind { - is_relevant_expr(cx, cx.tcx.body_tables(eid), &cx.tcx.hir().body(eid).value) + is_relevant_expr(cx, cx.tcx.typeck_body(eid), &cx.tcx.hir().body(eid).value) } else { true } @@ -469,7 +469,7 @@ fn is_relevant_item(cx: &LateContext<'_>, item: &Item<'_>) -> bool { fn is_relevant_impl(cx: &LateContext<'_>, item: &ImplItem<'_>) -> bool { match item.kind { - ImplItemKind::Fn(_, eid) => is_relevant_expr(cx, cx.tcx.body_tables(eid), &cx.tcx.hir().body(eid).value), + ImplItemKind::Fn(_, eid) => is_relevant_expr(cx, cx.tcx.typeck_body(eid), &cx.tcx.hir().body(eid).value), _ => false, } } @@ -478,31 +478,34 @@ fn is_relevant_trait(cx: &LateContext<'_>, item: &TraitItem<'_>) -> bool { match item.kind { TraitItemKind::Fn(_, TraitFn::Required(_)) => true, TraitItemKind::Fn(_, TraitFn::Provided(eid)) => { - is_relevant_expr(cx, cx.tcx.body_tables(eid), &cx.tcx.hir().body(eid).value) + is_relevant_expr(cx, cx.tcx.typeck_body(eid), &cx.tcx.hir().body(eid).value) }, _ => false, } } -fn is_relevant_block(cx: &LateContext<'_>, tables: &ty::TypeckTables<'_>, block: &Block<'_>) -> bool { +fn is_relevant_block(cx: &LateContext<'_>, typeck_results: &ty::TypeckResults<'_>, block: &Block<'_>) -> bool { block.stmts.first().map_or( - block.expr.as_ref().map_or(false, |e| is_relevant_expr(cx, tables, e)), + block + .expr + .as_ref() + .map_or(false, |e| is_relevant_expr(cx, typeck_results, e)), |stmt| match &stmt.kind { StmtKind::Local(_) => true, - StmtKind::Expr(expr) | StmtKind::Semi(expr) => is_relevant_expr(cx, tables, expr), + StmtKind::Expr(expr) | StmtKind::Semi(expr) => is_relevant_expr(cx, typeck_results, expr), _ => false, }, ) } -fn is_relevant_expr(cx: &LateContext<'_>, tables: &ty::TypeckTables<'_>, expr: &Expr<'_>) -> bool { +fn is_relevant_expr(cx: &LateContext<'_>, typeck_results: &ty::TypeckResults<'_>, expr: &Expr<'_>) -> bool { match &expr.kind { - ExprKind::Block(block, _) => is_relevant_block(cx, tables, block), - ExprKind::Ret(Some(e)) => is_relevant_expr(cx, tables, e), + ExprKind::Block(block, _) => is_relevant_block(cx, typeck_results, block), + ExprKind::Ret(Some(e)) => is_relevant_expr(cx, typeck_results, e), ExprKind::Ret(None) | ExprKind::Break(_, None) => false, ExprKind::Call(path_expr, _) => { if let ExprKind::Path(qpath) = &path_expr.kind { - tables + typeck_results .qpath_res(qpath, path_expr.hir_id) .opt_def_id() .map_or(true, |fun_id| !match_def_path(cx, fun_id, &paths::BEGIN_PANIC)) diff --git a/src/tools/clippy/clippy_lints/src/await_holding_lock.rs b/src/tools/clippy/clippy_lints/src/await_holding_lock.rs index d337262dfa6e2..b10b1e0a65ab9 100644 --- a/src/tools/clippy/clippy_lints/src/await_holding_lock.rs +++ b/src/tools/clippy/clippy_lints/src/await_holding_lock.rs @@ -59,8 +59,8 @@ impl LateLintPass<'_> for AwaitHoldingLock { hir_id: body.value.hir_id, }; let def_id = cx.tcx.hir().body_owner_def_id(body_id); - let tables = cx.tcx.typeck_tables_of(def_id); - check_interior_types(cx, &tables.generator_interior_types, body.value.span); + let typeck_results = cx.tcx.typeck(def_id); + check_interior_types(cx, &typeck_results.generator_interior_types, body.value.span); } } } diff --git a/src/tools/clippy/clippy_lints/src/bit_mask.rs b/src/tools/clippy/clippy_lints/src/bit_mask.rs index d1d177e7a4abb..81a34021e8a01 100644 --- a/src/tools/clippy/clippy_lints/src/bit_mask.rs +++ b/src/tools/clippy/clippy_lints/src/bit_mask.rs @@ -319,7 +319,7 @@ fn check_ineffective_gt(cx: &LateContext<'_>, span: Span, m: u128, c: u128, op: } fn fetch_int_literal(cx: &LateContext<'_>, lit: &Expr<'_>) -> Option { - match constant(cx, cx.tables(), lit)?.0 { + match constant(cx, cx.typeck_results(), lit)?.0 { Constant::Int(n) => Some(n), _ => None, } diff --git a/src/tools/clippy/clippy_lints/src/booleans.rs b/src/tools/clippy/clippy_lints/src/booleans.rs index 32d0979e99b60..18529f2113e77 100644 --- a/src/tools/clippy/clippy_lints/src/booleans.rs +++ b/src/tools/clippy/clippy_lints/src/booleans.rs @@ -111,8 +111,12 @@ impl<'a, 'tcx, 'v> Hir2Qmm<'a, 'tcx, 'v> { match &e.kind { ExprKind::Unary(UnOp::UnNot, inner) => return Ok(Bool::Not(box self.run(inner)?)), ExprKind::Binary(binop, lhs, rhs) => match &binop.node { - BinOpKind::Or => return Ok(Bool::Or(self.extract(BinOpKind::Or, &[lhs, rhs], Vec::new())?)), - BinOpKind::And => return Ok(Bool::And(self.extract(BinOpKind::And, &[lhs, rhs], Vec::new())?)), + BinOpKind::Or => { + return Ok(Bool::Or(self.extract(BinOpKind::Or, &[lhs, rhs], Vec::new())?)); + }, + BinOpKind::And => { + return Ok(Bool::And(self.extract(BinOpKind::And, &[lhs, rhs], Vec::new())?)); + }, _ => (), }, ExprKind::Lit(lit) => match lit.node { @@ -248,7 +252,7 @@ fn simplify_not(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option { }) }, ExprKind::MethodCall(path, _, args, _) if args.len() == 1 => { - let type_of_receiver = cx.tables().expr_ty(&args[0]); + let type_of_receiver = cx.typeck_results().expr_ty(&args[0]); if !is_type_diagnostic_item(cx, type_of_receiver, sym!(option_type)) && !is_type_diagnostic_item(cx, type_of_receiver, sym!(result_type)) { @@ -450,7 +454,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NonminimalBoolVisitor<'a, 'tcx> { self.bool_expr(e) }, ExprKind::Unary(UnOp::UnNot, inner) => { - if self.cx.tables().node_types()[inner.hir_id].is_bool() { + if self.cx.typeck_results().node_types()[inner.hir_id].is_bool() { self.bool_expr(e); } else { walk_expr(self, e); @@ -465,7 +469,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NonminimalBoolVisitor<'a, 'tcx> { } fn implements_ord<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>) -> bool { - let ty = cx.tables().expr_ty(expr); + let ty = cx.typeck_results().expr_ty(expr); get_trait_def_id(cx, &paths::ORD).map_or(false, |id| implements_trait(cx, ty, id, &[])) } diff --git a/src/tools/clippy/clippy_lints/src/bytecount.rs b/src/tools/clippy/clippy_lints/src/bytecount.rs index 1cdfea1f52655..dde799fcae4cc 100644 --- a/src/tools/clippy/clippy_lints/src/bytecount.rs +++ b/src/tools/clippy/clippy_lints/src/bytecount.rs @@ -53,7 +53,7 @@ impl<'tcx> LateLintPass<'tcx> for ByteCount { if let ExprKind::Binary(ref op, ref l, ref r) = body.value.kind; if op.node == BinOpKind::Eq; if match_type(cx, - walk_ptrs_ty(cx.tables().expr_ty(&filter_args[0])), + walk_ptrs_ty(cx.typeck_results().expr_ty(&filter_args[0])), &paths::SLICE_ITER); then { let needle = match get_path_name(l) { @@ -63,7 +63,7 @@ impl<'tcx> LateLintPass<'tcx> for ByteCount { _ => { return; } } }; - if ty::Uint(UintTy::U8) != walk_ptrs_ty(cx.tables().expr_ty(needle)).kind { + if ty::Uint(UintTy::U8) != walk_ptrs_ty(cx.typeck_results().expr_ty(needle)).kind { return; } let haystack = if let ExprKind::MethodCall(ref path, _, ref args, _) = diff --git a/src/tools/clippy/clippy_lints/src/cognitive_complexity.rs b/src/tools/clippy/clippy_lints/src/cognitive_complexity.rs index 6bbdbe957cc83..14ef8c319eff1 100644 --- a/src/tools/clippy/clippy_lints/src/cognitive_complexity.rs +++ b/src/tools/clippy/clippy_lints/src/cognitive_complexity.rs @@ -60,7 +60,7 @@ impl CognitiveComplexity { let mut helper = CCHelper { cc: 1, returns: 0 }; helper.visit_expr(expr); let CCHelper { cc, returns } = helper; - let ret_ty = cx.tables().node_type(expr.hir_id); + let ret_ty = cx.typeck_results().node_type(expr.hir_id); let ret_adjust = if is_type_diagnostic_item(cx, ret_ty, sym!(result_type)) { returns } else { diff --git a/src/tools/clippy/clippy_lints/src/comparison_chain.rs b/src/tools/clippy/clippy_lints/src/comparison_chain.rs index 25ccabc1c883e..99f161a0510f4 100644 --- a/src/tools/clippy/clippy_lints/src/comparison_chain.rs +++ b/src/tools/clippy/clippy_lints/src/comparison_chain.rs @@ -99,7 +99,7 @@ impl<'tcx> LateLintPass<'tcx> for ComparisonChain { } // Check that the type being compared implements `core::cmp::Ord` - let ty = cx.tables().expr_ty(lhs1); + let ty = cx.typeck_results().expr_ty(lhs1); let is_ord = get_trait_def_id(cx, &paths::ORD).map_or(false, |id| implements_trait(cx, ty, id, &[])); if !is_ord { diff --git a/src/tools/clippy/clippy_lints/src/consts.rs b/src/tools/clippy/clippy_lints/src/consts.rs index e6ef54f528f4b..49ff86a205d96 100644 --- a/src/tools/clippy/clippy_lints/src/consts.rs +++ b/src/tools/clippy/clippy_lints/src/consts.rs @@ -174,12 +174,12 @@ pub fn lit_to_constant(lit: &LitKind, ty: Option>) -> Constant { pub fn constant<'tcx>( lcx: &LateContext<'tcx>, - tables: &ty::TypeckTables<'tcx>, + typeck_results: &ty::TypeckResults<'tcx>, e: &Expr<'_>, ) -> Option<(Constant, bool)> { let mut cx = ConstEvalLateContext { lcx, - tables, + typeck_results, param_env: lcx.param_env, needed_resolution: false, substs: lcx.tcx.intern_substs(&[]), @@ -189,20 +189,20 @@ pub fn constant<'tcx>( pub fn constant_simple<'tcx>( lcx: &LateContext<'tcx>, - tables: &ty::TypeckTables<'tcx>, + typeck_results: &ty::TypeckResults<'tcx>, e: &Expr<'_>, ) -> Option { - constant(lcx, tables, e).and_then(|(cst, res)| if res { None } else { Some(cst) }) + constant(lcx, typeck_results, e).and_then(|(cst, res)| if res { None } else { Some(cst) }) } -/// Creates a `ConstEvalLateContext` from the given `LateContext` and `TypeckTables`. +/// Creates a `ConstEvalLateContext` from the given `LateContext` and `TypeckResults`. pub fn constant_context<'a, 'tcx>( lcx: &'a LateContext<'tcx>, - tables: &'a ty::TypeckTables<'tcx>, + typeck_results: &'a ty::TypeckResults<'tcx>, ) -> ConstEvalLateContext<'a, 'tcx> { ConstEvalLateContext { lcx, - tables, + typeck_results, param_env: lcx.param_env, needed_resolution: false, substs: lcx.tcx.intern_substs(&[]), @@ -211,7 +211,7 @@ pub fn constant_context<'a, 'tcx>( pub struct ConstEvalLateContext<'a, 'tcx> { lcx: &'a LateContext<'tcx>, - tables: &'a ty::TypeckTables<'tcx>, + typeck_results: &'a ty::TypeckResults<'tcx>, param_env: ty::ParamEnv<'tcx>, needed_resolution: bool, substs: SubstsRef<'tcx>, @@ -224,21 +224,21 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> { return self.ifthenelse(cond, then, otherwise); } match e.kind { - ExprKind::Path(ref qpath) => self.fetch_path(qpath, e.hir_id, self.tables.expr_ty(e)), + ExprKind::Path(ref qpath) => self.fetch_path(qpath, e.hir_id, self.typeck_results.expr_ty(e)), ExprKind::Block(ref block, _) => self.block(block), - ExprKind::Lit(ref lit) => Some(lit_to_constant(&lit.node, self.tables.expr_ty_opt(e))), + ExprKind::Lit(ref lit) => Some(lit_to_constant(&lit.node, self.typeck_results.expr_ty_opt(e))), ExprKind::Array(ref vec) => self.multi(vec).map(Constant::Vec), ExprKind::Tup(ref tup) => self.multi(tup).map(Constant::Tuple), ExprKind::Repeat(ref value, _) => { - let n = match self.tables.expr_ty(e).kind { + let n = match self.typeck_results.expr_ty(e).kind { ty::Array(_, n) => n.try_eval_usize(self.lcx.tcx, self.lcx.param_env)?, _ => span_bug!(e.span, "typeck error"), }; self.expr(value).map(|v| Constant::Repeat(Box::new(v), n)) }, ExprKind::Unary(op, ref operand) => self.expr(operand).and_then(|o| match op { - UnOp::UnNot => self.constant_not(&o, self.tables.expr_ty(e)), - UnOp::UnNeg => self.constant_negate(&o, self.tables.expr_ty(e)), + UnOp::UnNot => self.constant_not(&o, self.typeck_results.expr_ty(e)), + UnOp::UnNeg => self.constant_negate(&o, self.typeck_results.expr_ty(e)), UnOp::UnDeref => Some(o), }), ExprKind::Binary(op, ref left, ref right) => self.binop(op, left, right), @@ -247,7 +247,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> { if_chain! { if args.is_empty(); if let ExprKind::Path(qpath) = &callee.kind; - let res = self.tables.qpath_res(qpath, callee.hir_id); + let res = self.typeck_results.qpath_res(qpath, callee.hir_id); if let Some(def_id) = res.opt_def_id(); let def_path: Vec<_> = self.lcx.get_def_path(def_id).into_iter().map(Symbol::as_str).collect(); let def_path: Vec<&str> = def_path.iter().take(4).map(|s| &**s).collect(); @@ -319,10 +319,10 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> { /// Lookup a possibly constant expression from a `ExprKind::Path`. fn fetch_path(&mut self, qpath: &QPath<'_>, id: HirId, ty: Ty<'tcx>) -> Option { - let res = self.tables.qpath_res(qpath, id); + let res = self.typeck_results.qpath_res(qpath, id); match res { Res::Def(DefKind::Const | DefKind::AssocConst, def_id) => { - let substs = self.tables.node_substs(id); + let substs = self.typeck_results.node_substs(id); let substs = if self.substs.is_empty() { substs } else { @@ -332,7 +332,13 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> { let result = self .lcx .tcx - .const_eval_resolve(self.param_env, ty::WithOptConstParam::unknown(def_id), substs, None, None) + .const_eval_resolve( + self.param_env, + ty::WithOptConstParam::unknown(def_id), + substs, + None, + None, + ) .ok() .map(|val| rustc_middle::ty::Const::from_value(self.lcx.tcx, val, ty))?; let result = miri_to_const(&result); @@ -396,7 +402,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> { let l = self.expr(left)?; let r = self.expr(right); match (l, r) { - (Constant::Int(l), Some(Constant::Int(r))) => match self.tables.expr_ty_opt(left)?.kind { + (Constant::Int(l), Some(Constant::Int(r))) => match self.typeck_results.expr_ty_opt(left)?.kind { ty::Int(ity) => { let l = sext(self.lcx.tcx, l, ity); let r = sext(self.lcx.tcx, r, ity); @@ -488,23 +494,25 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> { pub fn miri_to_const(result: &ty::Const<'_>) -> Option { use rustc_middle::mir::interpret::{ConstValue, Scalar}; match result.val { - ty::ConstKind::Value(ConstValue::Scalar(Scalar::Raw { data: d, .. })) => match result.ty.kind { - ty::Bool => Some(Constant::Bool(d == 1)), - ty::Uint(_) | ty::Int(_) => Some(Constant::Int(d)), - ty::Float(FloatTy::F32) => Some(Constant::F32(f32::from_bits( - d.try_into().expect("invalid f32 bit representation"), - ))), - ty::Float(FloatTy::F64) => Some(Constant::F64(f64::from_bits( - d.try_into().expect("invalid f64 bit representation"), - ))), - ty::RawPtr(type_and_mut) => { - if let ty::Uint(_) = type_and_mut.ty.kind { - return Some(Constant::RawPtr(d)); - } - None - }, - // FIXME: implement other conversions. - _ => None, + ty::ConstKind::Value(ConstValue::Scalar(Scalar::Raw { data: d, .. })) => { + match result.ty.kind { + ty::Bool => Some(Constant::Bool(d == 1)), + ty::Uint(_) | ty::Int(_) => Some(Constant::Int(d)), + ty::Float(FloatTy::F32) => Some(Constant::F32(f32::from_bits( + d.try_into().expect("invalid f32 bit representation"), + ))), + ty::Float(FloatTy::F64) => Some(Constant::F64(f64::from_bits( + d.try_into().expect("invalid f64 bit representation"), + ))), + ty::RawPtr(type_and_mut) => { + if let ty::Uint(_) = type_and_mut.ty.kind { + return Some(Constant::RawPtr(d)); + } + None + }, + // FIXME: implement other conversions. + _ => None, + } }, ty::ConstKind::Value(ConstValue::Slice { data, start, end }) => match result.ty.kind { ty::Ref(_, tam, _) => match tam.kind { diff --git a/src/tools/clippy/clippy_lints/src/copies.rs b/src/tools/clippy/clippy_lints/src/copies.rs index 1257032337acc..1f8bff8d71e0f 100644 --- a/src/tools/clippy/clippy_lints/src/copies.rs +++ b/src/tools/clippy/clippy_lints/src/copies.rs @@ -320,7 +320,7 @@ fn bindings<'tcx>(cx: &LateContext<'tcx>, pat: &Pat<'_>) -> FxHashMap { if let Entry::Vacant(v) = map.entry(ident.name) { - v.insert(cx.tables().pat_ty(pat)); + v.insert(cx.typeck_results().pat_ty(pat)); } if let Some(ref as_pat) = *as_pat { bindings_impl(cx, as_pat, map); diff --git a/src/tools/clippy/clippy_lints/src/default_trait_access.rs b/src/tools/clippy/clippy_lints/src/default_trait_access.rs index fab95db019604..ea2447681293d 100644 --- a/src/tools/clippy/clippy_lints/src/default_trait_access.rs +++ b/src/tools/clippy/clippy_lints/src/default_trait_access.rs @@ -54,7 +54,7 @@ impl<'tcx> LateLintPass<'tcx> for DefaultTraitAccess { // TODO: Work out a way to put "whatever the imported way of referencing // this type in this file" rather than a fully-qualified type. - let expr_ty = cx.tables().expr_ty(expr); + let expr_ty = cx.typeck_results().expr_ty(expr); if let ty::Adt(..) = expr_ty.kind { let replacement = format!("{}::default()", expr_ty); span_lint_and_sugg( diff --git a/src/tools/clippy/clippy_lints/src/dereference.rs b/src/tools/clippy/clippy_lints/src/dereference.rs index 323cad7fa1a8c..102cf597d22e3 100644 --- a/src/tools/clippy/clippy_lints/src/dereference.rs +++ b/src/tools/clippy/clippy_lints/src/dereference.rs @@ -74,7 +74,7 @@ fn lint_deref(cx: &LateContext<'_>, method_name: &str, call_expr: &Expr<'_>, var match method_name { "deref" => { let impls_deref_trait = cx.tcx.lang_items().deref_trait().map_or(false, |id| { - implements_trait(cx, cx.tables().expr_ty(&call_expr), id, &[]) + implements_trait(cx, cx.typeck_results().expr_ty(&call_expr), id, &[]) }); if impls_deref_trait { span_lint_and_sugg( @@ -90,7 +90,7 @@ fn lint_deref(cx: &LateContext<'_>, method_name: &str, call_expr: &Expr<'_>, var }, "deref_mut" => { let impls_deref_mut_trait = cx.tcx.lang_items().deref_mut_trait().map_or(false, |id| { - implements_trait(cx, cx.tables().expr_ty(&call_expr), id, &[]) + implements_trait(cx, cx.typeck_results().expr_ty(&call_expr), id, &[]) }); if impls_deref_mut_trait { span_lint_and_sugg( diff --git a/src/tools/clippy/clippy_lints/src/drop_forget_ref.rs b/src/tools/clippy/clippy_lints/src/drop_forget_ref.rs index dcf772572e8cb..57ff569f14b0f 100644 --- a/src/tools/clippy/clippy_lints/src/drop_forget_ref.rs +++ b/src/tools/clippy/clippy_lints/src/drop_forget_ref.rs @@ -119,7 +119,7 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef { let lint; let msg; let arg = &args[0]; - let arg_ty = cx.tables().expr_ty(arg); + let arg_ty = cx.typeck_results().expr_ty(arg); if let ty::Ref(..) = arg_ty.kind { if match_def_path(cx, def_id, &paths::DROP) { diff --git a/src/tools/clippy/clippy_lints/src/duration_subsec.rs b/src/tools/clippy/clippy_lints/src/duration_subsec.rs index 2ded375091c60..1dfb2eaa57972 100644 --- a/src/tools/clippy/clippy_lints/src/duration_subsec.rs +++ b/src/tools/clippy/clippy_lints/src/duration_subsec.rs @@ -43,8 +43,8 @@ impl<'tcx> LateLintPass<'tcx> for DurationSubsec { if_chain! { if let ExprKind::Binary(Spanned { node: BinOpKind::Div, .. }, ref left, ref right) = expr.kind; if let ExprKind::MethodCall(ref method_path, _ , ref args, _) = left.kind; - if match_type(cx, walk_ptrs_ty(cx.tables().expr_ty(&args[0])), &paths::DURATION); - if let Some((Constant::Int(divisor), _)) = constant(cx, cx.tables(), right); + if match_type(cx, walk_ptrs_ty(cx.typeck_results().expr_ty(&args[0])), &paths::DURATION); + if let Some((Constant::Int(divisor), _)) = constant(cx, cx.typeck_results(), right); then { let suggested_fn = match (method_path.ident.as_str().as_ref(), divisor) { ("subsec_micros", 1_000) | ("subsec_nanos", 1_000_000) => "subsec_millis", diff --git a/src/tools/clippy/clippy_lints/src/entry.rs b/src/tools/clippy/clippy_lints/src/entry.rs index 4d2e17933ed6b..d616502a82a0c 100644 --- a/src/tools/clippy/clippy_lints/src/entry.rs +++ b/src/tools/clippy/clippy_lints/src/entry.rs @@ -106,7 +106,7 @@ fn check_cond<'a>(cx: &LateContext<'_>, check: &'a Expr<'a>) -> Option<(&'static if let ExprKind::AddrOf(BorrowKind::Ref, _, ref key) = params[1].kind; then { let map = ¶ms[0]; - let obj_ty = walk_ptrs_ty(cx.tables().expr_ty(map)); + let obj_ty = walk_ptrs_ty(cx.typeck_results().expr_ty(map)); return if match_type(cx, obj_ty, &paths::BTREEMAP) { Some(("BTreeMap", map, key)) diff --git a/src/tools/clippy/clippy_lints/src/eq_op.rs b/src/tools/clippy/clippy_lints/src/eq_op.rs index 01eff28cb195a..140cd21c34e67 100644 --- a/src/tools/clippy/clippy_lints/src/eq_op.rs +++ b/src/tools/clippy/clippy_lints/src/eq_op.rs @@ -103,8 +103,8 @@ impl<'tcx> LateLintPass<'tcx> for EqOp { (&ExprKind::Lit(..), _) | (_, &ExprKind::Lit(..)) => {}, // &foo == &bar (&ExprKind::AddrOf(BorrowKind::Ref, _, ref l), &ExprKind::AddrOf(BorrowKind::Ref, _, ref r)) => { - let lty = cx.tables().expr_ty(l); - let rty = cx.tables().expr_ty(r); + let lty = cx.typeck_results().expr_ty(l); + let rty = cx.typeck_results().expr_ty(r); let lcpy = is_copy(cx, lty); let rcpy = is_copy(cx, rty); // either operator autorefs or both args are copyable @@ -126,7 +126,7 @@ impl<'tcx> LateLintPass<'tcx> for EqOp { ) } else if lcpy && !rcpy - && implements_trait(cx, lty, trait_id, &[cx.tables().expr_ty(right).into()]) + && implements_trait(cx, lty, trait_id, &[cx.typeck_results().expr_ty(right).into()]) { span_lint_and_then( cx, @@ -145,7 +145,7 @@ impl<'tcx> LateLintPass<'tcx> for EqOp { ) } else if !lcpy && rcpy - && implements_trait(cx, cx.tables().expr_ty(left), trait_id, &[rty.into()]) + && implements_trait(cx, cx.typeck_results().expr_ty(left), trait_id, &[rty.into()]) { span_lint_and_then( cx, @@ -166,10 +166,10 @@ impl<'tcx> LateLintPass<'tcx> for EqOp { }, // &foo == bar (&ExprKind::AddrOf(BorrowKind::Ref, _, ref l), _) => { - let lty = cx.tables().expr_ty(l); + let lty = cx.typeck_results().expr_ty(l); let lcpy = is_copy(cx, lty); if (requires_ref || lcpy) - && implements_trait(cx, lty, trait_id, &[cx.tables().expr_ty(right).into()]) + && implements_trait(cx, lty, trait_id, &[cx.typeck_results().expr_ty(right).into()]) { span_lint_and_then( cx, @@ -190,10 +190,10 @@ impl<'tcx> LateLintPass<'tcx> for EqOp { }, // foo == &bar (_, &ExprKind::AddrOf(BorrowKind::Ref, _, ref r)) => { - let rty = cx.tables().expr_ty(r); + let rty = cx.typeck_results().expr_ty(r); let rcpy = is_copy(cx, rty); if (requires_ref || rcpy) - && implements_trait(cx, cx.tables().expr_ty(left), trait_id, &[rty.into()]) + && implements_trait(cx, cx.typeck_results().expr_ty(left), trait_id, &[rty.into()]) { span_lint_and_then(cx, OP_REF, e.span, "taken reference of right operand", |diag| { let rsnip = snippet(cx, r.span, "...").to_string(); diff --git a/src/tools/clippy/clippy_lints/src/erasing_op.rs b/src/tools/clippy/clippy_lints/src/erasing_op.rs index 8a26838061826..dbd1ff514f0e1 100644 --- a/src/tools/clippy/clippy_lints/src/erasing_op.rs +++ b/src/tools/clippy/clippy_lints/src/erasing_op.rs @@ -48,7 +48,7 @@ impl<'tcx> LateLintPass<'tcx> for ErasingOp { } fn check(cx: &LateContext<'_>, e: &Expr<'_>, span: Span) { - if let Some(Constant::Int(0)) = constant_simple(cx, cx.tables(), e) { + if let Some(Constant::Int(0)) = constant_simple(cx, cx.typeck_results(), e) { span_lint( cx, ERASING_OP, diff --git a/src/tools/clippy/clippy_lints/src/escape.rs b/src/tools/clippy/clippy_lints/src/escape.rs index ceb3c40d869a1..82549c12d0a20 100644 --- a/src/tools/clippy/clippy_lints/src/escape.rs +++ b/src/tools/clippy/clippy_lints/src/escape.rs @@ -84,7 +84,7 @@ impl<'tcx> LateLintPass<'tcx> for BoxedLocal { let fn_def_id = cx.tcx.hir().local_def_id(hir_id); cx.tcx.infer_ctxt().enter(|infcx| { - ExprUseVisitor::new(&mut v, &infcx, fn_def_id, cx.param_env, cx.tables()).consume_body(body); + ExprUseVisitor::new(&mut v, &infcx, fn_def_id, cx.param_env, cx.typeck_results()).consume_body(body); }); for node in v.set { diff --git a/src/tools/clippy/clippy_lints/src/eta_reduction.rs b/src/tools/clippy/clippy_lints/src/eta_reduction.rs index fb26b9fc27d25..87254c1dbc490 100644 --- a/src/tools/clippy/clippy_lints/src/eta_reduction.rs +++ b/src/tools/clippy/clippy_lints/src/eta_reduction.rs @@ -97,7 +97,7 @@ fn check_closure(cx: &LateContext<'_>, expr: &Expr<'_>) { // Are the expression or the arguments type-adjusted? Then we need the closure if !(is_adjusted(cx, ex) || args.iter().any(|arg| is_adjusted(cx, arg))); - let fn_ty = cx.tables().expr_ty(caller); + let fn_ty = cx.typeck_results().expr_ty(caller); if matches!(fn_ty.kind, ty::FnDef(_, _) | ty::FnPtr(_) | ty::Closure(_, _)); @@ -128,7 +128,7 @@ fn check_closure(cx: &LateContext<'_>, expr: &Expr<'_>) { // Are the expression or the arguments type-adjusted? Then we need the closure if !(is_adjusted(cx, ex) || args.iter().skip(1).any(|arg| is_adjusted(cx, arg))); - let method_def_id = cx.tables().type_dependent_def_id(ex.hir_id).unwrap(); + let method_def_id = cx.typeck_results().type_dependent_def_id(ex.hir_id).unwrap(); if !type_is_unsafe_function(cx, cx.tcx.type_of(method_def_id)); if compare_inputs(&mut iter_input_pats(decl, body), &mut args.iter()); @@ -153,7 +153,7 @@ fn check_closure(cx: &LateContext<'_>, expr: &Expr<'_>) { /// Tries to determine the type for universal function call to be used instead of the closure fn get_ufcs_type_name(cx: &LateContext<'_>, method_def_id: def_id::DefId, self_arg: &Expr<'_>) -> Option { let expected_type_of_self = &cx.tcx.fn_sig(method_def_id).inputs_and_output().skip_binder()[0]; - let actual_type_of_self = &cx.tables().node_type(self_arg.hir_id); + let actual_type_of_self = &cx.typeck_results().node_type(self_arg.hir_id); if let Some(trait_id) = cx.tcx.trait_of_item(method_def_id) { if match_borrow_depth(expected_type_of_self, &actual_type_of_self) diff --git a/src/tools/clippy/clippy_lints/src/eval_order_dependence.rs b/src/tools/clippy/clippy_lints/src/eval_order_dependence.rs index 01b0d3c5edec2..c00638ecc0c1d 100644 --- a/src/tools/clippy/clippy_lints/src/eval_order_dependence.rs +++ b/src/tools/clippy/clippy_lints/src/eval_order_dependence.rs @@ -137,7 +137,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> { match e.kind { ExprKind::Continue(_) | ExprKind::Break(_, _) | ExprKind::Ret(_) => self.report_diverging_sub_expr(e), ExprKind::Call(ref func, _) => { - let typ = self.cx.tables().expr_ty(func); + let typ = self.cx.typeck_results().expr_ty(func); match typ.kind { ty::FnDef(..) | ty::FnPtr(_) => { let sig = typ.fn_sig(self.cx.tcx); @@ -149,7 +149,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> { } }, ExprKind::MethodCall(..) => { - let borrowed_table = self.cx.tables(); + let borrowed_table = self.cx.typeck_results(); if borrowed_table.expr_ty(e).is_never() { self.report_diverging_sub_expr(e); } diff --git a/src/tools/clippy/clippy_lints/src/fallible_impl_from.rs b/src/tools/clippy/clippy_lints/src/fallible_impl_from.rs index 01ed0c426d436..000762334f61e 100644 --- a/src/tools/clippy/clippy_lints/src/fallible_impl_from.rs +++ b/src/tools/clippy/clippy_lints/src/fallible_impl_from.rs @@ -73,7 +73,7 @@ fn lint_impl_body<'tcx>(cx: &LateContext<'tcx>, impl_span: Span, impl_items: &[h struct FindPanicUnwrap<'a, 'tcx> { lcx: &'a LateContext<'tcx>, - tables: &'tcx ty::TypeckTables<'tcx>, + typeck_results: &'tcx ty::TypeckResults<'tcx>, result: Vec, } @@ -96,7 +96,7 @@ fn lint_impl_body<'tcx>(cx: &LateContext<'tcx>, impl_span: Span, impl_items: &[h // check for `unwrap` if let Some(arglists) = method_chain_args(expr, &["unwrap"]) { - let reciever_ty = walk_ptrs_ty(self.tables.expr_ty(&arglists[0][0])); + let reciever_ty = walk_ptrs_ty(self.typeck_results.expr_ty(&arglists[0][0])); if is_type_diagnostic_item(self.lcx, reciever_ty, sym!(option_type)) || is_type_diagnostic_item(self.lcx, reciever_ty, sym!(result_type)) { @@ -124,7 +124,7 @@ fn lint_impl_body<'tcx>(cx: &LateContext<'tcx>, impl_span: Span, impl_items: &[h let impl_item_def_id = cx.tcx.hir().local_def_id(impl_item.id.hir_id); let mut fpu = FindPanicUnwrap { lcx: cx, - tables: cx.tcx.typeck_tables_of(impl_item_def_id), + typeck_results: cx.tcx.typeck(impl_item_def_id), result: Vec::new(), }; fpu.visit_expr(&body.value); diff --git a/src/tools/clippy/clippy_lints/src/float_literal.rs b/src/tools/clippy/clippy_lints/src/float_literal.rs index a3d2a949535a4..358b9f6dcd0a5 100644 --- a/src/tools/clippy/clippy_lints/src/float_literal.rs +++ b/src/tools/clippy/clippy_lints/src/float_literal.rs @@ -61,7 +61,7 @@ declare_lint_pass!(FloatLiteral => [EXCESSIVE_PRECISION, LOSSY_FLOAT_LITERAL]); impl<'tcx> LateLintPass<'tcx> for FloatLiteral { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) { if_chain! { - let ty = cx.tables().expr_ty(expr); + let ty = cx.typeck_results().expr_ty(expr); if let ty::Float(fty) = ty.kind; if let hir::ExprKind::Lit(ref lit) = expr.kind; if let LitKind::Float(sym, lit_float_ty) = lit.node; diff --git a/src/tools/clippy/clippy_lints/src/floating_point_arithmetic.rs b/src/tools/clippy/clippy_lints/src/floating_point_arithmetic.rs index 3087d6a940a86..93f6ec92ec713 100644 --- a/src/tools/clippy/clippy_lints/src/floating_point_arithmetic.rs +++ b/src/tools/clippy/clippy_lints/src/floating_point_arithmetic.rs @@ -112,7 +112,7 @@ declare_lint_pass!(FloatingPointArithmetic => [ // Returns the specialized log method for a given base if base is constant // and is one of 2, 10 and e fn get_specialized_log_method(cx: &LateContext<'_>, base: &Expr<'_>) -> Option<&'static str> { - if let Some((value, _)) = constant(cx, cx.tables(), base) { + if let Some((value, _)) = constant(cx, cx.typeck_results(), base) { if F32(2.0) == value || F64(2.0) == value { return Some("log2"); } else if F32(10.0) == value || F64(10.0) == value { @@ -136,7 +136,7 @@ fn prepare_receiver_sugg<'a>(cx: &LateContext<'_>, mut expr: &'a Expr<'a>) -> Su if_chain! { // if the expression is a float literal and it is unsuffixed then // add a suffix so the suggestion is valid and unambiguous - if let ty::Float(float_ty) = cx.tables().expr_ty(expr).kind; + if let ty::Float(float_ty) = cx.typeck_results().expr_ty(expr).kind; if let ExprKind::Lit(lit) = &expr.kind; if let ast::LitKind::Float(sym, ast::LitFloatType::Unsuffixed) = lit.node; then { @@ -188,7 +188,10 @@ fn check_ln1p(cx: &LateContext<'_>, expr: &Expr<'_>, args: &[Expr<'_>]) { rhs, ) = &args[0].kind { - let recv = match (constant(cx, cx.tables(), lhs), constant(cx, cx.tables(), rhs)) { + let recv = match ( + constant(cx, cx.typeck_results(), lhs), + constant(cx, cx.typeck_results(), rhs), + ) { (Some((value, _)), _) if F32(1.0) == value || F64(1.0) == value => rhs, (_, Some((value, _))) if F32(1.0) == value || F64(1.0) == value => lhs, _ => return, @@ -233,7 +236,7 @@ fn get_integer_from_float_constant(value: &Constant) -> Option { fn check_powf(cx: &LateContext<'_>, expr: &Expr<'_>, args: &[Expr<'_>]) { // Check receiver - if let Some((value, _)) = constant(cx, cx.tables(), &args[0]) { + if let Some((value, _)) = constant(cx, cx.typeck_results(), &args[0]) { let method = if F32(f32_consts::E) == value || F64(f64_consts::E) == value { "exp" } else if F32(2.0) == value || F64(2.0) == value { @@ -254,7 +257,7 @@ fn check_powf(cx: &LateContext<'_>, expr: &Expr<'_>, args: &[Expr<'_>]) { } // Check argument - if let Some((value, _)) = constant(cx, cx.tables(), &args[1]) { + if let Some((value, _)) = constant(cx, cx.typeck_results(), &args[1]) { let (lint, help, suggestion) = if F32(1.0 / 2.0) == value || F64(1.0 / 2.0) == value { ( SUBOPTIMAL_FLOPS, @@ -294,7 +297,7 @@ fn check_powf(cx: &LateContext<'_>, expr: &Expr<'_>, args: &[Expr<'_>]) { } fn check_powi(cx: &LateContext<'_>, expr: &Expr<'_>, args: &[Expr<'_>]) { - if let Some((value, _)) = constant(cx, cx.tables(), &args[1]) { + if let Some((value, _)) = constant(cx, cx.typeck_results(), &args[1]) { if value == Int(2) { if let Some(parent) = get_parent_expr(cx, expr) { if let Some(grandparent) = get_parent_expr(cx, parent) { @@ -382,8 +385,8 @@ fn detect_hypot(cx: &LateContext<'_>, args: &[Expr<'_>]) -> Option { _ ) = add_rhs.kind; if lmethod_name.as_str() == "powi" && rmethod_name.as_str() == "powi"; - if let Some((lvalue, _)) = constant(cx, cx.tables(), &largs[1]); - if let Some((rvalue, _)) = constant(cx, cx.tables(), &rargs[1]); + if let Some((lvalue, _)) = constant(cx, cx.typeck_results(), &largs[1]); + if let Some((rvalue, _)) = constant(cx, cx.typeck_results(), &rargs[1]); if Int(2) == lvalue && Int(2) == rvalue; then { return Some(format!("{}.hypot({})", Sugg::hir(cx, &largs[0], ".."), Sugg::hir(cx, &rargs[0], ".."))); @@ -413,11 +416,11 @@ fn check_hypot(cx: &LateContext<'_>, expr: &Expr<'_>, args: &[Expr<'_>]) { fn check_expm1(cx: &LateContext<'_>, expr: &Expr<'_>) { if_chain! { if let ExprKind::Binary(Spanned { node: BinOpKind::Sub, .. }, ref lhs, ref rhs) = expr.kind; - if cx.tables().expr_ty(lhs).is_floating_point(); - if let Some((value, _)) = constant(cx, cx.tables(), rhs); + if cx.typeck_results().expr_ty(lhs).is_floating_point(); + if let Some((value, _)) = constant(cx, cx.typeck_results(), rhs); if F32(1.0) == value || F64(1.0) == value; if let ExprKind::MethodCall(ref path, _, ref method_args, _) = lhs.kind; - if cx.tables().expr_ty(&method_args[0]).is_floating_point(); + if cx.typeck_results().expr_ty(&method_args[0]).is_floating_point(); if path.ident.name.as_str() == "exp"; then { span_lint_and_sugg( @@ -439,8 +442,8 @@ fn check_expm1(cx: &LateContext<'_>, expr: &Expr<'_>) { fn is_float_mul_expr<'a>(cx: &LateContext<'_>, expr: &'a Expr<'a>) -> Option<(&'a Expr<'a>, &'a Expr<'a>)> { if_chain! { if let ExprKind::Binary(Spanned { node: BinOpKind::Mul, .. }, ref lhs, ref rhs) = &expr.kind; - if cx.tables().expr_ty(lhs).is_floating_point(); - if cx.tables().expr_ty(rhs).is_floating_point(); + if cx.typeck_results().expr_ty(lhs).is_floating_point(); + if cx.typeck_results().expr_ty(rhs).is_floating_point(); then { return Some((lhs, rhs)); } @@ -527,7 +530,7 @@ fn are_exprs_equal(cx: &LateContext<'_>, expr1: &Expr<'_>, expr2: &Expr<'_>) -> /// Returns true iff expr is some zero literal fn is_zero(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { - match constant_simple(cx, cx.tables(), expr) { + match constant_simple(cx, cx.typeck_results(), expr) { Some(Constant::Int(i)) => i == 0, Some(Constant::F32(f)) => f == 0.0, Some(Constant::F64(f)) => f == 0.0, @@ -662,8 +665,8 @@ fn check_radians(cx: &LateContext<'_>, expr: &Expr<'_>) { mul_lhs, mul_rhs, ) = &div_lhs.kind; - if let Some((rvalue, _)) = constant(cx, cx.tables(), div_rhs); - if let Some((lvalue, _)) = constant(cx, cx.tables(), mul_rhs); + if let Some((rvalue, _)) = constant(cx, cx.typeck_results(), div_rhs); + if let Some((lvalue, _)) = constant(cx, cx.typeck_results(), mul_rhs); then { // TODO: also check for constant values near PI/180 or 180/PI if (F32(f32_consts::PI) == rvalue || F64(f64_consts::PI) == rvalue) && @@ -699,7 +702,7 @@ fn check_radians(cx: &LateContext<'_>, expr: &Expr<'_>) { impl<'tcx> LateLintPass<'tcx> for FloatingPointArithmetic { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { if let ExprKind::MethodCall(ref path, _, args, _) = &expr.kind { - let recv_ty = cx.tables().expr_ty(&args[0]); + let recv_ty = cx.typeck_results().expr_ty(&args[0]); if recv_ty.is_floating_point() { match &*path.ident.name.as_str() { diff --git a/src/tools/clippy/clippy_lints/src/format.rs b/src/tools/clippy/clippy_lints/src/format.rs index 33b6bfc459f91..572c839502f4f 100644 --- a/src/tools/clippy/clippy_lints/src/format.rs +++ b/src/tools/clippy/clippy_lints/src/format.rs @@ -90,7 +90,7 @@ fn on_argumentv1_new<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, arms: & if let PatKind::Tuple(ref pats, None) = arms[0].pat.kind; if pats.len() == 1; then { - let ty = walk_ptrs_ty(cx.tables().pat_ty(&pats[0])); + let ty = walk_ptrs_ty(cx.typeck_results().pat_ty(&pats[0])); if ty.kind != rustc_middle::ty::Str && !is_type_diagnostic_item(cx, ty, sym!(string_type)) { return None; } diff --git a/src/tools/clippy/clippy_lints/src/functions.rs b/src/tools/clippy/clippy_lints/src/functions.rs index 63133a4872a3e..3ee0b3f74b8c5 100644 --- a/src/tools/clippy/clippy_lints/src/functions.rs +++ b/src/tools/clippy/clippy_lints/src/functions.rs @@ -392,11 +392,11 @@ impl<'tcx> Functions { .collect::>(); if !raw_ptrs.is_empty() { - let tables = cx.tcx.body_tables(body.id()); + let typeck_results = cx.tcx.typeck_body(body.id()); let mut v = DerefVisitor { cx, ptrs: raw_ptrs, - tables, + typeck_results, }; intravisit::walk_expr(&mut v, expr); @@ -494,13 +494,8 @@ fn is_mutable_pat(cx: &LateContext<'_>, pat: &hir::Pat<'_>, tys: &mut FxHashSet< return false; // ignore `_` patterns } let def_id = pat.hir_id.owner.to_def_id(); - if cx.tcx.has_typeck_tables(def_id) { - is_mutable_ty( - cx, - &cx.tcx.typeck_tables_of(def_id.expect_local()).pat_ty(pat), - pat.span, - tys, - ) + if cx.tcx.has_typeck_results(def_id) { + is_mutable_ty(cx, &cx.tcx.typeck(def_id.expect_local()).pat_ty(pat), pat.span, tys) } else { false } @@ -539,7 +534,7 @@ fn raw_ptr_arg(arg: &hir::Param<'_>, ty: &hir::Ty<'_>) -> Option { struct DerefVisitor<'a, 'tcx> { cx: &'a LateContext<'tcx>, ptrs: FxHashSet, - tables: &'a ty::TypeckTables<'tcx>, + typeck_results: &'a ty::TypeckResults<'tcx>, } impl<'a, 'tcx> intravisit::Visitor<'tcx> for DerefVisitor<'a, 'tcx> { @@ -548,7 +543,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for DerefVisitor<'a, 'tcx> { fn visit_expr(&mut self, expr: &'tcx hir::Expr<'_>) { match expr.kind { hir::ExprKind::Call(ref f, args) => { - let ty = self.tables.expr_ty(f); + let ty = self.typeck_results.expr_ty(f); if type_is_unsafe_function(self.cx, ty) { for arg in args { @@ -557,7 +552,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for DerefVisitor<'a, 'tcx> { } }, hir::ExprKind::MethodCall(_, _, args, _) => { - let def_id = self.tables.type_dependent_def_id(expr.hir_id).unwrap(); + let def_id = self.typeck_results.type_dependent_def_id(expr.hir_id).unwrap(); let base_type = self.cx.tcx.type_of(def_id); if type_is_unsafe_function(self.cx, base_type) { @@ -614,10 +609,10 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for StaticMutVisitor<'a, 'tcx> { let mut tys = FxHashSet::default(); for arg in args { let def_id = arg.hir_id.owner.to_def_id(); - if self.cx.tcx.has_typeck_tables(def_id) + if self.cx.tcx.has_typeck_results(def_id) && is_mutable_ty( self.cx, - self.cx.tcx.typeck_tables_of(def_id.expect_local()).expr_ty(arg), + self.cx.tcx.typeck(def_id.expect_local()).expr_ty(arg), arg.span, &mut tys, ) diff --git a/src/tools/clippy/clippy_lints/src/get_last_with_len.rs b/src/tools/clippy/clippy_lints/src/get_last_with_len.rs index 2d93ecc00a769..48ebcf5ebcd9c 100644 --- a/src/tools/clippy/clippy_lints/src/get_last_with_len.rs +++ b/src/tools/clippy/clippy_lints/src/get_last_with_len.rs @@ -54,7 +54,7 @@ impl<'tcx> LateLintPass<'tcx> for GetLastWithLen { // Argument 0 (the struct we're calling the method on) is a vector if let Some(struct_calling_on) = args.get(0); - let struct_ty = cx.tables().expr_ty(struct_calling_on); + let struct_ty = cx.typeck_results().expr_ty(struct_calling_on); if is_type_diagnostic_item(cx, struct_ty, sym!(vec_type)); // Argument to "get" is a subtraction diff --git a/src/tools/clippy/clippy_lints/src/identity_op.rs b/src/tools/clippy/clippy_lints/src/identity_op.rs index dc9d636bc6de1..4c62637858cde 100644 --- a/src/tools/clippy/clippy_lints/src/identity_op.rs +++ b/src/tools/clippy/clippy_lints/src/identity_op.rs @@ -62,8 +62,8 @@ fn is_allowed(cx: &LateContext<'_>, cmp: BinOp, left: &Expr<'_>, right: &Expr<'_ // `1 << 0` is a common pattern in bit manipulation code if_chain! { if let BinOpKind::Shl = cmp.node; - if let Some(Constant::Int(0)) = constant_simple(cx, cx.tables(), right); - if let Some(Constant::Int(1)) = constant_simple(cx, cx.tables(), left); + if let Some(Constant::Int(0)) = constant_simple(cx, cx.typeck_results(), right); + if let Some(Constant::Int(1)) = constant_simple(cx, cx.typeck_results(), left); then { return true; } @@ -74,8 +74,8 @@ fn is_allowed(cx: &LateContext<'_>, cmp: BinOp, left: &Expr<'_>, right: &Expr<'_ #[allow(clippy::cast_possible_wrap)] fn check(cx: &LateContext<'_>, e: &Expr<'_>, m: i8, span: Span, arg: Span) { - if let Some(Constant::Int(v)) = constant_simple(cx, cx.tables(), e) { - let check = match cx.tables().expr_ty(e).kind { + if let Some(Constant::Int(v)) = constant_simple(cx, cx.typeck_results(), e) { + let check = match cx.typeck_results().expr_ty(e).kind { ty::Int(ity) => unsext(cx.tcx, -1_i128, ity), ty::Uint(uty) => clip(cx.tcx, !0, uty), _ => return, diff --git a/src/tools/clippy/clippy_lints/src/if_let_mutex.rs b/src/tools/clippy/clippy_lints/src/if_let_mutex.rs index fbd2eeacc6ef5..2e55094d90c6f 100644 --- a/src/tools/clippy/clippy_lints/src/if_let_mutex.rs +++ b/src/tools/clippy/clippy_lints/src/if_let_mutex.rs @@ -146,7 +146,7 @@ fn is_mutex_lock_call<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Opt if_chain! { if let ExprKind::MethodCall(path, _span, args, _) = &expr.kind; if path.ident.to_string() == "lock"; - let ty = cx.tables().expr_ty(&args[0]); + let ty = cx.typeck_results().expr_ty(&args[0]); if is_type_diagnostic_item(cx, ty, sym!(mutex_type)); then { Some(&args[0]) diff --git a/src/tools/clippy/clippy_lints/src/if_let_some_result.rs b/src/tools/clippy/clippy_lints/src/if_let_some_result.rs index 9e2989dc01e52..5b22df5fe491e 100644 --- a/src/tools/clippy/clippy_lints/src/if_let_some_result.rs +++ b/src/tools/clippy/clippy_lints/src/if_let_some_result.rs @@ -45,7 +45,7 @@ impl<'tcx> LateLintPass<'tcx> for OkIfLet { if let ExprKind::MethodCall(_, ok_span, ref result_types, _) = op.kind; //check is expr.ok() has type Result.ok(, _) if let PatKind::TupleStruct(QPath::Resolved(_, ref x), ref y, _) = body[0].pat.kind; //get operation if method_chain_args(op, &["ok"]).is_some(); //test to see if using ok() methoduse std::marker::Sized; - if is_type_diagnostic_item(cx, cx.tables().expr_ty(&result_types[0]), sym!(result_type)); + if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(&result_types[0]), sym!(result_type)); if rustc_hir_pretty::to_string(rustc_hir_pretty::NO_ANN, |s| s.print_path(x, false)) == "Some"; then { diff --git a/src/tools/clippy/clippy_lints/src/implicit_saturating_sub.rs b/src/tools/clippy/clippy_lints/src/implicit_saturating_sub.rs index f38530aca0cec..5f931a0addedf 100644 --- a/src/tools/clippy/clippy_lints/src/implicit_saturating_sub.rs +++ b/src/tools/clippy/clippy_lints/src/implicit_saturating_sub.rs @@ -81,7 +81,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitSaturatingSub { }; // Check if the variable in the condition statement is an integer - if !cx.tables().expr_ty(cond_var).is_integral() { + if !cx.typeck_results().expr_ty(cond_var).is_integral() { return; } @@ -93,7 +93,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitSaturatingSub { ExprKind::Lit(ref cond_lit) => { // Check if the constant is zero if let LitKind::Int(0, _) = cond_lit.node { - if cx.tables().expr_ty(cond_left).is_signed() { + if cx.typeck_results().expr_ty(cond_left).is_signed() { } else { print_lint_and_sugg(cx, &var_name, expr); }; diff --git a/src/tools/clippy/clippy_lints/src/indexing_slicing.rs b/src/tools/clippy/clippy_lints/src/indexing_slicing.rs index 5857a405b0cf3..a1f58e54ae38e 100644 --- a/src/tools/clippy/clippy_lints/src/indexing_slicing.rs +++ b/src/tools/clippy/clippy_lints/src/indexing_slicing.rs @@ -88,7 +88,7 @@ declare_lint_pass!(IndexingSlicing => [INDEXING_SLICING, OUT_OF_BOUNDS_INDEXING] impl<'tcx> LateLintPass<'tcx> for IndexingSlicing { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { if let ExprKind::Index(ref array, ref index) = &expr.kind { - let ty = cx.tables().expr_ty(array); + let ty = cx.typeck_results().expr_ty(array); if let Some(range) = higher::range(cx, index) { // Ranged indexes, i.e., &x[n..m], &x[n..], &x[..n] and &x[..] if let ty::Array(_, s) = ty.kind { @@ -143,7 +143,7 @@ impl<'tcx> LateLintPass<'tcx> for IndexingSlicing { // Catchall non-range index, i.e., [n] or [n << m] if let ty::Array(..) = ty.kind { // Index is a constant uint. - if let Some(..) = constant(cx, cx.tables(), index) { + if let Some(..) = constant(cx, cx.typeck_results(), index) { // Let rustc's `const_err` lint handle constant `usize` indexing on arrays. return; } @@ -169,14 +169,18 @@ fn to_const_range<'tcx>( range: higher::Range<'_>, array_size: u128, ) -> (Option, Option) { - let s = range.start.map(|expr| constant(cx, cx.tables(), expr).map(|(c, _)| c)); + let s = range + .start + .map(|expr| constant(cx, cx.typeck_results(), expr).map(|(c, _)| c)); let start = match s { Some(Some(Constant::Int(x))) => Some(x), Some(_) => None, None => Some(0), }; - let e = range.end.map(|expr| constant(cx, cx.tables(), expr).map(|(c, _)| c)); + let e = range + .end + .map(|expr| constant(cx, cx.typeck_results(), expr).map(|(c, _)| c)); let end = match e { Some(Some(Constant::Int(x))) => { if range.limits == RangeLimits::Closed { diff --git a/src/tools/clippy/clippy_lints/src/infinite_iter.rs b/src/tools/clippy/clippy_lints/src/infinite_iter.rs index 3ffc2dd60d9c0..e511d3ea33046 100644 --- a/src/tools/clippy/clippy_lints/src/infinite_iter.rs +++ b/src/tools/clippy/clippy_lints/src/infinite_iter.rs @@ -231,13 +231,13 @@ fn complete_infinite_iter(cx: &LateContext<'_>, expr: &Expr<'_>) -> Finiteness { } if method.ident.name == sym!(last) && args.len() == 1 { let not_double_ended = get_trait_def_id(cx, &paths::DOUBLE_ENDED_ITERATOR).map_or(false, |id| { - !implements_trait(cx, cx.tables().expr_ty(&args[0]), id, &[]) + !implements_trait(cx, cx.typeck_results().expr_ty(&args[0]), id, &[]) }); if not_double_ended { return is_infinite(cx, &args[0]); } } else if method.ident.name == sym!(collect) { - let ty = cx.tables().expr_ty(expr); + let ty = cx.typeck_results().expr_ty(expr); if INFINITE_COLLECTORS.iter().any(|path| match_type(cx, ty, path)) { return is_infinite(cx, &args[0]); } diff --git a/src/tools/clippy/clippy_lints/src/integer_division.rs b/src/tools/clippy/clippy_lints/src/integer_division.rs index e754c7b482a68..31181c10d23db 100644 --- a/src/tools/clippy/clippy_lints/src/integer_division.rs +++ b/src/tools/clippy/clippy_lints/src/integer_division.rs @@ -50,7 +50,7 @@ fn is_integer_division<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) if let hir::ExprKind::Binary(binop, left, right) = &expr.kind; if let hir::BinOpKind::Div = &binop.node; then { - let (left_ty, right_ty) = (cx.tables().expr_ty(left), cx.tables().expr_ty(right)); + let (left_ty, right_ty) = (cx.typeck_results().expr_ty(left), cx.typeck_results().expr_ty(right)); return left_ty.is_integral() && right_ty.is_integral(); } } diff --git a/src/tools/clippy/clippy_lints/src/large_stack_arrays.rs b/src/tools/clippy/clippy_lints/src/large_stack_arrays.rs index 8eb986c25ff79..a7c715879232b 100644 --- a/src/tools/clippy/clippy_lints/src/large_stack_arrays.rs +++ b/src/tools/clippy/clippy_lints/src/large_stack_arrays.rs @@ -42,7 +42,7 @@ impl<'tcx> LateLintPass<'tcx> for LargeStackArrays { fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) { if_chain! { if let ExprKind::Repeat(_, _) = expr.kind; - if let ty::Array(element_type, cst) = cx.tables().expr_ty(expr).kind; + if let ty::Array(element_type, cst) = cx.typeck_results().expr_ty(expr).kind; if let ConstKind::Value(val) = cst.val; if let ConstValue::Scalar(element_count) = val; if let Ok(element_count) = element_count.to_machine_usize(&cx.tcx); diff --git a/src/tools/clippy/clippy_lints/src/len_zero.rs b/src/tools/clippy/clippy_lints/src/len_zero.rs index 1b09328ceabb0..00d0b8b4e5b7f 100644 --- a/src/tools/clippy/clippy_lints/src/len_zero.rs +++ b/src/tools/clippy/clippy_lints/src/len_zero.rs @@ -300,7 +300,7 @@ fn has_is_empty(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { return false; } - let ty = &walk_ptrs_ty(cx.tables().expr_ty(expr)); + let ty = &walk_ptrs_ty(cx.typeck_results().expr_ty(expr)); match ty.kind { ty::Dynamic(ref tt, ..) => tt.principal().map_or(false, |principal| { cx.tcx diff --git a/src/tools/clippy/clippy_lints/src/let_if_seq.rs b/src/tools/clippy/clippy_lints/src/let_if_seq.rs index 706c73ce66c61..8243b0a29bc68 100644 --- a/src/tools/clippy/clippy_lints/src/let_if_seq.rs +++ b/src/tools/clippy/clippy_lints/src/let_if_seq.rs @@ -73,7 +73,7 @@ impl<'tcx> LateLintPass<'tcx> for LetIfSeq { then { let span = stmt.span.to(if_.span); - let has_interior_mutability = !cx.tables().node_type(canonical_id).is_freeze( + let has_interior_mutability = !cx.typeck_results().node_type(canonical_id).is_freeze( cx.tcx.at(span), cx.param_env, ); diff --git a/src/tools/clippy/clippy_lints/src/let_underscore.rs b/src/tools/clippy/clippy_lints/src/let_underscore.rs index c7dda3c992826..ae2f6131b5b8f 100644 --- a/src/tools/clippy/clippy_lints/src/let_underscore.rs +++ b/src/tools/clippy/clippy_lints/src/let_underscore.rs @@ -76,7 +76,7 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore { if let PatKind::Wild = local.pat.kind; if let Some(ref init) = local.init; then { - let init_ty = cx.tables().expr_ty(init); + let init_ty = cx.typeck_results().expr_ty(init); let contains_sync_guard = init_ty.walk().any(|inner| match inner.unpack() { GenericArgKind::Type(inner_ty) => { SYNC_GUARD_PATHS.iter().any(|path| match_type(cx, inner_ty, path)) @@ -94,7 +94,7 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore { "consider using an underscore-prefixed named \ binding or dropping explicitly with `std::mem::drop`" ) - } else if is_must_use_ty(cx, cx.tables().expr_ty(init)) { + } else if is_must_use_ty(cx, cx.typeck_results().expr_ty(init)) { span_lint_and_help( cx, LET_UNDERSCORE_MUST_USE, diff --git a/src/tools/clippy/clippy_lints/src/loops.rs b/src/tools/clippy/clippy_lints/src/loops.rs index 396bb65910903..7e3876ff49b46 100644 --- a/src/tools/clippy/clippy_lints/src/loops.rs +++ b/src/tools/clippy/clippy_lints/src/loops.rs @@ -535,7 +535,7 @@ impl<'tcx> LateLintPass<'tcx> for Loops { if_chain! { if let ExprKind::MethodCall(..) | ExprKind::Call(..) = iter_expr.kind; if let Some(iter_def_id) = get_trait_def_id(cx, &paths::ITERATOR); - if implements_trait(cx, cx.tables().expr_ty(iter_expr), iter_def_id, &[]); + if implements_trait(cx, cx.typeck_results().expr_ty(iter_expr), iter_def_id, &[]); then { return; } @@ -981,8 +981,8 @@ fn detect_manual_memcpy<'tcx>( if_chain! { if let ExprKind::Index(seqexpr_left, idx_left) = lhs.kind; if let ExprKind::Index(seqexpr_right, idx_right) = rhs.kind; - if is_slice_like(cx, cx.tables().expr_ty(seqexpr_left)) - && is_slice_like(cx, cx.tables().expr_ty(seqexpr_right)); + if is_slice_like(cx, cx.typeck_results().expr_ty(seqexpr_left)) + && is_slice_like(cx, cx.typeck_results().expr_ty(seqexpr_right)); if let Some(offset_left) = get_offset(cx, &idx_left, canonical_id); if let Some(offset_right) = get_offset(cx, &idx_right, canonical_id); @@ -1250,8 +1250,8 @@ fn check_for_loop_arg(cx: &LateContext<'_>, pat: &Pat<'_>, arg: &Expr<'_>, expr: lint_iter_method(cx, args, arg, method_name); } } else if method_name == "into_iter" && match_trait_method(cx, arg, &paths::INTO_ITERATOR) { - let receiver_ty = cx.tables().expr_ty(&args[0]); - let receiver_ty_adjusted = cx.tables().expr_ty_adjusted(&args[0]); + let receiver_ty = cx.typeck_results().expr_ty(&args[0]); + let receiver_ty_adjusted = cx.typeck_results().expr_ty_adjusted(&args[0]); if TyS::same_type(receiver_ty, receiver_ty_adjusted) { let mut applicability = Applicability::MachineApplicable; let object = snippet_with_applicability(cx, args[0].span, "_", &mut applicability); @@ -1296,7 +1296,7 @@ fn check_for_loop_arg(cx: &LateContext<'_>, pat: &Pat<'_>, arg: &Expr<'_>, expr: /// Checks for `for` loops over `Option`s and `Result`s. fn check_arg_type(cx: &LateContext<'_>, pat: &Pat<'_>, arg: &Expr<'_>) { - let ty = cx.tables().expr_ty(arg); + let ty = cx.typeck_results().expr_ty(arg); if is_type_diagnostic_item(cx, ty, sym!(option_type)) { span_lint_and_help( cx, @@ -1400,8 +1400,9 @@ fn check_for_loop_explicit_counter<'tcx>( /// If `arg` was the argument to a `for` loop, return the "cleanest" way of writing the /// actual `Iterator` that the loop uses. fn make_iterator_snippet(cx: &LateContext<'_>, arg: &Expr<'_>, applic_ref: &mut Applicability) -> String { - let impls_iterator = get_trait_def_id(cx, &paths::ITERATOR) - .map_or(false, |id| implements_trait(cx, cx.tables().expr_ty(arg), id, &[])); + let impls_iterator = get_trait_def_id(cx, &paths::ITERATOR).map_or(false, |id| { + implements_trait(cx, cx.typeck_results().expr_ty(arg), id, &[]) + }); if impls_iterator { format!( "{}", @@ -1412,7 +1413,7 @@ fn make_iterator_snippet(cx: &LateContext<'_>, arg: &Expr<'_>, applic_ref: &mut // (&mut x).into_iter() ==> x.iter_mut() match &arg.kind { ExprKind::AddrOf(BorrowKind::Ref, mutability, arg_inner) - if has_iter_method(cx, cx.tables().expr_ty(&arg_inner)).is_some() => + if has_iter_method(cx, cx.typeck_results().expr_ty(&arg_inner)).is_some() => { let meth_name = match mutability { Mutability::Mut => "iter_mut", @@ -1445,7 +1446,7 @@ fn check_for_loop_over_map_kv<'tcx>( if let PatKind::Tuple(ref pat, _) = pat.kind { if pat.len() == 2 { let arg_span = arg.span; - let (new_pat_span, kind, ty, mutbl) = match cx.tables().expr_ty(arg).kind { + let (new_pat_span, kind, ty, mutbl) = match cx.typeck_results().expr_ty(arg).kind { ty::Ref(_, ty, mutbl) => match (&pat[0].kind, &pat[1].kind) { (key, _) if pat_is_wild(key, body) => (pat[1].span, "value", ty, mutbl), (_, value) if pat_is_wild(value, body) => (pat[0].span, "key", ty, Mutability::Not), @@ -1590,7 +1591,14 @@ fn check_for_mutation<'tcx>( }; let def_id = body.hir_id.owner.to_def_id(); cx.tcx.infer_ctxt().enter(|infcx| { - ExprUseVisitor::new(&mut delegate, &infcx, def_id.expect_local(), cx.param_env, cx.tables()).walk_expr(body); + ExprUseVisitor::new( + &mut delegate, + &infcx, + def_id.expect_local(), + cx.param_env, + cx.typeck_results(), + ) + .walk_expr(body); }); delegate.mutation_span() } @@ -1684,7 +1692,7 @@ impl<'a, 'tcx> VarVisitor<'a, 'tcx> { if index_used_directly { self.indexed_directly.insert( seqvar.segments[0].ident.name, - (Some(extent), self.cx.tables().node_type(seqexpr.hir_id)), + (Some(extent), self.cx.typeck_results().node_type(seqexpr.hir_id)), ); } return false; // no need to walk further *on the variable* @@ -1696,7 +1704,7 @@ impl<'a, 'tcx> VarVisitor<'a, 'tcx> { if index_used_directly { self.indexed_directly.insert( seqvar.segments[0].ident.name, - (None, self.cx.tables().node_type(seqexpr.hir_id)), + (None, self.cx.typeck_results().node_type(seqexpr.hir_id)), ); } return false; // no need to walk further *on the variable* @@ -1764,7 +1772,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> { ExprKind::Call(ref f, args) => { self.visit_expr(f); for expr in args { - let ty = self.cx.tables().expr_ty_adjusted(expr); + let ty = self.cx.typeck_results().expr_ty_adjusted(expr); self.prefer_mutable = false; if let ty::Ref(_, _, mutbl) = ty.kind { if mutbl == Mutability::Mut { @@ -1775,7 +1783,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> { } }, ExprKind::MethodCall(_, _, args, _) => { - let def_id = self.cx.tables().type_dependent_def_id(expr.hir_id).unwrap(); + let def_id = self.cx.typeck_results().type_dependent_def_id(expr.hir_id).unwrap(); for (ty, expr) in self.cx.tcx.fn_sig(def_id).inputs().skip_binder().iter().zip(args) { self.prefer_mutable = false; if let ty::Ref(_, _, mutbl) = ty.kind { @@ -1862,7 +1870,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarUsedAfterLoopVisitor<'a, 'tcx> { fn is_ref_iterable_type(cx: &LateContext<'_>, e: &Expr<'_>) -> bool { // no walk_ptrs_ty: calling iter() on a reference can make sense because it // will allow further borrows afterwards - let ty = cx.tables().expr_ty(e); + let ty = cx.typeck_results().expr_ty(e); is_iterable_array(ty, cx) || is_type_diagnostic_item(cx, ty, sym!(vec_type)) || match_type(cx, ty, &paths::LINKED_LIST) || @@ -2221,7 +2229,7 @@ fn path_name(e: &Expr<'_>) -> Option { } fn check_infinite_loop<'tcx>(cx: &LateContext<'tcx>, cond: &'tcx Expr<'_>, expr: &'tcx Expr<'_>) { - if constant(cx, cx.tables(), cond).is_some() { + if constant(cx, cx.typeck_results(), cond).is_some() { // A pure constant condition (e.g., `while false`) is not linted. return; } @@ -2357,7 +2365,7 @@ fn check_needless_collect<'tcx>(expr: &'tcx Expr<'_>, cx: &LateContext<'tcx>) { if let Some(ref generic_args) = chain_method.args; if let Some(GenericArg::Type(ref ty)) = generic_args.args.get(0); then { - let ty = cx.tables().node_type(ty.hir_id); + let ty = cx.typeck_results().node_type(ty.hir_id); if is_type_diagnostic_item(cx, ty, sym!(vec_type)) || is_type_diagnostic_item(cx, ty, sym!(vecdeque_type)) || match_type(cx, ty, &paths::BTREEMAP) || diff --git a/src/tools/clippy/clippy_lints/src/map_clone.rs b/src/tools/clippy/clippy_lints/src/map_clone.rs index 905a3f3ca71c7..641e6a1704324 100644 --- a/src/tools/clippy/clippy_lints/src/map_clone.rs +++ b/src/tools/clippy/clippy_lints/src/map_clone.rs @@ -52,7 +52,7 @@ impl<'tcx> LateLintPass<'tcx> for MapClone { if let hir::ExprKind::MethodCall(ref method, _, ref args, _) = e.kind; if args.len() == 2; if method.ident.as_str() == "map"; - let ty = cx.tables().expr_ty(&args[0]); + let ty = cx.typeck_results().expr_ty(&args[0]); if is_type_diagnostic_item(cx, ty, sym!(option_type)) || match_trait_method(cx, e, &paths::ITERATOR); if let hir::ExprKind::Closure(_, _, body_id, _, _) = args[1].kind; let closure_body = cx.tcx.hir().body(body_id); @@ -70,7 +70,7 @@ impl<'tcx> LateLintPass<'tcx> for MapClone { match closure_expr.kind { hir::ExprKind::Unary(hir::UnOp::UnDeref, ref inner) => { if ident_eq(name, inner) { - if let ty::Ref(.., Mutability::Not) = cx.tables().expr_ty(inner).kind { + if let ty::Ref(.., Mutability::Not) = cx.typeck_results().expr_ty(inner).kind { lint(cx, e.span, args[0].span, true); } } @@ -79,7 +79,7 @@ impl<'tcx> LateLintPass<'tcx> for MapClone { if ident_eq(name, &obj[0]) && method.ident.as_str() == "clone" && match_trait_method(cx, closure_expr, &paths::CLONE_TRAIT) { - let obj_ty = cx.tables().expr_ty(&obj[0]); + let obj_ty = cx.typeck_results().expr_ty(&obj[0]); if let ty::Ref(_, ty, _) = obj_ty.kind { let copy = is_copy(cx, ty); lint(cx, e.span, args[0].span, copy); diff --git a/src/tools/clippy/clippy_lints/src/map_identity.rs b/src/tools/clippy/clippy_lints/src/map_identity.rs index 24ec78c884647..d4c2e66ff4b1e 100644 --- a/src/tools/clippy/clippy_lints/src/map_identity.rs +++ b/src/tools/clippy/clippy_lints/src/map_identity.rs @@ -63,7 +63,7 @@ fn get_map_argument<'a>(cx: &LateContext<'_>, expr: &'a Expr<'a>) -> Option<&'a if_chain! { if let ExprKind::MethodCall(ref method, _, ref args, _) = expr.kind; if args.len() == 2 && method.ident.as_str() == "map"; - let caller_ty = cx.tables().expr_ty(&args[0]); + let caller_ty = cx.typeck_results().expr_ty(&args[0]); if match_trait_method(cx, expr, &paths::ITERATOR) || is_type_diagnostic_item(cx, caller_ty, sym!(result_type)) || is_type_diagnostic_item(cx, caller_ty, sym!(option_type)); @@ -119,7 +119,7 @@ fn is_body_identity_function(cx: &LateContext<'_>, func: &Body<'_>) -> bool { /// Returns true iff an expression returns the same thing as a parameter's pattern fn match_expr_param(cx: &LateContext<'_>, expr: &Expr<'_>, pat: &Pat<'_>) -> bool { if let PatKind::Binding(_, _, ident, _) = pat.kind { - match_var(expr, ident.name) && !(cx.tables().hir_owner == expr.hir_id.owner && is_adjusted(cx, expr)) + match_var(expr, ident.name) && !(cx.typeck_results().hir_owner == expr.hir_id.owner && is_adjusted(cx, expr)) } else { false } diff --git a/src/tools/clippy/clippy_lints/src/map_unit_fn.rs b/src/tools/clippy/clippy_lints/src/map_unit_fn.rs index 316a71c500512..198251c58ddc5 100644 --- a/src/tools/clippy/clippy_lints/src/map_unit_fn.rs +++ b/src/tools/clippy/clippy_lints/src/map_unit_fn.rs @@ -101,7 +101,7 @@ fn is_unit_type(ty: Ty<'_>) -> bool { } fn is_unit_function(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> bool { - let ty = cx.tables().expr_ty(expr); + let ty = cx.typeck_results().expr_ty(expr); if let ty::FnDef(id, _) = ty.kind { if let Some(fn_type) = cx.tcx.fn_sig(id).no_bound_vars() { @@ -112,7 +112,7 @@ fn is_unit_function(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> bool { } fn is_unit_expression(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> bool { - is_unit_type(cx.tables().expr_ty(expr)) + is_unit_type(cx.typeck_results().expr_ty(expr)) } /// The expression inside a closure may or may not have surrounding braces and @@ -205,13 +205,14 @@ fn suggestion_msg(function_type: &str, map_type: &str) -> String { fn lint_map_unit_fn(cx: &LateContext<'_>, stmt: &hir::Stmt<'_>, expr: &hir::Expr<'_>, map_args: &[hir::Expr<'_>]) { let var_arg = &map_args[0]; - let (map_type, variant, lint) = if is_type_diagnostic_item(cx, cx.tables().expr_ty(var_arg), sym!(option_type)) { - ("Option", "Some", OPTION_MAP_UNIT_FN) - } else if is_type_diagnostic_item(cx, cx.tables().expr_ty(var_arg), sym!(result_type)) { - ("Result", "Ok", RESULT_MAP_UNIT_FN) - } else { - return; - }; + let (map_type, variant, lint) = + if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(var_arg), sym!(option_type)) { + ("Option", "Some", OPTION_MAP_UNIT_FN) + } else if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(var_arg), sym!(result_type)) { + ("Result", "Ok", RESULT_MAP_UNIT_FN) + } else { + return; + }; let fn_arg = &map_args[1]; if is_unit_function(cx, fn_arg) { diff --git a/src/tools/clippy/clippy_lints/src/match_on_vec_items.rs b/src/tools/clippy/clippy_lints/src/match_on_vec_items.rs index 0003aa94a031e..4f8f2cb171d5b 100644 --- a/src/tools/clippy/clippy_lints/src/match_on_vec_items.rs +++ b/src/tools/clippy/clippy_lints/src/match_on_vec_items.rs @@ -88,13 +88,13 @@ fn is_vec_indexing<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> Opti } fn is_vector(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { - let ty = cx.tables().expr_ty(expr); + let ty = cx.typeck_results().expr_ty(expr); let ty = walk_ptrs_ty(ty); is_type_diagnostic_item(cx, ty, sym!(vec_type)) } fn is_full_range(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { - let ty = cx.tables().expr_ty(expr); + let ty = cx.typeck_results().expr_ty(expr); let ty = walk_ptrs_ty(ty); match_type(cx, ty, &utils::paths::RANGE_FULL) } diff --git a/src/tools/clippy/clippy_lints/src/matches.rs b/src/tools/clippy/clippy_lints/src/matches.rs index bd474c208070c..ea6fb9e902576 100644 --- a/src/tools/clippy/clippy_lints/src/matches.rs +++ b/src/tools/clippy/clippy_lints/src/matches.rs @@ -620,7 +620,7 @@ fn check_single_match(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>], exp return; }; - let ty = cx.tables().expr_ty(ex); + let ty = cx.typeck_results().expr_ty(ex); if ty.kind != ty::Bool || is_allowed(cx, MATCH_BOOL, ex.hir_id) { check_single_match_single_pattern(cx, ex, arms, expr, els); check_single_match_opt_like(cx, ex, arms, expr, ty, els); @@ -712,7 +712,7 @@ fn check_single_match_opt_like( fn check_match_bool(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>], expr: &Expr<'_>) { // Type of expression is `bool`. - if cx.tables().expr_ty(ex).kind == ty::Bool { + if cx.typeck_results().expr_ty(ex).kind == ty::Bool { span_lint_and_then( cx, MATCH_BOOL, @@ -775,8 +775,8 @@ fn check_match_bool(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>], expr: } fn check_overlapping_arms<'tcx>(cx: &LateContext<'tcx>, ex: &'tcx Expr<'_>, arms: &'tcx [Arm<'_>]) { - if arms.len() >= 2 && cx.tables().expr_ty(ex).is_integral() { - let ranges = all_ranges(cx, arms, cx.tables().expr_ty(ex)); + if arms.len() >= 2 && cx.typeck_results().expr_ty(ex).is_integral() { + let ranges = all_ranges(cx, arms, cx.typeck_results().expr_ty(ex)); let type_ranges = type_ranges(&ranges); if !type_ranges.is_empty() { if let Some((start, end)) = overlapping(&type_ranges) { @@ -794,7 +794,7 @@ fn check_overlapping_arms<'tcx>(cx: &LateContext<'tcx>, ex: &'tcx Expr<'_>, arms } fn check_wild_err_arm(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>]) { - let ex_ty = walk_ptrs_ty(cx.tables().expr_ty(ex)); + let ex_ty = walk_ptrs_ty(cx.typeck_results().expr_ty(ex)); if is_type_diagnostic_item(cx, ex_ty, sym!(result_type)) { for arm in arms { if let PatKind::TupleStruct(ref path, ref inner, _) = arm.pat.kind { @@ -835,7 +835,7 @@ fn check_wild_err_arm(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>]) { } fn check_wild_enum_match(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>]) { - let ty = cx.tables().expr_ty(ex); + let ty = cx.typeck_results().expr_ty(ex); if !ty.is_enum() { // If there isn't a nice closed set of possible values that can be conveniently enumerated, // don't complain about not enumerating the mall. @@ -1010,8 +1010,8 @@ fn check_match_as_ref(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>], exp "as_mut" }; - let output_ty = cx.tables().expr_ty(expr); - let input_ty = cx.tables().expr_ty(ex); + let output_ty = cx.typeck_results().expr_ty(expr); + let input_ty = cx.typeck_results().expr_ty(ex); let cast = if_chain! { if let ty::Adt(_, substs) = input_ty.kind; @@ -1079,7 +1079,7 @@ fn check_match_like_matches<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) fn find_matches_sugg(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>], expr: &Expr<'_>, desugared: bool) { if_chain! { if arms.len() == 2; - if cx.tables().expr_ty(expr).is_bool(); + if cx.typeck_results().expr_ty(expr).is_bool(); if is_wild(&arms[1].pat); if let Some(first) = find_bool_lit(&arms[0].body.kind, desugared); if let Some(second) = find_bool_lit(&arms[1].body.kind, desugared); @@ -1154,13 +1154,13 @@ fn check_match_single_binding<'a>(cx: &LateContext<'a>, ex: &Expr<'a>, arms: &[A match match_body.kind { ExprKind::Block(block, _) => { // macro + expr_ty(body) == () - if block.span.from_expansion() && cx.tables().expr_ty(&match_body).is_unit() { + if block.span.from_expansion() && cx.typeck_results().expr_ty(&match_body).is_unit() { snippet_body.push(';'); } }, _ => { // expr_ty(body) == () - if cx.tables().expr_ty(&match_body).is_unit() { + if cx.typeck_results().expr_ty(&match_body).is_unit() { snippet_body.push(';'); } }, @@ -1255,11 +1255,11 @@ fn all_ranges<'tcx>(cx: &LateContext<'tcx>, arms: &'tcx [Arm<'_>], ty: Ty<'tcx>) { if let PatKind::Range(ref lhs, ref rhs, range_end) = pat.kind { let lhs = match lhs { - Some(lhs) => constant(cx, cx.tables(), lhs)?.0, + Some(lhs) => constant(cx, cx.typeck_results(), lhs)?.0, None => miri_to_const(ty.numeric_min_val(cx.tcx)?)?, }; let rhs = match rhs { - Some(rhs) => constant(cx, cx.tables(), rhs)?.0, + Some(rhs) => constant(cx, cx.typeck_results(), rhs)?.0, None => miri_to_const(ty.numeric_max_val(cx.tcx)?)?, }; let rhs = match range_end { @@ -1273,7 +1273,7 @@ fn all_ranges<'tcx>(cx: &LateContext<'tcx>, arms: &'tcx [Arm<'_>], ty: Ty<'tcx>) } if let PatKind::Lit(ref value) = pat.kind { - let value = constant(cx, cx.tables(), value)?.0; + let value = constant(cx, cx.typeck_results(), value)?.0; return Some(SpannedRange { span: pat.span, node: (value.clone(), Bound::Included(value)), diff --git a/src/tools/clippy/clippy_lints/src/mem_discriminant.rs b/src/tools/clippy/clippy_lints/src/mem_discriminant.rs index 06c568513035f..c71c2ee7d70af 100644 --- a/src/tools/clippy/clippy_lints/src/mem_discriminant.rs +++ b/src/tools/clippy/clippy_lints/src/mem_discriminant.rs @@ -38,7 +38,7 @@ impl<'tcx> LateLintPass<'tcx> for MemDiscriminant { if let Some(def_id) = cx.qpath_res(func_qpath, func.hir_id).opt_def_id(); if match_def_path(cx, def_id, &paths::MEM_DISCRIMINANT); // type is non-enum - let ty_param = cx.tables().node_substs(func.hir_id).type_at(0); + let ty_param = cx.typeck_results().node_substs(func.hir_id).type_at(0); if !ty_param.is_enum(); then { diff --git a/src/tools/clippy/clippy_lints/src/mem_forget.rs b/src/tools/clippy/clippy_lints/src/mem_forget.rs index b895ba324c78a..8c6fd10f98a1e 100644 --- a/src/tools/clippy/clippy_lints/src/mem_forget.rs +++ b/src/tools/clippy/clippy_lints/src/mem_forget.rs @@ -31,7 +31,7 @@ impl<'tcx> LateLintPass<'tcx> for MemForget { if let ExprKind::Path(ref qpath) = path_expr.kind { if let Some(def_id) = qpath_res(cx, qpath, path_expr.hir_id).opt_def_id() { if match_def_path(cx, def_id, &paths::MEM_FORGET) { - let forgot_ty = cx.tables().expr_ty(&args[0]); + let forgot_ty = cx.typeck_results().expr_ty(&args[0]); if forgot_ty.ty_adt_def().map_or(false, |def| def.has_dtor(cx.tcx)) { span_lint(cx, MEM_FORGET, e.span, "usage of `mem::forget` on `Drop` type"); diff --git a/src/tools/clippy/clippy_lints/src/mem_replace.rs b/src/tools/clippy/clippy_lints/src/mem_replace.rs index 25f332cdcc286..bb0acecc5a92d 100644 --- a/src/tools/clippy/clippy_lints/src/mem_replace.rs +++ b/src/tools/clippy/clippy_lints/src/mem_replace.rs @@ -138,7 +138,7 @@ fn check_replace_option_with_none(cx: &LateContext<'_>, src: &Expr<'_>, dest: &E fn check_replace_with_uninit(cx: &LateContext<'_>, src: &Expr<'_>, dest: &Expr<'_>, expr_span: Span) { if_chain! { // check if replacement is mem::MaybeUninit::uninit().assume_init() - if let Some(method_def_id) = cx.tables().type_dependent_def_id(src.hir_id); + if let Some(method_def_id) = cx.typeck_results().type_dependent_def_id(src.hir_id); if cx.tcx.is_diagnostic_item(sym::assume_init, method_def_id); then { let mut applicability = Applicability::MachineApplicable; @@ -179,7 +179,7 @@ fn check_replace_with_uninit(cx: &LateContext<'_>, src: &Expr<'_>, dest: &Expr<' applicability, ); } else if cx.tcx.is_diagnostic_item(sym::mem_zeroed, repl_def_id) && - !cx.tables().expr_ty(src).is_primitive() { + !cx.typeck_results().expr_ty(src).is_primitive() { span_lint_and_help( cx, MEM_REPLACE_WITH_UNINIT, diff --git a/src/tools/clippy/clippy_lints/src/methods/bind_instead_of_map.rs b/src/tools/clippy/clippy_lints/src/methods/bind_instead_of_map.rs index fcf7b509eadbf..498f12518f8a3 100644 --- a/src/tools/clippy/clippy_lints/src/methods/bind_instead_of_map.rs +++ b/src/tools/clippy/clippy_lints/src/methods/bind_instead_of_map.rs @@ -157,7 +157,7 @@ pub(crate) trait BindInsteadOfMap { /// Lint use of `_.and_then(|x| Some(y))` for `Option`s fn lint(cx: &LateContext<'_>, expr: &hir::Expr<'_>, args: &[hir::Expr<'_>]) { - if !match_type(cx, cx.tables().expr_ty(&args[0]), Self::TYPE_QPATH) { + if !match_type(cx, cx.typeck_results().expr_ty(&args[0]), Self::TYPE_QPATH) { return; } diff --git a/src/tools/clippy/clippy_lints/src/methods/inefficient_to_string.rs b/src/tools/clippy/clippy_lints/src/methods/inefficient_to_string.rs index 1c0018a5b95e2..e5f815772eba9 100644 --- a/src/tools/clippy/clippy_lints/src/methods/inefficient_to_string.rs +++ b/src/tools/clippy/clippy_lints/src/methods/inefficient_to_string.rs @@ -11,9 +11,9 @@ use rustc_middle::ty::{self, Ty}; /// Checks for the `INEFFICIENT_TO_STRING` lint pub fn lint<'tcx>(cx: &LateContext<'tcx>, expr: &hir::Expr<'_>, arg: &hir::Expr<'_>, arg_ty: Ty<'tcx>) { if_chain! { - if let Some(to_string_meth_did) = cx.tables().type_dependent_def_id(expr.hir_id); + if let Some(to_string_meth_did) = cx.typeck_results().type_dependent_def_id(expr.hir_id); if match_def_path(cx, to_string_meth_did, &paths::TO_STRING_METHOD); - if let Some(substs) = cx.tables().node_substs_opt(expr.hir_id); + if let Some(substs) = cx.typeck_results().node_substs_opt(expr.hir_id); let self_ty = substs.type_at(0); let (deref_self_ty, deref_count) = walk_ptrs_ty_depth(self_ty); if deref_count >= 1; diff --git a/src/tools/clippy/clippy_lints/src/methods/manual_saturating_arithmetic.rs b/src/tools/clippy/clippy_lints/src/methods/manual_saturating_arithmetic.rs index 9c04b6d57b90f..40a6257586164 100644 --- a/src/tools/clippy/clippy_lints/src/methods/manual_saturating_arithmetic.rs +++ b/src/tools/clippy/clippy_lints/src/methods/manual_saturating_arithmetic.rs @@ -11,7 +11,7 @@ pub fn lint(cx: &LateContext<'_>, expr: &hir::Expr<'_>, args: &[&[hir::Expr<'_>] let arith_lhs = &args[1][0]; let arith_rhs = &args[1][1]; - let ty = cx.tables().expr_ty(arith_lhs); + let ty = cx.typeck_results().expr_ty(arith_lhs); if !ty.is_integral() { return; } @@ -101,7 +101,7 @@ fn is_min_or_max<'tcx>(cx: &LateContext<'tcx>, expr: &hir::Expr<'_>) -> Option LateLintPass<'tcx> for Methods { lint_or_fun_call(cx, expr, *method_span, &method_call.ident.as_str(), args); lint_expect_fun_call(cx, expr, *method_span, &method_call.ident.as_str(), args); - let self_ty = cx.tables().expr_ty_adjusted(&args[0]); + let self_ty = cx.typeck_results().expr_ty_adjusted(&args[0]); if args.len() == 1 && method_call.ident.name == sym!(clone) { lint_clone_on_copy(cx, expr, &args[0], self_ty); lint_clone_on_ref_ptr(cx, expr, &args[0]); @@ -1639,7 +1639,7 @@ fn lint_or_fun_call<'tcx>( if let hir::ExprKind::Path(ref qpath) = fun.kind; let path = &*last_path_segment(qpath).ident.as_str(); if ["default", "new"].contains(&path); - let arg_ty = cx.tables().expr_ty(arg); + let arg_ty = cx.typeck_results().expr_ty(arg); if let Some(default_trait_id) = get_trait_def_id(cx, &paths::DEFAULT_TRAIT); if implements_trait(cx, arg_ty, default_trait_id, &[]); @@ -1679,7 +1679,7 @@ fn lint_or_fun_call<'tcx>( ) { if let hir::ExprKind::MethodCall(ref path, _, ref args, _) = &arg.kind { if path.ident.as_str() == "len" { - let ty = walk_ptrs_ty(cx.tables().expr_ty(&args[0])); + let ty = walk_ptrs_ty(cx.typeck_results().expr_ty(&args[0])); match ty.kind { ty::Slice(_) | ty::Array(_, _) => return, @@ -1707,7 +1707,7 @@ fn lint_or_fun_call<'tcx>( if { finder.visit_expr(&arg); finder.found }; if !contains_return(&arg); - let self_ty = cx.tables().expr_ty(self_expr); + let self_ty = cx.typeck_results().expr_ty(self_expr); if let Some(&(_, fn_has_arguments, poss, suffix)) = know_types.iter().find(|&&i| match_type(cx, self_ty, i.0)); @@ -1786,7 +1786,7 @@ fn lint_expect_fun_call( if call_args.len() == 1 && (method_name.ident.name == sym!(as_str) || method_name.ident.name == sym!(as_ref)) && { - let arg_type = cx.tables().expr_ty(&call_args[0]); + let arg_type = cx.typeck_results().expr_ty(&call_args[0]); let base_type = walk_ptrs_ty(arg_type); base_type.kind == ty::Str || is_type_diagnostic_item(cx, base_type, sym!(string_type)) } @@ -1805,7 +1805,7 @@ fn lint_expect_fun_call( // Only `&'static str` or `String` can be used directly in the `panic!`. Other types should be // converted to string. fn requires_to_string(cx: &LateContext<'_>, arg: &hir::Expr<'_>) -> bool { - let arg_ty = cx.tables().expr_ty(arg); + let arg_ty = cx.typeck_results().expr_ty(arg); if is_type_diagnostic_item(cx, arg_ty, sym!(string_type)) { return false; } @@ -1835,15 +1835,16 @@ fn lint_expect_fun_call( false } }, - hir::ExprKind::MethodCall(..) => cx - .tables() - .type_dependent_def_id(arg.hir_id) - .map_or(false, |method_id| { - matches!( - cx.tcx.fn_sig(method_id).output().skip_binder().kind, - ty::Ref(ty::ReStatic, ..) - ) - }), + hir::ExprKind::MethodCall(..) => { + cx.typeck_results() + .type_dependent_def_id(arg.hir_id) + .map_or(false, |method_id| { + matches!( + cx.tcx.fn_sig(method_id).output().skip_binder().kind, + ty::Ref(ty::ReStatic, ..) + ) + }) + }, hir::ExprKind::Path(ref p) => matches!( cx.qpath_res(p, arg.hir_id), hir::def::Res::Def(hir::def::DefKind::Const | hir::def::DefKind::Static, _) @@ -1891,7 +1892,7 @@ fn lint_expect_fun_call( return; } - let receiver_type = cx.tables().expr_ty_adjusted(&args[0]); + let receiver_type = cx.typeck_results().expr_ty_adjusted(&args[0]); let closure_args = if is_type_diagnostic_item(cx, receiver_type, sym!(option_type)) { "||" } else if is_type_diagnostic_item(cx, receiver_type, sym!(result_type)) { @@ -1957,7 +1958,7 @@ fn lint_expect_fun_call( /// Checks for the `CLONE_ON_COPY` lint. fn lint_clone_on_copy(cx: &LateContext<'_>, expr: &hir::Expr<'_>, arg: &hir::Expr<'_>, arg_ty: Ty<'_>) { - let ty = cx.tables().expr_ty(expr); + let ty = cx.typeck_results().expr_ty(expr); if let ty::Ref(_, inner, _) = arg_ty.kind { if let ty::Ref(_, innermost, _) = inner.kind { span_lint_and_then( @@ -2005,7 +2006,9 @@ fn lint_clone_on_copy(cx: &LateContext<'_>, expr: &hir::Expr<'_>, arg: &hir::Exp // &*x is a nop, &x.clone() is not hir::ExprKind::AddrOf(..) => return, // (*x).func() is useless, x.clone().func() can work in case func borrows mutably - hir::ExprKind::MethodCall(_, _, parent_args, _) if expr.hir_id == parent_args[0].hir_id => return, + hir::ExprKind::MethodCall(_, _, parent_args, _) if expr.hir_id == parent_args[0].hir_id => { + return; + }, _ => {}, }, @@ -2021,11 +2024,11 @@ fn lint_clone_on_copy(cx: &LateContext<'_>, expr: &hir::Expr<'_>, arg: &hir::Exp } // x.clone() might have dereferenced x, possibly through Deref impls - if cx.tables().expr_ty(arg) == ty { + if cx.typeck_results().expr_ty(arg) == ty { snip = Some(("try removing the `clone` call", format!("{}", snippet))); } else { let deref_count = cx - .tables() + .typeck_results() .expr_adjustments(arg) .iter() .filter(|adj| matches!(adj.kind, ty::adjustment::Adjust::Deref(_))) @@ -2045,7 +2048,7 @@ fn lint_clone_on_copy(cx: &LateContext<'_>, expr: &hir::Expr<'_>, arg: &hir::Exp } fn lint_clone_on_ref_ptr(cx: &LateContext<'_>, expr: &hir::Expr<'_>, arg: &hir::Expr<'_>) { - let obj_ty = walk_ptrs_ty(cx.tables().expr_ty(arg)); + let obj_ty = walk_ptrs_ty(cx.typeck_results().expr_ty(arg)); if let ty::Adt(_, subst) = obj_ty.kind { let caller_type = if is_type_diagnostic_item(cx, obj_ty, sym::Rc) { @@ -2079,7 +2082,7 @@ fn lint_string_extend(cx: &LateContext<'_>, expr: &hir::Expr<'_>, args: &[hir::E let arg = &args[1]; if let Some(arglists) = method_chain_args(arg, &["chars"]) { let target = &arglists[0][0]; - let self_ty = walk_ptrs_ty(cx.tables().expr_ty(target)); + let self_ty = walk_ptrs_ty(cx.typeck_results().expr_ty(target)); let ref_str = if self_ty.kind == ty::Str { "" } else if is_type_diagnostic_item(cx, self_ty, sym!(string_type)) { @@ -2107,7 +2110,7 @@ fn lint_string_extend(cx: &LateContext<'_>, expr: &hir::Expr<'_>, args: &[hir::E } fn lint_extend(cx: &LateContext<'_>, expr: &hir::Expr<'_>, args: &[hir::Expr<'_>]) { - let obj_ty = walk_ptrs_ty(cx.tables().expr_ty(&args[0])); + let obj_ty = walk_ptrs_ty(cx.typeck_results().expr_ty(&args[0])); if is_type_diagnostic_item(cx, obj_ty, sym!(string_type)) { lint_string_extend(cx, expr, args); } @@ -2115,7 +2118,7 @@ fn lint_extend(cx: &LateContext<'_>, expr: &hir::Expr<'_>, args: &[hir::Expr<'_> fn lint_cstring_as_ptr(cx: &LateContext<'_>, expr: &hir::Expr<'_>, source: &hir::Expr<'_>, unwrap: &hir::Expr<'_>) { if_chain! { - let source_type = cx.tables().expr_ty(source); + let source_type = cx.typeck_results().expr_ty(source); if let ty::Adt(def, substs) = source_type.kind; if cx.tcx.is_diagnostic_item(sym!(result_type), def.did); if match_type(cx, substs.type_at(0), &paths::CSTRING); @@ -2135,8 +2138,8 @@ fn lint_cstring_as_ptr(cx: &LateContext<'_>, expr: &hir::Expr<'_>, source: &hir: fn lint_iter_cloned_collect<'tcx>(cx: &LateContext<'tcx>, expr: &hir::Expr<'_>, iter_args: &'tcx [hir::Expr<'_>]) { if_chain! { - if is_type_diagnostic_item(cx, cx.tables().expr_ty(expr), sym!(vec_type)); - if let Some(slice) = derefs_to_slice(cx, &iter_args[0], cx.tables().expr_ty(&iter_args[0])); + if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(expr), sym!(vec_type)); + if let Some(slice) = derefs_to_slice(cx, &iter_args[0], cx.typeck_results().expr_ty(&iter_args[0])); if let Some(to_replace) = expr.span.trim_start(slice.span.source_callsite()); then { @@ -2243,7 +2246,7 @@ fn lint_unnecessary_fold(cx: &LateContext<'_>, expr: &hir::Expr<'_>, fold_args: fn lint_step_by<'tcx>(cx: &LateContext<'tcx>, expr: &hir::Expr<'_>, args: &'tcx [hir::Expr<'_>]) { if match_trait_method(cx, expr, &paths::ITERATOR) { - if let Some((Constant::Int(0), _)) = constant(cx, cx.tables(), &args[1]) { + if let Some((Constant::Int(0), _)) = constant(cx, cx.typeck_results(), &args[1]) { span_lint( cx, ITERATOR_STEP_BY_ZERO, @@ -2267,7 +2270,7 @@ fn lint_iter_next<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>, iter_ parent_expr_opt = get_parent_expr(cx, parent_expr); } - if derefs_to_slice(cx, caller_expr, cx.tables().expr_ty(caller_expr)).is_some() { + if derefs_to_slice(cx, caller_expr, cx.typeck_results().expr_ty(caller_expr)).is_some() { // caller is a Slice if_chain! { if let hir::ExprKind::Index(ref caller_var, ref index_expr) = &caller_expr.kind; @@ -2288,8 +2291,11 @@ fn lint_iter_next<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>, iter_ ); } } - } else if is_type_diagnostic_item(cx, cx.tables().expr_ty(caller_expr), sym!(vec_type)) - || matches!(&walk_ptrs_ty(cx.tables().expr_ty(caller_expr)).kind, ty::Array(_, _)) + } else if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(caller_expr), sym!(vec_type)) + || matches!( + &walk_ptrs_ty(cx.typeck_results().expr_ty(caller_expr)).kind, + ty::Array(_, _) + ) { // caller is a Vec or an Array let mut applicability = Applicability::MachineApplicable; @@ -2316,11 +2322,11 @@ fn lint_iter_nth<'tcx>( ) { let iter_args = nth_and_iter_args[1]; let mut_str = if is_mut { "_mut" } else { "" }; - let caller_type = if derefs_to_slice(cx, &iter_args[0], cx.tables().expr_ty(&iter_args[0])).is_some() { + let caller_type = if derefs_to_slice(cx, &iter_args[0], cx.typeck_results().expr_ty(&iter_args[0])).is_some() { "slice" - } else if is_type_diagnostic_item(cx, cx.tables().expr_ty(&iter_args[0]), sym!(vec_type)) { + } else if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(&iter_args[0]), sym!(vec_type)) { "Vec" - } else if is_type_diagnostic_item(cx, cx.tables().expr_ty(&iter_args[0]), sym!(vecdeque_type)) { + } else if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(&iter_args[0]), sym!(vecdeque_type)) { "VecDeque" } else { let nth_args = nth_and_iter_args[0]; @@ -2341,7 +2347,7 @@ fn lint_iter_nth<'tcx>( fn lint_iter_nth_zero<'tcx>(cx: &LateContext<'tcx>, expr: &hir::Expr<'_>, nth_args: &'tcx [hir::Expr<'_>]) { if_chain! { if match_trait_method(cx, expr, &paths::ITERATOR); - if let Some((Constant::Int(0), _)) = constant(cx, cx.tables(), &nth_args[1]); + if let Some((Constant::Int(0), _)) = constant(cx, cx.typeck_results(), &nth_args[1]); then { let mut applicability = Applicability::MachineApplicable; span_lint_and_sugg( @@ -2361,7 +2367,7 @@ fn lint_get_unwrap<'tcx>(cx: &LateContext<'tcx>, expr: &hir::Expr<'_>, get_args: // Note: we don't want to lint `get_mut().unwrap` for `HashMap` or `BTreeMap`, // because they do not implement `IndexMut` let mut applicability = Applicability::MachineApplicable; - let expr_ty = cx.tables().expr_ty(&get_args[0]); + let expr_ty = cx.typeck_results().expr_ty(&get_args[0]); let get_args_str = if get_args.len() > 1 { snippet_with_applicability(cx, get_args[1].span, "_", &mut applicability) } else { @@ -2463,7 +2469,7 @@ fn derefs_to_slice<'tcx>( } if let hir::ExprKind::MethodCall(ref path, _, ref args, _) = expr.kind { - if path.ident.name == sym!(iter) && may_slice(cx, cx.tables().expr_ty(&args[0])) { + if path.ident.name == sym!(iter) && may_slice(cx, cx.typeck_results().expr_ty(&args[0])) { Some(&args[0]) } else { None @@ -2486,7 +2492,7 @@ fn derefs_to_slice<'tcx>( /// lint use of `unwrap()` for `Option`s and `Result`s fn lint_unwrap(cx: &LateContext<'_>, expr: &hir::Expr<'_>, unwrap_args: &[hir::Expr<'_>]) { - let obj_ty = walk_ptrs_ty(cx.tables().expr_ty(&unwrap_args[0])); + let obj_ty = walk_ptrs_ty(cx.typeck_results().expr_ty(&unwrap_args[0])); let mess = if is_type_diagnostic_item(cx, obj_ty, sym!(option_type)) { Some((UNWRAP_USED, "an Option", "None")) @@ -2514,7 +2520,7 @@ fn lint_unwrap(cx: &LateContext<'_>, expr: &hir::Expr<'_>, unwrap_args: &[hir::E /// lint use of `expect()` for `Option`s and `Result`s fn lint_expect(cx: &LateContext<'_>, expr: &hir::Expr<'_>, expect_args: &[hir::Expr<'_>]) { - let obj_ty = walk_ptrs_ty(cx.tables().expr_ty(&expect_args[0])); + let obj_ty = walk_ptrs_ty(cx.typeck_results().expr_ty(&expect_args[0])); let mess = if is_type_diagnostic_item(cx, obj_ty, sym!(option_type)) { Some((EXPECT_USED, "an Option", "None")) @@ -2540,8 +2546,8 @@ fn lint_expect(cx: &LateContext<'_>, expr: &hir::Expr<'_>, expect_args: &[hir::E fn lint_ok_expect(cx: &LateContext<'_>, expr: &hir::Expr<'_>, ok_args: &[hir::Expr<'_>]) { if_chain! { // lint if the caller of `ok()` is a `Result` - if is_type_diagnostic_item(cx, cx.tables().expr_ty(&ok_args[0]), sym!(result_type)); - let result_type = cx.tables().expr_ty(&ok_args[0]); + if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(&ok_args[0]), sym!(result_type)); + let result_type = cx.typeck_results().expr_ty(&ok_args[0]); if let Some(error_type) = get_error_type(cx, result_type); if has_debug_impl(error_type, cx); @@ -2579,7 +2585,7 @@ fn lint_map_flatten<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>, map } // lint if caller of `.map().flatten()` is an Option - if is_type_diagnostic_item(cx, cx.tables().expr_ty(&map_args[0]), sym!(option_type)) { + if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(&map_args[0]), sym!(option_type)) { let msg = "called `map(..).flatten()` on an `Option`. \ This is more succinctly expressed by calling `.and_then(..)`"; let self_snippet = snippet(cx, map_args[0].span, ".."); @@ -2605,8 +2611,8 @@ fn lint_map_unwrap_or_else<'tcx>( unwrap_args: &'tcx [hir::Expr<'_>], ) { // lint if the caller of `map()` is an `Option` - let is_option = is_type_diagnostic_item(cx, cx.tables().expr_ty(&map_args[0]), sym!(option_type)); - let is_result = is_type_diagnostic_item(cx, cx.tables().expr_ty(&map_args[0]), sym!(result_type)); + let is_option = is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(&map_args[0]), sym!(option_type)); + let is_result = is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(&map_args[0]), sym!(result_type)); if is_option || is_result { // Don't make a suggestion that may fail to compile due to mutably borrowing @@ -2656,8 +2662,8 @@ fn lint_map_unwrap_or_else<'tcx>( /// lint use of `_.map_or(None, _)` for `Option`s and `Result`s fn lint_map_or_none<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>, map_or_args: &'tcx [hir::Expr<'_>]) { - let is_option = is_type_diagnostic_item(cx, cx.tables().expr_ty(&map_or_args[0]), sym!(option_type)); - let is_result = is_type_diagnostic_item(cx, cx.tables().expr_ty(&map_or_args[0]), sym!(result_type)); + let is_option = is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(&map_or_args[0]), sym!(option_type)); + let is_result = is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(&map_or_args[0]), sym!(result_type)); // There are two variants of this `map_or` lint: // (1) using `map_or` as an adapter from `Result` to `Option` @@ -3014,7 +3020,7 @@ fn lint_chars_cmp( if segment.ident.name == sym!(Some); then { let mut applicability = Applicability::MachineApplicable; - let self_ty = walk_ptrs_ty(cx.tables().expr_ty_adjusted(&args[0][0])); + let self_ty = walk_ptrs_ty(cx.typeck_results().expr_ty_adjusted(&args[0][0])); if self_ty.kind != ty::Str { return false; @@ -3142,8 +3148,8 @@ fn lint_asref(cx: &LateContext<'_>, expr: &hir::Expr<'_>, call_name: &str, as_re if match_trait_method(cx, expr, &paths::ASREF_TRAIT) || match_trait_method(cx, expr, &paths::ASMUT_TRAIT) { // check if the type after `as_ref` or `as_mut` is the same as before let recvr = &as_ref_args[0]; - let rcv_ty = cx.tables().expr_ty(recvr); - let res_ty = cx.tables().expr_ty(expr); + let rcv_ty = cx.typeck_results().expr_ty(recvr); + let res_ty = cx.typeck_results().expr_ty(expr); let (base_res_ty, res_depth) = walk_ptrs_ty_depth(res_ty); let (base_rcv_ty, rcv_depth) = walk_ptrs_ty_depth(rcv_ty); if base_rcv_ty == base_res_ty && rcv_depth >= res_depth { @@ -3212,7 +3218,7 @@ fn lint_maybe_uninit(cx: &LateContext<'_>, expr: &hir::Expr<'_>, outer: &hir::Ex if args.is_empty(); if let hir::ExprKind::Path(ref path) = callee.kind; if match_qpath(path, &paths::MEM_MAYBEUNINIT_UNINIT); - if !is_maybe_uninit_ty_valid(cx, cx.tables().expr_ty_adjusted(outer)); + if !is_maybe_uninit_ty_valid(cx, cx.typeck_results().expr_ty_adjusted(outer)); then { span_lint( cx, @@ -3254,7 +3260,7 @@ fn lint_option_as_ref_deref<'tcx>( ) { let same_mutability = |m| (is_mut && m == &hir::Mutability::Mut) || (!is_mut && m == &hir::Mutability::Not); - let option_ty = cx.tables().expr_ty(&as_ref_args[0]); + let option_ty = cx.typeck_results().expr_ty(&as_ref_args[0]); if !is_type_diagnostic_item(cx, option_ty, sym!(option_type)) { return; } @@ -3284,10 +3290,10 @@ fn lint_option_as_ref_deref<'tcx>( if let hir::ExprKind::Path(qpath) = &args[0].kind; if let hir::def::Res::Local(local_id) = cx.qpath_res(qpath, args[0].hir_id); if closure_body.params[0].pat.hir_id == local_id; - let adj = cx.tables().expr_adjustments(&args[0]).iter().map(|x| &x.kind).collect::>(); + let adj = cx.typeck_results().expr_adjustments(&args[0]).iter().map(|x| &x.kind).collect::>(); if let [ty::adjustment::Adjust::Deref(None), ty::adjustment::Adjust::Borrow(_)] = *adj; then { - let method_did = cx.tables().type_dependent_def_id(closure_expr.hir_id).unwrap(); + let method_did = cx.typeck_results().type_dependent_def_id(closure_expr.hir_id).unwrap(); deref_aliases.iter().any(|path| match_def_path(cx, method_did, path)) } else { false @@ -3577,7 +3583,7 @@ fn contains_return(expr: &hir::Expr<'_>) -> bool { fn check_pointer_offset(cx: &LateContext<'_>, expr: &hir::Expr<'_>, args: &[hir::Expr<'_>]) { if_chain! { if args.len() == 2; - if let ty::RawPtr(ty::TypeAndMut { ref ty, .. }) = cx.tables().expr_ty(&args[0]).kind; + if let ty::RawPtr(ty::TypeAndMut { ref ty, .. }) = cx.typeck_results().expr_ty(&args[0]).kind; if let Ok(layout) = cx.tcx.layout_of(cx.param_env.and(ty)); if layout.is_zst(); then { @@ -3587,7 +3593,7 @@ fn check_pointer_offset(cx: &LateContext<'_>, expr: &hir::Expr<'_>, args: &[hir: } fn lint_filetype_is_file(cx: &LateContext<'_>, expr: &hir::Expr<'_>, args: &[hir::Expr<'_>]) { - let ty = cx.tables().expr_ty(&args[0]); + let ty = cx.typeck_results().expr_ty(&args[0]); if !match_type(cx, ty, &paths::FILE_TYPE) { return; diff --git a/src/tools/clippy/clippy_lints/src/methods/option_map_unwrap_or.rs b/src/tools/clippy/clippy_lints/src/methods/option_map_unwrap_or.rs index 672eb75c57fc6..95fa28e1c0f75 100644 --- a/src/tools/clippy/clippy_lints/src/methods/option_map_unwrap_or.rs +++ b/src/tools/clippy/clippy_lints/src/methods/option_map_unwrap_or.rs @@ -20,8 +20,8 @@ pub(super) fn lint<'tcx>( map_span: Span, ) { // lint if the caller of `map()` is an `Option` - if is_type_diagnostic_item(cx, cx.tables().expr_ty(&map_args[0]), sym!(option_type)) { - if !is_copy(cx, cx.tables().expr_ty(&unwrap_args[1])) { + if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(&map_args[0]), sym!(option_type)) { + if !is_copy(cx, cx.typeck_results().expr_ty(&unwrap_args[1])) { // Do not lint if the `map` argument uses identifiers in the `map` // argument that are also used in the `unwrap_or` argument diff --git a/src/tools/clippy/clippy_lints/src/minmax.rs b/src/tools/clippy/clippy_lints/src/minmax.rs index c8aa98d348927..dae39aaf5e216 100644 --- a/src/tools/clippy/clippy_lints/src/minmax.rs +++ b/src/tools/clippy/clippy_lints/src/minmax.rs @@ -36,7 +36,7 @@ impl<'tcx> LateLintPass<'tcx> for MinMaxPass { } match ( outer_max, - Constant::partial_cmp(cx.tcx, cx.tables().expr_ty(ie), &outer_c, &inner_c), + Constant::partial_cmp(cx.tcx, cx.typeck_results().expr_ty(ie), &outer_c, &inner_c), ) { (_, None) | (MinMax::Max, Some(Ordering::Less)) | (MinMax::Min, Some(Ordering::Greater)) => (), _ => { @@ -62,7 +62,7 @@ enum MinMax { fn min_max<'a>(cx: &LateContext<'_>, expr: &'a Expr<'a>) -> Option<(MinMax, Constant, &'a Expr<'a>)> { if let ExprKind::Call(ref path, ref args) = expr.kind { if let ExprKind::Path(ref qpath) = path.kind { - cx.tables() + cx.typeck_results() .qpath_res(qpath, path.hir_id) .opt_def_id() .and_then(|def_id| { @@ -86,10 +86,10 @@ fn fetch_const<'a>(cx: &LateContext<'_>, args: &'a [Expr<'a>], m: MinMax) -> Opt if args.len() != 2 { return None; } - constant_simple(cx, cx.tables(), &args[0]).map_or_else( - || constant_simple(cx, cx.tables(), &args[1]).map(|c| (m, c, &args[0])), + constant_simple(cx, cx.typeck_results(), &args[0]).map_or_else( + || constant_simple(cx, cx.typeck_results(), &args[1]).map(|c| (m, c, &args[0])), |c| { - if constant_simple(cx, cx.tables(), &args[1]).is_none() { + if constant_simple(cx, cx.typeck_results(), &args[1]).is_none() { // otherwise ignore Some((m, c, &args[1])) } else { diff --git a/src/tools/clippy/clippy_lints/src/misc.rs b/src/tools/clippy/clippy_lints/src/misc.rs index 400f4b609af7f..fc10e5077b839 100644 --- a/src/tools/clippy/clippy_lints/src/misc.rs +++ b/src/tools/clippy/clippy_lints/src/misc.rs @@ -496,7 +496,7 @@ fn get_lint_and_message( fn check_nan(cx: &LateContext<'_>, expr: &Expr<'_>, cmp_expr: &Expr<'_>) { if_chain! { if !in_constant(cx, cmp_expr.hir_id); - if let Some((value, _)) = constant(cx, cx.tables(), expr); + if let Some((value, _)) = constant(cx, cx.typeck_results(), expr); then { let needs_lint = match value { Constant::F32(num) => num.is_nan(), @@ -517,7 +517,7 @@ fn check_nan(cx: &LateContext<'_>, expr: &Expr<'_>, cmp_expr: &Expr<'_>) { } fn is_named_constant<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> bool { - if let Some((_, res)) = constant(cx, cx.tables(), expr) { + if let Some((_, res)) = constant(cx, cx.typeck_results(), expr) { res } else { false @@ -525,7 +525,7 @@ fn is_named_constant<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> bool } fn is_allowed<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> bool { - match constant(cx, cx.tables(), expr) { + match constant(cx, cx.typeck_results(), expr) { Some((Constant::F32(f), _)) => f == 0.0 || f.is_infinite(), Some((Constant::F64(f), _)) => f == 0.0 || f.is_infinite(), Some((Constant::Vec(vec), _)) => vec.iter().all(|f| match f { @@ -557,7 +557,7 @@ fn is_signum(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { } fn is_float(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { - let value = &walk_ptrs_ty(cx.tables().expr_ty(expr)).kind; + let value = &walk_ptrs_ty(cx.typeck_results().expr_ty(expr)).kind; if let ty::Array(arr_ty, _) = value { return matches!(arr_ty.kind, ty::Float(_)); @@ -567,7 +567,7 @@ fn is_float(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { } fn is_array(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { - matches!(&walk_ptrs_ty(cx.tables().expr_ty(expr)).kind, ty::Array(_, _)) + matches!(&walk_ptrs_ty(cx.typeck_results().expr_ty(expr)).kind, ty::Array(_, _)) } fn check_to_owned(cx: &LateContext<'_>, expr: &Expr<'_>, other: &Expr<'_>, left: bool) { @@ -593,7 +593,7 @@ fn check_to_owned(cx: &LateContext<'_>, expr: &Expr<'_>, other: &Expr<'_>, left: let (arg_ty, snip) = match expr.kind { ExprKind::MethodCall(.., ref args, _) if args.len() == 1 => { if match_trait_method(cx, expr, &paths::TO_STRING) || match_trait_method(cx, expr, &paths::TO_OWNED) { - (cx.tables().expr_ty(&args[0]), snippet(cx, args[0].span, "..")) + (cx.typeck_results().expr_ty(&args[0]), snippet(cx, args[0].span, "..")) } else { return; } @@ -601,7 +601,7 @@ fn check_to_owned(cx: &LateContext<'_>, expr: &Expr<'_>, other: &Expr<'_>, left: ExprKind::Call(ref path, ref v) if v.len() == 1 => { if let ExprKind::Path(ref path) = path.kind { if match_qpath(path, &["String", "from_str"]) || match_qpath(path, &["String", "from"]) { - (cx.tables().expr_ty(&v[0]), snippet(cx, v[0].span, "..")) + (cx.typeck_results().expr_ty(&v[0]), snippet(cx, v[0].span, "..")) } else { return; } @@ -612,7 +612,7 @@ fn check_to_owned(cx: &LateContext<'_>, expr: &Expr<'_>, other: &Expr<'_>, left: _ => return, }; - let other_ty = cx.tables().expr_ty(other); + let other_ty = cx.typeck_results().expr_ty(other); let without_deref = symmetric_partial_eq(cx, arg_ty, other_ty).unwrap_or_default(); let with_deref = arg_ty diff --git a/src/tools/clippy/clippy_lints/src/modulo_arithmetic.rs b/src/tools/clippy/clippy_lints/src/modulo_arithmetic.rs index 59ccc6333fdcd..5d4436bd206d2 100644 --- a/src/tools/clippy/clippy_lints/src/modulo_arithmetic.rs +++ b/src/tools/clippy/clippy_lints/src/modulo_arithmetic.rs @@ -37,8 +37,8 @@ struct OperandInfo { } fn analyze_operand(operand: &Expr<'_>, cx: &LateContext<'_>, expr: &Expr<'_>) -> Option { - match constant(cx, cx.tables(), operand) { - Some((Constant::Int(v), _)) => match cx.tables().expr_ty(expr).kind { + match constant(cx, cx.typeck_results(), operand) { + Some((Constant::Int(v), _)) => match cx.typeck_results().expr_ty(expr).kind { ty::Int(ity) => { let value = sext(cx.tcx, v, ity); return Some(OperandInfo { @@ -106,7 +106,7 @@ fn check_const_operands<'tcx>( } fn check_non_const_operands<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, operand: &Expr<'_>) { - let operand_type = cx.tables().expr_ty(operand); + let operand_type = cx.typeck_results().expr_ty(operand); if might_have_negative_value(operand_type) { span_lint_and_then( cx, diff --git a/src/tools/clippy/clippy_lints/src/mut_key.rs b/src/tools/clippy/clippy_lints/src/mut_key.rs index d8fb8a4bb776b..9f8f401cc0f67 100644 --- a/src/tools/clippy/clippy_lints/src/mut_key.rs +++ b/src/tools/clippy/clippy_lints/src/mut_key.rs @@ -76,7 +76,7 @@ impl<'tcx> LateLintPass<'tcx> for MutableKeyType { if let hir::PatKind::Wild = local.pat.kind { return; } - check_ty(cx, local.span, cx.tables().pat_ty(&*local.pat)); + check_ty(cx, local.span, cx.typeck_results().pat_ty(&*local.pat)); } } diff --git a/src/tools/clippy/clippy_lints/src/mut_mut.rs b/src/tools/clippy/clippy_lints/src/mut_mut.rs index 259b4c73d7609..b02e86bca2719 100644 --- a/src/tools/clippy/clippy_lints/src/mut_mut.rs +++ b/src/tools/clippy/clippy_lints/src/mut_mut.rs @@ -69,7 +69,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for MutVisitor<'a, 'tcx> { expr.span, "generally you want to avoid `&mut &mut _` if possible", ); - } else if let ty::Ref(_, _, hir::Mutability::Mut) = self.cx.tables().expr_ty(e).kind { + } else if let ty::Ref(_, _, hir::Mutability::Mut) = self.cx.typeck_results().expr_ty(e).kind { span_lint( self.cx, MUT_MUT, diff --git a/src/tools/clippy/clippy_lints/src/mut_reference.rs b/src/tools/clippy/clippy_lints/src/mut_reference.rs index 53341b6eba752..b8dc508163297 100644 --- a/src/tools/clippy/clippy_lints/src/mut_reference.rs +++ b/src/tools/clippy/clippy_lints/src/mut_reference.rs @@ -37,14 +37,14 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryMutPassed { check_arguments( cx, arguments, - cx.tables().expr_ty(fn_expr), + cx.typeck_results().expr_ty(fn_expr), &rustc_hir_pretty::to_string(rustc_hir_pretty::NO_ANN, |s| s.print_qpath(path, false)), ); } }, ExprKind::MethodCall(ref path, _, ref arguments, _) => { - let def_id = cx.tables().type_dependent_def_id(e.hir_id).unwrap(); - let substs = cx.tables().node_substs(e.hir_id); + let def_id = cx.typeck_results().type_dependent_def_id(e.hir_id).unwrap(); + let substs = cx.typeck_results().node_substs(e.hir_id); let method_type = cx.tcx.type_of(def_id).subst(cx.tcx, substs); check_arguments(cx, arguments, method_type, &path.ident.as_str()) }, diff --git a/src/tools/clippy/clippy_lints/src/mutable_debug_assertion.rs b/src/tools/clippy/clippy_lints/src/mutable_debug_assertion.rs index 78d2356748f1e..7f529f0404c00 100644 --- a/src/tools/clippy/clippy_lints/src/mutable_debug_assertion.rs +++ b/src/tools/clippy/clippy_lints/src/mutable_debug_assertion.rs @@ -135,7 +135,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MutArgVisitor<'a, 'tcx> { return; }, ExprKind::Path(_) => { - if let Some(adj) = self.cx.tables().adjustments().get(expr.hir_id) { + if let Some(adj) = self.cx.typeck_results().adjustments().get(expr.hir_id) { if adj .iter() .any(|a| matches!(a.target.kind, ty::Ref(_, _, Mutability::Mut))) diff --git a/src/tools/clippy/clippy_lints/src/mutex_atomic.rs b/src/tools/clippy/clippy_lints/src/mutex_atomic.rs index 1a821491fcaf2..568898aa5c9b7 100644 --- a/src/tools/clippy/clippy_lints/src/mutex_atomic.rs +++ b/src/tools/clippy/clippy_lints/src/mutex_atomic.rs @@ -66,7 +66,7 @@ declare_lint_pass!(Mutex => [MUTEX_ATOMIC, MUTEX_INTEGER]); impl<'tcx> LateLintPass<'tcx> for Mutex { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { - let ty = cx.tables().expr_ty(expr); + let ty = cx.typeck_results().expr_ty(expr); if let ty::Adt(_, subst) = ty.kind { if is_type_diagnostic_item(cx, ty, sym!(mutex_type)) { let mutex_param = subst.type_at(0); diff --git a/src/tools/clippy/clippy_lints/src/needless_bool.rs b/src/tools/clippy/clippy_lints/src/needless_bool.rs index e15376b932628..8e44f2ec2408c 100644 --- a/src/tools/clippy/clippy_lints/src/needless_bool.rs +++ b/src/tools/clippy/clippy_lints/src/needless_bool.rs @@ -229,7 +229,10 @@ fn check_comparison<'a, 'tcx>( use self::Expression::{Bool, Other}; if let ExprKind::Binary(op, ref left_side, ref right_side) = e.kind { - let (l_ty, r_ty) = (cx.tables().expr_ty(left_side), cx.tables().expr_ty(right_side)); + let (l_ty, r_ty) = ( + cx.typeck_results().expr_ty(left_side), + cx.typeck_results().expr_ty(right_side), + ); if l_ty.is_bool() && r_ty.is_bool() { let mut applicability = Applicability::MachineApplicable; diff --git a/src/tools/clippy/clippy_lints/src/needless_borrow.rs b/src/tools/clippy/clippy_lints/src/needless_borrow.rs index 1bea93fcb7522..415ab556c9fd4 100644 --- a/src/tools/clippy/clippy_lints/src/needless_borrow.rs +++ b/src/tools/clippy/clippy_lints/src/needless_borrow.rs @@ -46,8 +46,8 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessBorrow { return; } if let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, ref inner) = e.kind { - if let ty::Ref(..) = cx.tables().expr_ty(inner).kind { - for adj3 in cx.tables().expr_adjustments(e).windows(3) { + if let ty::Ref(..) = cx.typeck_results().expr_ty(inner).kind { + for adj3 in cx.typeck_results().expr_adjustments(e).windows(3) { if let [Adjustment { kind: Adjust::Deref(_), .. }, Adjustment { @@ -85,7 +85,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessBorrow { } if_chain! { if let PatKind::Binding(BindingAnnotation::Ref, .., name, _) = pat.kind; - if let ty::Ref(_, tam, mutbl) = cx.tables().pat_ty(pat).kind; + if let ty::Ref(_, tam, mutbl) = cx.typeck_results().pat_ty(pat).kind; if mutbl == Mutability::Not; if let ty::Ref(_, _, mutbl) = tam.kind; // only lint immutable refs, because borrowed `&mut T` cannot be moved out diff --git a/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs b/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs index 29e5d4d166498..81774b617ac2e 100644 --- a/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs +++ b/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs @@ -135,7 +135,8 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue { } = { let mut ctx = MovedVariablesCtxt::default(); cx.tcx.infer_ctxt().enter(|infcx| { - euv::ExprUseVisitor::new(&mut ctx, &infcx, fn_def_id, cx.param_env, cx.tables()).consume_body(body); + euv::ExprUseVisitor::new(&mut ctx, &infcx, fn_def_id, cx.param_env, cx.typeck_results()) + .consume_body(body); }); ctx }; diff --git a/src/tools/clippy/clippy_lints/src/needless_update.rs b/src/tools/clippy/clippy_lints/src/needless_update.rs index 6ec73041604e6..ce3f066eff5e7 100644 --- a/src/tools/clippy/clippy_lints/src/needless_update.rs +++ b/src/tools/clippy/clippy_lints/src/needless_update.rs @@ -47,7 +47,7 @@ declare_lint_pass!(NeedlessUpdate => [NEEDLESS_UPDATE]); impl<'tcx> LateLintPass<'tcx> for NeedlessUpdate { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { if let ExprKind::Struct(_, ref fields, Some(ref base)) = expr.kind { - let ty = cx.tables().expr_ty(expr); + let ty = cx.typeck_results().expr_ty(expr); if let ty::Adt(def, _) = ty.kind { if fields.len() == def.non_enum_variant().fields.len() { span_lint( diff --git a/src/tools/clippy/clippy_lints/src/neg_cmp_op_on_partial_ord.rs b/src/tools/clippy/clippy_lints/src/neg_cmp_op_on_partial_ord.rs index 1be766d8e8dc5..95613a1b82ef0 100644 --- a/src/tools/clippy/clippy_lints/src/neg_cmp_op_on_partial_ord.rs +++ b/src/tools/clippy/clippy_lints/src/neg_cmp_op_on_partial_ord.rs @@ -56,7 +56,7 @@ impl<'tcx> LateLintPass<'tcx> for NoNegCompOpForPartialOrd { then { - let ty = cx.tables().expr_ty(left); + let ty = cx.typeck_results().expr_ty(left); let implements_ord = { if let Some(id) = utils::get_trait_def_id(cx, &paths::ORD) { diff --git a/src/tools/clippy/clippy_lints/src/neg_multiply.rs b/src/tools/clippy/clippy_lints/src/neg_multiply.rs index 1346145da327e..6b6c950e0abee 100644 --- a/src/tools/clippy/clippy_lints/src/neg_multiply.rs +++ b/src/tools/clippy/clippy_lints/src/neg_multiply.rs @@ -44,8 +44,8 @@ impl<'tcx> LateLintPass<'tcx> for NegMultiply { fn check_mul(cx: &LateContext<'_>, span: Span, lit: &Expr<'_>, exp: &Expr<'_>) { if_chain! { if let ExprKind::Lit(ref l) = lit.kind; - if let Constant::Int(1) = consts::lit_to_constant(&l.node, cx.tables().expr_ty_opt(lit)); - if cx.tables().expr_ty(exp).is_integral(); + if let Constant::Int(1) = consts::lit_to_constant(&l.node, cx.typeck_results().expr_ty_opt(lit)); + if cx.typeck_results().expr_ty(exp).is_integral(); then { span_lint(cx, NEG_MULTIPLY, span, "Negation by multiplying with `-1`"); } diff --git a/src/tools/clippy/clippy_lints/src/no_effect.rs b/src/tools/clippy/clippy_lints/src/no_effect.rs index 95283dae71470..b1b5b3439a0e3 100644 --- a/src/tools/clippy/clippy_lints/src/no_effect.rs +++ b/src/tools/clippy/clippy_lints/src/no_effect.rs @@ -48,7 +48,7 @@ fn has_no_effect(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { } match expr.kind { ExprKind::Lit(..) | ExprKind::Closure(..) => true, - ExprKind::Path(..) => !has_drop(cx, cx.tables().expr_ty(expr)), + ExprKind::Path(..) => !has_drop(cx, cx.typeck_results().expr_ty(expr)), ExprKind::Index(ref a, ref b) | ExprKind::Binary(_, ref a, ref b) => { has_no_effect(cx, a) && has_no_effect(cx, b) }, @@ -61,7 +61,7 @@ fn has_no_effect(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { | ExprKind::AddrOf(_, _, ref inner) | ExprKind::Box(ref inner) => has_no_effect(cx, inner), ExprKind::Struct(_, ref fields, ref base) => { - !has_drop(cx, cx.tables().expr_ty(expr)) + !has_drop(cx, cx.typeck_results().expr_ty(expr)) && fields.iter().all(|field| has_no_effect(cx, &field.expr)) && base.as_ref().map_or(true, |base| has_no_effect(cx, base)) }, @@ -70,7 +70,8 @@ fn has_no_effect(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { let res = qpath_res(cx, qpath, callee.hir_id); match res { Res::Def(DefKind::Struct | DefKind::Variant | DefKind::Ctor(..), ..) => { - !has_drop(cx, cx.tables().expr_ty(expr)) && args.iter().all(|arg| has_no_effect(cx, arg)) + !has_drop(cx, cx.typeck_results().expr_ty(expr)) + && args.iter().all(|arg| has_no_effect(cx, arg)) }, _ => false, } @@ -137,7 +138,7 @@ fn reduce_expression<'a>(cx: &LateContext<'_>, expr: &'a Expr<'a>) -> Option reduce_expression(cx, inner).or_else(|| Some(vec![inner])), ExprKind::Struct(_, ref fields, ref base) => { - if has_drop(cx, cx.tables().expr_ty(expr)) { + if has_drop(cx, cx.typeck_results().expr_ty(expr)) { None } else { Some(fields.iter().map(|f| &f.expr).chain(base).map(Deref::deref).collect()) @@ -148,7 +149,7 @@ fn reduce_expression<'a>(cx: &LateContext<'_>, expr: &'a Expr<'a>) -> Option + if !has_drop(cx, cx.typeck_results().expr_ty(expr)) => { Some(args.iter().collect()) }, diff --git a/src/tools/clippy/clippy_lints/src/non_copy_const.rs b/src/tools/clippy/clippy_lints/src/non_copy_const.rs index a3521c31a6be6..031d69e86a13e 100644 --- a/src/tools/clippy/clippy_lints/src/non_copy_const.rs +++ b/src/tools/clippy/clippy_lints/src/non_copy_const.rs @@ -237,13 +237,13 @@ impl<'tcx> LateLintPass<'tcx> for NonCopyConst { } let ty = if needs_check_adjustment { - let adjustments = cx.tables().expr_adjustments(dereferenced_expr); + let adjustments = cx.typeck_results().expr_adjustments(dereferenced_expr); if let Some(i) = adjustments .iter() .position(|adj| matches!(adj.kind, Adjust::Borrow(_) | Adjust::Deref(_))) { if i == 0 { - cx.tables().expr_ty(dereferenced_expr) + cx.typeck_results().expr_ty(dereferenced_expr) } else { adjustments[i - 1].target } @@ -252,7 +252,7 @@ impl<'tcx> LateLintPass<'tcx> for NonCopyConst { return; } } else { - cx.tables().expr_ty(dereferenced_expr) + cx.typeck_results().expr_ty(dereferenced_expr) }; verify_ty_bound(cx, ty, Source::Expr { expr: expr.span }); diff --git a/src/tools/clippy/clippy_lints/src/open_options.rs b/src/tools/clippy/clippy_lints/src/open_options.rs index 2b83efa84f64d..e99d0317ba2e8 100644 --- a/src/tools/clippy/clippy_lints/src/open_options.rs +++ b/src/tools/clippy/clippy_lints/src/open_options.rs @@ -30,7 +30,7 @@ declare_lint_pass!(OpenOptions => [NONSENSICAL_OPEN_OPTIONS]); impl<'tcx> LateLintPass<'tcx> for OpenOptions { fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) { if let ExprKind::MethodCall(ref path, _, ref arguments, _) = e.kind { - let obj_ty = walk_ptrs_ty(cx.tables().expr_ty(&arguments[0])); + let obj_ty = walk_ptrs_ty(cx.typeck_results().expr_ty(&arguments[0])); if path.ident.name == sym!(open) && match_type(cx, obj_ty, &paths::OPEN_OPTIONS) { let mut options = Vec::new(); get_open_options(cx, &arguments[0], &mut options); @@ -58,7 +58,7 @@ enum OpenOption { fn get_open_options(cx: &LateContext<'_>, argument: &Expr<'_>, options: &mut Vec<(OpenOption, Argument)>) { if let ExprKind::MethodCall(ref path, _, ref arguments, _) = argument.kind { - let obj_ty = walk_ptrs_ty(cx.tables().expr_ty(&arguments[0])); + let obj_ty = walk_ptrs_ty(cx.typeck_results().expr_ty(&arguments[0])); // Only proceed if this is a call on some object of type std::fs::OpenOptions if match_type(cx, obj_ty, &paths::OPEN_OPTIONS) && arguments.len() >= 2 { diff --git a/src/tools/clippy/clippy_lints/src/option_if_let_else.rs b/src/tools/clippy/clippy_lints/src/option_if_let_else.rs index 8dbe58763bfb2..065f863b8654e 100644 --- a/src/tools/clippy/clippy_lints/src/option_if_let_else.rs +++ b/src/tools/clippy/clippy_lints/src/option_if_let_else.rs @@ -72,7 +72,8 @@ declare_lint_pass!(OptionIfLetElse => [OPTION_IF_LET_ELSE]); /// Returns true iff the given expression is the result of calling `Result::ok` fn is_result_ok(cx: &LateContext<'_>, expr: &'_ Expr<'_>) -> bool { if let ExprKind::MethodCall(ref path, _, &[ref receiver], _) = &expr.kind { - path.ident.name.to_ident_string() == "ok" && match_type(cx, &cx.tables().expr_ty(&receiver), &paths::RESULT) + path.ident.name.to_ident_string() == "ok" + && match_type(cx, &cx.typeck_results().expr_ty(&receiver), &paths::RESULT) } else { false } diff --git a/src/tools/clippy/clippy_lints/src/overflow_check_conditional.rs b/src/tools/clippy/clippy_lints/src/overflow_check_conditional.rs index 0850f88df44fe..4d4a967665482 100644 --- a/src/tools/clippy/clippy_lints/src/overflow_check_conditional.rs +++ b/src/tools/clippy/clippy_lints/src/overflow_check_conditional.rs @@ -36,8 +36,8 @@ impl<'tcx> LateLintPass<'tcx> for OverflowCheckConditional { if let ExprKind::Path(QPath::Resolved(_, ref path2)) = ident2.kind; if let ExprKind::Path(QPath::Resolved(_, ref path3)) = second.kind; if eq(&path1.segments[0], &path3.segments[0]) || eq(&path2.segments[0], &path3.segments[0]); - if cx.tables().expr_ty(ident1).is_integral(); - if cx.tables().expr_ty(ident2).is_integral(); + if cx.typeck_results().expr_ty(ident1).is_integral(); + if cx.typeck_results().expr_ty(ident2).is_integral(); then { if let BinOpKind::Lt = op.node { if let BinOpKind::Add = op2.node { @@ -61,8 +61,8 @@ impl<'tcx> LateLintPass<'tcx> for OverflowCheckConditional { if let ExprKind::Path(QPath::Resolved(_, ref path2)) = ident2.kind; if let ExprKind::Path(QPath::Resolved(_, ref path3)) = first.kind; if eq(&path1.segments[0], &path3.segments[0]) || eq(&path2.segments[0], &path3.segments[0]); - if cx.tables().expr_ty(ident1).is_integral(); - if cx.tables().expr_ty(ident2).is_integral(); + if cx.typeck_results().expr_ty(ident1).is_integral(); + if cx.typeck_results().expr_ty(ident2).is_integral(); then { if let BinOpKind::Gt = op.node { if let BinOpKind::Add = op2.node { diff --git a/src/tools/clippy/clippy_lints/src/path_buf_push_overwrite.rs b/src/tools/clippy/clippy_lints/src/path_buf_push_overwrite.rs index 48e609542793b..66a145a7f14b3 100644 --- a/src/tools/clippy/clippy_lints/src/path_buf_push_overwrite.rs +++ b/src/tools/clippy/clippy_lints/src/path_buf_push_overwrite.rs @@ -46,7 +46,7 @@ impl<'tcx> LateLintPass<'tcx> for PathBufPushOverwrite { if let ExprKind::MethodCall(ref path, _, ref args, _) = expr.kind; if path.ident.name == sym!(push); if args.len() == 2; - if match_type(cx, walk_ptrs_ty(cx.tables().expr_ty(&args[0])), &paths::PATH_BUF); + if match_type(cx, walk_ptrs_ty(cx.typeck_results().expr_ty(&args[0])), &paths::PATH_BUF); if let Some(get_index_arg) = args.get(1); if let ExprKind::Lit(ref lit) = get_index_arg.kind; if let LitKind::Str(ref path_lit, _) = lit.node; diff --git a/src/tools/clippy/clippy_lints/src/pattern_type_mismatch.rs b/src/tools/clippy/clippy_lints/src/pattern_type_mismatch.rs index a49dc87c0b47f..ef26fc667b225 100644 --- a/src/tools/clippy/clippy_lints/src/pattern_type_mismatch.rs +++ b/src/tools/clippy/clippy_lints/src/pattern_type_mismatch.rs @@ -87,7 +87,7 @@ impl<'tcx> LateLintPass<'tcx> for PatternTypeMismatch { fn check_stmt(&mut self, cx: &LateContext<'tcx>, stmt: &'tcx Stmt<'_>) { if let StmtKind::Local(ref local) = stmt.kind { if let Some(init) = &local.init { - if let Some(init_ty) = cx.tables().node_type_opt(init.hir_id) { + if let Some(init_ty) = cx.typeck_results().node_type_opt(init.hir_id) { let pat = &local.pat; if in_external_macro(cx.sess(), pat.span) { return; @@ -106,7 +106,7 @@ impl<'tcx> LateLintPass<'tcx> for PatternTypeMismatch { if let ExprKind::Match(ref expr, arms, source) = expr.kind { match source { MatchSource::Normal | MatchSource::IfLetDesugar { .. } | MatchSource::WhileLetDesugar => { - if let Some(expr_ty) = cx.tables().node_type_opt(expr.hir_id) { + if let Some(expr_ty) = cx.typeck_results().node_type_opt(expr.hir_id) { 'pattern_checks: for arm in arms { let pat = &arm.pat; if in_external_macro(cx.sess(), pat.span) { @@ -132,7 +132,7 @@ impl<'tcx> LateLintPass<'tcx> for PatternTypeMismatch { _: Span, hir_id: HirId, ) { - if let Some(fn_sig) = cx.tables().liberated_fn_sigs().get(hir_id) { + if let Some(fn_sig) = cx.typeck_results().liberated_fn_sigs().get(hir_id) { for (param, ty) in body.params.iter().zip(fn_sig.inputs().iter()) { apply_lint(cx, ¶m.pat, ty, DerefPossible::Impossible); } diff --git a/src/tools/clippy/clippy_lints/src/ptr_offset_with_cast.rs b/src/tools/clippy/clippy_lints/src/ptr_offset_with_cast.rs index 61e186a4b4653..0a2d1b5fbe6ac 100644 --- a/src/tools/clippy/clippy_lints/src/ptr_offset_with_cast.rs +++ b/src/tools/clippy/clippy_lints/src/ptr_offset_with_cast.rs @@ -105,12 +105,12 @@ fn expr_as_ptr_offset_call<'tcx>( // Is the type of the expression a usize? fn is_expr_ty_usize<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>) -> bool { - cx.tables().expr_ty(expr) == cx.tcx.types.usize + cx.typeck_results().expr_ty(expr) == cx.tcx.types.usize } // Is the type of the expression a raw pointer? fn is_expr_ty_raw_ptr<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>) -> bool { - cx.tables().expr_ty(expr).is_unsafe_ptr() + cx.typeck_results().expr_ty(expr).is_unsafe_ptr() } fn build_suggestion<'tcx>( diff --git a/src/tools/clippy/clippy_lints/src/question_mark.rs b/src/tools/clippy/clippy_lints/src/question_mark.rs index cc9c2f196079f..fb12c565afd86 100644 --- a/src/tools/clippy/clippy_lints/src/question_mark.rs +++ b/src/tools/clippy/clippy_lints/src/question_mark.rs @@ -135,13 +135,13 @@ impl QuestionMark { } fn moves_by_default(cx: &LateContext<'_>, expression: &Expr<'_>) -> bool { - let expr_ty = cx.tables().expr_ty(expression); + let expr_ty = cx.typeck_results().expr_ty(expression); !expr_ty.is_copy_modulo_regions(cx.tcx.at(expression.span), cx.param_env) } fn is_option(cx: &LateContext<'_>, expression: &Expr<'_>) -> bool { - let expr_ty = cx.tables().expr_ty(expression); + let expr_ty = cx.typeck_results().expr_ty(expression); is_type_diagnostic_item(cx, expr_ty, sym!(option_type)) } diff --git a/src/tools/clippy/clippy_lints/src/ranges.rs b/src/tools/clippy/clippy_lints/src/ranges.rs index dd608de5723e2..4c1f2e8e01a8c 100644 --- a/src/tools/clippy/clippy_lints/src/ranges.rs +++ b/src/tools/clippy/clippy_lints/src/ranges.rs @@ -280,10 +280,10 @@ fn check_reversed_empty_range(cx: &LateContext<'_>, expr: &Expr<'_>) { if_chain! { if let Some(higher::Range { start: Some(start), end: Some(end), limits }) = higher::range(cx, expr); - let ty = cx.tables().expr_ty(start); + let ty = cx.typeck_results().expr_ty(start); if let ty::Int(_) | ty::Uint(_) = ty.kind; - if let Some((start_idx, _)) = constant(cx, cx.tables(), start); - if let Some((end_idx, _)) = constant(cx, cx.tables(), end); + if let Some((start_idx, _)) = constant(cx, cx.typeck_results(), start); + if let Some((end_idx, _)) = constant(cx, cx.typeck_results(), end); if let Some(ordering) = Constant::partial_cmp(cx.tcx, ty, &start_idx, &end_idx); if is_empty_range(limits, ordering); then { diff --git a/src/tools/clippy/clippy_lints/src/regex.rs b/src/tools/clippy/clippy_lints/src/regex.rs index f204a0ffb2c7b..dfc158661cbf6 100644 --- a/src/tools/clippy/clippy_lints/src/regex.rs +++ b/src/tools/clippy/clippy_lints/src/regex.rs @@ -89,7 +89,7 @@ fn str_span(base: Span, c: regex_syntax::ast::Span, offset: u16) -> Span { } fn const_str<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) -> Option { - constant(cx, cx.tables(), e).and_then(|(c, _)| match c { + constant(cx, cx.typeck_results(), e).and_then(|(c, _)| match c { Constant::Str(s) => Some(s), _ => None, }) diff --git a/src/tools/clippy/clippy_lints/src/repeat_once.rs b/src/tools/clippy/clippy_lints/src/repeat_once.rs index a3af369e41e5a..77c206002ea79 100644 --- a/src/tools/clippy/clippy_lints/src/repeat_once.rs +++ b/src/tools/clippy/clippy_lints/src/repeat_once.rs @@ -41,10 +41,10 @@ impl<'tcx> LateLintPass<'tcx> for RepeatOnce { if_chain! { if let ExprKind::MethodCall(ref path, _, ref args, _) = expr.kind; if path.ident.name == sym!(repeat); - if let Some(Constant::Int(1)) = constant_context(cx, cx.tables()).expr(&args[1]); + if let Some(Constant::Int(1)) = constant_context(cx, cx.typeck_results()).expr(&args[1]); if !in_macro(args[0].span); then { - let ty = walk_ptrs_ty(cx.tables().expr_ty(&args[0])); + let ty = walk_ptrs_ty(cx.typeck_results().expr_ty(&args[0])); if ty.is_str() { span_lint_and_sugg( cx, diff --git a/src/tools/clippy/clippy_lints/src/shadow.rs b/src/tools/clippy/clippy_lints/src/shadow.rs index 194786c5c4145..901c0a65d7fef 100644 --- a/src/tools/clippy/clippy_lints/src/shadow.rs +++ b/src/tools/clippy/clippy_lints/src/shadow.rs @@ -164,7 +164,7 @@ fn check_local<'tcx>(cx: &LateContext<'tcx>, local: &'tcx Local<'_>, bindings: & } fn is_binding(cx: &LateContext<'_>, pat_id: HirId) -> bool { - let var_ty = cx.tables().node_type_opt(pat_id); + let var_ty = cx.typeck_results().node_type_opt(pat_id); var_ty.map_or(false, |var_ty| !matches!(var_ty.kind, ty::Adt(..))) } diff --git a/src/tools/clippy/clippy_lints/src/strings.rs b/src/tools/clippy/clippy_lints/src/strings.rs index 89aa6a4edd62d..bada6fa7c522f 100644 --- a/src/tools/clippy/clippy_lints/src/strings.rs +++ b/src/tools/clippy/clippy_lints/src/strings.rs @@ -134,7 +134,7 @@ impl<'tcx> LateLintPass<'tcx> for StringAdd { } fn is_string(cx: &LateContext<'_>, e: &Expr<'_>) -> bool { - is_type_diagnostic_item(cx, walk_ptrs_ty(cx.tables().expr_ty(e)), sym!(string_type)) + is_type_diagnostic_item(cx, walk_ptrs_ty(cx.typeck_results().expr_ty(e)), sym!(string_type)) } fn is_add(cx: &LateContext<'_>, src: &Expr<'_>, target: &Expr<'_>) -> bool { diff --git a/src/tools/clippy/clippy_lints/src/swap.rs b/src/tools/clippy/clippy_lints/src/swap.rs index eb7d35839206b..754f87e6b55e2 100644 --- a/src/tools/clippy/clippy_lints/src/swap.rs +++ b/src/tools/clippy/clippy_lints/src/swap.rs @@ -194,7 +194,7 @@ fn check_for_slice<'a>(cx: &LateContext<'_>, lhs1: &'a Expr<'_>, lhs2: &'a Expr< if let ExprKind::Index(ref lhs1, ref idx1) = lhs1.kind { if let ExprKind::Index(ref lhs2, ref idx2) = lhs2.kind { if SpanlessEq::new(cx).ignore_fn().eq_expr(lhs1, lhs2) { - let ty = walk_ptrs_ty(cx.tables().expr_ty(lhs1)); + let ty = walk_ptrs_ty(cx.typeck_results().expr_ty(lhs1)); if matches!(ty.kind, ty::Slice(_)) || matches!(ty.kind, ty::Array(_, _)) diff --git a/src/tools/clippy/clippy_lints/src/to_digit_is_some.rs b/src/tools/clippy/clippy_lints/src/to_digit_is_some.rs index 4157103a574e1..6750452941f28 100644 --- a/src/tools/clippy/clippy_lints/src/to_digit_is_some.rs +++ b/src/tools/clippy/clippy_lints/src/to_digit_is_some.rs @@ -43,7 +43,7 @@ impl<'tcx> LateLintPass<'tcx> for ToDigitIsSome { if_chain! { if let [char_arg, radix_arg] = &**to_digit_args; if to_digits_path.ident.name.as_str() == "to_digit"; - let char_arg_ty = cx.tables().expr_ty_adjusted(char_arg); + let char_arg_ty = cx.typeck_results().expr_ty_adjusted(char_arg); if char_arg_ty.kind == ty::Char; then { Some((true, char_arg, radix_arg)) diff --git a/src/tools/clippy/clippy_lints/src/transmute.rs b/src/tools/clippy/clippy_lints/src/transmute.rs index 5f76d5c46efba..d55eb1a0c9387 100644 --- a/src/tools/clippy/clippy_lints/src/transmute.rs +++ b/src/tools/clippy/clippy_lints/src/transmute.rs @@ -302,8 +302,8 @@ impl<'tcx> LateLintPass<'tcx> for Transmute { if let Some(def_id) = cx.qpath_res(qpath, path_expr.hir_id).opt_def_id(); if match_def_path(cx, def_id, &paths::TRANSMUTE); then { - let from_ty = cx.tables().expr_ty(&args[0]); - let to_ty = cx.tables().expr_ty(e); + let from_ty = cx.typeck_results().expr_ty(&args[0]); + let to_ty = cx.typeck_results().expr_ty(e); match (&from_ty.kind, &to_ty.kind) { _ if from_ty == to_ty => span_lint( diff --git a/src/tools/clippy/clippy_lints/src/transmuting_null.rs b/src/tools/clippy/clippy_lints/src/transmuting_null.rs index 2f03c6db42d99..fbf7f0b2517ac 100644 --- a/src/tools/clippy/clippy_lints/src/transmuting_null.rs +++ b/src/tools/clippy/clippy_lints/src/transmuting_null.rs @@ -44,7 +44,7 @@ impl<'tcx> LateLintPass<'tcx> for TransmutingNull { then { // Catching transmute over constants that resolve to `null`. - let mut const_eval_context = constant_context(cx, cx.tables()); + let mut const_eval_context = constant_context(cx, cx.typeck_results()); if_chain! { if let ExprKind::Path(ref _qpath) = args[0].kind; let x = const_eval_context.expr(&args[0]); diff --git a/src/tools/clippy/clippy_lints/src/try_err.rs b/src/tools/clippy/clippy_lints/src/try_err.rs index 208d248faa57d..d3b351f30ef7c 100644 --- a/src/tools/clippy/clippy_lints/src/try_err.rs +++ b/src/tools/clippy/clippy_lints/src/try_err.rs @@ -68,7 +68,7 @@ impl<'tcx> LateLintPass<'tcx> for TryErr { if let Some(return_type) = find_err_return_type(cx, &expr.kind); then { - let err_type = cx.tables().expr_ty(err_arg); + let err_type = cx.typeck_results().expr_ty(err_arg); let origin_snippet = if err_arg.span.from_expansion() { snippet_with_macro_callsite(cx, err_arg.span, "_") } else { @@ -114,7 +114,7 @@ fn find_err_return_type_arm<'tcx>(cx: &LateContext<'tcx>, arm: &'tcx Arm<'_>) -> if match_qpath(from_error_fn, &paths::TRY_FROM_ERROR); if let Some(from_error_arg) = from_error_args.get(0); then { - Some(cx.tables().expr_ty(from_error_arg)) + Some(cx.typeck_results().expr_ty(from_error_arg)) } else { None } diff --git a/src/tools/clippy/clippy_lints/src/types.rs b/src/tools/clippy/clippy_lints/src/types.rs index bca388ecdcc38..c3dea44752133 100644 --- a/src/tools/clippy/clippy_lints/src/types.rs +++ b/src/tools/clippy/clippy_lints/src/types.rs @@ -17,7 +17,7 @@ use rustc_hir::{ use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::hir::map::Map; use rustc_middle::lint::in_external_macro; -use rustc_middle::ty::{self, InferTy, Ty, TyCtxt, TyS, TypeckTables}; +use rustc_middle::ty::{self, InferTy, Ty, TyCtxt, TyS, TypeckResults}; use rustc_session::{declare_lint_pass, declare_tool_lint, impl_lint_pass}; use rustc_span::hygiene::{ExpnKind, MacroKind}; use rustc_span::source_map::Span; @@ -595,7 +595,7 @@ declare_lint_pass!(LetUnitValue => [LET_UNIT_VALUE]); impl<'tcx> LateLintPass<'tcx> for LetUnitValue { fn check_stmt(&mut self, cx: &LateContext<'tcx>, stmt: &'tcx Stmt<'_>) { if let StmtKind::Local(ref local) = stmt.kind { - if is_unit(cx.tables().pat_ty(&local.pat)) { + if is_unit(cx.typeck_results().pat_ty(&local.pat)) { if in_external_macro(cx.sess(), stmt.span) || local.pat.span.from_expansion() { return; } @@ -680,7 +680,7 @@ impl<'tcx> LateLintPass<'tcx> for UnitCmp { if let ExpnKind::Macro(MacroKind::Bang, symbol) = callee.kind { if let ExprKind::Binary(ref cmp, ref left, _) = expr.kind { let op = cmp.node; - if op.is_comparison() && is_unit(cx.tables().expr_ty(left)) { + if op.is_comparison() && is_unit(cx.typeck_results().expr_ty(left)) { let result = match &*symbol.as_str() { "assert_eq" | "debug_assert_eq" => "succeed", "assert_ne" | "debug_assert_ne" => "fail", @@ -704,7 +704,7 @@ impl<'tcx> LateLintPass<'tcx> for UnitCmp { } if let ExprKind::Binary(ref cmp, ref left, _) = expr.kind { let op = cmp.node; - if op.is_comparison() && is_unit(cx.tables().expr_ty(left)) { + if op.is_comparison() && is_unit(cx.typeck_results().expr_ty(left)) { let result = match op { BinOpKind::Eq | BinOpKind::Le | BinOpKind::Ge => "true", _ => "false", @@ -774,7 +774,7 @@ impl<'tcx> LateLintPass<'tcx> for UnitArg { let args_to_recover = args .iter() .filter(|arg| { - if is_unit(cx.tables().expr_ty(arg)) && !is_unit_literal(arg) { + if is_unit(cx.typeck_results().expr_ty(arg)) && !is_unit_literal(arg) { !matches!(&arg.kind, ExprKind::Match(.., MatchSource::TryDesugar)) } else { false @@ -1232,7 +1232,7 @@ fn check_loss_of_sign(cx: &LateContext<'_>, expr: &Expr<'_>, op: &Expr<'_>, cast } // don't lint for positive constants - let const_val = constant(cx, &cx.tables(), op); + let const_val = constant(cx, &cx.typeck_results(), op); if_chain! { if let Some((const_val, _)) = const_val; if let Constant::Int(n) = const_val; @@ -1398,7 +1398,7 @@ impl<'tcx> LateLintPass<'tcx> for Casts { return; } if let ExprKind::Cast(ref ex, _) = expr.kind { - let (cast_from, cast_to) = (cx.tables().expr_ty(ex), cx.tables().expr_ty(expr)); + let (cast_from, cast_to) = (cx.typeck_results().expr_ty(ex), cx.typeck_results().expr_ty(expr)); lint_fn_to_numeric_cast(cx, expr, ex, cast_from, cast_to); if let ExprKind::Lit(ref lit) = ex.kind { if_chain! { @@ -1786,7 +1786,7 @@ impl<'tcx> LateLintPass<'tcx> for CharLitAsU8 { if let ExprKind::Cast(e, _) = &expr.kind; if let ExprKind::Lit(l) = &e.kind; if let LitKind::Char(c) = l.node; - if ty::Uint(UintTy::U8) == cx.tables().expr_ty(expr).kind; + if ty::Uint(UintTy::U8) == cx.typeck_results().expr_ty(expr).kind; then { let mut applicability = Applicability::MachineApplicable; let snippet = snippet_with_applicability(cx, e.span, "'x'", &mut applicability); @@ -1862,8 +1862,8 @@ enum AbsurdComparisonResult { fn is_cast_between_fixed_and_target<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> bool { if let ExprKind::Cast(ref cast_exp, _) = expr.kind { - let precast_ty = cx.tables().expr_ty(cast_exp); - let cast_ty = cx.tables().expr_ty(expr); + let precast_ty = cx.typeck_results().expr_ty(cast_exp); + let cast_ty = cx.typeck_results().expr_ty(expr); return is_isize_or_usize(precast_ty) != is_isize_or_usize(cast_ty); } @@ -1883,7 +1883,7 @@ fn detect_absurd_comparison<'tcx>( // absurd comparison only makes sense on primitive types // primitive types don't implement comparison operators with each other - if cx.tables().expr_ty(lhs) != cx.tables().expr_ty(rhs) { + if cx.typeck_results().expr_ty(lhs) != cx.typeck_results().expr_ty(rhs) { return None; } @@ -1921,9 +1921,9 @@ fn detect_absurd_comparison<'tcx>( fn detect_extreme_expr<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Option> { use crate::types::ExtremeType::{Maximum, Minimum}; - let ty = cx.tables().expr_ty(expr); + let ty = cx.typeck_results().expr_ty(expr); - let cv = constant(cx, cx.tables(), expr)?.0; + let cv = constant(cx, cx.typeck_results(), expr)?.0; let which = match (&ty.kind, cv) { (&ty::Bool, Constant::Bool(false)) | (&ty::Uint(_), Constant::Int(0)) => Minimum, @@ -2053,8 +2053,8 @@ impl Ord for FullInt { fn numeric_cast_precast_bounds<'a>(cx: &LateContext<'_>, expr: &'a Expr<'_>) -> Option<(FullInt, FullInt)> { if let ExprKind::Cast(ref cast_exp, _) = expr.kind { - let pre_cast_ty = cx.tables().expr_ty(cast_exp); - let cast_ty = cx.tables().expr_ty(expr); + let pre_cast_ty = cx.typeck_results().expr_ty(cast_exp); + let cast_ty = cx.typeck_results().expr_ty(expr); // if it's a cast from i32 to u32 wrapping will invalidate all these checks if cx.layout_of(pre_cast_ty).ok().map(|l| l.size) == cx.layout_of(cast_ty).ok().map(|l| l.size) { return None; @@ -2084,9 +2084,9 @@ fn numeric_cast_precast_bounds<'a>(cx: &LateContext<'_>, expr: &'a Expr<'_>) -> } fn node_as_const_fullint<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Option { - let val = constant(cx, cx.tables(), expr)?.0; + let val = constant(cx, cx.typeck_results(), expr)?.0; if let Constant::Int(const_int) = val { - match cx.tables().expr_ty(expr).kind { + match cx.typeck_results().expr_ty(expr).kind { ty::Int(ity) => Some(FullInt::S(sext(cx.tcx, const_int, ity))), ty::Uint(_) => Some(FullInt::U(const_int)), _ => None, @@ -2472,7 +2472,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ImplicitHasherTypeVisitor<'a, 'tcx> { /// Looks for default-hasher-dependent constructors like `HashMap::new`. struct ImplicitHasherConstructorVisitor<'a, 'b, 'tcx> { cx: &'a LateContext<'tcx>, - maybe_typeck_tables: Option<&'tcx TypeckTables<'tcx>>, + maybe_typeck_results: Option<&'tcx TypeckResults<'tcx>>, target: &'b ImplicitHasherType<'tcx>, suggestions: BTreeMap, } @@ -2481,7 +2481,7 @@ impl<'a, 'b, 'tcx> ImplicitHasherConstructorVisitor<'a, 'b, 'tcx> { fn new(cx: &'a LateContext<'tcx>, target: &'b ImplicitHasherType<'tcx>) -> Self { Self { cx, - maybe_typeck_tables: cx.maybe_typeck_tables(), + maybe_typeck_results: cx.maybe_typeck_results(), target, suggestions: BTreeMap::new(), } @@ -2492,9 +2492,9 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for ImplicitHasherConstructorVisitor<'a, 'b, 't type Map = Map<'tcx>; fn visit_body(&mut self, body: &'tcx Body<'_>) { - let old_maybe_typeck_tables = self.maybe_typeck_tables.replace(self.cx.tcx.body_tables(body.id())); + let old_maybe_typeck_results = self.maybe_typeck_results.replace(self.cx.tcx.typeck_body(body.id())); walk_body(self, body); - self.maybe_typeck_tables = old_maybe_typeck_tables; + self.maybe_typeck_results = old_maybe_typeck_results; } fn visit_expr(&mut self, e: &'tcx Expr<'_>) { @@ -2503,7 +2503,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for ImplicitHasherConstructorVisitor<'a, 'b, 't if let ExprKind::Path(QPath::TypeRelative(ref ty, ref method)) = fun.kind; if let TyKind::Path(QPath::Resolved(None, ty_path)) = ty.kind; then { - if !TyS::same_type(self.target.ty(), self.maybe_typeck_tables.unwrap().expr_ty(e)) { + if !TyS::same_type(self.target.ty(), self.maybe_typeck_results.unwrap().expr_ty(e)) { return; } @@ -2589,7 +2589,7 @@ impl<'tcx> LateLintPass<'tcx> for RefToMut { if let TyKind::Ptr(MutTy { mutbl: Mutability::Mut, .. }) = t.kind; if let ExprKind::Cast(e, t) = &e.kind; if let TyKind::Ptr(MutTy { mutbl: Mutability::Not, .. }) = t.kind; - if let ty::Ref(..) = cx.tables().node_type(e.hir_id).kind; + if let ty::Ref(..) = cx.typeck_results().node_type(e.hir_id).kind; then { span_lint( cx, diff --git a/src/tools/clippy/clippy_lints/src/unnamed_address.rs b/src/tools/clippy/clippy_lints/src/unnamed_address.rs index 25d136e564d3e..28b393b9f11f0 100644 --- a/src/tools/clippy/clippy_lints/src/unnamed_address.rs +++ b/src/tools/clippy/clippy_lints/src/unnamed_address.rs @@ -65,14 +65,14 @@ impl LateLintPass<'_> for UnnamedAddress { } fn is_trait_ptr(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { - match cx.tables().expr_ty_adjusted(expr).kind { + match cx.typeck_results().expr_ty_adjusted(expr).kind { ty::RawPtr(ty::TypeAndMut { ty, .. }) => ty.is_trait(), _ => false, } } fn is_fn_def(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { - matches!(cx.tables().expr_ty(expr).kind, ty::FnDef(..)) + matches!(cx.typeck_results().expr_ty(expr).kind, ty::FnDef(..)) } if_chain! { @@ -98,7 +98,7 @@ impl LateLintPass<'_> for UnnamedAddress { if match_def_path(cx, def_id, &paths::PTR_EQ) || match_def_path(cx, def_id, &paths::RC_PTR_EQ) || match_def_path(cx, def_id, &paths::ARC_PTR_EQ); - let ty_param = cx.tables().node_substs(func.hir_id).type_at(0); + let ty_param = cx.typeck_results().node_substs(func.hir_id).type_at(0); if ty_param.is_trait(); then { span_lint_and_help( @@ -115,8 +115,8 @@ impl LateLintPass<'_> for UnnamedAddress { if_chain! { if let ExprKind::Binary(binop, ref left, ref right) = expr.kind; if is_comparison(binop.node); - if cx.tables().expr_ty_adjusted(left).is_fn_ptr() && - cx.tables().expr_ty_adjusted(right).is_fn_ptr(); + if cx.typeck_results().expr_ty_adjusted(left).is_fn_ptr() && + cx.typeck_results().expr_ty_adjusted(right).is_fn_ptr(); if is_fn_def(cx, left) || is_fn_def(cx, right); then { span_lint( diff --git a/src/tools/clippy/clippy_lints/src/unnecessary_sort_by.rs b/src/tools/clippy/clippy_lints/src/unnecessary_sort_by.rs index 91c1789a2ffb1..59993d25bb470 100644 --- a/src/tools/clippy/clippy_lints/src/unnecessary_sort_by.rs +++ b/src/tools/clippy/clippy_lints/src/unnecessary_sort_by.rs @@ -176,7 +176,7 @@ fn detect_lint(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option { if let name = name_ident.ident.name.to_ident_string(); if name == "sort_by" || name == "sort_unstable_by"; if let [vec, Expr { kind: ExprKind::Closure(_, _, closure_body_id, _, _), .. }] = args; - if utils::match_type(cx, &cx.tables().expr_ty(vec), &paths::VEC); + if utils::match_type(cx, &cx.typeck_results().expr_ty(vec), &paths::VEC); if let closure_body = cx.tcx.hir().body(*closure_body_id); if let &[ Param { pat: Pat { kind: PatKind::Binding(_, _, left_ident, _), .. }, ..}, diff --git a/src/tools/clippy/clippy_lints/src/unwrap.rs b/src/tools/clippy/clippy_lints/src/unwrap.rs index 56ff62eca033a..f2bbde28c2abc 100644 --- a/src/tools/clippy/clippy_lints/src/unwrap.rs +++ b/src/tools/clippy/clippy_lints/src/unwrap.rs @@ -114,7 +114,7 @@ fn collect_unwrap_info<'tcx>( if_chain! { if let ExprKind::MethodCall(method_name, _, args, _) = &expr.kind; if let ExprKind::Path(QPath::Resolved(None, path)) = &args[0].kind; - let ty = cx.tables().expr_ty(&args[0]); + let ty = cx.typeck_results().expr_ty(&args[0]); let name = method_name.ident.as_str(); if is_relevant_option_call(cx, ty, &name) || is_relevant_result_call(cx, ty, &name); then { diff --git a/src/tools/clippy/clippy_lints/src/useless_conversion.rs b/src/tools/clippy/clippy_lints/src/useless_conversion.rs index 69c0b092520d8..a48ad3185e9c2 100644 --- a/src/tools/clippy/clippy_lints/src/useless_conversion.rs +++ b/src/tools/clippy/clippy_lints/src/useless_conversion.rs @@ -63,8 +63,8 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion { ExprKind::MethodCall(ref name, .., ref args, _) => { if match_trait_method(cx, e, &paths::INTO) && &*name.ident.as_str() == "into" { - let a = cx.tables().expr_ty(e); - let b = cx.tables().expr_ty(&args[0]); + let a = cx.typeck_results().expr_ty(e); + let b = cx.typeck_results().expr_ty(&args[0]); if TyS::same_type(a, b) { let sugg = snippet_with_macro_callsite(cx, args[0].span, "").to_string(); span_lint_and_sugg( @@ -79,8 +79,8 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion { } } if match_trait_method(cx, e, &paths::INTO_ITERATOR) && &*name.ident.as_str() == "into_iter" { - let a = cx.tables().expr_ty(e); - let b = cx.tables().expr_ty(&args[0]); + let a = cx.typeck_results().expr_ty(e); + let b = cx.typeck_results().expr_ty(&args[0]); if TyS::same_type(a, b) { let sugg = snippet(cx, args[0].span, "").into_owned(); span_lint_and_sugg( @@ -96,8 +96,8 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion { } if match_trait_method(cx, e, &paths::TRY_INTO_TRAIT) && &*name.ident.as_str() == "try_into" { if_chain! { - let a = cx.tables().expr_ty(e); - let b = cx.tables().expr_ty(&args[0]); + let a = cx.typeck_results().expr_ty(e); + let b = cx.typeck_results().expr_ty(&args[0]); if is_type_diagnostic_item(cx, a, sym!(result_type)); if let ty::Adt(_, substs) = a.kind; if let Some(a_type) = substs.types().next(); @@ -122,8 +122,8 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion { if args.len() == 1; if let ExprKind::Path(ref qpath) = path.kind; if let Some(def_id) = cx.qpath_res(qpath, path.hir_id).opt_def_id(); - let a = cx.tables().expr_ty(e); - let b = cx.tables().expr_ty(&args[0]); + let a = cx.typeck_results().expr_ty(e); + let b = cx.typeck_results().expr_ty(&args[0]); then { if_chain! { diff --git a/src/tools/clippy/clippy_lints/src/utils/higher.rs b/src/tools/clippy/clippy_lints/src/utils/higher.rs index eb7ac2447e493..f81a132c7e7b4 100644 --- a/src/tools/clippy/clippy_lints/src/utils/higher.rs +++ b/src/tools/clippy/clippy_lints/src/utils/higher.rs @@ -56,7 +56,7 @@ pub fn range<'a, 'tcx>(cx: &LateContext<'tcx>, expr: &'a hir::Expr<'_>) -> Optio Some(expr) } - let def_path = match cx.tables().expr_ty(expr).kind { + let def_path = match cx.typeck_results().expr_ty(expr).kind { ty::Adt(def, _) => cx.tcx.def_path(def.did), _ => return None, }; diff --git a/src/tools/clippy/clippy_lints/src/utils/hir_utils.rs b/src/tools/clippy/clippy_lints/src/utils/hir_utils.rs index 34341594c1985..28fb6ed12a05a 100644 --- a/src/tools/clippy/clippy_lints/src/utils/hir_utils.rs +++ b/src/tools/clippy/clippy_lints/src/utils/hir_utils.rs @@ -9,7 +9,7 @@ use rustc_hir::{ }; use rustc_lint::LateContext; use rustc_middle::ich::StableHashingContextProvider; -use rustc_middle::ty::TypeckTables; +use rustc_middle::ty::TypeckResults; use rustc_span::Symbol; use std::hash::Hash; @@ -22,7 +22,7 @@ use std::hash::Hash; pub struct SpanlessEq<'a, 'tcx> { /// Context used to evaluate constant expressions. cx: &'a LateContext<'tcx>, - maybe_typeck_tables: Option<&'tcx TypeckTables<'tcx>>, + maybe_typeck_results: Option<&'tcx TypeckResults<'tcx>>, /// If is true, never consider as equal expressions containing function /// calls. ignore_fn: bool, @@ -32,7 +32,7 @@ impl<'a, 'tcx> SpanlessEq<'a, 'tcx> { pub fn new(cx: &'a LateContext<'tcx>) -> Self { Self { cx, - maybe_typeck_tables: cx.maybe_typeck_tables(), + maybe_typeck_results: cx.maybe_typeck_results(), ignore_fn: false, } } @@ -71,10 +71,10 @@ impl<'a, 'tcx> SpanlessEq<'a, 'tcx> { return false; } - if let Some(tables) = self.maybe_typeck_tables { + if let Some(typeck_results) = self.maybe_typeck_results { if let (Some(l), Some(r)) = ( - constant_simple(self.cx, tables, left), - constant_simple(self.cx, tables, right), + constant_simple(self.cx, typeck_results, left), + constant_simple(self.cx, typeck_results, right), ) { if l == r { return true; @@ -137,9 +137,9 @@ impl<'a, 'tcx> SpanlessEq<'a, 'tcx> { !self.ignore_fn && self.eq_path_segment(l_path, r_path) && self.eq_exprs(l_args, r_args) }, (&ExprKind::Repeat(ref le, ref ll_id), &ExprKind::Repeat(ref re, ref rl_id)) => { - let mut celcx = constant_context(self.cx, self.cx.tcx.body_tables(ll_id.body)); + let mut celcx = constant_context(self.cx, self.cx.tcx.typeck_body(ll_id.body)); let ll = celcx.expr(&self.cx.tcx.hir().body(ll_id.body).value); - let mut celcx = constant_context(self.cx, self.cx.tcx.body_tables(rl_id.body)); + let mut celcx = constant_context(self.cx, self.cx.tcx.typeck_body(rl_id.body)); let rl = celcx.expr(&self.cx.tcx.hir().body(rl_id.body).value); self.eq_expr(le, re) && ll == rl @@ -272,18 +272,18 @@ impl<'a, 'tcx> SpanlessEq<'a, 'tcx> { match (left, right) { (&TyKind::Slice(ref l_vec), &TyKind::Slice(ref r_vec)) => self.eq_ty(l_vec, r_vec), (&TyKind::Array(ref lt, ref ll_id), &TyKind::Array(ref rt, ref rl_id)) => { - let old_maybe_typeck_tables = self.maybe_typeck_tables; + let old_maybe_typeck_results = self.maybe_typeck_results; - let mut celcx = constant_context(self.cx, self.cx.tcx.body_tables(ll_id.body)); - self.maybe_typeck_tables = Some(self.cx.tcx.body_tables(ll_id.body)); + let mut celcx = constant_context(self.cx, self.cx.tcx.typeck_body(ll_id.body)); + self.maybe_typeck_results = Some(self.cx.tcx.typeck_body(ll_id.body)); let ll = celcx.expr(&self.cx.tcx.hir().body(ll_id.body).value); - let mut celcx = constant_context(self.cx, self.cx.tcx.body_tables(rl_id.body)); - self.maybe_typeck_tables = Some(self.cx.tcx.body_tables(rl_id.body)); + let mut celcx = constant_context(self.cx, self.cx.tcx.typeck_body(rl_id.body)); + self.maybe_typeck_results = Some(self.cx.tcx.typeck_body(rl_id.body)); let rl = celcx.expr(&self.cx.tcx.hir().body(rl_id.body).value); let eq_ty = self.eq_ty(lt, rt); - self.maybe_typeck_tables = old_maybe_typeck_tables; + self.maybe_typeck_results = old_maybe_typeck_results; eq_ty && ll == rl }, (&TyKind::Ptr(ref l_mut), &TyKind::Ptr(ref r_mut)) => { @@ -348,7 +348,7 @@ pub fn over(left: &[X], right: &[X], mut eq_fn: impl FnMut(&X, &X) -> bool) - pub struct SpanlessHash<'a, 'tcx> { /// Context used to evaluate constant expressions. cx: &'a LateContext<'tcx>, - maybe_typeck_tables: Option<&'tcx TypeckTables<'tcx>>, + maybe_typeck_results: Option<&'tcx TypeckResults<'tcx>>, s: StableHasher, } @@ -356,7 +356,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> { pub fn new(cx: &'a LateContext<'tcx>) -> Self { Self { cx, - maybe_typeck_tables: cx.maybe_typeck_tables(), + maybe_typeck_results: cx.maybe_typeck_results(), s: StableHasher::new(), } } @@ -386,8 +386,8 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> { #[allow(clippy::many_single_char_names, clippy::too_many_lines)] pub fn hash_expr(&mut self, e: &Expr<'_>) { let simple_const = self - .maybe_typeck_tables - .and_then(|tables| constant_simple(self.cx, tables, e)); + .maybe_typeck_results + .and_then(|typeck_results| constant_simple(self.cx, typeck_results, e)); // const hashing may result in the same hash as some unrelated node, so add a sort of // discriminant depending on which path we're choosing next @@ -458,7 +458,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> { CaptureBy::Ref => 1, } .hash(&mut self.s); - // closures inherit TypeckTables + // closures inherit TypeckResults self.hash_expr(&self.cx.tcx.hir().body(eid).value); }, ExprKind::Field(ref e, ref f) => { @@ -602,7 +602,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> { self.hash_name(path.ident.name); }, } - // self.maybe_typeck_tables.unwrap().qpath_res(p, id).hash(&mut self.s); + // self.maybe_typeck_results.unwrap().qpath_res(p, id).hash(&mut self.s); } pub fn hash_path(&mut self, p: &Path<'_>) { @@ -725,10 +725,10 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> { } pub fn hash_body(&mut self, body_id: BodyId) { - // swap out TypeckTables when hashing a body - let old_maybe_typeck_tables = self.maybe_typeck_tables.replace(self.cx.tcx.body_tables(body_id)); + // swap out TypeckResults when hashing a body + let old_maybe_typeck_results = self.maybe_typeck_results.replace(self.cx.tcx.typeck_body(body_id)); self.hash_expr(&self.cx.tcx.hir().body(body_id).value); - self.maybe_typeck_tables = old_maybe_typeck_tables; + self.maybe_typeck_results = old_maybe_typeck_results; } fn hash_generic_args(&mut self, arg_list: &[GenericArg<'_>]) { diff --git a/src/tools/clippy/clippy_lints/src/utils/inspector.rs b/src/tools/clippy/clippy_lints/src/utils/inspector.rs index fbd103323e313..d8fa1fa278e29 100644 --- a/src/tools/clippy/clippy_lints/src/utils/inspector.rs +++ b/src/tools/clippy/clippy_lints/src/utils/inspector.rs @@ -114,7 +114,7 @@ impl<'tcx> LateLintPass<'tcx> for DeepCodeInspector { } match stmt.kind { hir::StmtKind::Local(ref local) => { - println!("local variable of type {}", cx.tables().node_type(local.hir_id)); + println!("local variable of type {}", cx.typeck_results().node_type(local.hir_id)); println!("pattern:"); print_pat(cx, &local.pat, 0); if let Some(ref e) = local.init { @@ -144,8 +144,12 @@ fn has_attr(sess: &Session, attrs: &[Attribute]) -> bool { fn print_expr(cx: &LateContext<'_>, expr: &hir::Expr<'_>, indent: usize) { let ind = " ".repeat(indent); println!("{}+", ind); - println!("{}ty: {}", ind, cx.tables().expr_ty(expr)); - println!("{}adjustments: {:?}", ind, cx.tables().adjustments().get(expr.hir_id)); + println!("{}ty: {}", ind, cx.typeck_results().expr_ty(expr)); + println!( + "{}adjustments: {:?}", + ind, + cx.typeck_results().adjustments().get(expr.hir_id) + ); match expr.kind { hir::ExprKind::Box(ref e) => { println!("{}Box", ind); diff --git a/src/tools/clippy/clippy_lints/src/utils/internal_lints.rs b/src/tools/clippy/clippy_lints/src/utils/internal_lints.rs index 38cb764adde7b..6c2356799142d 100644 --- a/src/tools/clippy/clippy_lints/src/utils/internal_lints.rs +++ b/src/tools/clippy/clippy_lints/src/utils/internal_lints.rs @@ -405,7 +405,7 @@ impl<'tcx> LateLintPass<'tcx> for CompilerLintFunctions { if let ExprKind::MethodCall(ref path, _, ref args, _) = expr.kind; let fn_name = path.ident; if let Some(sugg) = self.map.get(&*fn_name.as_str()); - let ty = walk_ptrs_ty(cx.tables().expr_ty(&args[0])); + let ty = walk_ptrs_ty(cx.typeck_results().expr_ty(&args[0])); if match_type(cx, ty, &paths::EARLY_CONTEXT) || match_type(cx, ty, &paths::LATE_CONTEXT); then { @@ -438,7 +438,7 @@ impl<'tcx> LateLintPass<'tcx> for OuterExpnDataPass { let args = arg_lists[1]; if args.len() == 1; let self_arg = &args[0]; - let self_ty = walk_ptrs_ty(cx.tables().expr_ty(self_arg)); + let self_ty = walk_ptrs_ty(cx.typeck_results().expr_ty(self_arg)); if match_type(cx, self_ty, &paths::SYNTAX_CONTEXT); then { span_lint_and_sugg( diff --git a/src/tools/clippy/clippy_lints/src/utils/mod.rs b/src/tools/clippy/clippy_lints/src/utils/mod.rs index 4b7a1c2b537f3..4b163fba52890 100644 --- a/src/tools/clippy/clippy_lints/src/utils/mod.rs +++ b/src/tools/clippy/clippy_lints/src/utils/mod.rs @@ -144,7 +144,7 @@ pub fn is_type_diagnostic_item(cx: &LateContext<'_>, ty: Ty<'_>, diag_item: Symb /// Checks if the method call given in `expr` belongs to the given trait. pub fn match_trait_method(cx: &LateContext<'_>, expr: &Expr<'_>, path: &[&str]) -> bool { - 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(); let trt_id = cx.tcx.trait_of_item(def_id); trt_id.map_or(false, |trt_id| match_def_path(cx, trt_id, path)) } @@ -278,10 +278,8 @@ pub fn qpath_res(cx: &LateContext<'_>, qpath: &hir::QPath<'_>, id: hir::HirId) - match qpath { hir::QPath::Resolved(_, path) => path.res, hir::QPath::TypeRelative(..) => { - if cx.tcx.has_typeck_tables(id.owner.to_def_id()) { - cx.tcx - .typeck_tables_of(id.owner.to_def_id().expect_local()) - .qpath_res(qpath, id) + if cx.tcx.has_typeck_results(id.owner.to_def_id()) { + cx.tcx.typeck(id.owner.to_def_id().expect_local()).qpath_res(qpath, id) } else { Res::Err } @@ -772,7 +770,7 @@ pub fn is_integer_const(cx: &LateContext<'_>, e: &Expr<'_>, value: u128) -> bool let parent_item = map.get_parent_item(e.hir_id); if let Some((Constant::Int(v), _)) = map .maybe_body_owned_by(parent_item) - .and_then(|body_id| constant(cx, cx.tcx.body_tables(body_id), e)) + .and_then(|body_id| constant(cx, cx.tcx.typeck_body(body_id), e)) { value == v } else { @@ -799,7 +797,7 @@ pub fn is_integer_literal(expr: &Expr<'_>, value: u128) -> bool { /// See `rustc_middle::ty::adjustment::Adjustment` and `rustc_typeck::check::coercion` for more /// information on adjustments and coercions. pub fn is_adjusted(cx: &LateContext<'_>, e: &Expr<'_>) -> bool { - cx.tables().adjustments().get(e.hir_id).is_some() + cx.typeck_results().adjustments().get(e.hir_id).is_some() } /// Returns the pre-expansion span if is this comes from an expansion of the @@ -916,7 +914,7 @@ pub fn is_refutable(cx: &LateContext<'_>, pat: &Pat<'_>) -> bool { is_enum_variant(cx, qpath, pat.hir_id) || are_refutable(cx, pats.iter().map(|pat| &**pat)) }, PatKind::Slice(ref head, ref middle, ref tail) => { - match &cx.tables().node_type(pat.hir_id).kind { + match &cx.typeck_results().node_type(pat.hir_id).kind { ty::Slice(..) => { // [..] is the only irrefutable slice pattern. !head.is_empty() || middle.is_none() || !tail.is_empty() @@ -1299,7 +1297,7 @@ pub fn is_must_use_func_call(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { None } }, - ExprKind::MethodCall(_, _, _, _) => cx.tables().type_dependent_def_id(expr.hir_id), + ExprKind::MethodCall(_, _, _, _) => cx.typeck_results().type_dependent_def_id(expr.hir_id), _ => None, }; @@ -1359,14 +1357,14 @@ pub fn fn_has_unsatisfiable_preds(cx: &LateContext<'_>, did: DefId) -> bool { /// Returns the `DefId` of the callee if the given expression is a function or method call. pub fn fn_def_id(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option { match &expr.kind { - ExprKind::MethodCall(..) => cx.tables().type_dependent_def_id(expr.hir_id), + ExprKind::MethodCall(..) => cx.typeck_results().type_dependent_def_id(expr.hir_id), ExprKind::Call( Expr { kind: ExprKind::Path(qpath), .. }, .., - ) => cx.tables().qpath_res(qpath, expr.hir_id).opt_def_id(), + ) => cx.typeck_results().qpath_res(qpath, expr.hir_id).opt_def_id(), _ => None, } } diff --git a/src/tools/clippy/clippy_lints/src/utils/usage.rs b/src/tools/clippy/clippy_lints/src/utils/usage.rs index 53d3a241f58af..4a64b935ac9b4 100644 --- a/src/tools/clippy/clippy_lints/src/utils/usage.rs +++ b/src/tools/clippy/clippy_lints/src/utils/usage.rs @@ -18,7 +18,14 @@ pub fn mutated_variables<'tcx>(expr: &'tcx Expr<'_>, cx: &LateContext<'tcx>) -> }; let def_id = expr.hir_id.owner.to_def_id(); cx.tcx.infer_ctxt().enter(|infcx| { - ExprUseVisitor::new(&mut delegate, &infcx, def_id.expect_local(), cx.param_env, cx.tables()).walk_expr(expr); + ExprUseVisitor::new( + &mut delegate, + &infcx, + def_id.expect_local(), + cx.param_env, + cx.typeck_results(), + ) + .walk_expr(expr); }); if delegate.skip { diff --git a/src/tools/clippy/clippy_lints/src/vec.rs b/src/tools/clippy/clippy_lints/src/vec.rs index e1043c36e0a54..f2e76442a19ba 100644 --- a/src/tools/clippy/clippy_lints/src/vec.rs +++ b/src/tools/clippy/clippy_lints/src/vec.rs @@ -37,7 +37,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessVec { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { // search for `&vec![_]` expressions where the adjusted type is `&[_]` if_chain! { - if let ty::Ref(_, ty, _) = cx.tables().expr_ty_adjusted(expr).kind; + if let ty::Ref(_, ty, _) = cx.typeck_results().expr_ty_adjusted(expr).kind; if let ty::Slice(..) = ty.kind; if let ExprKind::AddrOf(BorrowKind::Ref, _, ref addressee) = expr.kind; if let Some(vec_args) = higher::vec_macro(cx, addressee); @@ -50,7 +50,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessVec { if_chain! { if let Some((_, arg, _)) = higher::for_loop(expr); if let Some(vec_args) = higher::vec_macro(cx, arg); - if is_copy(cx, vec_type(cx.tables().expr_ty_adjusted(arg))); + if is_copy(cx, vec_type(cx.typeck_results().expr_ty_adjusted(arg))); then { // report the error around the `vec!` not inside `:` let span = arg.span @@ -70,7 +70,7 @@ fn check_vec_macro<'tcx>(cx: &LateContext<'tcx>, vec_args: &higher::VecArgs<'tcx let mut applicability = Applicability::MachineApplicable; let snippet = match *vec_args { higher::VecArgs::Repeat(elem, len) => { - if constant(cx, cx.tables(), len).is_some() { + if constant(cx, cx.typeck_results(), len).is_some() { format!( "&[{}; {}]", snippet_with_applicability(cx, elem.span, "elem", &mut applicability), diff --git a/src/tools/clippy/clippy_lints/src/vec_resize_to_zero.rs b/src/tools/clippy/clippy_lints/src/vec_resize_to_zero.rs index cc5e21a7ca6fc..ad73a1ea1acdf 100644 --- a/src/tools/clippy/clippy_lints/src/vec_resize_to_zero.rs +++ b/src/tools/clippy/clippy_lints/src/vec_resize_to_zero.rs @@ -32,7 +32,7 @@ impl<'tcx> LateLintPass<'tcx> for VecResizeToZero { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { if_chain! { if let hir::ExprKind::MethodCall(path_segment, _, ref args, _) = expr.kind; - if let Some(method_def_id) = cx.tables().type_dependent_def_id(expr.hir_id); + if let Some(method_def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id); if match_def_path(cx, method_def_id, &paths::VEC_RESIZE) && args.len() == 3; if let ExprKind::Lit(Spanned { node: LitKind::Int(0, _), .. }) = args[1].kind; if let ExprKind::Lit(Spanned { node: LitKind::Int(..), .. }) = args[2].kind; diff --git a/src/tools/clippy/clippy_lints/src/verbose_file_reads.rs b/src/tools/clippy/clippy_lints/src/verbose_file_reads.rs index b06fe36da631b..32574d9d6c9a8 100644 --- a/src/tools/clippy/clippy_lints/src/verbose_file_reads.rs +++ b/src/tools/clippy/clippy_lints/src/verbose_file_reads.rs @@ -62,7 +62,7 @@ fn is_file_read_to_end<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> if let ExprKind::MethodCall(method_name, _, exprs, _) = expr.kind; if method_name.ident.as_str() == "read_to_end"; if let ExprKind::Path(QPath::Resolved(None, _)) = &exprs[0].kind; - let ty = cx.tables().expr_ty(&exprs[0]); + let ty = cx.typeck_results().expr_ty(&exprs[0]); if match_type(cx, ty, &paths::FILE); then { return true @@ -76,7 +76,7 @@ fn is_file_read_to_string<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) if let ExprKind::MethodCall(method_name, _, exprs, _) = expr.kind; if method_name.ident.as_str() == "read_to_string"; if let ExprKind::Path(QPath::Resolved(None, _)) = &exprs[0].kind; - let ty = cx.tables().expr_ty(&exprs[0]); + let ty = cx.typeck_results().expr_ty(&exprs[0]); if match_type(cx, ty, &paths::FILE); then { return true diff --git a/src/tools/clippy/clippy_lints/src/zero_div_zero.rs b/src/tools/clippy/clippy_lints/src/zero_div_zero.rs index 1e011ea9cba5e..4b81a27632d8d 100644 --- a/src/tools/clippy/clippy_lints/src/zero_div_zero.rs +++ b/src/tools/clippy/clippy_lints/src/zero_div_zero.rs @@ -36,8 +36,8 @@ impl<'tcx> LateLintPass<'tcx> for ZeroDiv { // TODO - constant_simple does not fold many operations involving floats. // That's probably fine for this lint - it's pretty unlikely that someone would // do something like 0.0/(2.0 - 2.0), but it would be nice to warn on that case too. - if let Some(lhs_value) = constant_simple(cx, cx.tables(), left); - if let Some(rhs_value) = constant_simple(cx, cx.tables(), right); + if let Some(lhs_value) = constant_simple(cx, cx.typeck_results(), left); + if let Some(rhs_value) = constant_simple(cx, cx.typeck_results(), right); if Constant::F32(0.0) == lhs_value || Constant::F64(0.0) == lhs_value; if Constant::F32(0.0) == rhs_value || Constant::F64(0.0) == rhs_value; then { diff --git a/src/tools/clippy/doc/common_tools_writing_lints.md b/src/tools/clippy/doc/common_tools_writing_lints.md index 412ff99314d99..9dd4c8a5f7a70 100644 --- a/src/tools/clippy/doc/common_tools_writing_lints.md +++ b/src/tools/clippy/doc/common_tools_writing_lints.md @@ -23,7 +23,7 @@ Sometimes you may want to retrieve the type `Ty` of an expression `Expr`, for ex - is it a primitive type? - does it implement a trait? -This operation is performed using the [`expr_ty()`][expr_ty] method from the [`TypeckTables`][TypeckTables] struct, +This operation is performed using the [`expr_ty()`][expr_ty] method from the [`TypeckResults`][TypeckResults] struct, that gives you access to the underlying structure [`TyS`][TyS]. Example of use: @@ -31,7 +31,7 @@ Example of use: impl LateLintPass<'_> for MyStructLint { fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) { // Get type of `expr` - let ty = cx.tables().expr_ty(expr); + let ty = cx.typeck_results().expr_ty(expr); // Match its kind to enter its type match ty.kind { ty::Adt(adt_def, _) if adt_def.is_struct() => println!("Our `expr` is a struct!"), @@ -41,14 +41,14 @@ impl LateLintPass<'_> for MyStructLint { } ``` -Similarly in [`TypeckTables`][TypeckTables] methods, you have the [`pat_ty()`][pat_ty] method +Similarly in [`TypeckResults`][TypeckResults] methods, you have the [`pat_ty()`][pat_ty] method to retrieve a type from a pattern. Two noticeable items here: - `cx` is the lint context [`LateContext`][LateContext]. The two most useful data structures in this context are `tcx` and `tables`, allowing us to jump to type definitions and other compilation stages such as HIR. -- `tables` is [`TypeckTables`][TypeckTables] and is created by type checking step, +- `tables` is [`TypeckResults`][TypeckResults] and is created by type checking step, it includes useful information such as types of expressions, ways to resolve methods and so on. # Checking if an expr is calling a specific method @@ -87,7 +87,7 @@ impl LateLintPass<'_> for MyStructLint { } // 2. Using type context `TyCtxt` - let ty = cx.tables().expr_ty(expr); + let ty = cx.typeck_results().expr_ty(expr); if cx.tcx.lang_items() // we are looking for the `DefId` of `Drop` trait in lang items .drop_trait() @@ -192,9 +192,9 @@ assert_eq!(differing_macro_contexts(x_is_some_span, x_unwrap_span), true); [TyS]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyS.html [TyKind]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/enum.TyKind.html -[TypeckTables]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TypeckTables.html -[expr_ty]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TypeckTables.html#method.expr_ty +[TypeckResults]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TypeckResults.html +[expr_ty]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TypeckResults.html#method.expr_ty [LateContext]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/struct.LateContext.html [TyCtxt]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html -[pat_ty]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TypeckTables.html#method.pat_ty +[pat_ty]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TypeckResults.html#method.pat_ty [paths]: ../clippy_lints/src/utils/paths.rs