Skip to content

Commit 522e0ac

Browse files
committed
Fix some comments.
- Remove comment about blanket implementation of `FallibleTypeFolder` -- it does not exist. (It probably used to.) - Fix some incorrect name references. - Fix minor grammatical errors. - Fix stale comment on `visit_region` -- it was a no-op once, but no longer. LLM disclosure: Claude Code identified these problems with comments when I asked it to review `fold.rs` and `visit.rs`. I verified the correctness of the problems and made the changes by hand.
1 parent ad3a598 commit 522e0ac

3 files changed

Lines changed: 10 additions & 14 deletions

File tree

compiler/rustc_type_ir/src/flags.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ bitflags::bitflags! {
139139
/// Does this type have any coroutines in it?
140140
const HAS_TY_CORO = 1 << 25;
141141

142-
/// Does this have have a `Bound(BoundVarIndexKind::Canonical, _)`?
142+
/// Does this have a `Bound(BoundVarIndexKind::Canonical, _)`?
143143
const HAS_CANONICAL_BOUND = 1 << 26;
144144
}
145145
}

compiler/rustc_type_ir/src/fold.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,6 @@ pub trait TypeSuperFoldable<I: Interner>: TypeFoldable<I> {
121121
/// default that does an "identity" fold. Implementations of these methods
122122
/// often fall back to a `super_fold_with` method if the primary argument
123123
/// doesn't satisfy a particular condition.
124-
///
125-
/// A blanket implementation of [`FallibleTypeFolder`] will defer to
126-
/// the infallible methods of this trait to ensure that the two APIs
127-
/// are coherent.
128124
pub trait TypeFolder<I: Interner>: Sized {
129125
fn cx(&self) -> I;
130126

@@ -477,10 +473,10 @@ where
477473
/// Folds over the substructure of a type, visiting its component
478474
/// types and all regions that occur *free* within it.
479475
///
480-
/// That is, function pointer types and trait object can introduce
481-
/// new bound regions which are not visited by this visitors as
476+
/// That is, function pointer types and trait objects can introduce
477+
/// new bound regions which are not visited by this visitor as
482478
/// they are not free; only regions that occur free will be
483-
/// visited by `fld_r`.
479+
/// visited by `fold_region_fn`.
484480
pub struct RegionFolder<I, F> {
485481
cx: I,
486482

@@ -489,7 +485,7 @@ pub struct RegionFolder<I, F> {
489485
/// binder, it is incremented (via `shift_in`).
490486
current_index: ty::DebruijnIndex,
491487

492-
/// Callback invokes for each free region. The `DebruijnIndex`
488+
/// Callback invoked for each free region. The `DebruijnIndex`
493489
/// points to the binder *just outside* the ones we have passed
494490
/// through.
495491
fold_region_fn: F,

compiler/rustc_type_ir/src/visit.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub trait TypeVisitable<I: Interner>: fmt::Debug {
6767
/// each field/element.
6868
///
6969
/// For types of interest (such as `Ty`), the implementation of this method
70-
/// that calls a visitor method specifically for that type (such as
70+
/// calls a visitor method specifically for that type (such as
7171
/// `V::visit_ty`). This is where control transfers from `TypeVisitable` to
7272
/// `TypeVisitor`.
7373
fn visit_with<V: TypeVisitor<I>>(&self, visitor: &mut V) -> V::Result;
@@ -102,8 +102,8 @@ pub trait TypeVisitor<I: Interner>: Sized {
102102
t.super_visit_with(self)
103103
}
104104

105-
// The default region visitor is a no-op because `Region` is non-recursive
106-
// and has no `super_visit_with` method to call.
105+
// `Region` is non-recursive so the default region visitor has no
106+
// `super_visit_with` method to call.
107107
fn visit_region(&mut self, r: I::Region) -> Self::Result {
108108
if let ty::ReError(guar) = r.kind() {
109109
self.visit_error(guar)
@@ -252,7 +252,7 @@ pub trait TypeVisitableExt<I: Interner>: TypeVisitable<I> {
252252
}
253253

254254
/// Return `true` if this type has regions that are not a part of the type.
255-
/// For example, `for<'a> fn(&'a i32)` return `false`, while `fn(&'a i32)`
255+
/// For example, `for<'a> fn(&'a i32)` returns `false`, while `fn(&'a i32)`
256256
/// would return `true`. The latter can occur when traversing through the
257257
/// former.
258258
///
@@ -571,7 +571,7 @@ impl<I: Interner> TypeVisitor<I> for HasEscapingVarsVisitor {
571571
// `outer_index`, that means that `ct` contains some content
572572
// bound at `outer_index` or above (because
573573
// `outer_exclusive_binder` is always 1 higher than the
574-
// content in `t`). Therefore, `t` has some escaping vars.
574+
// content in `ct`). Therefore, `ct` has some escaping vars.
575575
if ct.outer_exclusive_binder() > self.outer_index {
576576
ControlFlow::Break(FoundEscapingVars)
577577
} else {

0 commit comments

Comments
 (0)