diff options
| author | bors <bors@rust-lang.org> | 2025-01-09 05:21:43 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-01-09 05:21:43 +0000 |
| commit | 65d7296fc9868af121adb5e07358a3815a80a7a1 (patch) | |
| tree | 8f8d05107e4da71372ddb2a8af2bca9a3591e562 /compiler/rustc_hir/src/hir.rs | |
| parent | e26ff2f9086fc449b963df578f8641c31846abe6 (diff) | |
| parent | afbd73559ff5505fbb349b2845eb1b823b44c049 (diff) | |
| download | rust-65d7296fc9868af121adb5e07358a3815a80a7a1.tar.gz rust-65d7296fc9868af121adb5e07358a3815a80a7a1.zip | |
Auto merge of #135277 - matthiaskrgr:rollup-0k61sf8, r=matthiaskrgr
Rollup of 6 pull requests
Successful merges:
- #128110 (Suggest Replacing Comma with Semicolon in Incorrect Repeat Expressions)
- #134609 (Add new `{x86_64,i686}-win7-windows-gnu` targets)
- #134875 (Implement `const Destruct` in old solver)
- #135221 (Include rustc and rustdoc book in replace-version-placeholder)
- #135231 (bootstrap: Add more comments to some of the test steps)
- #135256 (Move `mod cargo` below the import statements)
Failed merges:
- #135195 (Make `lit_to_mir_constant` and `lit_to_const` infallible)
r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_hir/src/hir.rs')
| -rw-r--r-- | compiler/rustc_hir/src/hir.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 951e95a6385..dd96b30fefc 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -7,7 +7,7 @@ use rustc_ast::token::CommentKind; use rustc_ast::util::parser::{AssocOp, ExprPrecedence}; use rustc_ast::{ self as ast, AttrId, AttrStyle, DelimArgs, FloatTy, InlineAsmOptions, InlineAsmTemplatePiece, - IntTy, Label, LitKind, MetaItemInner, MetaItemLit, TraitObjectSyntax, UintTy, + IntTy, Label, LitIntType, LitKind, MetaItemInner, MetaItemLit, TraitObjectSyntax, UintTy, }; pub use rustc_ast::{ BinOp, BinOpKind, BindingMode, BorrowKind, BoundConstness, BoundPolarity, ByRef, CaptureBy, @@ -2094,6 +2094,18 @@ impl Expr<'_> { } } + /// Check if expression is an integer literal that can be used + /// where `usize` is expected. + pub fn is_size_lit(&self) -> bool { + matches!( + self.kind, + ExprKind::Lit(Lit { + node: LitKind::Int(_, LitIntType::Unsuffixed | LitIntType::Unsigned(UintTy::Usize)), + .. + }) + ) + } + /// If `Self.kind` is `ExprKind::DropTemps(expr)`, drill down until we get a non-`DropTemps` /// `Expr`. This is used in suggestions to ignore this `ExprKind` as it is semantically /// silent, only signaling the ownership system. By doing this, suggestions that check the |
