Skip to content

Commit 8cf3ea0

Browse files
committed
Rename ast_* local variables to hir_*
1 parent da52816 commit 8cf3ea0

File tree

7 files changed

+87
-88
lines changed

7 files changed

+87
-88
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,
@@ -489,7 +489,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
489489
binding.span,
490490
);
491491
}
492-
LoweredBindingKind::Constraint(ast_bounds) => {
492+
LoweredBindingKind::Constraint(hir_bounds) => {
493493
// "Desugar" a constraint like `T: Iterator<Item: Debug>` to
494494
//
495495
// `<T as Iterator>::Item: Debug`
@@ -504,7 +504,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
504504
let param_ty = Ty::new_alias(tcx, ty::Projection, projection_ty.skip_binder());
505505
self.add_bounds(
506506
param_ty,
507-
ast_bounds.iter(),
507+
hir_bounds.iter(),
508508
bounds,
509509
projection_ty.bound_vars(),
510510
only_self_bounds,

compiler/rustc_hir_analysis/src/astconv/mod.rs

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

23032303
/// Parses the programmer's textual representation of a type into our
23042304
/// internal notion of a type.
2305-
pub fn lower_ty(&self, ast_ty: &hir::Ty<'tcx>) -> Ty<'tcx> {
2306-
self.lower_ty_inner(ast_ty, false, false)
2305+
pub fn lower_ty(&self, hir_ty: &hir::Ty<'tcx>) -> Ty<'tcx> {
2306+
self.lower_ty_inner(hir_ty, false, false)
23072307
}
23082308

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

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

2431-
let result_ty = match &ast_ty.kind {
2431+
let result_ty = match &hir_ty.kind {
24322432
hir::TyKind::InferDelegation(sig_id, idx) => {
2433-
self.lower_delegation_ty(*sig_id, *idx, ast_ty.span)
2433+
self.lower_delegation_ty(*sig_id, *idx, hir_ty.span)
24342434
}
24352435
hir::TyKind::Slice(ty) => Ty::new_slice(tcx, self.lower_ty(ty)),
24362436
hir::TyKind::Ptr(mt) => {
@@ -2460,30 +2460,30 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
24602460
Ty::new_adt(tcx, adt_def, tcx.mk_args(args))
24612461
}
24622462
hir::TyKind::BareFn(bf) => {
2463-
require_c_abi_if_c_variadic(tcx, bf.decl, bf.abi, ast_ty.span);
2463+
require_c_abi_if_c_variadic(tcx, bf.decl, bf.abi, hir_ty.span);
24642464

24652465
Ty::new_fn_ptr(
24662466
tcx,
24672467
self.lower_fn_ty(
2468-
ast_ty.hir_id,
2468+
hir_ty.hir_id,
24692469
bf.unsafety,
24702470
bf.abi,
24712471
bf.decl,
24722472
None,
2473-
Some(ast_ty),
2473+
Some(hir_ty),
24742474
),
24752475
)
24762476
}
24772477
hir::TyKind::TraitObject(bounds, lifetime, repr) => {
2478-
self.maybe_lint_bare_trait(ast_ty, in_path);
2478+
self.maybe_lint_bare_trait(hir_ty, in_path);
24792479
let repr = match repr {
24802480
TraitObjectSyntax::Dyn | TraitObjectSyntax::None => ty::Dyn,
24812481
TraitObjectSyntax::DynStar => ty::DynStar,
24822482
};
24832483

24842484
self.lower_object_ty_to_poly_trait_ref(
2485-
ast_ty.span,
2486-
ast_ty.hir_id,
2485+
hir_ty.span,
2486+
hir_ty.hir_id,
24872487
bounds,
24882488
lifetime,
24892489
borrowed,
@@ -2493,7 +2493,7 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
24932493
hir::TyKind::Path(hir::QPath::Resolved(maybe_qself, path)) => {
24942494
debug!(?maybe_qself, ?path);
24952495
let opt_self_ty = maybe_qself.as_ref().map(|qself| self.lower_ty(qself));
2496-
self.lower_res_to_ty(opt_self_ty, path, ast_ty.hir_id, false)
2496+
self.lower_res_to_ty(opt_self_ty, path, hir_ty.hir_id, false)
24972497
}
24982498
&hir::TyKind::OpaqueDef(item_id, lifetimes, in_trait) => {
24992499
let opaque_ty = tcx.hir().item(item_id);
@@ -2517,7 +2517,7 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
25172517
hir::TyKind::Path(hir::QPath::TypeRelative(qself, segment)) => {
25182518
debug!(?qself, ?segment);
25192519
let ty = self.lower_ty_inner(qself, false, true);
2520-
self.lower_assoc_path_to_ty(ast_ty.hir_id, ast_ty.span, ty, qself, segment, false)
2520+
self.lower_assoc_path_to_ty(hir_ty.hir_id, hir_ty.span, ty, qself, segment, false)
25212521
.map(|(ty, _, _)| ty)
25222522
.unwrap_or_else(|guar| Ty::new_error(tcx, guar))
25232523
}
@@ -2551,12 +2551,12 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
25512551
// values in an ExprKind::Closure, or as
25522552
// the type of local variables. Both of these cases are
25532553
// handled specially and will not descend into this routine.
2554-
self.ty_infer(None, ast_ty.span)
2554+
self.ty_infer(None, hir_ty.span)
25552555
}
25562556
hir::TyKind::Err(guar) => Ty::new_error(tcx, *guar),
25572557
};
25582558

2559-
self.record_ty(ast_ty.hir_id, result_ty, ast_ty.span);
2559+
self.record_ty(hir_ty.hir_id, result_ty, hir_ty.span);
25602560
result_ty
25612561
}
25622562

compiler/rustc_hir_analysis/src/check/wfcheck.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -296,31 +296,31 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
296296
hir::ItemKind::Const(ty, ..) => {
297297
check_item_type(tcx, def_id, ty.span, UnsizedHandling::Forbid)
298298
}
299-
hir::ItemKind::Struct(_, ast_generics) => {
299+
hir::ItemKind::Struct(_, hir_generics) => {
300300
let res = check_type_defn(tcx, item, false);
301-
check_variances_for_type_defn(tcx, item, ast_generics);
301+
check_variances_for_type_defn(tcx, item, hir_generics);
302302
res
303303
}
304-
hir::ItemKind::Union(_, ast_generics) => {
304+
hir::ItemKind::Union(_, hir_generics) => {
305305
let res = check_type_defn(tcx, item, true);
306-
check_variances_for_type_defn(tcx, item, ast_generics);
306+
check_variances_for_type_defn(tcx, item, hir_generics);
307307
res
308308
}
309-
hir::ItemKind::Enum(_, ast_generics) => {
309+
hir::ItemKind::Enum(_, hir_generics) => {
310310
let res = check_type_defn(tcx, item, true);
311-
check_variances_for_type_defn(tcx, item, ast_generics);
311+
check_variances_for_type_defn(tcx, item, hir_generics);
312312
res
313313
}
314314
hir::ItemKind::Trait(..) => check_trait(tcx, item),
315315
hir::ItemKind::TraitAlias(..) => check_trait(tcx, item),
316316
// `ForeignItem`s are handled separately.
317317
hir::ItemKind::ForeignMod { .. } => Ok(()),
318-
hir::ItemKind::TyAlias(hir_ty, ast_generics) => {
318+
hir::ItemKind::TyAlias(hir_ty, hir_generics) => {
319319
if tcx.type_alias_is_lazy(item.owner_id) {
320320
// Bounds of lazy type aliases and of eager ones that contain opaque types are respected.
321321
// E.g: `type X = impl Trait;`, `type X = (impl Trait, Y);`.
322322
let res = check_item_type(tcx, def_id, hir_ty.span, UnsizedHandling::Allow);
323-
check_variances_for_type_defn(tcx, item, ast_generics);
323+
check_variances_for_type_defn(tcx, item, hir_generics);
324324
res
325325
} else {
326326
Ok(())
@@ -1283,16 +1283,16 @@ fn check_item_type(
12831283
})
12841284
}
12851285

1286-
#[instrument(level = "debug", skip(tcx, ast_self_ty, ast_trait_ref))]
1286+
#[instrument(level = "debug", skip(tcx, hir_self_ty, hir_trait_ref))]
12871287
fn check_impl<'tcx>(
12881288
tcx: TyCtxt<'tcx>,
12891289
item: &'tcx hir::Item<'tcx>,
1290-
ast_self_ty: &hir::Ty<'_>,
1291-
ast_trait_ref: &Option<hir::TraitRef<'_>>,
1290+
hir_self_ty: &hir::Ty<'_>,
1291+
hir_trait_ref: &Option<hir::TraitRef<'_>>,
12921292
) -> Result<(), ErrorGuaranteed> {
12931293
enter_wf_checking_ctxt(tcx, item.span, item.owner_id.def_id, |wfcx| {
1294-
match ast_trait_ref {
1295-
Some(ast_trait_ref) => {
1294+
match hir_trait_ref {
1295+
Some(hir_trait_ref) => {
12961296
// `#[rustc_reservation_impl]` impls are not real impls and
12971297
// therefore don't need to be WF (the trait's `Self: Trait` predicate
12981298
// won't hold).
@@ -1301,7 +1301,7 @@ fn check_impl<'tcx>(
13011301
// other `Foo` impls are incoherent.
13021302
tcx.ensure().coherent_trait(trait_ref.def_id)?;
13031303
let trait_ref = wfcx.normalize(
1304-
ast_trait_ref.path.span,
1304+
hir_trait_ref.path.span,
13051305
Some(WellFormedLoc::Ty(item.hir_id().expect_owner().def_id)),
13061306
trait_ref,
13071307
);
@@ -1312,14 +1312,14 @@ fn check_impl<'tcx>(
13121312
wfcx.param_env,
13131313
wfcx.body_def_id,
13141314
trait_pred,
1315-
ast_trait_ref.path.span,
1315+
hir_trait_ref.path.span,
13161316
item,
13171317
);
13181318
for obligation in &mut obligations {
13191319
if let Some(pred) = obligation.predicate.to_opt_poly_trait_pred()
13201320
&& pred.self_ty().skip_binder() == trait_ref.self_ty()
13211321
{
1322-
obligation.cause.span = ast_self_ty.span;
1322+
obligation.cause.span = hir_self_ty.span;
13231323
}
13241324
}
13251325
debug!(?obligations);
@@ -1333,7 +1333,7 @@ fn check_impl<'tcx>(
13331333
self_ty,
13341334
);
13351335
wfcx.register_wf_obligation(
1336-
ast_self_ty.span,
1336+
hir_self_ty.span,
13371337
Some(WellFormedLoc::Ty(item.hir_id().expect_owner().def_id)),
13381338
self_ty.into(),
13391339
);

0 commit comments

Comments
 (0)