/// 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))
}
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
}
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 {
/// 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
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()
ty::Tuple(ref substs) => substs.types().any(|ty| is_must_use_ty(cx, ty)),
ty::Opaque(ref def_id, _) => {
for (predicate, _) in cx.tcx.predicates_of(*def_id).predicates {
- if let ty::PredicateKind::Trait(ref poly_trait_predicate, _) = predicate.kind() {
- if must_use_attr(&cx.tcx.get_attrs(poly_trait_predicate.skip_binder().trait_ref.def_id)).is_some() {
+ if let ty::PredicateAtom::Trait(trait_predicate, _) = predicate.skip_binders() {
+ if must_use_attr(&cx.tcx.get_attrs(trait_predicate.trait_ref.def_id)).is_some() {
return true;
}
}
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,
};
.predicates
.iter()
.filter_map(|(p, _)| if p.is_global() { Some(*p) } else { None });
- !traits::normalize_and_test_predicates(
+ traits::impossible_predicates(
cx.tcx,
traits::elaborate_predicates(cx.tcx, predicates)
.map(|o| o.predicate)
/// 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<DefId> {
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,
}
}