Skip to content

Commit f23ebf0

Browse files
authored
Rollup merge of rust-lang#125483 - workingjubilee:move-transform-validate-to-mir-transform, r=oli-obk
compiler: validate.rs belongs next to what it validates It's hard to find code that is deeply nested and far away from its callsites, so let's move `rustc_const_eval::transform::validate` into `rustc_mir_transform`, where all of its callers are. As `rustc_mir_transform` already depends on `rustc_const_eval`, the added visible dependency edge doesn't mean the dependency tree got any worse. This also lets us unnest the `check_consts` module. I did look into moving everything inside `rustc_const_eval::transform` into `rustc_mir_transform`. It turned out to be a much more complex operation, with more concerns and real edges into the `const_eval` crate, whereas this was both faster and more obvious.
2 parents fafe13a + 14fc3fd commit f23ebf0

File tree

16 files changed

+9
-9
lines changed

16 files changed

+9
-9
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -4252,6 +4252,7 @@ dependencies = [
42524252
"rustc_fluent_macro",
42534253
"rustc_hir",
42544254
"rustc_index",
4255+
"rustc_infer",
42554256
"rustc_macros",
42564257
"rustc_middle",
42574258
"rustc_mir_build",

compiler/rustc_const_eval/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
#![feature(yeet_expr)]
1515
#![feature(if_let_guard)]
1616

17+
pub mod check_consts;
1718
pub mod const_eval;
1819
mod errors;
1920
pub mod interpret;
20-
pub mod transform;
2121
pub mod util;
2222

2323
use std::sync::atomic::AtomicBool;

compiler/rustc_const_eval/src/transform/mod.rs

-2
This file was deleted.

compiler/rustc_mir_transform/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ rustc_errors = { path = "../rustc_errors" }
1616
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
1717
rustc_hir = { path = "../rustc_hir" }
1818
rustc_index = { path = "../rustc_index" }
19+
rustc_infer = { path = "../rustc_infer" }
1920
rustc_macros = { path = "../rustc_macros" }
2021
rustc_middle = { path = "../rustc_middle" }
2122
rustc_mir_build = { path = "../rustc_mir_build" }

compiler/rustc_mir_transform/src/inline.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! Inlining pass for MIR functions
22
use crate::deref_separator::deref_finder;
33
use rustc_attr::InlineAttr;
4-
use rustc_const_eval::transform::validate::validate_types;
54
use rustc_hir::def::DefKind;
65
use rustc_hir::def_id::DefId;
76
use rustc_index::bit_set::BitSet;
@@ -21,6 +20,7 @@ use rustc_target::spec::abi::Abi;
2120
use crate::cost_checker::CostChecker;
2221
use crate::simplify::simplify_cfg;
2322
use crate::util;
23+
use crate::validate::validate_types;
2424
use std::iter;
2525
use std::ops::{Range, RangeFrom};
2626

compiler/rustc_mir_transform/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ mod simplify_comparison_integral;
109109
mod sroa;
110110
mod unreachable_enum_branching;
111111
mod unreachable_prop;
112+
mod validate;
112113

113-
use rustc_const_eval::transform::check_consts::{self, ConstCx};
114-
use rustc_const_eval::transform::validate;
114+
use rustc_const_eval::check_consts::{self, ConstCx};
115115
use rustc_mir_dataflow::rustc_peek;
116116

117117
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

compiler/rustc_mir_transform/src/promote_consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use std::assert_matches::assert_matches;
3030
use std::cell::Cell;
3131
use std::{cmp, iter, mem};
3232

33-
use rustc_const_eval::transform::check_consts::{qualifs, ConstCx};
33+
use rustc_const_eval::check_consts::{qualifs, ConstCx};
3434

3535
/// A `MirPass` for promotion.
3636
///

src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use clippy_config::msrvs::{self, Msrv};
77
use hir::LangItem;
88
use rustc_attr::StableSince;
9-
use rustc_const_eval::transform::check_consts::ConstCx;
9+
use rustc_const_eval::check_consts::ConstCx;
1010
use rustc_hir as hir;
1111
use rustc_hir::def_id::DefId;
1212
use rustc_infer::infer::TyCtxtInferExt;

src/tools/miri/tests/panic/mir-validation.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
thread 'rustc' panicked at compiler/rustc_const_eval/src/transform/validate.rs:LL:CC:
1+
thread 'rustc' panicked at compiler/rustc_mir_transform/src/validate.rs:LL:CC:
22
broken MIR in Item(DefId) (after phase change to runtime-optimized) at bb0[1]:
33
(*(_2.0: *mut i32)), has deref at the wrong place
44
stack backtrace:

0 commit comments

Comments
 (0)