diff options
| author | Ralf Jung <post@ralfj.de> | 2022-08-29 08:05:04 -0400 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2022-08-29 08:05:20 -0400 |
| commit | 8b53abd60208614f0ab8d85be022f59e55f2a3ce (patch) | |
| tree | 2e1bfbf704d29cd3cb9abd5cf720e8de1cc01d0b /compiler/rustc_const_eval/src | |
| parent | 7a42ca942cda0d197a63373127e7e373305957a0 (diff) | |
| download | rust-8b53abd60208614f0ab8d85be022f59e55f2a3ce.tar.gz rust-8b53abd60208614f0ab8d85be022f59e55f2a3ce.zip | |
interpret: fix unnecessary allocation in validation visitor
Diffstat (limited to 'compiler/rustc_const_eval/src')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/validity.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/validity.rs b/compiler/rustc_const_eval/src/interpret/validity.rs index 5f77c9b8892..2d096199e91 100644 --- a/compiler/rustc_const_eval/src/interpret/validity.rs +++ b/compiler/rustc_const_eval/src/interpret/validity.rs @@ -5,7 +5,7 @@ //! to be const-safe. use std::convert::TryFrom; -use std::fmt::Write; +use std::fmt::{Display, Write}; use std::num::NonZeroUsize; use rustc_ast::Mutability; @@ -308,7 +308,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, ' fn read_immediate( &self, op: &OpTy<'tcx, M::Provenance>, - expected: &str, + expected: impl Display, ) -> InterpResult<'tcx, ImmTy<'tcx, M::Provenance>> { Ok(try_validation!( self.ecx.read_immediate(op), @@ -321,7 +321,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, ' fn read_scalar( &self, op: &OpTy<'tcx, M::Provenance>, - expected: &str, + expected: impl Display, ) -> InterpResult<'tcx, Scalar<M::Provenance>> { Ok(self.read_immediate(op, expected)?.to_scalar()) } @@ -370,7 +370,8 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, ' value: &OpTy<'tcx, M::Provenance>, kind: &str, ) -> InterpResult<'tcx> { - let place = self.ecx.ref_to_mplace(&self.read_immediate(value, &format!("a {kind}"))?)?; + let place = + self.ecx.ref_to_mplace(&self.read_immediate(value, format_args!("a {kind}"))?)?; // Handle wide pointers. // Check metadata early, for better diagnostics if place.layout.is_unsized() { |
