Skip to content

Commit b79335d

Browse files
committed
Update local variables and tracing calls
Most of the tracing calls didn't fully leverage the power of `tracing`. For example, several of them used to hard-code method names / tracing spans as well as variable names. Use `#[instrument]` and `?var` / `%var` (etc.) instead. In my opinion, this is the proper way to migrate them from the old AstConv nomenclature to the new HIR ty lowering one.
1 parent 82c2c8d commit b79335d

File tree

11 files changed

+136
-148
lines changed

11 files changed

+136
-148
lines changed

compiler/rustc_hir_analysis/src/astconv/bounds.rs

+18-18
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
2424
&self,
2525
bounds: &mut Bounds<'tcx>,
2626
self_ty: Ty<'tcx>,
27-
ast_bounds: &'tcx [hir::GenericBound<'tcx>],
27+
hir_bounds: &'tcx [hir::GenericBound<'tcx>],
2828
self_ty_where_predicates: Option<(LocalDefId, &'tcx [hir::WherePredicate<'tcx>])>,
2929
span: Span,
3030
) {
@@ -35,9 +35,9 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
3535

3636
// Try to find an unbound in bounds.
3737
let mut unbounds: SmallVec<[_; 1]> = SmallVec::new();
38-
let mut search_bounds = |ast_bounds: &'tcx [hir::GenericBound<'tcx>]| {
39-
for ab in ast_bounds {
40-
let hir::GenericBound::Trait(ptr, modifier) = ab else {
38+
let mut search_bounds = |hir_bounds: &'tcx [hir::GenericBound<'tcx>]| {
39+
for hir_bound in hir_bounds {
40+
let hir::GenericBound::Trait(ptr, modifier) = hir_bound else {
4141
continue;
4242
};
4343
match modifier {
@@ -60,7 +60,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
6060
}
6161
}
6262
};
63-
search_bounds(ast_bounds);
63+
search_bounds(hir_bounds);
6464
if let Some((self_ty, where_clause)) = self_ty_where_predicates {
6565
for clause in where_clause {
6666
if let hir::WherePredicate::BoundPredicate(pred) = clause
@@ -109,34 +109,34 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
109109
///
110110
/// ```ignore (illustrative)
111111
/// fn foo<T>() where for<'a> T: Trait<'a> + Copy {}
112-
/// // ^^^^^^^ ^ ^^^^^^^^^^^^^^^^ `ast_bounds`, in HIR form
112+
/// // ^^^^^^^ ^ ^^^^^^^^^^^^^^^^ `hir_bounds`, in HIR form
113113
/// // | |
114114
/// // | `param_ty`, in ty form
115115
/// // `bound_vars`, in ty form
116116
///
117117
/// fn bar<T>() where T: for<'a> Trait<'a> + Copy {} // no overarching `bound_vars` here!
118-
/// // ^ ^^^^^^^^^^^^^^^^^^^^^^^^ `ast_bounds`, in HIR form
118+
/// // ^ ^^^^^^^^^^^^^^^^^^^^^^^^ `hir_bounds`, in HIR form
119119
/// // |
120120
/// // `param_ty`, in ty form
121121
/// ```
122122
///
123123
/// ### A Note on Binders
124124
///
125-
/// There is an implied binder around `param_ty` and `ast_bounds`.
125+
/// There is an implied binder around `param_ty` and `hir_bounds`.
126126
/// See `lower_poly_trait_ref` for more details.
127-
#[instrument(level = "debug", skip(self, ast_bounds, bounds))]
127+
#[instrument(level = "debug", skip(self, hir_bounds, bounds))]
128128
pub(crate) fn lower_poly_bounds<'hir, I: Iterator<Item = &'hir hir::GenericBound<'tcx>>>(
129129
&self,
130130
param_ty: Ty<'tcx>,
131-
ast_bounds: I,
131+
hir_bounds: I,
132132
bounds: &mut Bounds<'tcx>,
133133
bound_vars: &'tcx ty::List<ty::BoundVariableKind>,
134134
only_self_bounds: OnlySelfBounds,
135135
) where
136136
'tcx: 'hir,
137137
{
138-
for ast_bound in ast_bounds {
139-
match ast_bound {
138+
for hir_bound in hir_bounds {
139+
match hir_bound {
140140
hir::GenericBound::Trait(poly_trait_ref, modifier) => {
141141
let (constness, polarity) = match modifier {
142142
hir::TraitBoundModifier::Const => {
@@ -183,14 +183,14 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
183183
/// ### Example
184184
///
185185
/// ```ignore (illustrative)
186-
/// fn foo<T: Bar + Baz>() {}
187-
/// // ^ ^^^^^^^^^ ast_bounds
186+
/// fn foo<T: Bar + Baz>() { }
187+
/// // ^ ^^^^^^^^^ hir_bounds
188188
/// // param_ty
189189
/// ```
190190
pub(crate) fn lower_mono_bounds(
191191
&self,
192192
param_ty: Ty<'tcx>,
193-
ast_bounds: &[hir::GenericBound<'tcx>],
193+
hir_bounds: &[hir::GenericBound<'tcx>],
194194
filter: PredicateFilter,
195195
) -> Bounds<'tcx> {
196196
let mut bounds = Bounds::default();
@@ -204,7 +204,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
204204

205205
self.lower_poly_bounds(
206206
param_ty,
207-
ast_bounds.iter().filter(|bound| match filter {
207+
hir_bounds.iter().filter(|bound| match filter {
208208
PredicateFilter::All
209209
| PredicateFilter::SelfOnly
210210
| PredicateFilter::SelfAndAssociatedTypeBounds => true,
@@ -496,7 +496,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
496496
}
497497
// Lower a constraint like `Item: Debug` as found in HIR bound `T: Iterator<Item: Debug>`
498498
// to a bound involving a projection: `<T as Iterator>::Item: Debug`.
499-
hir::TypeBindingKind::Constraint { bounds: ast_bounds } => {
499+
hir::TypeBindingKind::Constraint { bounds: hir_bounds } => {
500500
// NOTE: If `only_self_bounds` is true, do NOT expand this associated type bound into
501501
// a trait predicate, since we only want to add predicates for the `Self` type.
502502
if !only_self_bounds.0 {
@@ -505,7 +505,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
505505
let param_ty = Ty::new_alias(tcx, ty::Projection, projection_ty.skip_binder());
506506
self.lower_poly_bounds(
507507
param_ty,
508-
ast_bounds.iter(),
508+
hir_bounds.iter(),
509509
bounds,
510510
projection_ty.bound_vars(),
511511
only_self_bounds,

0 commit comments

Comments
 (0)