mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-21 22:34:05 +00:00
Avoid lots of hir::HirId{,Map,Set}
qualifiers.
Because they're a bit redundant.
This commit is contained in:
parent
e93f754289
commit
4b27cc8b7a
@ -14,6 +14,7 @@ use rustc_ast::*;
|
||||
use rustc_data_structures::stack::ensure_sufficient_stack;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::HirId;
|
||||
use rustc_middle::span_bug;
|
||||
use rustc_session::errors::report_lit_error;
|
||||
use rustc_span::source_map::{respan, Spanned};
|
||||
@ -701,8 +702,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
pub(super) fn maybe_forward_track_caller(
|
||||
&mut self,
|
||||
span: Span,
|
||||
outer_hir_id: hir::HirId,
|
||||
inner_hir_id: hir::HirId,
|
||||
outer_hir_id: HirId,
|
||||
inner_hir_id: HirId,
|
||||
) {
|
||||
if self.tcx.features().async_fn_track_caller
|
||||
&& let Some(attrs) = self.attrs.get(&outer_hir_id.local_id)
|
||||
@ -1048,7 +1049,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
binder: &ClosureBinder,
|
||||
capture_clause: CaptureBy,
|
||||
closure_id: NodeId,
|
||||
closure_hir_id: hir::HirId,
|
||||
closure_hir_id: HirId,
|
||||
coroutine_kind: CoroutineKind,
|
||||
decl: &FnDecl,
|
||||
body: &Expr,
|
||||
@ -2036,7 +2037,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
&mut self,
|
||||
sp: Span,
|
||||
ident: Ident,
|
||||
binding: hir::HirId,
|
||||
binding: HirId,
|
||||
) -> &'hir hir::Expr<'hir> {
|
||||
self.arena.alloc(self.expr_ident_mut(sp, ident, binding))
|
||||
}
|
||||
@ -2045,7 +2046,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
&mut self,
|
||||
span: Span,
|
||||
ident: Ident,
|
||||
binding: hir::HirId,
|
||||
binding: HirId,
|
||||
) -> hir::Expr<'hir> {
|
||||
let hir_id = self.next_id();
|
||||
let res = Res::Local(binding);
|
||||
|
@ -56,7 +56,7 @@ use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res};
|
||||
use rustc_hir::def_id::{LocalDefId, LocalDefIdMap, CRATE_DEF_ID, LOCAL_CRATE};
|
||||
use rustc_hir::{
|
||||
ConstArg, GenericArg, ItemLocalMap, MissingLifetimeKind, ParamName, TraitCandidate,
|
||||
ConstArg, GenericArg, HirId, ItemLocalMap, MissingLifetimeKind, ParamName, TraitCandidate,
|
||||
};
|
||||
use rustc_index::{Idx, IndexSlice, IndexVec};
|
||||
use rustc_macros::extension;
|
||||
@ -107,7 +107,7 @@ struct LoweringContext<'a, 'hir> {
|
||||
|
||||
/// When inside an `async` context, this is the `HirId` of the
|
||||
/// `task_context` local bound to the resume argument of the coroutine.
|
||||
task_context: Option<hir::HirId>,
|
||||
task_context: Option<HirId>,
|
||||
|
||||
/// Used to get the current `fn`'s def span to point to when using `await`
|
||||
/// outside of an `async fn`.
|
||||
@ -661,18 +661,16 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
/// `HirIdValidator` later on, which makes sure that all `NodeId`s got mapped
|
||||
/// properly. Calling the method twice with the same `NodeId` is fine though.
|
||||
#[instrument(level = "debug", skip(self), ret)]
|
||||
fn lower_node_id(&mut self, ast_node_id: NodeId) -> hir::HirId {
|
||||
fn lower_node_id(&mut self, ast_node_id: NodeId) -> HirId {
|
||||
assert_ne!(ast_node_id, DUMMY_NODE_ID);
|
||||
|
||||
match self.node_id_to_local_id.entry(ast_node_id) {
|
||||
Entry::Occupied(o) => {
|
||||
hir::HirId { owner: self.current_hir_id_owner, local_id: *o.get() }
|
||||
}
|
||||
Entry::Occupied(o) => HirId { owner: self.current_hir_id_owner, local_id: *o.get() },
|
||||
Entry::Vacant(v) => {
|
||||
// Generate a new `HirId`.
|
||||
let owner = self.current_hir_id_owner;
|
||||
let local_id = self.item_local_id_counter;
|
||||
let hir_id = hir::HirId { owner, local_id };
|
||||
let hir_id = HirId { owner, local_id };
|
||||
|
||||
v.insert(local_id);
|
||||
self.item_local_id_counter.increment_by(1);
|
||||
@ -693,12 +691,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
|
||||
/// Generate a new `HirId` without a backing `NodeId`.
|
||||
#[instrument(level = "debug", skip(self), ret)]
|
||||
fn next_id(&mut self) -> hir::HirId {
|
||||
fn next_id(&mut self) -> HirId {
|
||||
let owner = self.current_hir_id_owner;
|
||||
let local_id = self.item_local_id_counter;
|
||||
assert_ne!(local_id, hir::ItemLocalId::ZERO);
|
||||
self.item_local_id_counter.increment_by(1);
|
||||
hir::HirId { owner, local_id }
|
||||
HirId { owner, local_id }
|
||||
}
|
||||
|
||||
#[instrument(level = "trace", skip(self))]
|
||||
@ -706,7 +704,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
let res: Result<Res, ()> = res.apply_id(|id| {
|
||||
let owner = self.current_hir_id_owner;
|
||||
let local_id = self.node_id_to_local_id.get(&id).copied().ok_or(())?;
|
||||
Ok(hir::HirId { owner, local_id })
|
||||
Ok(HirId { owner, local_id })
|
||||
});
|
||||
trace!(?res);
|
||||
|
||||
@ -889,7 +887,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
ret
|
||||
}
|
||||
|
||||
fn lower_attrs(&mut self, id: hir::HirId, attrs: &[Attribute]) -> Option<&'hir [Attribute]> {
|
||||
fn lower_attrs(&mut self, id: HirId, attrs: &[Attribute]) -> Option<&'hir [Attribute]> {
|
||||
if attrs.is_empty() {
|
||||
None
|
||||
} else {
|
||||
@ -921,7 +919,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
Attribute { kind, id: attr.id, style: attr.style, span: self.lower_span(attr.span) }
|
||||
}
|
||||
|
||||
fn alias_attrs(&mut self, id: hir::HirId, target_id: hir::HirId) {
|
||||
fn alias_attrs(&mut self, id: HirId, target_id: HirId) {
|
||||
debug_assert_eq!(id.owner, self.current_hir_id_owner);
|
||||
debug_assert_eq!(target_id.owner, self.current_hir_id_owner);
|
||||
if let Some(&a) = self.attrs.get(&target_id.local_id) {
|
||||
@ -2421,11 +2419,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
self.pat(span, hir::PatKind::Struct(qpath, fields, false))
|
||||
}
|
||||
|
||||
fn pat_ident(&mut self, span: Span, ident: Ident) -> (&'hir hir::Pat<'hir>, hir::HirId) {
|
||||
fn pat_ident(&mut self, span: Span, ident: Ident) -> (&'hir hir::Pat<'hir>, HirId) {
|
||||
self.pat_ident_binding_mode(span, ident, hir::BindingAnnotation::NONE)
|
||||
}
|
||||
|
||||
fn pat_ident_mut(&mut self, span: Span, ident: Ident) -> (hir::Pat<'hir>, hir::HirId) {
|
||||
fn pat_ident_mut(&mut self, span: Span, ident: Ident) -> (hir::Pat<'hir>, HirId) {
|
||||
self.pat_ident_binding_mode_mut(span, ident, hir::BindingAnnotation::NONE)
|
||||
}
|
||||
|
||||
@ -2434,7 +2432,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
span: Span,
|
||||
ident: Ident,
|
||||
bm: hir::BindingAnnotation,
|
||||
) -> (&'hir hir::Pat<'hir>, hir::HirId) {
|
||||
) -> (&'hir hir::Pat<'hir>, HirId) {
|
||||
let (pat, hir_id) = self.pat_ident_binding_mode_mut(span, ident, bm);
|
||||
(self.arena.alloc(pat), hir_id)
|
||||
}
|
||||
@ -2444,7 +2442,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
span: Span,
|
||||
ident: Ident,
|
||||
bm: hir::BindingAnnotation,
|
||||
) -> (hir::Pat<'hir>, hir::HirId) {
|
||||
) -> (hir::Pat<'hir>, HirId) {
|
||||
let hir_id = self.next_id();
|
||||
|
||||
(
|
||||
@ -2476,12 +2474,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
}
|
||||
}
|
||||
|
||||
fn ty_path(
|
||||
&mut self,
|
||||
mut hir_id: hir::HirId,
|
||||
span: Span,
|
||||
qpath: hir::QPath<'hir>,
|
||||
) -> hir::Ty<'hir> {
|
||||
fn ty_path(&mut self, mut hir_id: HirId, span: Span, qpath: hir::QPath<'hir>) -> hir::Ty<'hir> {
|
||||
let kind = match qpath {
|
||||
hir::QPath::Resolved(None, path) => {
|
||||
// Turn trait object paths into `TyKind::TraitObject` instead.
|
||||
|
@ -13,7 +13,7 @@ use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_hir::intravisit::{self, Visitor};
|
||||
use rustc_hir::{GenericArg, GenericParam, GenericParamKind, HirIdMap, LifetimeName, Node};
|
||||
use rustc_hir::{GenericArg, GenericParam, GenericParamKind, HirId, HirIdMap, LifetimeName, Node};
|
||||
use rustc_macros::extension;
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::hir::nested_filter;
|
||||
@ -107,7 +107,7 @@ enum Scope<'a> {
|
||||
/// queried later. However, if we enter an elision scope, we have to
|
||||
/// later append the elided bound vars to the list and need to know what
|
||||
/// to append to.
|
||||
hir_id: hir::HirId,
|
||||
hir_id: HirId,
|
||||
|
||||
s: ScopeRef<'a>,
|
||||
|
||||
@ -781,7 +781,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_path(&mut self, path: &hir::Path<'tcx>, hir_id: hir::HirId) {
|
||||
fn visit_path(&mut self, path: &hir::Path<'tcx>, hir_id: HirId) {
|
||||
for (i, segment) in path.segments.iter().enumerate() {
|
||||
let depth = path.segments.len() - i - 1;
|
||||
if let Some(args) = segment.args {
|
||||
@ -983,7 +983,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn record_late_bound_vars(&mut self, hir_id: hir::HirId, binder: Vec<ty::BoundVariableKind>) {
|
||||
fn record_late_bound_vars(&mut self, hir_id: HirId, binder: Vec<ty::BoundVariableKind>) {
|
||||
if let Some(old) = self.map.late_bound_vars.insert(hir_id, binder) {
|
||||
bug!(
|
||||
"overwrote bound vars for {hir_id:?}:\nold={old:?}\nnew={:?}",
|
||||
@ -1010,12 +1010,8 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
||||
/// already in scope (for a fn item, that will be 0, but for a method it might not be). Late
|
||||
/// bound lifetimes are resolved by name and associated with a binder ID (`binder_id`), so the
|
||||
/// ordering is not important there.
|
||||
fn visit_early_late<F>(
|
||||
&mut self,
|
||||
hir_id: hir::HirId,
|
||||
generics: &'tcx hir::Generics<'tcx>,
|
||||
walk: F,
|
||||
) where
|
||||
fn visit_early_late<F>(&mut self, hir_id: HirId, generics: &'tcx hir::Generics<'tcx>, walk: F)
|
||||
where
|
||||
F: for<'b, 'c> FnOnce(&'b mut BoundVarContext<'c, 'tcx>),
|
||||
{
|
||||
let mut named_late_bound_vars = 0;
|
||||
@ -1062,7 +1058,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
||||
self.with(scope, walk);
|
||||
}
|
||||
|
||||
fn visit_early<F>(&mut self, hir_id: hir::HirId, generics: &'tcx hir::Generics<'tcx>, walk: F)
|
||||
fn visit_early<F>(&mut self, hir_id: HirId, generics: &'tcx hir::Generics<'tcx>, walk: F)
|
||||
where
|
||||
F: for<'b, 'c> FnOnce(&'b mut BoundVarContext<'c, 'tcx>),
|
||||
{
|
||||
@ -1288,7 +1284,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
||||
);
|
||||
}
|
||||
|
||||
fn resolve_type_ref(&mut self, param_def_id: LocalDefId, hir_id: hir::HirId) {
|
||||
fn resolve_type_ref(&mut self, param_def_id: LocalDefId, hir_id: HirId) {
|
||||
// Walk up the scope chain, tracking the number of fn scopes
|
||||
// that we pass through, until we find a lifetime with the
|
||||
// given name or we run out of scopes.
|
||||
|
@ -35,7 +35,7 @@ use rustc_hir as hir;
|
||||
use rustc_hir::def::{CtorOf, DefKind, Namespace, Res};
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_hir::intravisit::{walk_generics, Visitor as _};
|
||||
use rustc_hir::{GenericArg, GenericArgs};
|
||||
use rustc_hir::{GenericArg, GenericArgs, HirId};
|
||||
use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
|
||||
use rustc_infer::traits::ObligationCause;
|
||||
use rustc_middle::middle::stability::AllowUnstable;
|
||||
@ -158,7 +158,7 @@ pub trait HirTyLowerer<'tcx> {
|
||||
fn probe_adt(&self, span: Span, ty: Ty<'tcx>) -> Option<ty::AdtDef<'tcx>>;
|
||||
|
||||
/// Record the lowered type of a HIR node in this context.
|
||||
fn record_ty(&self, hir_id: hir::HirId, ty: Ty<'tcx>, span: Span);
|
||||
fn record_ty(&self, hir_id: HirId, ty: Ty<'tcx>, span: Span);
|
||||
|
||||
/// The inference context of the lowering context if applicable.
|
||||
fn infcx(&self) -> Option<&InferCtxt<'tcx>>;
|
||||
@ -999,7 +999,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
||||
#[instrument(level = "debug", skip_all, ret)]
|
||||
pub fn lower_assoc_path(
|
||||
&self,
|
||||
hir_ref_id: hir::HirId,
|
||||
hir_ref_id: HirId,
|
||||
span: Span,
|
||||
qself_ty: Ty<'tcx>,
|
||||
qself: &'tcx hir::Ty<'tcx>,
|
||||
@ -1200,7 +1200,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
||||
segment: &hir::PathSegment<'tcx>,
|
||||
adt_did: DefId,
|
||||
self_ty: Ty<'tcx>,
|
||||
block: hir::HirId,
|
||||
block: HirId,
|
||||
span: Span,
|
||||
) -> Result<Option<(Ty<'tcx>, DefId)>, ErrorGuaranteed> {
|
||||
let tcx = self.tcx();
|
||||
@ -1349,13 +1349,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
||||
}
|
||||
}
|
||||
|
||||
fn probe_assoc_ty(
|
||||
&self,
|
||||
name: Ident,
|
||||
block: hir::HirId,
|
||||
span: Span,
|
||||
scope: DefId,
|
||||
) -> Option<DefId> {
|
||||
fn probe_assoc_ty(&self, name: Ident, block: HirId, span: Span, scope: DefId) -> Option<DefId> {
|
||||
let (item, def_scope) = self.probe_assoc_ty_unchecked(name, block, scope)?;
|
||||
self.check_assoc_ty(item, name, def_scope, block, span);
|
||||
Some(item)
|
||||
@ -1364,7 +1358,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
||||
fn probe_assoc_ty_unchecked(
|
||||
&self,
|
||||
name: Ident,
|
||||
block: hir::HirId,
|
||||
block: HirId,
|
||||
scope: DefId,
|
||||
) -> Option<(DefId, DefId)> {
|
||||
let tcx = self.tcx();
|
||||
@ -1381,14 +1375,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
||||
Some((item.def_id, def_scope))
|
||||
}
|
||||
|
||||
fn check_assoc_ty(
|
||||
&self,
|
||||
item: DefId,
|
||||
name: Ident,
|
||||
def_scope: DefId,
|
||||
block: hir::HirId,
|
||||
span: Span,
|
||||
) {
|
||||
fn check_assoc_ty(&self, item: DefId, name: Ident, def_scope: DefId, block: HirId, span: Span) {
|
||||
let tcx = self.tcx();
|
||||
let kind = DefKind::AssocTy;
|
||||
|
||||
@ -1714,7 +1701,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
||||
&self,
|
||||
opt_self_ty: Option<Ty<'tcx>>,
|
||||
path: &hir::Path<'tcx>,
|
||||
hir_id: hir::HirId,
|
||||
hir_id: HirId,
|
||||
permit_variants: bool,
|
||||
) -> Ty<'tcx> {
|
||||
debug!(?path.res, ?opt_self_ty, ?path.segments);
|
||||
@ -1887,7 +1874,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
||||
///
|
||||
/// Early-bound type parameters get lowered to [`ty::Param`]
|
||||
/// and late-bound ones to [`ty::Bound`].
|
||||
pub(crate) fn lower_ty_param(&self, hir_id: hir::HirId) -> Ty<'tcx> {
|
||||
pub(crate) fn lower_ty_param(&self, hir_id: HirId) -> Ty<'tcx> {
|
||||
let tcx = self.tcx();
|
||||
match tcx.named_bound_var(hir_id) {
|
||||
Some(rbv::ResolvedArg::LateBound(debruijn, index, def_id)) => {
|
||||
@ -1914,7 +1901,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
||||
///
|
||||
/// Early-bound const parameters get lowered to [`ty::ConstKind::Param`]
|
||||
/// and late-bound ones to [`ty::ConstKind::Bound`].
|
||||
pub(crate) fn lower_const_param(&self, hir_id: hir::HirId, param_ty: Ty<'tcx>) -> Const<'tcx> {
|
||||
pub(crate) fn lower_const_param(&self, hir_id: HirId, param_ty: Ty<'tcx>) -> Const<'tcx> {
|
||||
let tcx = self.tcx();
|
||||
match tcx.named_bound_var(hir_id) {
|
||||
Some(rbv::ResolvedArg::EarlyBound(def_id)) => {
|
||||
@ -2341,7 +2328,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
||||
#[instrument(level = "debug", skip(self, hir_id, unsafety, abi, decl, generics, hir_ty), ret)]
|
||||
pub fn lower_fn_ty(
|
||||
&self,
|
||||
hir_id: hir::HirId,
|
||||
hir_id: HirId,
|
||||
unsafety: hir::Unsafety,
|
||||
abi: abi::Abi,
|
||||
decl: &hir::FnDecl<'tcx>,
|
||||
@ -2469,7 +2456,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
||||
/// corresponds to the return type.
|
||||
fn suggest_trait_fn_ty_for_impl_fn_infer(
|
||||
&self,
|
||||
fn_hir_id: hir::HirId,
|
||||
fn_hir_id: HirId,
|
||||
arg_idx: Option<usize>,
|
||||
) -> Option<Ty<'tcx>> {
|
||||
let tcx = self.tcx();
|
||||
|
@ -9,9 +9,10 @@ use rustc_ast_pretty::pp::Breaks::{Consistent, Inconsistent};
|
||||
use rustc_ast_pretty::pp::{self, Breaks};
|
||||
use rustc_ast_pretty::pprust::{Comments, PrintState};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::LifetimeParamKind;
|
||||
use rustc_hir::{BindingAnnotation, ByRef, GenericArg, GenericParam, GenericParamKind, Node, Term};
|
||||
use rustc_hir::{GenericBound, PatKind, RangeEnd, TraitBoundModifier};
|
||||
use rustc_hir::{
|
||||
BindingAnnotation, ByRef, GenericArg, GenericBound, GenericParam, GenericParamKind, HirId,
|
||||
LifetimeParamKind, Node, PatKind, RangeEnd, Term, TraitBoundModifier,
|
||||
};
|
||||
use rustc_span::source_map::SourceMap;
|
||||
use rustc_span::symbol::{kw, Ident, Symbol};
|
||||
use rustc_span::FileName;
|
||||
@ -20,7 +21,7 @@ use rustc_target::spec::abi::Abi;
|
||||
use std::cell::Cell;
|
||||
use std::vec;
|
||||
|
||||
pub fn id_to_string(map: &dyn rustc_hir::intravisit::Map<'_>, hir_id: hir::HirId) -> String {
|
||||
pub fn id_to_string(map: &dyn rustc_hir::intravisit::Map<'_>, hir_id: HirId) -> String {
|
||||
to_string(&map, |s| s.print_node(map.hir_node(hir_id)))
|
||||
}
|
||||
|
||||
@ -28,7 +29,7 @@ pub enum AnnNode<'a> {
|
||||
Name(&'a Symbol),
|
||||
Block(&'a hir::Block<'a>),
|
||||
Item(&'a hir::Item<'a>),
|
||||
SubItem(hir::HirId),
|
||||
SubItem(HirId),
|
||||
Expr(&'a hir::Expr<'a>),
|
||||
Pat(&'a hir::Pat<'a>),
|
||||
Arm(&'a hir::Arm<'a>),
|
||||
@ -65,12 +66,12 @@ impl PpAnn for &dyn rustc_hir::intravisit::Map<'_> {
|
||||
pub struct State<'a> {
|
||||
pub s: pp::Printer,
|
||||
comments: Option<Comments<'a>>,
|
||||
attrs: &'a dyn Fn(hir::HirId) -> &'a [ast::Attribute],
|
||||
attrs: &'a dyn Fn(HirId) -> &'a [ast::Attribute],
|
||||
ann: &'a (dyn PpAnn + 'a),
|
||||
}
|
||||
|
||||
impl<'a> State<'a> {
|
||||
fn attrs(&self, id: hir::HirId) -> &'a [ast::Attribute] {
|
||||
fn attrs(&self, id: HirId) -> &'a [ast::Attribute] {
|
||||
(self.attrs)(id)
|
||||
}
|
||||
|
||||
@ -159,7 +160,7 @@ pub fn print_crate<'a>(
|
||||
krate: &hir::Mod<'_>,
|
||||
filename: FileName,
|
||||
input: String,
|
||||
attrs: &'a dyn Fn(hir::HirId) -> &'a [ast::Attribute],
|
||||
attrs: &'a dyn Fn(HirId) -> &'a [ast::Attribute],
|
||||
ann: &'a dyn PpAnn,
|
||||
) -> String {
|
||||
let mut s = State {
|
||||
|
@ -2851,7 +2851,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
span: Span,
|
||||
base_ty: Ty<'tcx>,
|
||||
mod_id: DefId,
|
||||
hir_id: hir::HirId,
|
||||
hir_id: HirId,
|
||||
) -> Vec<(Vec<&'tcx ty::FieldDef>, GenericArgsRef<'tcx>)> {
|
||||
debug!("get_field_candidates(span: {:?}, base_t: {:?}", span, base_ty);
|
||||
|
||||
|
@ -13,7 +13,7 @@ use rustc_data_structures::fx::FxIndexMap;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::Res;
|
||||
use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_hir::PatKind;
|
||||
use rustc_hir::{HirId, PatKind};
|
||||
use rustc_infer::infer::InferCtxt;
|
||||
use rustc_middle::hir::place::ProjectionKind;
|
||||
use rustc_middle::mir::FakeReadCause;
|
||||
@ -39,20 +39,20 @@ pub trait Delegate<'tcx> {
|
||||
/// diagnostics. Around pattern matching such as `let pat = expr`, the diagnostic
|
||||
/// id will be the id of the expression `expr` but the place itself will have
|
||||
/// the id of the binding in the pattern `pat`.
|
||||
fn consume(&mut self, place_with_id: &PlaceWithHirId<'tcx>, diag_expr_id: hir::HirId);
|
||||
fn consume(&mut self, place_with_id: &PlaceWithHirId<'tcx>, diag_expr_id: HirId);
|
||||
|
||||
/// The value found at `place` is being borrowed with kind `bk`.
|
||||
/// `diag_expr_id` is the id used for diagnostics (see `consume` for more details).
|
||||
fn borrow(
|
||||
&mut self,
|
||||
place_with_id: &PlaceWithHirId<'tcx>,
|
||||
diag_expr_id: hir::HirId,
|
||||
diag_expr_id: HirId,
|
||||
bk: ty::BorrowKind,
|
||||
);
|
||||
|
||||
/// The value found at `place` is being copied.
|
||||
/// `diag_expr_id` is the id used for diagnostics (see `consume` for more details).
|
||||
fn copy(&mut self, place_with_id: &PlaceWithHirId<'tcx>, diag_expr_id: hir::HirId) {
|
||||
fn copy(&mut self, place_with_id: &PlaceWithHirId<'tcx>, diag_expr_id: HirId) {
|
||||
// In most cases, copying data from `x` is equivalent to doing `*&x`, so by default
|
||||
// we treat a copy of `x` as a borrow of `x`.
|
||||
self.borrow(place_with_id, diag_expr_id, ty::BorrowKind::ImmBorrow)
|
||||
@ -60,12 +60,12 @@ pub trait Delegate<'tcx> {
|
||||
|
||||
/// The path at `assignee_place` is being assigned to.
|
||||
/// `diag_expr_id` is the id used for diagnostics (see `consume` for more details).
|
||||
fn mutate(&mut self, assignee_place: &PlaceWithHirId<'tcx>, diag_expr_id: hir::HirId);
|
||||
fn mutate(&mut self, assignee_place: &PlaceWithHirId<'tcx>, diag_expr_id: HirId);
|
||||
|
||||
/// The path at `binding_place` is a binding that is being initialized.
|
||||
///
|
||||
/// This covers cases such as `let x = 42;`
|
||||
fn bind(&mut self, binding_place: &PlaceWithHirId<'tcx>, diag_expr_id: hir::HirId) {
|
||||
fn bind(&mut self, binding_place: &PlaceWithHirId<'tcx>, diag_expr_id: HirId) {
|
||||
// Bindings can normally be treated as a regular assignment, so by default we
|
||||
// forward this to the mutate callback.
|
||||
self.mutate(binding_place, diag_expr_id)
|
||||
@ -76,7 +76,7 @@ pub trait Delegate<'tcx> {
|
||||
&mut self,
|
||||
place_with_id: &PlaceWithHirId<'tcx>,
|
||||
cause: FakeReadCause,
|
||||
diag_expr_id: hir::HirId,
|
||||
diag_expr_id: HirId,
|
||||
);
|
||||
}
|
||||
|
||||
@ -154,7 +154,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
||||
self.mc.tcx()
|
||||
}
|
||||
|
||||
fn delegate_consume(&mut self, place_with_id: &PlaceWithHirId<'tcx>, diag_expr_id: hir::HirId) {
|
||||
fn delegate_consume(&mut self, place_with_id: &PlaceWithHirId<'tcx>, diag_expr_id: HirId) {
|
||||
delegate_consume(&self.mc, self.delegate, place_with_id, diag_expr_id)
|
||||
}
|
||||
|
||||
@ -775,8 +775,8 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
||||
/// closure as the DefId.
|
||||
fn walk_captures(&mut self, closure_expr: &hir::Closure<'_>) {
|
||||
fn upvar_is_local_variable(
|
||||
upvars: Option<&FxIndexMap<hir::HirId, hir::Upvar>>,
|
||||
upvar_id: hir::HirId,
|
||||
upvars: Option<&FxIndexMap<HirId, hir::Upvar>>,
|
||||
upvar_id: HirId,
|
||||
body_owner_is_closure: bool,
|
||||
) -> bool {
|
||||
upvars.map(|upvars| !upvars.contains_key(&upvar_id)).unwrap_or(body_owner_is_closure)
|
||||
@ -902,7 +902,7 @@ fn delegate_consume<'a, 'tcx>(
|
||||
mc: &mc::MemCategorizationContext<'a, 'tcx>,
|
||||
delegate: &mut (dyn Delegate<'tcx> + 'a),
|
||||
place_with_id: &PlaceWithHirId<'tcx>,
|
||||
diag_expr_id: hir::HirId,
|
||||
diag_expr_id: HirId,
|
||||
) {
|
||||
debug!("delegate_consume(place_with_id={:?})", place_with_id);
|
||||
|
||||
|
@ -10,7 +10,7 @@ use rustc_hir as hir;
|
||||
use rustc_hir::def::{CtorOf, DefKind, Res};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::lang_items::LangItem;
|
||||
use rustc_hir::{ExprKind, GenericArg, Node, QPath};
|
||||
use rustc_hir::{ExprKind, GenericArg, HirId, Node, QPath};
|
||||
use rustc_hir_analysis::hir_ty_lowering::errors::GenericsArgsErrExtend;
|
||||
use rustc_hir_analysis::hir_ty_lowering::generics::{
|
||||
check_generic_arg_count_for_call, lower_generic_args,
|
||||
@ -47,7 +47,7 @@ use std::slice;
|
||||
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
/// Produces warning on the given node, if the current point in the
|
||||
/// function is unreachable, and there hasn't been another warning.
|
||||
pub(in super::super) fn warn_if_unreachable(&self, id: hir::HirId, span: Span, kind: &str) {
|
||||
pub(in super::super) fn warn_if_unreachable(&self, id: HirId, span: Span, kind: &str) {
|
||||
// FIXME: Combine these two 'if' expressions into one once
|
||||
// let chains are implemented
|
||||
if let Diverges::Always { span: orig_span, custom_note } = self.diverges.get() {
|
||||
@ -130,14 +130,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
format!("{self:p}")
|
||||
}
|
||||
|
||||
pub fn local_ty(&self, span: Span, nid: hir::HirId) -> Ty<'tcx> {
|
||||
pub fn local_ty(&self, span: Span, nid: HirId) -> Ty<'tcx> {
|
||||
self.locals.borrow().get(&nid).cloned().unwrap_or_else(|| {
|
||||
span_bug!(span, "no type for local variable {}", self.tcx.hir().node_to_string(nid))
|
||||
})
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn write_ty(&self, id: hir::HirId, ty: Ty<'tcx>) {
|
||||
pub fn write_ty(&self, id: HirId, ty: Ty<'tcx>) {
|
||||
debug!("write_ty({:?}, {:?}) in fcx {}", id, self.resolve_vars_if_possible(ty), self.tag());
|
||||
let mut typeck = self.typeck_results.borrow_mut();
|
||||
let mut node_ty = typeck.node_types_mut();
|
||||
@ -161,7 +161,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
|
||||
pub fn write_field_index(
|
||||
&self,
|
||||
hir_id: hir::HirId,
|
||||
hir_id: HirId,
|
||||
index: FieldIdx,
|
||||
nested_fields: Vec<(Ty<'tcx>, FieldIdx)>,
|
||||
) {
|
||||
@ -174,7 +174,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
#[instrument(level = "debug", skip(self))]
|
||||
pub(in super::super) fn write_resolution(
|
||||
&self,
|
||||
hir_id: hir::HirId,
|
||||
hir_id: HirId,
|
||||
r: Result<(DefKind, DefId), ErrorGuaranteed>,
|
||||
) {
|
||||
self.typeck_results.borrow_mut().type_dependent_defs_mut().insert(hir_id, r);
|
||||
@ -183,7 +183,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
#[instrument(level = "debug", skip(self))]
|
||||
pub fn write_method_call_and_enforce_effects(
|
||||
&self,
|
||||
hir_id: hir::HirId,
|
||||
hir_id: HirId,
|
||||
span: Span,
|
||||
method: MethodCallee<'tcx>,
|
||||
) {
|
||||
@ -192,7 +192,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
self.write_args(hir_id, method.args);
|
||||
}
|
||||
|
||||
pub fn write_args(&self, node_id: hir::HirId, args: GenericArgsRef<'tcx>) {
|
||||
pub fn write_args(&self, node_id: HirId, args: GenericArgsRef<'tcx>) {
|
||||
if !args.is_empty() {
|
||||
debug!("write_args({:?}, {:?}) in fcx {}", node_id, args, self.tag());
|
||||
|
||||
@ -210,7 +210,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
#[instrument(skip(self), level = "debug")]
|
||||
pub fn write_user_type_annotation_from_args(
|
||||
&self,
|
||||
hir_id: hir::HirId,
|
||||
hir_id: HirId,
|
||||
def_id: DefId,
|
||||
args: GenericArgsRef<'tcx>,
|
||||
user_self_ty: Option<UserSelfTy<'tcx>>,
|
||||
@ -230,7 +230,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
#[instrument(skip(self), level = "debug")]
|
||||
pub fn write_user_type_annotation(
|
||||
&self,
|
||||
hir_id: hir::HirId,
|
||||
hir_id: HirId,
|
||||
canonical_user_type_annotation: CanonicalUserType<'tcx>,
|
||||
) {
|
||||
debug!("fcx {}", self.tag());
|
||||
@ -464,7 +464,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
t.has_free_regions() || t.has_aliases() || t.has_infer_types()
|
||||
}
|
||||
|
||||
pub fn node_ty(&self, id: hir::HirId) -> Ty<'tcx> {
|
||||
pub fn node_ty(&self, id: HirId) -> Ty<'tcx> {
|
||||
match self.typeck_results.borrow().node_types().get(id) {
|
||||
Some(&t) => t,
|
||||
None if let Some(e) = self.tainted_by_errors() => Ty::new_error(self.tcx, e),
|
||||
@ -478,7 +478,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn node_ty_opt(&self, id: hir::HirId) -> Option<Ty<'tcx>> {
|
||||
pub fn node_ty_opt(&self, id: HirId) -> Option<Ty<'tcx>> {
|
||||
match self.typeck_results.borrow().node_types().get(id) {
|
||||
Some(&t) => Some(t),
|
||||
None if let Some(e) = self.tainted_by_errors() => Some(Ty::new_error(self.tcx, e)),
|
||||
@ -742,7 +742,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
&self,
|
||||
lang_item: hir::LangItem,
|
||||
span: Span,
|
||||
hir_id: hir::HirId,
|
||||
hir_id: HirId,
|
||||
) -> (Res, Ty<'tcx>) {
|
||||
let def_id = self.tcx.require_lang_item(lang_item, Some(span));
|
||||
let def_kind = self.tcx.def_kind(def_id);
|
||||
@ -790,7 +790,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
pub fn resolve_ty_and_res_fully_qualified_call(
|
||||
&self,
|
||||
qpath: &'tcx QPath<'tcx>,
|
||||
hir_id: hir::HirId,
|
||||
hir_id: HirId,
|
||||
span: Span,
|
||||
args: Option<&'tcx [hir::Expr<'tcx>]>,
|
||||
) -> (Res, Option<LoweredTy<'tcx>>, &'tcx [hir::PathSegment<'tcx>]) {
|
||||
@ -984,7 +984,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
/// suggestion can be made, `None` otherwise.
|
||||
pub fn get_fn_decl(
|
||||
&self,
|
||||
blk_id: hir::HirId,
|
||||
blk_id: HirId,
|
||||
) -> Option<(LocalDefId, &'tcx hir::FnDecl<'tcx>, bool)> {
|
||||
// Get enclosing Fn, if it is a function or a trait method, unless there's a `loop` or
|
||||
// `while` before reaching it, as block tail returns are not available in them.
|
||||
@ -1080,7 +1080,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
res: Res,
|
||||
span: Span,
|
||||
path_span: Span,
|
||||
hir_id: hir::HirId,
|
||||
hir_id: HirId,
|
||||
) -> (Ty<'tcx>, Res) {
|
||||
let tcx = self.tcx;
|
||||
|
||||
@ -1450,7 +1450,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
span: Span,
|
||||
def_id: DefId,
|
||||
args: GenericArgsRef<'tcx>,
|
||||
hir_id: hir::HirId,
|
||||
hir_id: HirId,
|
||||
) {
|
||||
self.add_required_obligations_with_code(span, def_id, args, |idx, span| {
|
||||
if span.is_dummy() {
|
||||
@ -1541,7 +1541,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
|
||||
pub(in super::super) fn with_breakable_ctxt<F: FnOnce() -> R, R>(
|
||||
&self,
|
||||
id: hir::HirId,
|
||||
id: HirId,
|
||||
ctxt: BreakableCtxt<'tcx>,
|
||||
f: F,
|
||||
) -> (BreakableCtxt<'tcx>, R) {
|
||||
@ -1580,7 +1580,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
}
|
||||
|
||||
/// Returns `true` if an expression is contained inside the LHS of an assignment expression.
|
||||
pub(in super::super) fn expr_in_place(&self, mut expr_id: hir::HirId) -> bool {
|
||||
pub(in super::super) fn expr_in_place(&self, mut expr_id: HirId) -> bool {
|
||||
let mut contained_in_place = false;
|
||||
|
||||
while let hir::Node::Expr(parent_expr) = self.tcx.parent_hir_node(expr_id) {
|
||||
|
@ -24,7 +24,7 @@ use rustc_hir as hir;
|
||||
use rustc_hir::def::{CtorOf, DefKind, Res};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::intravisit::Visitor;
|
||||
use rustc_hir::{ExprKind, Node, QPath};
|
||||
use rustc_hir::{ExprKind, HirId, Node, QPath};
|
||||
use rustc_hir_analysis::check::intrinsicck::InlineAsmCtxt;
|
||||
use rustc_hir_analysis::check::potentially_plural_count;
|
||||
use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer;
|
||||
@ -1489,7 +1489,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
pub fn check_struct_path(
|
||||
&self,
|
||||
qpath: &QPath<'tcx>,
|
||||
hir_id: hir::HirId,
|
||||
hir_id: HirId,
|
||||
) -> Result<(&'tcx ty::VariantDef, Ty<'tcx>), ErrorGuaranteed> {
|
||||
let path_span = qpath.span();
|
||||
let (def, ty) = self.finish_resolving_struct_path(qpath, path_span, hir_id);
|
||||
@ -1554,7 +1554,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
|
||||
pub fn check_decl_initializer(
|
||||
&self,
|
||||
hir_id: hir::HirId,
|
||||
hir_id: HirId,
|
||||
pat: &'tcx hir::Pat<'tcx>,
|
||||
init: &'tcx hir::Expr<'tcx>,
|
||||
) -> Ty<'tcx> {
|
||||
@ -1879,7 +1879,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
ty
|
||||
}
|
||||
|
||||
fn parent_item_span(&self, id: hir::HirId) -> Option<Span> {
|
||||
fn parent_item_span(&self, id: HirId) -> Option<Span> {
|
||||
let node = self.tcx.hir_node_by_def_id(self.tcx.hir().get_parent_item(id).def_id);
|
||||
match node {
|
||||
Node::Item(&hir::Item { kind: hir::ItemKind::Fn(_, _, body_id), .. })
|
||||
@ -1897,7 +1897,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
/// Given a function block's `HirId`, returns its `FnDecl` if it exists, or `None` otherwise.
|
||||
pub(crate) fn get_parent_fn_decl(
|
||||
&self,
|
||||
blk_id: hir::HirId,
|
||||
blk_id: HirId,
|
||||
) -> Option<(&'tcx hir::FnDecl<'tcx>, Ident)> {
|
||||
let parent = self.tcx.hir_node_by_def_id(self.tcx.hir().get_parent_item(blk_id).def_id);
|
||||
self.get_node_fn_decl(parent).map(|(_, fn_decl, ident, _)| (fn_decl, ident))
|
||||
@ -1939,12 +1939,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
expr.span
|
||||
}
|
||||
|
||||
fn overwrite_local_ty_if_err(
|
||||
&self,
|
||||
hir_id: hir::HirId,
|
||||
pat: &'tcx hir::Pat<'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
) {
|
||||
fn overwrite_local_ty_if_err(&self, hir_id: HirId, pat: &'tcx hir::Pat<'tcx>, ty: Ty<'tcx>) {
|
||||
if let Err(guar) = ty.error_reported() {
|
||||
struct OverwritePatternsWithError {
|
||||
pat_hir_ids: Vec<hir::HirId>,
|
||||
@ -1977,7 +1972,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
&self,
|
||||
qpath: &QPath<'tcx>,
|
||||
path_span: Span,
|
||||
hir_id: hir::HirId,
|
||||
hir_id: HirId,
|
||||
) -> (Res, LoweredTy<'tcx>) {
|
||||
match *qpath {
|
||||
QPath::Resolved(ref maybe_qself, path) => {
|
||||
|
@ -71,7 +71,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
expr: &'tcx hir::Expr<'tcx>,
|
||||
expected: Ty<'tcx>,
|
||||
found: Ty<'tcx>,
|
||||
blk_id: hir::HirId,
|
||||
blk_id: HirId,
|
||||
) -> bool {
|
||||
let expr = expr.peel_drop_temps();
|
||||
let mut pointing_at_return_type = false;
|
||||
@ -1031,7 +1031,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
fn_decl: &hir::FnDecl<'tcx>,
|
||||
expected: Ty<'tcx>,
|
||||
found: Ty<'tcx>,
|
||||
id: hir::HirId,
|
||||
id: HirId,
|
||||
fn_id: LocalDefId,
|
||||
) {
|
||||
if !expected.is_unit() {
|
||||
@ -1600,12 +1600,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn is_loop(&self, id: hir::HirId) -> bool {
|
||||
fn is_loop(&self, id: HirId) -> bool {
|
||||
let node = self.tcx.hir_node(id);
|
||||
matches!(node, Node::Expr(Expr { kind: ExprKind::Loop(..), .. }))
|
||||
}
|
||||
|
||||
fn is_local_statement(&self, id: hir::HirId) -> bool {
|
||||
fn is_local_statement(&self, id: HirId) -> bool {
|
||||
let node = self.tcx.hir_node(id);
|
||||
matches!(node, Node::Stmt(Stmt { kind: StmtKind::Let(..), .. }))
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::FnCtxt;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::intravisit::{self, Visitor};
|
||||
use rustc_hir::PatKind;
|
||||
use rustc_hir::{HirId, PatKind};
|
||||
use rustc_infer::infer::type_variable::TypeVariableOrigin;
|
||||
use rustc_middle::ty::Ty;
|
||||
use rustc_middle::ty::UserType;
|
||||
@ -33,7 +33,7 @@ impl<'a> DeclOrigin<'a> {
|
||||
///
|
||||
/// It must have a hir_id, as this is how we connect gather_locals to the check functions.
|
||||
pub(super) struct Declaration<'a> {
|
||||
pub hir_id: hir::HirId,
|
||||
pub hir_id: HirId,
|
||||
pub pat: &'a hir::Pat<'a>,
|
||||
pub ty: Option<&'a hir::Ty<'a>>,
|
||||
pub span: Span,
|
||||
@ -48,8 +48,8 @@ impl<'a> From<&'a hir::LetStmt<'a>> for Declaration<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<(&'a hir::LetExpr<'a>, hir::HirId)> for Declaration<'a> {
|
||||
fn from((let_expr, hir_id): (&'a hir::LetExpr<'a>, hir::HirId)) -> Self {
|
||||
impl<'a> From<(&'a hir::LetExpr<'a>, HirId)> for Declaration<'a> {
|
||||
fn from((let_expr, hir_id): (&'a hir::LetExpr<'a>, HirId)) -> Self {
|
||||
let hir::LetExpr { pat, ty, span, init, is_recovered: _ } = *let_expr;
|
||||
Declaration { hir_id, pat, ty, span, init: Some(init), origin: DeclOrigin::LetExpr }
|
||||
}
|
||||
@ -60,7 +60,7 @@ pub(super) struct GatherLocalsVisitor<'a, 'tcx> {
|
||||
// parameters are special cases of patterns, but we want to handle them as
|
||||
// *distinct* cases. so track when we are hitting a pattern *within* an fn
|
||||
// parameter.
|
||||
outermost_fn_param_pat: Option<(Span, hir::HirId)>,
|
||||
outermost_fn_param_pat: Option<(Span, HirId)>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> {
|
||||
@ -68,7 +68,7 @@ impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> {
|
||||
Self { fcx, outermost_fn_param_pat: None }
|
||||
}
|
||||
|
||||
fn assign(&mut self, span: Span, nid: hir::HirId, ty_opt: Option<Ty<'tcx>>) -> Ty<'tcx> {
|
||||
fn assign(&mut self, span: Span, nid: HirId, ty_opt: Option<Ty<'tcx>>) -> Ty<'tcx> {
|
||||
match ty_opt {
|
||||
None => {
|
||||
// Infer the variable's type.
|
||||
|
@ -57,7 +57,7 @@ use rustc_errors::{codes::*, struct_span_code_err, ErrorGuaranteed};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::intravisit::Visitor;
|
||||
use rustc_hir::{HirIdMap, Node};
|
||||
use rustc_hir::{HirId, HirIdMap, Node};
|
||||
use rustc_hir_analysis::check::check_abi;
|
||||
use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer;
|
||||
use rustc_infer::infer::type_variable::TypeVariableOrigin;
|
||||
@ -339,13 +339,13 @@ pub struct EnclosingBreakables<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> EnclosingBreakables<'tcx> {
|
||||
fn find_breakable(&mut self, target_id: hir::HirId) -> &mut BreakableCtxt<'tcx> {
|
||||
fn find_breakable(&mut self, target_id: HirId) -> &mut BreakableCtxt<'tcx> {
|
||||
self.opt_find_breakable(target_id).unwrap_or_else(|| {
|
||||
bug!("could not find enclosing breakable with id {}", target_id);
|
||||
})
|
||||
}
|
||||
|
||||
fn opt_find_breakable(&mut self, target_id: hir::HirId) -> Option<&mut BreakableCtxt<'tcx>> {
|
||||
fn opt_find_breakable(&mut self, target_id: HirId) -> Option<&mut BreakableCtxt<'tcx>> {
|
||||
match self.by_id.get(&target_id) {
|
||||
Some(ix) => Some(&mut self.stack[*ix]),
|
||||
None => None,
|
||||
|
@ -58,24 +58,24 @@ use rustc_hir as hir;
|
||||
use rustc_hir::def::{CtorOf, DefKind, Res};
|
||||
use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_hir::pat_util::EnumerateAndAdjustIterator;
|
||||
use rustc_hir::PatKind;
|
||||
use rustc_hir::{HirId, PatKind};
|
||||
use rustc_infer::infer::InferCtxt;
|
||||
use rustc_span::Span;
|
||||
use rustc_target::abi::{FieldIdx, VariantIdx, FIRST_VARIANT};
|
||||
use rustc_trait_selection::infer::InferCtxtExt;
|
||||
|
||||
pub(crate) trait HirNode {
|
||||
fn hir_id(&self) -> hir::HirId;
|
||||
fn hir_id(&self) -> HirId;
|
||||
}
|
||||
|
||||
impl HirNode for hir::Expr<'_> {
|
||||
fn hir_id(&self) -> hir::HirId {
|
||||
fn hir_id(&self) -> HirId {
|
||||
self.hir_id
|
||||
}
|
||||
}
|
||||
|
||||
impl HirNode for hir::Pat<'_> {
|
||||
fn hir_id(&self) -> hir::HirId {
|
||||
fn hir_id(&self) -> HirId {
|
||||
self.hir_id
|
||||
}
|
||||
}
|
||||
@ -86,7 +86,7 @@ pub(crate) struct MemCategorizationContext<'a, 'tcx> {
|
||||
infcx: &'a InferCtxt<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
body_owner: LocalDefId,
|
||||
upvars: Option<&'tcx FxIndexMap<hir::HirId, hir::Upvar>>,
|
||||
upvars: Option<&'tcx FxIndexMap<HirId, hir::Upvar>>,
|
||||
}
|
||||
|
||||
pub(crate) type McResult<T> = Result<T, ()>;
|
||||
@ -127,11 +127,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
||||
self.infcx.tainted_by_errors().is_some()
|
||||
}
|
||||
|
||||
fn resolve_type_vars_or_error(
|
||||
&self,
|
||||
id: hir::HirId,
|
||||
ty: Option<Ty<'tcx>>,
|
||||
) -> McResult<Ty<'tcx>> {
|
||||
fn resolve_type_vars_or_error(&self, id: HirId, ty: Option<Ty<'tcx>>) -> McResult<Ty<'tcx>> {
|
||||
match ty {
|
||||
Some(ty) => {
|
||||
let ty = self.resolve_vars_if_possible(ty);
|
||||
@ -153,7 +149,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn node_ty(&self, hir_id: hir::HirId) -> McResult<Ty<'tcx>> {
|
||||
pub(crate) fn node_ty(&self, hir_id: HirId) -> McResult<Ty<'tcx>> {
|
||||
self.resolve_type_vars_or_error(hir_id, self.typeck_results.node_type_opt(hir_id))
|
||||
}
|
||||
|
||||
@ -377,7 +373,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
||||
#[instrument(level = "debug", skip(self, span), ret)]
|
||||
pub(crate) fn cat_res(
|
||||
&self,
|
||||
hir_id: hir::HirId,
|
||||
hir_id: HirId,
|
||||
span: Span,
|
||||
expr_ty: Ty<'tcx>,
|
||||
res: Res,
|
||||
@ -416,7 +412,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
||||
/// environment and upvar reference as appropriate. Only regionck cares
|
||||
/// about these dereferences, so we let it compute them as needed.
|
||||
#[instrument(level = "debug", skip(self), ret)]
|
||||
fn cat_upvar(&self, hir_id: hir::HirId, var_id: hir::HirId) -> McResult<PlaceWithHirId<'tcx>> {
|
||||
fn cat_upvar(&self, hir_id: HirId, var_id: HirId) -> McResult<PlaceWithHirId<'tcx>> {
|
||||
let closure_expr_def_id = self.body_owner;
|
||||
|
||||
let upvar_id = ty::UpvarId {
|
||||
@ -429,7 +425,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
||||
}
|
||||
|
||||
#[instrument(level = "debug", skip(self), ret)]
|
||||
pub(crate) fn cat_rvalue(&self, hir_id: hir::HirId, expr_ty: Ty<'tcx>) -> PlaceWithHirId<'tcx> {
|
||||
pub(crate) fn cat_rvalue(&self, hir_id: HirId, expr_ty: Ty<'tcx>) -> PlaceWithHirId<'tcx> {
|
||||
PlaceWithHirId::new(hir_id, expr_ty, PlaceBase::Rvalue, Vec::new())
|
||||
}
|
||||
|
||||
@ -523,7 +519,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
||||
fn variant_index_for_adt(
|
||||
&self,
|
||||
qpath: &hir::QPath<'_>,
|
||||
pat_hir_id: hir::HirId,
|
||||
pat_hir_id: HirId,
|
||||
span: Span,
|
||||
) -> McResult<VariantIdx> {
|
||||
let res = self.typeck_results.qpath_res(qpath, pat_hir_id);
|
||||
@ -556,7 +552,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
||||
/// Here `pat_hir_id` is the HirId of the pattern itself.
|
||||
fn total_fields_in_adt_variant(
|
||||
&self,
|
||||
pat_hir_id: hir::HirId,
|
||||
pat_hir_id: HirId,
|
||||
variant_index: VariantIdx,
|
||||
span: Span,
|
||||
) -> McResult<usize> {
|
||||
@ -573,7 +569,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
||||
|
||||
/// Returns the total number of fields in a tuple used within a Tuple pattern.
|
||||
/// Here `pat_hir_id` is the HirId of the pattern itself.
|
||||
fn total_fields_in_tuple(&self, pat_hir_id: hir::HirId, span: Span) -> McResult<usize> {
|
||||
fn total_fields_in_tuple(&self, pat_hir_id: HirId, span: Span) -> McResult<usize> {
|
||||
let ty = self.typeck_results.node_type(pat_hir_id);
|
||||
match ty.kind() {
|
||||
ty::Tuple(args) => Ok(args.len()),
|
||||
|
@ -8,6 +8,7 @@ use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_hir::HirId;
|
||||
use rustc_hir_analysis::autoderef::{self, Autoderef};
|
||||
use rustc_infer::infer::canonical::OriginalQueryValues;
|
||||
use rustc_infer::infer::canonical::{Canonical, QueryResponse};
|
||||
@ -86,7 +87,7 @@ pub(crate) struct ProbeContext<'a, 'tcx> {
|
||||
Vec<(ty::Predicate<'tcx>, Option<ty::Predicate<'tcx>>, Option<ObligationCause<'tcx>>)>,
|
||||
>,
|
||||
|
||||
scope_expr_id: hir::HirId,
|
||||
scope_expr_id: HirId,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Deref for ProbeContext<'a, 'tcx> {
|
||||
@ -263,7 +264,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
mode: Mode,
|
||||
return_type: Ty<'tcx>,
|
||||
self_ty: Ty<'tcx>,
|
||||
scope_expr_id: hir::HirId,
|
||||
scope_expr_id: HirId,
|
||||
candidate_filter: impl Fn(&ty::AssocItem) -> bool,
|
||||
) -> Vec<ty::AssocItem> {
|
||||
let method_names = self
|
||||
@ -307,7 +308,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
return_type: Option<Ty<'tcx>>,
|
||||
is_suggestion: IsSuggestion,
|
||||
self_ty: Ty<'tcx>,
|
||||
scope_expr_id: hir::HirId,
|
||||
scope_expr_id: HirId,
|
||||
scope: ProbeScope,
|
||||
) -> PickResult<'tcx> {
|
||||
self.probe_op(
|
||||
@ -331,7 +332,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
return_type: Option<Ty<'tcx>>,
|
||||
is_suggestion: IsSuggestion,
|
||||
self_ty: Ty<'tcx>,
|
||||
scope_expr_id: hir::HirId,
|
||||
scope_expr_id: HirId,
|
||||
scope: ProbeScope,
|
||||
) -> Vec<Candidate<'tcx>> {
|
||||
self.probe_op(
|
||||
@ -362,7 +363,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
return_type: Option<Ty<'tcx>>,
|
||||
is_suggestion: IsSuggestion,
|
||||
self_ty: Ty<'tcx>,
|
||||
scope_expr_id: hir::HirId,
|
||||
scope_expr_id: HirId,
|
||||
scope: ProbeScope,
|
||||
op: OP,
|
||||
) -> Result<R, MethodError<'tcx>>
|
||||
@ -589,7 +590,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
||||
return_type: Option<Ty<'tcx>>,
|
||||
orig_steps_var_values: &'a OriginalQueryValues<'tcx>,
|
||||
steps: &'tcx [CandidateStep<'tcx>],
|
||||
scope_expr_id: hir::HirId,
|
||||
scope_expr_id: HirId,
|
||||
) -> ProbeContext<'a, 'tcx> {
|
||||
ProbeContext {
|
||||
fcx,
|
||||
@ -1381,7 +1382,7 @@ impl<'tcx> Pick<'tcx> {
|
||||
&self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
span: Span,
|
||||
scope_expr_id: hir::HirId,
|
||||
scope_expr_id: HirId,
|
||||
) {
|
||||
if self.unstable_candidates.is_empty() {
|
||||
return;
|
||||
|
@ -3,7 +3,7 @@ use super::callee::DeferredCallResolution;
|
||||
use rustc_data_structures::unord::{UnordMap, UnordSet};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_hir::HirIdMap;
|
||||
use rustc_hir::{HirId, HirIdMap};
|
||||
use rustc_infer::infer::{InferCtxt, InferOk, TyCtxtInferExt};
|
||||
use rustc_middle::ty::visit::TypeVisitableExt;
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
@ -52,9 +52,9 @@ pub(crate) struct TypeckRootCtxt<'tcx> {
|
||||
|
||||
pub(super) deferred_cast_checks: RefCell<Vec<super::cast::CastCheck<'tcx>>>,
|
||||
|
||||
pub(super) deferred_transmute_checks: RefCell<Vec<(Ty<'tcx>, Ty<'tcx>, hir::HirId)>>,
|
||||
pub(super) deferred_transmute_checks: RefCell<Vec<(Ty<'tcx>, Ty<'tcx>, HirId)>>,
|
||||
|
||||
pub(super) deferred_asm_checks: RefCell<Vec<(&'tcx hir::InlineAsm<'tcx>, hir::HirId)>>,
|
||||
pub(super) deferred_asm_checks: RefCell<Vec<(&'tcx hir::InlineAsm<'tcx>, HirId)>>,
|
||||
|
||||
pub(super) deferred_coroutine_interiors: RefCell<Vec<(LocalDefId, hir::BodyId, Ty<'tcx>)>>,
|
||||
|
||||
|
@ -38,6 +38,7 @@ use rustc_errors::{Applicability, MultiSpan};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_hir::intravisit::{self, Visitor};
|
||||
use rustc_hir::HirId;
|
||||
use rustc_infer::infer::UpvarRegion;
|
||||
use rustc_middle::hir::place::{Place, PlaceBase, PlaceWithHirId, Projection, ProjectionKind};
|
||||
use rustc_middle::mir::FakeReadCause;
|
||||
@ -88,7 +89,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
enum UpvarMigrationInfo {
|
||||
/// We previously captured all of `x`, but now we capture some sub-path.
|
||||
CapturingPrecise { source_expr: Option<hir::HirId>, var_name: String },
|
||||
CapturingPrecise { source_expr: Option<HirId>, var_name: String },
|
||||
CapturingNothing {
|
||||
// where the variable appears in the closure (but is not captured)
|
||||
use_span: Span,
|
||||
@ -131,7 +132,7 @@ struct MigrationLintNote {
|
||||
/// Intermediate format to store the hir id of the root variable and a HashSet containing
|
||||
/// information on why the root variable should be fully captured
|
||||
struct NeededMigration {
|
||||
var_hir_id: hir::HirId,
|
||||
var_hir_id: HirId,
|
||||
diagnostics_info: Vec<MigrationLintNote>,
|
||||
}
|
||||
|
||||
@ -163,7 +164,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
#[instrument(skip(self, body), level = "debug")]
|
||||
fn analyze_closure(
|
||||
&self,
|
||||
closure_hir_id: hir::HirId,
|
||||
closure_hir_id: HirId,
|
||||
span: Span,
|
||||
body_id: hir::BodyId,
|
||||
body: &'tcx hir::Body<'tcx>,
|
||||
@ -1098,7 +1099,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
fn compute_2229_migrations_for_trait(
|
||||
&self,
|
||||
min_captures: Option<&ty::RootVariableMinCaptureList<'tcx>>,
|
||||
var_hir_id: hir::HirId,
|
||||
var_hir_id: HirId,
|
||||
closure_clause: hir::CaptureBy,
|
||||
) -> Option<FxIndexMap<UpvarMigrationInfo, UnordSet<&'static str>>> {
|
||||
let auto_traits_def_id = [
|
||||
@ -1210,7 +1211,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
closure_span: Span,
|
||||
min_captures: Option<&ty::RootVariableMinCaptureList<'tcx>>,
|
||||
closure_clause: hir::CaptureBy,
|
||||
var_hir_id: hir::HirId,
|
||||
var_hir_id: HirId,
|
||||
) -> Option<FxIndexSet<UpvarMigrationInfo>> {
|
||||
let ty = self.resolve_vars_if_possible(self.node_ty(var_hir_id));
|
||||
|
||||
@ -1650,7 +1651,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
fn place_for_root_variable(
|
||||
&self,
|
||||
closure_def_id: LocalDefId,
|
||||
var_hir_id: hir::HirId,
|
||||
var_hir_id: HirId,
|
||||
) -> Place<'tcx> {
|
||||
let upvar_id = ty::UpvarId::new(var_hir_id, closure_def_id);
|
||||
|
||||
@ -1881,7 +1882,7 @@ fn apply_capture_kind_on_capture_ty<'tcx>(
|
||||
}
|
||||
|
||||
/// Returns the Span of where the value with the provided HirId would be dropped
|
||||
fn drop_location_span(tcx: TyCtxt<'_>, hir_id: hir::HirId) -> Span {
|
||||
fn drop_location_span(tcx: TyCtxt<'_>, hir_id: HirId) -> Span {
|
||||
let owner_id = tcx.hir().get_enclosing_scope(hir_id).unwrap();
|
||||
|
||||
let owner_node = tcx.hir_node(owner_id);
|
||||
@ -1933,7 +1934,7 @@ struct InferBorrowKind<'tcx> {
|
||||
/// Place { V1, [ProjectionKind::Field(Index=1, Variant=0)] } : CaptureKind { E2, MutableBorrow }
|
||||
/// ```
|
||||
capture_information: InferredCaptureInformation<'tcx>,
|
||||
fake_reads: Vec<(Place<'tcx>, FakeReadCause, hir::HirId)>,
|
||||
fake_reads: Vec<(Place<'tcx>, FakeReadCause, HirId)>,
|
||||
}
|
||||
|
||||
impl<'tcx> euv::Delegate<'tcx> for InferBorrowKind<'tcx> {
|
||||
@ -1941,7 +1942,7 @@ impl<'tcx> euv::Delegate<'tcx> for InferBorrowKind<'tcx> {
|
||||
&mut self,
|
||||
place: &PlaceWithHirId<'tcx>,
|
||||
cause: FakeReadCause,
|
||||
diag_expr_id: hir::HirId,
|
||||
diag_expr_id: HirId,
|
||||
) {
|
||||
let PlaceBase::Upvar(_) = place.place.base else { return };
|
||||
|
||||
@ -1956,7 +1957,7 @@ impl<'tcx> euv::Delegate<'tcx> for InferBorrowKind<'tcx> {
|
||||
}
|
||||
|
||||
#[instrument(skip(self), level = "debug")]
|
||||
fn consume(&mut self, place_with_id: &PlaceWithHirId<'tcx>, diag_expr_id: hir::HirId) {
|
||||
fn consume(&mut self, place_with_id: &PlaceWithHirId<'tcx>, diag_expr_id: HirId) {
|
||||
let PlaceBase::Upvar(upvar_id) = place_with_id.place.base else { return };
|
||||
assert_eq!(self.closure_def_id, upvar_id.closure_expr_id);
|
||||
|
||||
@ -1974,7 +1975,7 @@ impl<'tcx> euv::Delegate<'tcx> for InferBorrowKind<'tcx> {
|
||||
fn borrow(
|
||||
&mut self,
|
||||
place_with_id: &PlaceWithHirId<'tcx>,
|
||||
diag_expr_id: hir::HirId,
|
||||
diag_expr_id: HirId,
|
||||
bk: ty::BorrowKind,
|
||||
) {
|
||||
let PlaceBase::Upvar(upvar_id) = place_with_id.place.base else { return };
|
||||
@ -2005,7 +2006,7 @@ impl<'tcx> euv::Delegate<'tcx> for InferBorrowKind<'tcx> {
|
||||
}
|
||||
|
||||
#[instrument(skip(self), level = "debug")]
|
||||
fn mutate(&mut self, assignee_place: &PlaceWithHirId<'tcx>, diag_expr_id: hir::HirId) {
|
||||
fn mutate(&mut self, assignee_place: &PlaceWithHirId<'tcx>, diag_expr_id: HirId) {
|
||||
self.borrow(assignee_place, diag_expr_id, ty::BorrowKind::MutBorrow);
|
||||
}
|
||||
}
|
||||
@ -2192,14 +2193,14 @@ fn construct_capture_info_string<'tcx>(
|
||||
format!("{place_str} -> {capture_kind_str}")
|
||||
}
|
||||
|
||||
fn var_name(tcx: TyCtxt<'_>, var_hir_id: hir::HirId) -> Symbol {
|
||||
fn var_name(tcx: TyCtxt<'_>, var_hir_id: HirId) -> Symbol {
|
||||
tcx.hir().name(var_hir_id)
|
||||
}
|
||||
|
||||
#[instrument(level = "debug", skip(tcx))]
|
||||
fn should_do_rust_2021_incompatible_closure_captures_analysis(
|
||||
tcx: TyCtxt<'_>,
|
||||
closure_id: hir::HirId,
|
||||
closure_id: HirId,
|
||||
) -> bool {
|
||||
if tcx.sess.at_least_rust_2021() {
|
||||
return false;
|
||||
|
@ -7,6 +7,7 @@ use rustc_data_structures::unord::ExtendUnord;
|
||||
use rustc_errors::{ErrorGuaranteed, StashKey};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::intravisit::{self, Visitor};
|
||||
use rustc_hir::HirId;
|
||||
use rustc_infer::infer::error_reporting::TypeAnnotationNeeded::E0282;
|
||||
use rustc_middle::traits::ObligationCause;
|
||||
use rustc_middle::ty::adjustment::{Adjust, Adjustment, PointerCoercion};
|
||||
@ -134,7 +135,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
||||
self.fcx.tcx
|
||||
}
|
||||
|
||||
fn write_ty_to_typeck_results(&mut self, hir_id: hir::HirId, ty: Ty<'tcx>) {
|
||||
fn write_ty_to_typeck_results(&mut self, hir_id: HirId, ty: Ty<'tcx>) {
|
||||
debug!("write_ty_to_typeck_results({:?}, {:?})", hir_id, ty);
|
||||
assert!(
|
||||
!ty.has_infer() && !ty.has_placeholders() && !ty.has_free_regions(),
|
||||
@ -461,7 +462,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
||||
fcx_typeck_results.closure_kind_origins().items_in_stable_order();
|
||||
|
||||
for (local_id, origin) in fcx_closure_kind_origins {
|
||||
let hir_id = hir::HirId { owner: common_hir_owner, local_id };
|
||||
let hir_id = HirId { owner: common_hir_owner, local_id };
|
||||
let place_span = origin.0;
|
||||
let place = self.resolve(origin.1.clone(), &place_span);
|
||||
self.typeck_results.closure_kind_origins_mut().insert(hir_id, (place_span, place));
|
||||
@ -490,7 +491,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
||||
|
||||
let mut errors_buffer = Vec::new();
|
||||
for (local_id, c_ty) in sorted_user_provided_types {
|
||||
let hir_id = hir::HirId { owner: common_hir_owner, local_id };
|
||||
let hir_id = HirId { owner: common_hir_owner, local_id };
|
||||
|
||||
if let ty::UserType::TypeOf(_, user_args) = c_ty.value {
|
||||
// This is a unit-testing mechanism.
|
||||
@ -513,7 +514,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
||||
|
||||
self.typeck_results.user_provided_types_mut().extend(
|
||||
fcx_typeck_results.user_provided_types().items().map(|(local_id, c_ty)| {
|
||||
let hir_id = hir::HirId { owner: common_hir_owner, local_id };
|
||||
let hir_id = HirId { owner: common_hir_owner, local_id };
|
||||
|
||||
if cfg!(debug_assertions) && c_ty.has_infer() {
|
||||
span_bug!(
|
||||
@ -604,7 +605,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_field_id(&mut self, hir_id: hir::HirId) {
|
||||
fn visit_field_id(&mut self, hir_id: HirId) {
|
||||
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);
|
||||
@ -617,7 +618,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
||||
}
|
||||
|
||||
#[instrument(skip(self, span), level = "debug")]
|
||||
fn visit_node_id(&mut self, span: Span, hir_id: hir::HirId) {
|
||||
fn visit_node_id(&mut self, span: Span, hir_id: HirId) {
|
||||
// Export associated path extensions and method resolutions.
|
||||
if let Some(def) =
|
||||
self.fcx.typeck_results.borrow_mut().type_dependent_defs_mut().remove(hir_id)
|
||||
@ -644,7 +645,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
||||
}
|
||||
|
||||
#[instrument(skip(self, span), level = "debug")]
|
||||
fn visit_adjustments(&mut self, span: Span, hir_id: hir::HirId) {
|
||||
fn visit_adjustments(&mut self, span: Span, hir_id: HirId) {
|
||||
let adjustment = self.fcx.typeck_results.borrow_mut().adjustments_mut().remove(hir_id);
|
||||
match adjustment {
|
||||
None => {
|
||||
@ -660,7 +661,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
||||
}
|
||||
|
||||
#[instrument(skip(self, span), level = "debug")]
|
||||
fn visit_pat_adjustments(&mut self, span: Span, hir_id: hir::HirId) {
|
||||
fn visit_pat_adjustments(&mut self, span: Span, hir_id: HirId) {
|
||||
let adjustment = self.fcx.typeck_results.borrow_mut().pat_adjustments_mut().remove(hir_id);
|
||||
match adjustment {
|
||||
None => {
|
||||
@ -691,7 +692,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
||||
let fcx_liberated_fn_sigs = fcx_typeck_results.liberated_fn_sigs().items_in_stable_order();
|
||||
|
||||
for (local_id, &fn_sig) in fcx_liberated_fn_sigs {
|
||||
let hir_id = hir::HirId { owner: common_hir_owner, local_id };
|
||||
let hir_id = HirId { owner: common_hir_owner, local_id };
|
||||
let fn_sig = self.resolve(fn_sig, &hir_id);
|
||||
self.typeck_results.liberated_fn_sigs_mut().insert(hir_id, fn_sig);
|
||||
}
|
||||
@ -705,7 +706,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
||||
let fcx_fru_field_types = fcx_typeck_results.fru_field_types().items_in_stable_order();
|
||||
|
||||
for (local_id, ftys) in fcx_fru_field_types {
|
||||
let hir_id = hir::HirId { owner: common_hir_owner, local_id };
|
||||
let hir_id = HirId { owner: common_hir_owner, local_id };
|
||||
let ftys = self.resolve(ftys.clone(), &hir_id);
|
||||
self.typeck_results.fru_field_types_mut().insert(hir_id, ftys);
|
||||
}
|
||||
@ -719,7 +720,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
||||
for (local_id, &(container, ref indices)) in
|
||||
fcx_typeck_results.offset_of_data().items_in_stable_order()
|
||||
{
|
||||
let hir_id = hir::HirId { owner: common_hir_owner, local_id };
|
||||
let hir_id = HirId { owner: common_hir_owner, local_id };
|
||||
let container = self.resolve(container, &hir_id);
|
||||
self.typeck_results.offset_of_data_mut().insert(hir_id, (container, indices.clone()));
|
||||
}
|
||||
@ -754,7 +755,7 @@ impl Locatable for Span {
|
||||
}
|
||||
}
|
||||
|
||||
impl Locatable for hir::HirId {
|
||||
impl Locatable for HirId {
|
||||
fn to_span(&self, tcx: TyCtxt<'_>) -> Span {
|
||||
tcx.hir().span(*self)
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ use rustc_data_structures::sync::{join, Lrc};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{LocalDefId, LocalModDefId};
|
||||
use rustc_hir::intravisit as hir_visit;
|
||||
use rustc_hir::HirId;
|
||||
use rustc_middle::hir::nested_filter;
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use rustc_session::lint::LintPass;
|
||||
@ -53,7 +54,7 @@ impl<'tcx, T: LateLintPass<'tcx>> LateContextAndPass<'tcx, T> {
|
||||
/// Merge the lints specified by any lint attributes into the
|
||||
/// current lint context, call the provided function, then reset the
|
||||
/// lints in effect to their previous state.
|
||||
fn with_lint_attrs<F>(&mut self, id: hir::HirId, f: F)
|
||||
fn with_lint_attrs<F>(&mut self, id: HirId, f: F)
|
||||
where
|
||||
F: FnOnce(&mut Self),
|
||||
{
|
||||
@ -81,7 +82,7 @@ impl<'tcx, T: LateLintPass<'tcx>> LateContextAndPass<'tcx, T> {
|
||||
self.context.param_env = old_param_env;
|
||||
}
|
||||
|
||||
fn process_mod(&mut self, m: &'tcx hir::Mod<'tcx>, n: hir::HirId) {
|
||||
fn process_mod(&mut self, m: &'tcx hir::Mod<'tcx>, n: HirId) {
|
||||
lint_callback!(self, check_mod, m, n);
|
||||
hir_visit::walk_mod(self, m, n);
|
||||
}
|
||||
@ -231,7 +232,7 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
|
||||
hir_visit::walk_inf(self, inf);
|
||||
}
|
||||
|
||||
fn visit_mod(&mut self, m: &'tcx hir::Mod<'tcx>, _: Span, n: hir::HirId) {
|
||||
fn visit_mod(&mut self, m: &'tcx hir::Mod<'tcx>, _: Span, n: HirId) {
|
||||
if !self.context.only_module {
|
||||
self.process_mod(m, n);
|
||||
}
|
||||
@ -305,7 +306,7 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
|
||||
hir_visit::walk_lifetime(self, lt);
|
||||
}
|
||||
|
||||
fn visit_path(&mut self, p: &hir::Path<'tcx>, id: hir::HirId) {
|
||||
fn visit_path(&mut self, p: &hir::Path<'tcx>, id: HirId) {
|
||||
lint_callback!(self, check_path, p, id);
|
||||
hir_visit::walk_path(self, p);
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ use crate::ty::TyCtxt;
|
||||
use rustc_data_structures::fx::FxIndexMap;
|
||||
use rustc_data_structures::unord::UnordMap;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::{HirIdMap, Node};
|
||||
use rustc_hir::{HirId, HirIdMap, Node};
|
||||
use rustc_macros::HashStable;
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
|
||||
@ -164,10 +164,10 @@ impl Scope {
|
||||
self.id
|
||||
}
|
||||
|
||||
pub fn hir_id(&self, scope_tree: &ScopeTree) -> Option<hir::HirId> {
|
||||
pub fn hir_id(&self, scope_tree: &ScopeTree) -> Option<HirId> {
|
||||
scope_tree
|
||||
.root_body
|
||||
.map(|hir_id| hir::HirId { owner: hir_id.owner, local_id: self.item_local_id() })
|
||||
.map(|hir_id| HirId { owner: hir_id.owner, local_id: self.item_local_id() })
|
||||
}
|
||||
|
||||
/// Returns the span of this `Scope`. Note that in general the
|
||||
@ -207,7 +207,7 @@ pub type ScopeDepth = u32;
|
||||
#[derive(Default, Debug, HashStable)]
|
||||
pub struct ScopeTree {
|
||||
/// If not empty, this body is the root of this region hierarchy.
|
||||
pub root_body: Option<hir::HirId>,
|
||||
pub root_body: Option<HirId>,
|
||||
|
||||
/// Maps from a scope ID to the enclosing scope id;
|
||||
/// this is usually corresponding to the lexical nesting, though
|
||||
@ -341,11 +341,7 @@ impl ScopeTree {
|
||||
self.var_map.insert(var, lifetime);
|
||||
}
|
||||
|
||||
pub fn record_rvalue_candidate(
|
||||
&mut self,
|
||||
var: hir::HirId,
|
||||
candidate_type: RvalueCandidateType,
|
||||
) {
|
||||
pub fn record_rvalue_candidate(&mut self, var: HirId, candidate_type: RvalueCandidateType) {
|
||||
debug!("record_rvalue_candidate(var={var:?}, type={candidate_type:?})");
|
||||
match &candidate_type {
|
||||
RvalueCandidateType::Borrow { lifetime: Some(lifetime), .. }
|
||||
|
@ -1545,7 +1545,7 @@ pub struct SourceScopeData<'tcx> {
|
||||
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable)]
|
||||
pub struct SourceScopeLocalData {
|
||||
/// An `HirId` with lint levels equivalent to this scope's lint levels.
|
||||
pub lint_root: hir::HirId,
|
||||
pub lint_root: HirId,
|
||||
}
|
||||
|
||||
/// A collection of projections into user types.
|
||||
|
@ -12,7 +12,7 @@ use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
|
||||
use rustc_errors::{DiagArgValue, IntoDiagArg};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::{BindingAnnotation, ByRef, MatchSource, RangeEnd};
|
||||
use rustc_hir::{BindingAnnotation, ByRef, HirId, MatchSource, RangeEnd};
|
||||
use rustc_index::newtype_index;
|
||||
use rustc_index::IndexVec;
|
||||
use rustc_middle::middle::region;
|
||||
@ -115,13 +115,13 @@ pub struct Param<'tcx> {
|
||||
/// Whether this param is `self`, and how it is bound.
|
||||
pub self_kind: Option<hir::ImplicitSelfKind>,
|
||||
/// HirId for lints.
|
||||
pub hir_id: Option<hir::HirId>,
|
||||
pub hir_id: Option<HirId>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, HashStable)]
|
||||
pub enum LintLevel {
|
||||
Inherited,
|
||||
Explicit(hir::HirId),
|
||||
Explicit(HirId),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, HashStable)]
|
||||
@ -167,7 +167,7 @@ pub struct ClosureExpr<'tcx> {
|
||||
pub args: UpvarArgs<'tcx>,
|
||||
pub upvars: Box<[ExprId]>,
|
||||
pub movability: Option<hir::Movability>,
|
||||
pub fake_reads: Vec<(ExprId, FakeReadCause, hir::HirId)>,
|
||||
pub fake_reads: Vec<(ExprId, FakeReadCause, HirId)>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, HashStable)]
|
||||
@ -184,7 +184,7 @@ pub enum BlockSafety {
|
||||
/// A compiler-generated unsafe block
|
||||
BuiltinUnsafe,
|
||||
/// An `unsafe` block. The `HirId` is the ID of the block.
|
||||
ExplicitUnsafe(hir::HirId),
|
||||
ExplicitUnsafe(HirId),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, HashStable)]
|
||||
@ -233,7 +233,7 @@ pub enum StmtKind<'tcx> {
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Copy, PartialEq, Eq, Hash, HashStable, TyEncodable, TyDecodable)]
|
||||
pub struct LocalVarId(pub hir::HirId);
|
||||
pub struct LocalVarId(pub HirId);
|
||||
|
||||
/// A THIR expression.
|
||||
#[derive(Clone, Debug, HashStable)]
|
||||
@ -356,7 +356,7 @@ pub enum ExprKind<'tcx> {
|
||||
/// A `match` expression.
|
||||
Match {
|
||||
scrutinee: ExprId,
|
||||
scrutinee_hir_id: hir::HirId,
|
||||
scrutinee_hir_id: HirId,
|
||||
arms: Box<[ArmId]>,
|
||||
match_source: MatchSource,
|
||||
},
|
||||
|
@ -19,6 +19,7 @@ use rustc_data_structures::sync::Lrc;
|
||||
use rustc_errors::{Applicability, Diag, EmissionGuarantee};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::HirId;
|
||||
use rustc_span::def_id::{LocalDefId, CRATE_DEF_ID};
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
@ -262,10 +263,10 @@ pub enum ObligationCauseCode<'tcx> {
|
||||
/// expression that caused the obligation, and the `usize`
|
||||
/// indicates exactly which predicate it is in the list of
|
||||
/// instantiated predicates.
|
||||
ExprItemObligation(DefId, rustc_hir::HirId, usize),
|
||||
ExprItemObligation(DefId, HirId, usize),
|
||||
|
||||
/// Combines `ExprItemObligation` and `BindingObligation`.
|
||||
ExprBindingObligation(DefId, Span, rustc_hir::HirId, usize),
|
||||
ExprBindingObligation(DefId, Span, HirId, usize),
|
||||
|
||||
/// A type like `&'a T` is WF only if `T: 'a`.
|
||||
ReferenceOutlivesReferent(Ty<'tcx>),
|
||||
@ -287,9 +288,9 @@ pub enum ObligationCauseCode<'tcx> {
|
||||
/// `S { ... }` must be `Sized`.
|
||||
StructInitializerSized,
|
||||
/// Type of each variable must be `Sized`.
|
||||
VariableType(hir::HirId),
|
||||
VariableType(HirId),
|
||||
/// Argument type must be `Sized`.
|
||||
SizedArgumentType(Option<hir::HirId>),
|
||||
SizedArgumentType(Option<HirId>),
|
||||
/// Return type must be `Sized`.
|
||||
SizedReturnType,
|
||||
/// Return type of a call expression must be `Sized`.
|
||||
@ -335,9 +336,9 @@ pub enum ObligationCauseCode<'tcx> {
|
||||
|
||||
FunctionArgumentObligation {
|
||||
/// The node of the relevant argument in the function call.
|
||||
arg_hir_id: hir::HirId,
|
||||
arg_hir_id: HirId,
|
||||
/// The node of the function call.
|
||||
call_hir_id: hir::HirId,
|
||||
call_hir_id: HirId,
|
||||
/// The obligation introduced by this argument.
|
||||
parent_code: InternedObligationCauseCode<'tcx>,
|
||||
},
|
||||
@ -402,18 +403,18 @@ pub enum ObligationCauseCode<'tcx> {
|
||||
ReturnNoExpression,
|
||||
|
||||
/// `return` with an expression
|
||||
ReturnValue(hir::HirId),
|
||||
ReturnValue(HirId),
|
||||
|
||||
/// Opaque return type of this function
|
||||
OpaqueReturnType(Option<(Ty<'tcx>, Span)>),
|
||||
|
||||
/// Block implicit return
|
||||
BlockTailExpression(hir::HirId, hir::MatchSource),
|
||||
BlockTailExpression(HirId, hir::MatchSource),
|
||||
|
||||
/// #[feature(trivial_bounds)] is not enabled
|
||||
TrivialBound,
|
||||
|
||||
AwaitableExpr(hir::HirId),
|
||||
AwaitableExpr(HirId),
|
||||
|
||||
ForLoopIterator,
|
||||
|
||||
@ -431,8 +432,8 @@ pub enum ObligationCauseCode<'tcx> {
|
||||
MatchImpl(ObligationCause<'tcx>, DefId),
|
||||
|
||||
BinOp {
|
||||
lhs_hir_id: hir::HirId,
|
||||
rhs_hir_id: Option<hir::HirId>,
|
||||
lhs_hir_id: HirId,
|
||||
rhs_hir_id: Option<HirId>,
|
||||
rhs_span: Option<Span>,
|
||||
rhs_is_lit: bool,
|
||||
output_ty: Option<Ty<'tcx>>,
|
||||
@ -562,10 +563,10 @@ pub enum StatementAsExpression {
|
||||
#[derive(Clone, Debug, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)]
|
||||
#[derive(TypeVisitable, TypeFoldable)]
|
||||
pub struct MatchExpressionArmCause<'tcx> {
|
||||
pub arm_block_id: Option<hir::HirId>,
|
||||
pub arm_block_id: Option<HirId>,
|
||||
pub arm_ty: Ty<'tcx>,
|
||||
pub arm_span: Span,
|
||||
pub prior_arm_block_id: Option<hir::HirId>,
|
||||
pub prior_arm_block_id: Option<HirId>,
|
||||
pub prior_arm_ty: Ty<'tcx>,
|
||||
pub prior_arm_span: Span,
|
||||
pub scrut_span: Span,
|
||||
@ -578,8 +579,8 @@ pub struct MatchExpressionArmCause<'tcx> {
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
#[derive(TypeFoldable, TypeVisitable, HashStable, TyEncodable, TyDecodable)]
|
||||
pub struct IfExpressionCause<'tcx> {
|
||||
pub then_id: hir::HirId,
|
||||
pub else_id: hir::HirId,
|
||||
pub then_id: HirId,
|
||||
pub else_id: HirId,
|
||||
pub then_ty: Ty<'tcx>,
|
||||
pub else_ty: Ty<'tcx>,
|
||||
pub outer_span: Option<Span>,
|
||||
|
@ -10,6 +10,7 @@ use rustc_data_structures::captures::Captures;
|
||||
use rustc_data_structures::fx::FxIndexMap;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_hir::HirId;
|
||||
use rustc_span::def_id::LocalDefIdMap;
|
||||
use rustc_span::symbol::Ident;
|
||||
use rustc_span::{Span, Symbol};
|
||||
@ -25,7 +26,7 @@ pub const CAPTURE_STRUCT_LOCAL: mir::Local = mir::Local::from_u32(1);
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable)]
|
||||
#[derive(TypeFoldable, TypeVisitable)]
|
||||
pub struct UpvarPath {
|
||||
pub hir_id: hir::HirId,
|
||||
pub hir_id: HirId,
|
||||
}
|
||||
|
||||
/// Upvars do not get their own `NodeId`. Instead, we use the pair of
|
||||
@ -39,7 +40,7 @@ pub struct UpvarId {
|
||||
}
|
||||
|
||||
impl UpvarId {
|
||||
pub fn new(var_hir_id: hir::HirId, closure_def_id: LocalDefId) -> UpvarId {
|
||||
pub fn new(var_hir_id: HirId, closure_def_id: LocalDefId) -> UpvarId {
|
||||
UpvarId { var_path: UpvarPath { hir_id: var_hir_id }, closure_expr_id: closure_def_id }
|
||||
}
|
||||
}
|
||||
@ -68,7 +69,7 @@ pub type MinCaptureInformationMap<'tcx> = LocalDefIdMap<RootVariableMinCaptureLi
|
||||
///
|
||||
/// This provides a convenient and quick way of checking if a variable being used within
|
||||
/// a closure is a capture of a local variable.
|
||||
pub type RootVariableMinCaptureList<'tcx> = FxIndexMap<hir::HirId, MinCaptureList<'tcx>>;
|
||||
pub type RootVariableMinCaptureList<'tcx> = FxIndexMap<HirId, MinCaptureList<'tcx>>;
|
||||
|
||||
/// Part of `MinCaptureInformationMap`; List of `CapturePlace`s.
|
||||
pub type MinCaptureList<'tcx> = Vec<CapturedPlace<'tcx>>;
|
||||
@ -135,7 +136,7 @@ impl<'tcx> CapturedPlace<'tcx> {
|
||||
|
||||
/// Returns the hir-id of the root variable for the captured place.
|
||||
/// e.g., if `a.b.c` was captured, would return the hir-id for `a`.
|
||||
pub fn get_root_variable(&self) -> hir::HirId {
|
||||
pub fn get_root_variable(&self) -> HirId {
|
||||
match self.place.base {
|
||||
HirPlaceBase::Upvar(upvar_id) => upvar_id.var_path.hir_id,
|
||||
base => bug!("Expected upvar, found={:?}", base),
|
||||
@ -286,12 +287,12 @@ pub struct CaptureInfo {
|
||||
///
|
||||
/// In this example, if `capture_disjoint_fields` is **not** set, then x will be captured,
|
||||
/// but we won't see it being used during capture analysis, since it's essentially a discard.
|
||||
pub capture_kind_expr_id: Option<hir::HirId>,
|
||||
pub capture_kind_expr_id: Option<HirId>,
|
||||
/// Expr Id pointing to use that resulted the corresponding place being captured
|
||||
///
|
||||
/// See `capture_kind_expr_id` for example.
|
||||
///
|
||||
pub path_expr_id: Option<hir::HirId>,
|
||||
pub path_expr_id: Option<HirId>,
|
||||
|
||||
/// Capture mode that was selected
|
||||
pub capture_kind: UpvarCapture,
|
||||
|
@ -192,7 +192,7 @@ pub struct TypeckResults<'tcx> {
|
||||
/// we never capture `t`. This becomes an issue when we build MIR as we require
|
||||
/// information on `t` in order to create place `t.0` and `t.1`. We can solve this
|
||||
/// issue by fake reading `t`.
|
||||
pub closure_fake_reads: LocalDefIdMap<Vec<(HirPlace<'tcx>, FakeReadCause, hir::HirId)>>,
|
||||
pub closure_fake_reads: LocalDefIdMap<Vec<(HirPlace<'tcx>, FakeReadCause, HirId)>>,
|
||||
|
||||
/// Tracks the rvalue scoping rules which defines finer scoping for rvalue expressions
|
||||
/// by applying extended parameter rules.
|
||||
@ -251,7 +251,7 @@ impl<'tcx> TypeckResults<'tcx> {
|
||||
}
|
||||
|
||||
/// Returns the final resolution of a `QPath` in an `Expr` or `Pat` node.
|
||||
pub fn qpath_res(&self, qpath: &hir::QPath<'_>, id: hir::HirId) -> Res {
|
||||
pub fn qpath_res(&self, qpath: &hir::QPath<'_>, id: HirId) -> Res {
|
||||
match *qpath {
|
||||
hir::QPath::Resolved(_, path) => path.res,
|
||||
hir::QPath::TypeRelative(..) | hir::QPath::LangItem(..) => self
|
||||
@ -289,11 +289,11 @@ impl<'tcx> TypeckResults<'tcx> {
|
||||
LocalTableInContextMut { hir_owner: self.hir_owner, data: &mut self.field_indices }
|
||||
}
|
||||
|
||||
pub fn field_index(&self, id: hir::HirId) -> FieldIdx {
|
||||
pub fn field_index(&self, id: HirId) -> FieldIdx {
|
||||
self.field_indices().get(id).cloned().expect("no index for a field")
|
||||
}
|
||||
|
||||
pub fn opt_field_index(&self, id: hir::HirId) -> Option<FieldIdx> {
|
||||
pub fn opt_field_index(&self, id: HirId) -> Option<FieldIdx> {
|
||||
self.field_indices().get(id).cloned()
|
||||
}
|
||||
|
||||
@ -305,7 +305,7 @@ impl<'tcx> TypeckResults<'tcx> {
|
||||
LocalTableInContextMut { hir_owner: self.hir_owner, data: &mut self.nested_fields }
|
||||
}
|
||||
|
||||
pub fn nested_field_tys_and_indices(&self, id: hir::HirId) -> &[(Ty<'tcx>, FieldIdx)] {
|
||||
pub fn nested_field_tys_and_indices(&self, id: HirId) -> &[(Ty<'tcx>, FieldIdx)] {
|
||||
self.nested_fields().get(id).map_or(&[], Vec::as_slice)
|
||||
}
|
||||
|
||||
@ -327,13 +327,13 @@ impl<'tcx> TypeckResults<'tcx> {
|
||||
LocalTableInContextMut { hir_owner: self.hir_owner, data: &mut self.node_types }
|
||||
}
|
||||
|
||||
pub fn node_type(&self, id: hir::HirId) -> Ty<'tcx> {
|
||||
pub fn node_type(&self, id: HirId) -> Ty<'tcx> {
|
||||
self.node_type_opt(id).unwrap_or_else(|| {
|
||||
bug!("node_type: no type for node {}", tls::with(|tcx| tcx.hir().node_to_string(id)))
|
||||
})
|
||||
}
|
||||
|
||||
pub fn node_type_opt(&self, id: hir::HirId) -> Option<Ty<'tcx>> {
|
||||
pub fn node_type_opt(&self, id: HirId) -> Option<Ty<'tcx>> {
|
||||
validate_hir_id_for_typeck_results(self.hir_owner, id);
|
||||
self.node_types.get(&id.local_id).cloned()
|
||||
}
|
||||
@ -342,12 +342,12 @@ impl<'tcx> TypeckResults<'tcx> {
|
||||
LocalTableInContextMut { hir_owner: self.hir_owner, data: &mut self.node_args }
|
||||
}
|
||||
|
||||
pub fn node_args(&self, id: hir::HirId) -> GenericArgsRef<'tcx> {
|
||||
pub fn node_args(&self, id: HirId) -> GenericArgsRef<'tcx> {
|
||||
validate_hir_id_for_typeck_results(self.hir_owner, id);
|
||||
self.node_args.get(&id.local_id).cloned().unwrap_or_else(|| GenericArgs::empty())
|
||||
}
|
||||
|
||||
pub fn node_args_opt(&self, id: hir::HirId) -> Option<GenericArgsRef<'tcx>> {
|
||||
pub fn node_args_opt(&self, id: HirId) -> Option<GenericArgsRef<'tcx>> {
|
||||
validate_hir_id_for_typeck_results(self.hir_owner, id);
|
||||
self.node_args.get(&id.local_id).cloned()
|
||||
}
|
||||
@ -512,7 +512,7 @@ impl<'tcx> TypeckResults<'tcx> {
|
||||
LocalTableInContextMut { hir_owner: self.hir_owner, data: &mut self.fru_field_types }
|
||||
}
|
||||
|
||||
pub fn is_coercion_cast(&self, hir_id: hir::HirId) -> bool {
|
||||
pub fn is_coercion_cast(&self, hir_id: HirId) -> bool {
|
||||
validate_hir_id_for_typeck_results(self.hir_owner, hir_id);
|
||||
self.coercion_casts.contains(&hir_id.local_id)
|
||||
}
|
||||
@ -546,7 +546,7 @@ impl<'tcx> TypeckResults<'tcx> {
|
||||
/// would result in lookup errors, or worse, in silently wrong data being
|
||||
/// stored/returned.
|
||||
#[inline]
|
||||
fn validate_hir_id_for_typeck_results(hir_owner: OwnerId, hir_id: hir::HirId) {
|
||||
fn validate_hir_id_for_typeck_results(hir_owner: OwnerId, hir_id: HirId) {
|
||||
if hir_id.owner != hir_owner {
|
||||
invalid_hir_id_for_typeck_results(hir_owner, hir_id);
|
||||
}
|
||||
@ -554,7 +554,7 @@ fn validate_hir_id_for_typeck_results(hir_owner: OwnerId, hir_id: hir::HirId) {
|
||||
|
||||
#[cold]
|
||||
#[inline(never)]
|
||||
fn invalid_hir_id_for_typeck_results(hir_owner: OwnerId, hir_id: hir::HirId) {
|
||||
fn invalid_hir_id_for_typeck_results(hir_owner: OwnerId, hir_id: HirId) {
|
||||
ty::tls::with(|tcx| {
|
||||
bug!(
|
||||
"node {} cannot be placed in TypeckResults with hir_owner {:?}",
|
||||
@ -570,12 +570,12 @@ pub struct LocalTableInContext<'a, V> {
|
||||
}
|
||||
|
||||
impl<'a, V> LocalTableInContext<'a, V> {
|
||||
pub fn contains_key(&self, id: hir::HirId) -> bool {
|
||||
pub fn contains_key(&self, id: HirId) -> bool {
|
||||
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<&'a V> {
|
||||
pub fn get(&self, id: HirId) -> Option<&'a V> {
|
||||
validate_hir_id_for_typeck_results(self.hir_owner, id);
|
||||
self.data.get(&id.local_id)
|
||||
}
|
||||
@ -592,10 +592,10 @@ impl<'a, V> LocalTableInContext<'a, V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, V> ::std::ops::Index<hir::HirId> for LocalTableInContext<'a, V> {
|
||||
impl<'a, V> ::std::ops::Index<HirId> for LocalTableInContext<'a, V> {
|
||||
type Output = V;
|
||||
|
||||
fn index(&self, key: hir::HirId) -> &V {
|
||||
fn index(&self, key: HirId) -> &V {
|
||||
self.get(key).expect("LocalTableInContext: key not found")
|
||||
}
|
||||
}
|
||||
@ -606,35 +606,32 @@ pub struct LocalTableInContextMut<'a, V> {
|
||||
}
|
||||
|
||||
impl<'a, V> LocalTableInContextMut<'a, V> {
|
||||
pub fn get_mut(&mut self, id: hir::HirId) -> Option<&mut V> {
|
||||
pub fn get_mut(&mut self, id: HirId) -> Option<&mut V> {
|
||||
validate_hir_id_for_typeck_results(self.hir_owner, id);
|
||||
self.data.get_mut(&id.local_id)
|
||||
}
|
||||
|
||||
pub fn get(&mut self, id: hir::HirId) -> Option<&V> {
|
||||
pub fn get(&mut self, id: HirId) -> Option<&V> {
|
||||
validate_hir_id_for_typeck_results(self.hir_owner, id);
|
||||
self.data.get(&id.local_id)
|
||||
}
|
||||
|
||||
pub fn entry(&mut self, id: hir::HirId) -> Entry<'_, hir::ItemLocalId, V> {
|
||||
pub fn entry(&mut self, id: HirId) -> Entry<'_, hir::ItemLocalId, V> {
|
||||
validate_hir_id_for_typeck_results(self.hir_owner, id);
|
||||
self.data.entry(id.local_id)
|
||||
}
|
||||
|
||||
pub fn insert(&mut self, id: hir::HirId, val: V) -> Option<V> {
|
||||
pub fn insert(&mut self, id: HirId, val: V) -> Option<V> {
|
||||
validate_hir_id_for_typeck_results(self.hir_owner, id);
|
||||
self.data.insert(id.local_id, val)
|
||||
}
|
||||
|
||||
pub fn remove(&mut self, id: hir::HirId) -> Option<V> {
|
||||
pub fn remove(&mut self, id: HirId) -> Option<V> {
|
||||
validate_hir_id_for_typeck_results(self.hir_owner, id);
|
||||
self.data.remove(&id.local_id)
|
||||
}
|
||||
|
||||
pub fn extend(
|
||||
&mut self,
|
||||
items: UnordItems<(hir::HirId, V), impl Iterator<Item = (hir::HirId, V)>>,
|
||||
) {
|
||||
pub fn extend(&mut self, items: UnordItems<(HirId, V), impl Iterator<Item = (HirId, V)>>) {
|
||||
self.data.extend_unord(items.map(|(id, value)| {
|
||||
validate_hir_id_for_typeck_results(self.hir_owner, id);
|
||||
(id.local_id, value)
|
||||
|
@ -9,7 +9,7 @@ use rustc_data_structures::sorted_map::SortedIndexMultiMap;
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_hir::{self as hir, BindingAnnotation, ByRef, Node};
|
||||
use rustc_hir::{self as hir, BindingAnnotation, ByRef, HirId, Node};
|
||||
use rustc_index::bit_set::GrowableBitSet;
|
||||
use rustc_index::{Idx, IndexSlice, IndexVec};
|
||||
use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
|
||||
@ -158,7 +158,7 @@ struct Builder<'a, 'tcx> {
|
||||
cfg: CFG<'tcx>,
|
||||
|
||||
def_id: LocalDefId,
|
||||
hir_id: hir::HirId,
|
||||
hir_id: HirId,
|
||||
parent_module: DefId,
|
||||
check_overflow: bool,
|
||||
fn_span: Span,
|
||||
@ -222,7 +222,7 @@ struct Builder<'a, 'tcx> {
|
||||
coverage_branch_info: Option<coverageinfo::BranchInfoBuilder>,
|
||||
}
|
||||
|
||||
type CaptureMap<'tcx> = SortedIndexMultiMap<usize, hir::HirId, Capture<'tcx>>;
|
||||
type CaptureMap<'tcx> = SortedIndexMultiMap<usize, HirId, Capture<'tcx>>;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Capture<'tcx> {
|
||||
@ -721,7 +721,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
thir: &'a Thir<'tcx>,
|
||||
infcx: InferCtxt<'tcx>,
|
||||
def: LocalDefId,
|
||||
hir_id: hir::HirId,
|
||||
hir_id: HirId,
|
||||
span: Span,
|
||||
arg_count: usize,
|
||||
return_ty: Ty<'tcx>,
|
||||
@ -981,7 +981,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
|
||||
fn set_correct_source_scope_for_arg(
|
||||
&mut self,
|
||||
arg_hir_id: hir::HirId,
|
||||
arg_hir_id: HirId,
|
||||
original_source_scope: SourceScope,
|
||||
pattern_span: Span,
|
||||
) {
|
||||
|
@ -1,10 +1,8 @@
|
||||
use std::borrow::Cow;
|
||||
|
||||
use crate::build::ExprCategory;
|
||||
use crate::errors::*;
|
||||
|
||||
use rustc_errors::DiagArgValue;
|
||||
use rustc_hir::{self as hir, BindingAnnotation, ByRef, Mutability};
|
||||
use rustc_hir::{self as hir, BindingAnnotation, ByRef, HirId, Mutability};
|
||||
use rustc_middle::mir::BorrowKind;
|
||||
use rustc_middle::thir::visit::Visitor;
|
||||
use rustc_middle::thir::*;
|
||||
@ -16,6 +14,7 @@ use rustc_span::def_id::{DefId, LocalDefId};
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_span::{sym, Span};
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::mem;
|
||||
use std::ops::Bound;
|
||||
|
||||
@ -24,7 +23,7 @@ struct UnsafetyVisitor<'a, 'tcx> {
|
||||
thir: &'a Thir<'tcx>,
|
||||
/// The `HirId` of the current scope, which would be the `HirId`
|
||||
/// of the current HIR node, modulo adjustments. Used for lint levels.
|
||||
hir_context: hir::HirId,
|
||||
hir_context: HirId,
|
||||
/// The current "safety context". This notably tracks whether we are in an
|
||||
/// `unsafe` block, and whether it has been used.
|
||||
safety_context: SafetyContext,
|
||||
@ -123,7 +122,7 @@ impl<'tcx> UnsafetyVisitor<'_, 'tcx> {
|
||||
|
||||
fn warn_unused_unsafe(
|
||||
&mut self,
|
||||
hir_id: hir::HirId,
|
||||
hir_id: HirId,
|
||||
block_span: Span,
|
||||
enclosing_unsafe: Option<UnusedUnsafeEnclosing>,
|
||||
) {
|
||||
@ -537,22 +536,17 @@ enum SafetyContext {
|
||||
Safe,
|
||||
BuiltinUnsafeBlock,
|
||||
UnsafeFn,
|
||||
UnsafeBlock {
|
||||
span: Span,
|
||||
hir_id: hir::HirId,
|
||||
used: bool,
|
||||
nested_used_blocks: Vec<NestedUsedBlock>,
|
||||
},
|
||||
UnsafeBlock { span: Span, hir_id: HirId, used: bool, nested_used_blocks: Vec<NestedUsedBlock> },
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
struct NestedUsedBlock {
|
||||
hir_id: hir::HirId,
|
||||
hir_id: HirId,
|
||||
span: Span,
|
||||
}
|
||||
|
||||
struct UnusedUnsafeWarning {
|
||||
hir_id: hir::HirId,
|
||||
hir_id: HirId,
|
||||
block_span: Span,
|
||||
enclosing_unsafe: Option<UnusedUnsafeEnclosing>,
|
||||
}
|
||||
@ -585,7 +579,7 @@ impl UnsafeOpKind {
|
||||
pub fn emit_unsafe_op_in_unsafe_fn_lint(
|
||||
&self,
|
||||
tcx: TyCtxt<'_>,
|
||||
hir_id: hir::HirId,
|
||||
hir_id: HirId,
|
||||
span: Span,
|
||||
suggest_unsafe_block: bool,
|
||||
) {
|
||||
@ -726,7 +720,7 @@ impl UnsafeOpKind {
|
||||
&self,
|
||||
tcx: TyCtxt<'_>,
|
||||
span: Span,
|
||||
hir_context: hir::HirId,
|
||||
hir_context: HirId,
|
||||
unsafe_op_in_unsafe_fn_allowed: bool,
|
||||
) {
|
||||
let note_non_inherited = tcx.hir().parent_iter(hir_context).find(|(id, node)| {
|
||||
|
@ -389,7 +389,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
|
||||
hir_visit::walk_fn(self, fk, fd, b, id)
|
||||
}
|
||||
|
||||
fn visit_use(&mut self, p: &'v hir::UsePath<'v>, hir_id: hir::HirId) {
|
||||
fn visit_use(&mut self, p: &'v hir::UsePath<'v>, hir_id: HirId) {
|
||||
// This is `visit_use`, but the type is `Path` so record it that way.
|
||||
self.record("Path", Id::None, p);
|
||||
hir_visit::walk_use(self, p, hir_id)
|
||||
@ -462,7 +462,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
|
||||
hir_visit::walk_lifetime(self, lifetime)
|
||||
}
|
||||
|
||||
fn visit_path(&mut self, path: &hir::Path<'v>, _id: hir::HirId) {
|
||||
fn visit_path(&mut self, path: &hir::Path<'v>, _id: HirId) {
|
||||
self.record("Path", Id::None, path);
|
||||
hir_visit::walk_path(self, path)
|
||||
}
|
||||
|
@ -602,7 +602,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||
String::from_utf8(wr).unwrap()
|
||||
}
|
||||
|
||||
fn log_liveness(&self, entry_ln: LiveNode, hir_id: hir::HirId) {
|
||||
fn log_liveness(&self, entry_ln: LiveNode, hir_id: HirId) {
|
||||
// hack to skip the loop unless debug! is enabled:
|
||||
debug!(
|
||||
"^^ liveness computation results for body {} (entry={:?})",
|
||||
|
@ -5,7 +5,7 @@ use rustc_hir as hir;
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_hir::def_id::{LocalDefId, LocalModDefId};
|
||||
use rustc_hir::intravisit::Visitor;
|
||||
use rustc_hir::{ExprKind, InlineAsmOperand, StmtKind};
|
||||
use rustc_hir::{ExprKind, HirIdSet, InlineAsmOperand, StmtKind};
|
||||
use rustc_middle::query::Providers;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_session::lint::builtin::UNDEFINED_NAKED_FUNCTION_ABI;
|
||||
@ -94,7 +94,7 @@ fn check_no_patterns(tcx: TyCtxt<'_>, params: &[hir::Param<'_>]) {
|
||||
|
||||
/// Checks that function parameters aren't used in the function body.
|
||||
fn check_no_parameters_use<'tcx>(tcx: TyCtxt<'tcx>, body: &'tcx hir::Body<'tcx>) {
|
||||
let mut params = hir::HirIdSet::default();
|
||||
let mut params = HirIdSet::default();
|
||||
for param in body.params {
|
||||
param.pat.each_binding(|_binding_mode, hir_id, _span, _ident| {
|
||||
params.insert(hir_id);
|
||||
@ -105,7 +105,7 @@ fn check_no_parameters_use<'tcx>(tcx: TyCtxt<'tcx>, body: &'tcx hir::Body<'tcx>)
|
||||
|
||||
struct CheckParameters<'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
params: hir::HirIdSet,
|
||||
params: HirIdSet,
|
||||
}
|
||||
|
||||
impl<'tcx> Visitor<'tcx> for CheckParameters<'tcx> {
|
||||
|
@ -66,7 +66,7 @@ impl CaptureCollector<'_, '_> {
|
||||
}
|
||||
|
||||
impl<'tcx> Visitor<'tcx> for CaptureCollector<'_, 'tcx> {
|
||||
fn visit_path(&mut self, path: &hir::Path<'tcx>, _: hir::HirId) {
|
||||
fn visit_path(&mut self, path: &hir::Path<'tcx>, _: HirId) {
|
||||
if let Res::Local(var_id) = path.res {
|
||||
self.visit_local_use(var_id, path.span);
|
||||
}
|
||||
|
@ -4251,7 +4251,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||
type_diffs: &[TypeError<'tcx>],
|
||||
span: Span,
|
||||
prev_ty: Ty<'tcx>,
|
||||
body_id: hir::HirId,
|
||||
body_id: HirId,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
) -> Vec<Option<(Span, (DefId, Ty<'tcx>))>> {
|
||||
let ocx = ObligationCtxt::new(self.infcx);
|
||||
@ -4757,7 +4757,7 @@ impl<'v> Visitor<'v> for ReturnsVisitor<'v> {
|
||||
/// Collect all the awaited expressions within the input expression.
|
||||
#[derive(Default)]
|
||||
struct AwaitsVisitor {
|
||||
awaits: Vec<hir::HirId>,
|
||||
awaits: Vec<HirId>,
|
||||
}
|
||||
|
||||
impl<'v> Visitor<'v> for AwaitsVisitor {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use rustc_hir::{self as hir, intravisit, HirIdSet};
|
||||
use rustc_hir::{self as hir, intravisit, HirId, HirIdSet};
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_middle::ty;
|
||||
use rustc_span::def_id::LocalDefId;
|
||||
@ -74,7 +74,7 @@ fn check_raw_ptr<'tcx>(
|
||||
}
|
||||
}
|
||||
|
||||
fn raw_ptr_arg(cx: &LateContext<'_>, arg: &hir::Param<'_>) -> Option<hir::HirId> {
|
||||
fn raw_ptr_arg(cx: &LateContext<'_>, arg: &hir::Param<'_>) -> Option<HirId> {
|
||||
if let (&hir::PatKind::Binding(_, id, _, _), Some(&ty::RawPtr(_, _))) = (
|
||||
&arg.pat.kind,
|
||||
cx.maybe_typeck_results()
|
||||
|
@ -7,6 +7,7 @@ use clippy_utils::{is_expn_of, is_lint_allowed, path_to_local};
|
||||
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::HirId;
|
||||
use rustc_hir::intravisit::{self, Visitor};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::hir::nested_filter;
|
||||
@ -87,9 +88,9 @@ impl<'tcx> LateLintPass<'tcx> for IndexRefutableSlice {
|
||||
extract_msrv_attr!(LateContext);
|
||||
}
|
||||
|
||||
fn find_slice_values(cx: &LateContext<'_>, pat: &hir::Pat<'_>) -> FxIndexMap<hir::HirId, SliceLintInformation> {
|
||||
let mut removed_pat: FxHashSet<hir::HirId> = FxHashSet::default();
|
||||
let mut slices: FxIndexMap<hir::HirId, SliceLintInformation> = FxIndexMap::default();
|
||||
fn find_slice_values(cx: &LateContext<'_>, pat: &hir::Pat<'_>) -> FxIndexMap<HirId, SliceLintInformation> {
|
||||
let mut removed_pat: FxHashSet<HirId> = FxHashSet::default();
|
||||
let mut slices: FxIndexMap<HirId, SliceLintInformation> = FxIndexMap::default();
|
||||
pat.walk_always(|pat| {
|
||||
// We'll just ignore mut and ref mut for simplicity sake right now
|
||||
if let hir::PatKind::Binding(
|
||||
@ -206,10 +207,10 @@ impl SliceLintInformation {
|
||||
|
||||
fn filter_lintable_slices<'tcx>(
|
||||
cx: &LateContext<'tcx>,
|
||||
slice_lint_info: FxIndexMap<hir::HirId, SliceLintInformation>,
|
||||
slice_lint_info: FxIndexMap<HirId, SliceLintInformation>,
|
||||
max_suggested_slice: u64,
|
||||
scope: &'tcx hir::Expr<'tcx>,
|
||||
) -> FxIndexMap<hir::HirId, SliceLintInformation> {
|
||||
) -> FxIndexMap<HirId, SliceLintInformation> {
|
||||
let mut visitor = SliceIndexLintingVisitor {
|
||||
cx,
|
||||
slice_lint_info,
|
||||
@ -223,7 +224,7 @@ fn filter_lintable_slices<'tcx>(
|
||||
|
||||
struct SliceIndexLintingVisitor<'a, 'tcx> {
|
||||
cx: &'a LateContext<'tcx>,
|
||||
slice_lint_info: FxIndexMap<hir::HirId, SliceLintInformation>,
|
||||
slice_lint_info: FxIndexMap<HirId, SliceLintInformation>,
|
||||
max_suggested_slice: u64,
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ use clippy_utils::{binop_traits, eq_expr_value, trait_ref_of_method};
|
||||
use core::ops::ControlFlow;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::{HirId, HirIdSet};
|
||||
use rustc_hir_typeck::expr_use_visitor::{Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId};
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_middle::mir::FakeReadCause;
|
||||
@ -98,10 +99,10 @@ pub(super) fn check<'tcx>(
|
||||
}
|
||||
}
|
||||
|
||||
fn imm_borrows_in_expr(cx: &LateContext<'_>, e: &hir::Expr<'_>) -> hir::HirIdSet {
|
||||
struct S(hir::HirIdSet);
|
||||
fn imm_borrows_in_expr(cx: &LateContext<'_>, e: &hir::Expr<'_>) -> HirIdSet {
|
||||
struct S(HirIdSet);
|
||||
impl Delegate<'_> for S {
|
||||
fn borrow(&mut self, place: &PlaceWithHirId<'_>, _: hir::HirId, kind: BorrowKind) {
|
||||
fn borrow(&mut self, place: &PlaceWithHirId<'_>, _: HirId, kind: BorrowKind) {
|
||||
if matches!(kind, BorrowKind::ImmBorrow | BorrowKind::UniqueImmBorrow) {
|
||||
self.0.insert(match place.place.base {
|
||||
PlaceBase::Local(id) => id,
|
||||
@ -111,13 +112,13 @@ fn imm_borrows_in_expr(cx: &LateContext<'_>, e: &hir::Expr<'_>) -> hir::HirIdSet
|
||||
}
|
||||
}
|
||||
|
||||
fn consume(&mut self, _: &PlaceWithHirId<'_>, _: hir::HirId) {}
|
||||
fn mutate(&mut self, _: &PlaceWithHirId<'_>, _: hir::HirId) {}
|
||||
fn fake_read(&mut self, _: &PlaceWithHirId<'_>, _: FakeReadCause, _: hir::HirId) {}
|
||||
fn copy(&mut self, _: &PlaceWithHirId<'_>, _: hir::HirId) {}
|
||||
fn consume(&mut self, _: &PlaceWithHirId<'_>, _: HirId) {}
|
||||
fn mutate(&mut self, _: &PlaceWithHirId<'_>, _: HirId) {}
|
||||
fn fake_read(&mut self, _: &PlaceWithHirId<'_>, _: FakeReadCause, _: HirId) {}
|
||||
fn copy(&mut self, _: &PlaceWithHirId<'_>, _: HirId) {}
|
||||
}
|
||||
|
||||
let mut s = S(hir::HirIdSet::default());
|
||||
let mut s = S(HirIdSet::default());
|
||||
let infcx = cx.tcx.infer_ctxt().build();
|
||||
let mut v = ExprUseVisitor::new(
|
||||
&mut s,
|
||||
@ -130,10 +131,10 @@ fn imm_borrows_in_expr(cx: &LateContext<'_>, e: &hir::Expr<'_>) -> hir::HirIdSet
|
||||
s.0
|
||||
}
|
||||
|
||||
fn mut_borrows_in_expr(cx: &LateContext<'_>, e: &hir::Expr<'_>) -> hir::HirIdSet {
|
||||
struct S(hir::HirIdSet);
|
||||
fn mut_borrows_in_expr(cx: &LateContext<'_>, e: &hir::Expr<'_>) -> HirIdSet {
|
||||
struct S(HirIdSet);
|
||||
impl Delegate<'_> for S {
|
||||
fn borrow(&mut self, place: &PlaceWithHirId<'_>, _: hir::HirId, kind: BorrowKind) {
|
||||
fn borrow(&mut self, place: &PlaceWithHirId<'_>, _: HirId, kind: BorrowKind) {
|
||||
if matches!(kind, BorrowKind::MutBorrow) {
|
||||
self.0.insert(match place.place.base {
|
||||
PlaceBase::Local(id) => id,
|
||||
@ -143,13 +144,13 @@ fn mut_borrows_in_expr(cx: &LateContext<'_>, e: &hir::Expr<'_>) -> hir::HirIdSet
|
||||
}
|
||||
}
|
||||
|
||||
fn consume(&mut self, _: &PlaceWithHirId<'_>, _: hir::HirId) {}
|
||||
fn mutate(&mut self, _: &PlaceWithHirId<'_>, _: hir::HirId) {}
|
||||
fn fake_read(&mut self, _: &PlaceWithHirId<'_>, _: FakeReadCause, _: hir::HirId) {}
|
||||
fn copy(&mut self, _: &PlaceWithHirId<'_>, _: hir::HirId) {}
|
||||
fn consume(&mut self, _: &PlaceWithHirId<'_>, _: HirId) {}
|
||||
fn mutate(&mut self, _: &PlaceWithHirId<'_>, _: HirId) {}
|
||||
fn fake_read(&mut self, _: &PlaceWithHirId<'_>, _: FakeReadCause, _: HirId) {}
|
||||
fn copy(&mut self, _: &PlaceWithHirId<'_>, _: HirId) {}
|
||||
}
|
||||
|
||||
let mut s = S(hir::HirIdSet::default());
|
||||
let mut s = S(HirIdSet::default());
|
||||
let infcx = cx.tcx.infer_ctxt().build();
|
||||
let mut v = ExprUseVisitor::new(
|
||||
&mut s,
|
||||
|
@ -8,7 +8,7 @@ use clippy_utils::{get_expr_use_or_unification_node, is_lint_allowed, path_def_i
|
||||
use hir::LifetimeName;
|
||||
use rustc_errors::{Applicability, MultiSpan};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::hir_id::HirIdMap;
|
||||
use rustc_hir::hir_id::{HirId, HirIdMap};
|
||||
use rustc_hir::intravisit::{walk_expr, Visitor};
|
||||
use rustc_hir::{
|
||||
self as hir, AnonConst, BinOpKind, BindingAnnotation, Body, Expr, ExprKind, FnRetTy, FnSig, GenericArg,
|
||||
@ -324,7 +324,7 @@ struct PtrArgReplacement {
|
||||
|
||||
struct PtrArg<'tcx> {
|
||||
idx: usize,
|
||||
emission_id: hir::HirId,
|
||||
emission_id: HirId,
|
||||
span: Span,
|
||||
ty_did: DefId,
|
||||
ty_name: Symbol,
|
||||
|
@ -5,7 +5,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::intravisit::{walk_expr, Visitor};
|
||||
use rustc_hir::{self as hir};
|
||||
use rustc_hir::{self as hir, HirId};
|
||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||
use rustc_middle::ty::{GenericArgKind, Ty};
|
||||
use rustc_session::impl_lint_pass;
|
||||
@ -55,7 +55,7 @@ impl_lint_pass!(SignificantDropTightening<'_> => [SIGNIFICANT_DROP_TIGHTENING]);
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct SignificantDropTightening<'tcx> {
|
||||
apas: FxIndexMap<hir::HirId, AuxParamsAttr>,
|
||||
apas: FxIndexMap<HirId, AuxParamsAttr>,
|
||||
/// Auxiliary structure used to avoid having to verify the same type multiple times.
|
||||
seen_types: FxHashSet<Ty<'tcx>>,
|
||||
type_cache: FxHashMap<Ty<'tcx>, bool>,
|
||||
@ -359,9 +359,9 @@ impl<'ap, 'lc, 'others, 'stmt, 'tcx> Visitor<'tcx> for StmtsChecker<'ap, 'lc, 'o
|
||||
/// Auxiliary parameters used on each block check of an item
|
||||
struct AuxParams<'others, 'stmt, 'tcx> {
|
||||
//// See [AuxParamsAttr].
|
||||
apas: &'others mut FxIndexMap<hir::HirId, AuxParamsAttr>,
|
||||
apas: &'others mut FxIndexMap<HirId, AuxParamsAttr>,
|
||||
/// The current block identifier that is being visited.
|
||||
curr_block_hir_id: hir::HirId,
|
||||
curr_block_hir_id: HirId,
|
||||
/// The current block span that is being visited.
|
||||
curr_block_span: Span,
|
||||
/// The current statement that is being visited.
|
||||
@ -369,10 +369,10 @@ struct AuxParams<'others, 'stmt, 'tcx> {
|
||||
}
|
||||
|
||||
impl<'others, 'stmt, 'tcx> AuxParams<'others, 'stmt, 'tcx> {
|
||||
fn new(apas: &'others mut FxIndexMap<hir::HirId, AuxParamsAttr>, curr_stmt: &'stmt hir::Stmt<'tcx>) -> Self {
|
||||
fn new(apas: &'others mut FxIndexMap<HirId, AuxParamsAttr>, curr_stmt: &'stmt hir::Stmt<'tcx>) -> Self {
|
||||
Self {
|
||||
apas,
|
||||
curr_block_hir_id: hir::HirId::INVALID,
|
||||
curr_block_hir_id: HirId::INVALID,
|
||||
curr_block_span: DUMMY_SP,
|
||||
curr_stmt: Cow::Borrowed(curr_stmt),
|
||||
}
|
||||
@ -389,7 +389,7 @@ struct AuxParamsAttr {
|
||||
has_expensive_expr_after_last_attr: bool,
|
||||
|
||||
/// The identifier of the block that involves the first `#[has_significant_drop]`.
|
||||
first_block_hir_id: hir::HirId,
|
||||
first_block_hir_id: HirId,
|
||||
/// The span of the block that involves the first `#[has_significant_drop]`.
|
||||
first_block_span: Span,
|
||||
/// The binding or variable that references the initial construction of the type marked with
|
||||
@ -414,7 +414,7 @@ impl Default for AuxParamsAttr {
|
||||
Self {
|
||||
counter: 0,
|
||||
has_expensive_expr_after_last_attr: false,
|
||||
first_block_hir_id: hir::HirId::INVALID,
|
||||
first_block_hir_id: HirId::INVALID,
|
||||
first_bind_ident: Ident::empty(),
|
||||
first_block_span: DUMMY_SP,
|
||||
first_method_span: DUMMY_SP,
|
||||
@ -428,7 +428,7 @@ impl Default for AuxParamsAttr {
|
||||
|
||||
fn dummy_stmt_expr<'any>(expr: &'any hir::Expr<'any>) -> hir::Stmt<'any> {
|
||||
hir::Stmt {
|
||||
hir_id: hir::HirId::INVALID,
|
||||
hir_id: HirId::INVALID,
|
||||
kind: hir::StmtKind::Expr(expr),
|
||||
span: DUMMY_SP,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user