Skip to content

Commit 4161ae7

Browse files
committed
Improved comments for UserAssertTy statement.
1 parent 3a0162b commit 4161ae7

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

src/librustc/mir/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1260,6 +1260,14 @@ pub enum StatementKind<'tcx> {
12601260
///
12611261
/// Here we would insert a `UserAssertTy<(T, U)>(y)` instruction to check that the type of `y`
12621262
/// is the right thing.
1263+
///
1264+
/// `CanonicalTy` is used to capture "inference variables" from the user's types. For example:
1265+
///
1266+
/// let x: Vec<_> = ...;
1267+
/// let y: &u32 = ...;
1268+
///
1269+
/// would result in `Vec<?0>` and `&'?0 u32` respectively (where `?0` is a canonicalized
1270+
/// variable).
12631271
UserAssertTy(CanonicalTy<'tcx>, Local),
12641272

12651273
/// No-op. Useful for deleting instructions without affecting statement indices.

src/librustc/ty/context.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,8 @@ pub struct TypeckTables<'tcx> {
345345
/// method calls, including those of overloaded operators.
346346
type_dependent_defs: ItemLocalMap<Def>,
347347

348-
/// Stores the canonicalized types provided by the user.
348+
/// Stores the canonicalized types provided by the user. See also `UserAssertTy` statement in
349+
/// MIR.
349350
user_provided_tys: ItemLocalMap<CanonicalTy<'tcx>>,
350351

351352
/// Stores the types for various nodes in the AST. Note that this table

src/librustc_mir/build/block.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
125125
})
126126
}));
127127
} else {
128-
// FIXME: We currently only insert `UserAssertTy` statements for patterns
129-
// that are bindings, this is as we do not want to deconstruct the type
130-
// being assertion to match the pattern.
128+
// FIXME(#47184): We currently only insert `UserAssertTy` statements for
129+
// patterns that are bindings, this is as we do not want to deconstruct
130+
// the type being assertion to match the pattern.
131131
if let PatternKind::Binding { var, .. } = *pattern.kind {
132132
if let Some(ty) = ty {
133133
this.user_assert_ty(block, ty, var, span);

0 commit comments

Comments
 (0)