Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0692db1

Browse files
committedSep 19, 2023
Auto merge of #115865 - RalfJung:mir-mod, r=oli-obk
move things out of mir/mod.rs This moves a bunch of things out of `mir/mod.rs`: - all const-related stuff to a new file consts.rs - all statement/place/operand-related stuff to a new file statement.rs - all pretty-printing related stuff to pretty.rs `mod.rs` started out with 3100 lines and ends up with 1600. :) Also there was some pretty-printing stuff in terminator.rs, that also got moved to pretty.rs, and I reordered things in pretty.rs so that it can be grouped by functionality. Only the commit "use pretty_print_const_value from MIR constant 'extra' printing" has any behavior changes; it resolves the issue of having a fancy and a very crude pretty-printer for `ConstValue`. r? `@oli-obk`
2 parents 8769c26 + d14e601 commit 0692db1

File tree

41 files changed

+2269
-2214
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2269
-2214
lines changed
 

‎compiler/rustc_const_eval/src/interpret/place.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@ use either::{Either, Left, Right};
99
use rustc_ast::Mutability;
1010
use rustc_index::IndexSlice;
1111
use rustc_middle::mir;
12-
use rustc_middle::mir::interpret::PointerArithmetic;
1312
use rustc_middle::ty;
1413
use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
1514
use rustc_middle::ty::Ty;
1615
use rustc_target::abi::{Abi, Align, FieldIdx, HasDataLayout, Size, FIRST_VARIANT};
1716

1817
use super::{
19-
alloc_range, mir_assign_valid_types, AllocId, AllocRef, AllocRefMut, CheckInAllocMsg,
20-
ConstAlloc, ImmTy, Immediate, InterpCx, InterpResult, Machine, MemoryKind, OpTy, Operand,
21-
Pointer, Projectable, Provenance, Readable, Scalar,
18+
alloc_range, mir_assign_valid_types, AllocId, AllocRef, AllocRefMut, CheckInAllocMsg, ImmTy,
19+
Immediate, InterpCx, InterpResult, Machine, MemoryKind, OpTy, Operand, Pointer,
20+
PointerArithmetic, Projectable, Provenance, Readable, Scalar,
2221
};
2322

2423
#[derive(Copy, Clone, Hash, PartialEq, Eq, Debug)]
@@ -1037,7 +1036,7 @@ where
10371036

10381037
pub fn raw_const_to_mplace(
10391038
&self,
1040-
raw: ConstAlloc<'tcx>,
1039+
raw: mir::ConstAlloc<'tcx>,
10411040
) -> InterpResult<'tcx, MPlaceTy<'tcx, M::Provenance>> {
10421041
// This must be an allocation in `tcx`
10431042
let _ = self.tcx.global_alloc(raw.alloc_id);

‎compiler/rustc_data_structures/src/lib.rs

+19
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ extern crate cfg_if;
4747
#[macro_use]
4848
extern crate rustc_macros;
4949

50+
use std::fmt;
51+
5052
pub use rustc_index::static_assert_size;
5153

5254
#[inline(never)]
@@ -126,6 +128,23 @@ impl<F: FnOnce()> Drop for OnDrop<F> {
126128
}
127129
}
128130

131+
/// Turns a closure that takes an `&mut Formatter` into something that can be display-formatted.
132+
pub fn make_display(f: impl Fn(&mut fmt::Formatter<'_>) -> fmt::Result) -> impl fmt::Display {
133+
struct Printer<F> {
134+
f: F,
135+
}
136+
impl<F> fmt::Display for Printer<F>
137+
where
138+
F: Fn(&mut fmt::Formatter<'_>) -> fmt::Result,
139+
{
140+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
141+
(self.f)(fmt)
142+
}
143+
}
144+
145+
Printer { f }
146+
}
147+
129148
// See comments in src/librustc_middle/lib.rs
130149
#[doc(hidden)]
131150
pub fn __noop_fix_for_27438() {}
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.