Skip to content

Commit 904c6be

Browse files
committed
Rename ast_* local variables to hir_*
1 parent 12db6d1 commit 904c6be

File tree

7 files changed

+86
-87
lines changed

7 files changed

+86
-87
lines changed

compiler/rustc_hir_analysis/src/astconv/bounds.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
2222
&self,
2323
bounds: &mut Bounds<'tcx>,
2424
self_ty: Ty<'tcx>,
25-
ast_bounds: &'tcx [hir::GenericBound<'tcx>],
25+
hir_bounds: &'tcx [hir::GenericBound<'tcx>],
2626
self_ty_where_predicates: Option<(LocalDefId, &'tcx [hir::WherePredicate<'tcx>])>,
2727
span: Span,
2828
) {
@@ -33,9 +33,9 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
3333

3434
// Try to find an unbound in bounds.
3535
let mut unbounds: SmallVec<[_; 1]> = SmallVec::new();
36-
let mut search_bounds = |ast_bounds: &'tcx [hir::GenericBound<'tcx>]| {
37-
for ab in ast_bounds {
38-
let hir::GenericBound::Trait(ptr, modifier) = ab else {
36+
let mut search_bounds = |hir_bounds: &'tcx [hir::GenericBound<'tcx>]| {
37+
for hir_bound in hir_bounds {
38+
let hir::GenericBound::Trait(ptr, modifier) = hir_bound else {
3939
continue;
4040
};
4141
match modifier {
@@ -58,7 +58,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
5858
}
5959
}
6060
};
61-
search_bounds(ast_bounds);
61+
search_bounds(hir_bounds);
6262
if let Some((self_ty, where_clause)) = self_ty_where_predicates {
6363
for clause in where_clause {
6464
if let hir::WherePredicate::BoundPredicate(pred) = clause
@@ -105,27 +105,27 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
105105
///
106106
/// ```text
107107
/// fn foo<T: Debug>
108-
/// ^ ^^^^^ `ast_bounds` parameter, in HIR form
108+
/// ^ ^^^^^ `hir_bounds` parameter, in HIR form
109109
/// |
110110
/// `param_ty`, in ty form
111111
/// ```
112112
///
113113
/// **A note on binders:** there is an implied binder around
114-
/// `param_ty` and `ast_bounds`. See `instantiate_poly_trait_ref`
114+
/// `param_ty` and `hir_bounds`. See `instantiate_poly_trait_ref`
115115
/// for more details.
116-
#[instrument(level = "debug", skip(self, ast_bounds, bounds))]
116+
#[instrument(level = "debug", skip(self, hir_bounds, bounds))]
117117
pub(crate) fn add_bounds<'hir, I: Iterator<Item = &'hir hir::GenericBound<'tcx>>>(
118118
&self,
119119
param_ty: Ty<'tcx>,
120-
ast_bounds: I,
120+
hir_bounds: I,
121121
bounds: &mut Bounds<'tcx>,
122122
bound_vars: &'tcx ty::List<ty::BoundVariableKind>,
123123
only_self_bounds: OnlySelfBounds,
124124
) where
125125
'tcx: 'hir,
126126
{
127-
for ast_bound in ast_bounds {
128-
match ast_bound {
127+
for hir_bound in hir_bounds {
128+
match hir_bound {
129129
hir::GenericBound::Trait(poly_trait_ref, modifier) => {
130130
let (constness, polarity) = match modifier {
131131
hir::TraitBoundModifier::Const => {
@@ -175,7 +175,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
175175
///
176176
/// ```ignore (illustrative)
177177
/// fn foo<T: Bar + Baz>() { }
178-
/// // ^ ^^^^^^^^^ ast_bounds
178+
/// // ^ ^^^^^^^^^ hir_bounds
179179
/// // param_ty
180180
/// ```
181181
///
@@ -187,7 +187,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
187187
pub(crate) fn compute_bounds(
188188
&self,
189189
param_ty: Ty<'tcx>,
190-
ast_bounds: &[hir::GenericBound<'tcx>],
190+
hir_bounds: &[hir::GenericBound<'tcx>],
191191
filter: PredicateFilter,
192192
) -> Bounds<'tcx> {
193193
let mut bounds = Bounds::default();
@@ -201,7 +201,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
201201

202202
self.add_bounds(
203203
param_ty,
204-
ast_bounds.iter().filter(|bound| match filter {
204+
hir_bounds.iter().filter(|bound| match filter {
205205
PredicateFilter::All
206206
| PredicateFilter::SelfOnly
207207
| PredicateFilter::SelfAndAssociatedTypeBounds => true,
@@ -488,7 +488,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
488488
binding.span,
489489
);
490490
}
491-
LoweredBindingKind::Constraint(ast_bounds) => {
491+
LoweredBindingKind::Constraint(hir_bounds) => {
492492
// "Desugar" a constraint like `T: Iterator<Item: Debug>` to
493493
//
494494
// `<T as Iterator>::Item: Debug`
@@ -503,7 +503,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
503503
let param_ty = Ty::new_alias(tcx, ty::Projection, projection_ty.skip_binder());
504504
self.add_bounds(
505505
param_ty,
506-
ast_bounds.iter(),
506+
hir_bounds.iter(),
507507
bounds,
508508
projection_ty.bound_vars(),
509509
only_self_bounds,

compiler/rustc_hir_analysis/src/astconv/mod.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -2299,14 +2299,14 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
22992299

23002300
/// Parses the programmer's textual representation of a type into our
23012301
/// internal notion of a type.
2302-
pub fn lower_ty(&self, ast_ty: &hir::Ty<'tcx>) -> Ty<'tcx> {
2303-
self.lower_ty_inner(ast_ty, false, false)
2302+
pub fn lower_ty(&self, hir_ty: &hir::Ty<'tcx>) -> Ty<'tcx> {
2303+
self.lower_ty_inner(hir_ty, false, false)
23042304
}
23052305

23062306
/// Parses the programmer's textual representation of a type into our
23072307
/// internal notion of a type. This is meant to be used within a path.
2308-
pub fn lower_ty_in_path(&self, ast_ty: &hir::Ty<'tcx>) -> Ty<'tcx> {
2309-
self.lower_ty_inner(ast_ty, false, true)
2308+
pub fn lower_ty_in_path(&self, hir_ty: &hir::Ty<'tcx>) -> Ty<'tcx> {
2309+
self.lower_ty_inner(hir_ty, false, true)
23102310
}
23112311

23122312
fn check_delegation_constraints(&self, sig_id: DefId, span: Span, emit: bool) -> bool {
@@ -2422,12 +2422,12 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
24222422
/// For diagnostics' purposes we keep track of whether trait objects are
24232423
/// borrowed like `&dyn Trait` to avoid emitting redundant errors.
24242424
#[instrument(level = "debug", skip(self), ret)]
2425-
fn lower_ty_inner(&self, ast_ty: &hir::Ty<'tcx>, borrowed: bool, in_path: bool) -> Ty<'tcx> {
2425+
fn lower_ty_inner(&self, hir_ty: &hir::Ty<'tcx>, borrowed: bool, in_path: bool) -> Ty<'tcx> {
24262426
let tcx = self.tcx();
24272427

2428-
let result_ty = match &ast_ty.kind {
2428+
let result_ty = match &hir_ty.kind {
24292429
hir::TyKind::InferDelegation(sig_id, idx) => {
2430-
self.lower_delegation_ty(*sig_id, *idx, ast_ty.span)
2430+
self.lower_delegation_ty(*sig_id, *idx, hir_ty.span)
24312431
}
24322432
hir::TyKind::Slice(ty) => Ty::new_slice(tcx, self.lower_ty(ty)),
24332433
hir::TyKind::Ptr(mt) => {
@@ -2444,30 +2444,30 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
24442444
Ty::new_tup_from_iter(tcx, fields.iter().map(|t| self.lower_ty(t)))
24452445
}
24462446
hir::TyKind::BareFn(bf) => {
2447-
require_c_abi_if_c_variadic(tcx, bf.decl, bf.abi, ast_ty.span);
2447+
require_c_abi_if_c_variadic(tcx, bf.decl, bf.abi, hir_ty.span);
24482448

24492449
Ty::new_fn_ptr(
24502450
tcx,
24512451
self.lower_fn_ty(
2452-
ast_ty.hir_id,
2452+
hir_ty.hir_id,
24532453
bf.unsafety,
24542454
bf.abi,
24552455
bf.decl,
24562456
None,
2457-
Some(ast_ty),
2457+
Some(hir_ty),
24582458
),
24592459
)
24602460
}
24612461
hir::TyKind::TraitObject(bounds, lifetime, repr) => {
2462-
self.maybe_lint_bare_trait(ast_ty, in_path);
2462+
self.maybe_lint_bare_trait(hir_ty, in_path);
24632463
let repr = match repr {
24642464
TraitObjectSyntax::Dyn | TraitObjectSyntax::None => ty::Dyn,
24652465
TraitObjectSyntax::DynStar => ty::DynStar,
24662466
};
24672467

24682468
self.lower_object_ty_to_poly_trait_ref(
2469-
ast_ty.span,
2470-
ast_ty.hir_id,
2469+
hir_ty.span,
2470+
hir_ty.hir_id,
24712471
bounds,
24722472
lifetime,
24732473
borrowed,
@@ -2477,7 +2477,7 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
24772477
hir::TyKind::Path(hir::QPath::Resolved(maybe_qself, path)) => {
24782478
debug!(?maybe_qself, ?path);
24792479
let opt_self_ty = maybe_qself.as_ref().map(|qself| self.lower_ty(qself));
2480-
self.lower_res_to_ty(opt_self_ty, path, ast_ty.hir_id, false)
2480+
self.lower_res_to_ty(opt_self_ty, path, hir_ty.hir_id, false)
24812481
}
24822482
&hir::TyKind::OpaqueDef(item_id, lifetimes, in_trait) => {
24832483
let opaque_ty = tcx.hir().item(item_id);
@@ -2501,7 +2501,7 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
25012501
hir::TyKind::Path(hir::QPath::TypeRelative(qself, segment)) => {
25022502
debug!(?qself, ?segment);
25032503
let ty = self.lower_ty_inner(qself, false, true);
2504-
self.lower_assoc_path_to_ty(ast_ty.hir_id, ast_ty.span, ty, qself, segment, false)
2504+
self.lower_assoc_path_to_ty(hir_ty.hir_id, hir_ty.span, ty, qself, segment, false)
25052505
.map(|(ty, _, _)| ty)
25062506
.unwrap_or_else(|guar| Ty::new_error(tcx, guar))
25072507
}
@@ -2535,12 +2535,12 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
25352535
// values in an ExprKind::Closure, or as
25362536
// the type of local variables. Both of these cases are
25372537
// handled specially and will not descend into this routine.
2538-
self.ty_infer(None, ast_ty.span)
2538+
self.ty_infer(None, hir_ty.span)
25392539
}
25402540
hir::TyKind::Err(guar) => Ty::new_error(tcx, *guar),
25412541
};
25422542

2543-
self.record_ty(ast_ty.hir_id, result_ty, ast_ty.span);
2543+
self.record_ty(hir_ty.hir_id, result_ty, hir_ty.span);
25442544
result_ty
25452545
}
25462546

compiler/rustc_hir_analysis/src/check/wfcheck.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -295,31 +295,31 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
295295
hir::ItemKind::Const(ty, ..) => {
296296
check_item_type(tcx, def_id, ty.span, UnsizedHandling::Forbid)
297297
}
298-
hir::ItemKind::Struct(_, ast_generics) => {
298+
hir::ItemKind::Struct(_, hir_generics) => {
299299
let res = check_type_defn(tcx, item, false);
300-
check_variances_for_type_defn(tcx, item, ast_generics);
300+
check_variances_for_type_defn(tcx, item, hir_generics);
301301
res
302302
}
303-
hir::ItemKind::Union(_, ast_generics) => {
303+
hir::ItemKind::Union(_, hir_generics) => {
304304
let res = check_type_defn(tcx, item, true);
305-
check_variances_for_type_defn(tcx, item, ast_generics);
305+
check_variances_for_type_defn(tcx, item, hir_generics);
306306
res
307307
}
308-
hir::ItemKind::Enum(_, ast_generics) => {
308+
hir::ItemKind::Enum(_, hir_generics) => {
309309
let res = check_type_defn(tcx, item, true);
310-
check_variances_for_type_defn(tcx, item, ast_generics);
310+
check_variances_for_type_defn(tcx, item, hir_generics);
311311
res
312312
}
313313
hir::ItemKind::Trait(..) => check_trait(tcx, item),
314314
hir::ItemKind::TraitAlias(..) => check_trait(tcx, item),
315315
// `ForeignItem`s are handled separately.
316316
hir::ItemKind::ForeignMod { .. } => Ok(()),
317-
hir::ItemKind::TyAlias(hir_ty, ast_generics) => {
317+
hir::ItemKind::TyAlias(hir_ty, hir_generics) => {
318318
if tcx.type_alias_is_lazy(item.owner_id) {
319319
// Bounds of lazy type aliases and of eager ones that contain opaque types are respected.
320320
// E.g: `type X = impl Trait;`, `type X = (impl Trait, Y);`.
321321
let res = check_item_type(tcx, def_id, hir_ty.span, UnsizedHandling::Allow);
322-
check_variances_for_type_defn(tcx, item, ast_generics);
322+
check_variances_for_type_defn(tcx, item, hir_generics);
323323
res
324324
} else {
325325
Ok(())
@@ -1282,16 +1282,16 @@ fn check_item_type(
12821282
})
12831283
}
12841284

1285-
#[instrument(level = "debug", skip(tcx, ast_self_ty, ast_trait_ref))]
1285+
#[instrument(level = "debug", skip(tcx, hir_self_ty, hir_trait_ref))]
12861286
fn check_impl<'tcx>(
12871287
tcx: TyCtxt<'tcx>,
12881288
item: &'tcx hir::Item<'tcx>,
1289-
ast_self_ty: &hir::Ty<'_>,
1290-
ast_trait_ref: &Option<hir::TraitRef<'_>>,
1289+
hir_self_ty: &hir::Ty<'_>,
1290+
hir_trait_ref: &Option<hir::TraitRef<'_>>,
12911291
) -> Result<(), ErrorGuaranteed> {
12921292
enter_wf_checking_ctxt(tcx, item.span, item.owner_id.def_id, |wfcx| {
1293-
match ast_trait_ref {
1294-
Some(ast_trait_ref) => {
1293+
match hir_trait_ref {
1294+
Some(hir_trait_ref) => {
12951295
// `#[rustc_reservation_impl]` impls are not real impls and
12961296
// therefore don't need to be WF (the trait's `Self: Trait` predicate
12971297
// won't hold).
@@ -1300,7 +1300,7 @@ fn check_impl<'tcx>(
13001300
// other `Foo` impls are incoherent.
13011301
tcx.ensure().coherent_trait(trait_ref.def_id)?;
13021302
let trait_ref = wfcx.normalize(
1303-
ast_trait_ref.path.span,
1303+
hir_trait_ref.path.span,
13041304
Some(WellFormedLoc::Ty(item.hir_id().expect_owner().def_id)),
13051305
trait_ref,
13061306
);
@@ -1311,14 +1311,14 @@ fn check_impl<'tcx>(
13111311
wfcx.param_env,
13121312
wfcx.body_def_id,
13131313
trait_pred,
1314-
ast_trait_ref.path.span,
1314+
hir_trait_ref.path.span,
13151315
item,
13161316
);
13171317
for obligation in &mut obligations {
13181318
if let Some(pred) = obligation.predicate.to_opt_poly_trait_pred()
13191319
&& pred.self_ty().skip_binder() == trait_ref.self_ty()
13201320
{
1321-
obligation.cause.span = ast_self_ty.span;
1321+
obligation.cause.span = hir_self_ty.span;
13221322
}
13231323
}
13241324
debug!(?obligations);
@@ -1332,7 +1332,7 @@ fn check_impl<'tcx>(
13321332
self_ty,
13331333
);
13341334
wfcx.register_wf_obligation(
1335-
ast_self_ty.span,
1335+
hir_self_ty.span,
13361336
Some(WellFormedLoc::Ty(item.hir_id().expect_owner().def_id)),
13371337
self_ty.into(),
13381338
);

0 commit comments

Comments
 (0)