Skip to content

Commit

Permalink
Improved comments for UserAssertTy statement.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtwco committed Mar 23, 2018
1 parent 3a0162b commit 4161ae7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
8 changes: 8 additions & 0 deletions src/librustc/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,14 @@ pub enum StatementKind<'tcx> {
///
/// Here we would insert a `UserAssertTy<(T, U)>(y)` instruction to check that the type of `y`
/// is the right thing.
///
/// `CanonicalTy` is used to capture "inference variables" from the user's types. For example:
///
/// let x: Vec<_> = ...;
/// let y: &u32 = ...;
///
/// would result in `Vec<?0>` and `&'?0 u32` respectively (where `?0` is a canonicalized
/// variable).
UserAssertTy(CanonicalTy<'tcx>, Local),

/// No-op. Useful for deleting instructions without affecting statement indices.
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,8 @@ pub struct TypeckTables<'tcx> {
/// method calls, including those of overloaded operators.
type_dependent_defs: ItemLocalMap<Def>,

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

/// Stores the types for various nodes in the AST. Note that this table
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_mir/build/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
})
}));
} else {
// FIXME: We currently only insert `UserAssertTy` statements for patterns
// that are bindings, this is as we do not want to deconstruct the type
// being assertion to match the pattern.
// FIXME(#47184): We currently only insert `UserAssertTy` statements for
// patterns that are bindings, this is as we do not want to deconstruct
// the type being assertion to match the pattern.
if let PatternKind::Binding { var, .. } = *pattern.kind {
if let Some(ty) = ty {
this.user_assert_ty(block, ty, var, span);
Expand Down

0 comments on commit 4161ae7

Please sign in to comment.