Skip to content

Commit 657c4da

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.
1 parent 4e7e8e7 commit 657c4da

File tree

11 files changed

+134
-146
lines changed

11 files changed

+134
-146
lines changed

compiler/rustc_hir_analysis/src/astconv/bounds.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
2121
&self,
2222
bounds: &mut Bounds<'tcx>,
2323
self_ty: Ty<'tcx>,
24-
ast_bounds: &'tcx [hir::GenericBound<'tcx>],
24+
hir_bounds: &'tcx [hir::GenericBound<'tcx>],
2525
self_ty_where_predicates: Option<(LocalDefId, &'tcx [hir::WherePredicate<'tcx>])>,
2626
span: Span,
2727
) {
@@ -32,9 +32,9 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
3232

3333
// Try to find an unbound in bounds.
3434
let mut unbounds: SmallVec<[_; 1]> = SmallVec::new();
35-
let mut search_bounds = |ast_bounds: &'tcx [hir::GenericBound<'tcx>]| {
36-
for ab in ast_bounds {
37-
let hir::GenericBound::Trait(ptr, modifier) = ab else {
35+
let mut search_bounds = |hir_bounds: &'tcx [hir::GenericBound<'tcx>]| {
36+
for hir_bound in hir_bounds {
37+
let hir::GenericBound::Trait(ptr, modifier) = hir_bound else {
3838
continue;
3939
};
4040
match modifier {
@@ -57,7 +57,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
5757
}
5858
}
5959
};
60-
search_bounds(ast_bounds);
60+
search_bounds(hir_bounds);
6161
if let Some((self_ty, where_clause)) = self_ty_where_predicates {
6262
for clause in where_clause {
6363
if let hir::WherePredicate::BoundPredicate(pred) = clause
@@ -106,28 +106,28 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
106106
///
107107
/// ```ignore (illustrative)
108108
/// fn foo<T: Debug>() { }
109-
/// // ^ ^^^^^ `ast_bounds`, in HIR form
109+
/// // ^ ^^^^^ `hir_bounds`, in HIR form
110110
/// // |
111111
/// // `param_ty`, in ty form
112112
/// ```
113113
///
114114
/// ### A Note on Binders
115115
///
116-
/// There is an implied binder around `param_ty` and `ast_bounds`.
116+
/// There is an implied binder around `param_ty` and `hir_bounds`.
117117
/// See `lower_poly_trait_ref` for more details.
118-
#[instrument(level = "debug", skip(self, ast_bounds, bounds))]
118+
#[instrument(level = "debug", skip(self, hir_bounds, bounds))]
119119
pub(crate) fn lower_poly_bounds<'hir, I: Iterator<Item = &'hir hir::GenericBound<'tcx>>>(
120120
&self,
121121
param_ty: Ty<'tcx>,
122-
ast_bounds: I,
122+
hir_bounds: I,
123123
bounds: &mut Bounds<'tcx>,
124124
bound_vars: &'tcx ty::List<ty::BoundVariableKind>,
125125
only_self_bounds: OnlySelfBounds,
126126
) where
127127
'tcx: 'hir,
128128
{
129-
for ast_bound in ast_bounds {
130-
match ast_bound {
129+
for hir_bound in hir_bounds {
130+
match hir_bound {
131131
hir::GenericBound::Trait(poly_trait_ref, modifier) => {
132132
let (constness, polarity) = match modifier {
133133
hir::TraitBoundModifier::Const => {
@@ -176,13 +176,13 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
176176
///
177177
/// ```ignore (illustrative)
178178
/// fn foo<T: Bar + Baz>() { }
179-
/// // ^ ^^^^^^^^^ ast_bounds
179+
/// // ^ ^^^^^^^^^ hir_bounds
180180
/// // param_ty
181181
/// ```
182182
pub(crate) fn lower_mono_bounds(
183183
&self,
184184
param_ty: Ty<'tcx>,
185-
ast_bounds: &[hir::GenericBound<'tcx>],
185+
hir_bounds: &[hir::GenericBound<'tcx>],
186186
filter: PredicateFilter,
187187
) -> Bounds<'tcx> {
188188
let mut bounds = Bounds::default();
@@ -196,7 +196,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
196196

197197
self.lower_poly_bounds(
198198
param_ty,
199-
ast_bounds.iter().filter(|bound| match filter {
199+
hir_bounds.iter().filter(|bound| match filter {
200200
PredicateFilter::All
201201
| PredicateFilter::SelfOnly
202202
| PredicateFilter::SelfAndAssociatedTypeBounds => true,
@@ -500,7 +500,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
500500
}
501501
// Lower a constraint like `Item: Debug` as found in HIR bound `T: Iterator<Item: Debug>`
502502
// to a bound involving a projection: `<T as Iterator>::Item: Debug`.
503-
hir::TypeBindingKind::Constraint { bounds: ast_bounds } => {
503+
hir::TypeBindingKind::Constraint { bounds: hir_bounds } => {
504504
// NOTE: If `only_self_bounds` is true, do NOT expand this associated type bound into
505505
// a trait predicate, since we only want to add predicates for the `Self` type.
506506
if !only_self_bounds.0 {
@@ -509,7 +509,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
509509
let param_ty = Ty::new_alias(tcx, ty::Projection, projection_ty.skip_binder());
510510
self.lower_poly_bounds(
511511
param_ty,
512-
ast_bounds.iter(),
512+
hir_bounds.iter(),
513513
bounds,
514514
projection_ty.bound_vars(),
515515
only_self_bounds,

0 commit comments

Comments
 (0)