Skip to content

Commit d805b26

Browse files
committed
add some comments explaining why MIR opts are marked as unsound
1 parent 2de4546 commit d805b26

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

Diff for: compiler/rustc_mir_transform/src/early_otherwise_branch.rs

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ pub struct EarlyOtherwiseBranch;
9595

9696
impl<'tcx> MirPass<'tcx> for EarlyOtherwiseBranch {
9797
fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
98+
// unsound: https://github.com/rust-lang/rust/issues/95162
9899
sess.mir_opt_level() >= 3 && sess.opts.unstable_opts.unsound_mir_opts
99100
}
100101

Diff for: compiler/rustc_mir_transform/src/large_enums.rs

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ pub struct EnumSizeOpt {
3030

3131
impl<'tcx> MirPass<'tcx> for EnumSizeOpt {
3232
fn is_enabled(&self, sess: &Session) -> bool {
33+
// There are some differences in behavior on wasm and ARM that are not properly
34+
// understood, so we conservatively treat this optimization as unsound:
35+
// https://github.com/rust-lang/rust/pull/85158#issuecomment-1101836457
3336
sess.opts.unstable_opts.unsound_mir_opts || sess.mir_opt_level() >= 3
3437
}
3538
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {

Diff for: compiler/rustc_mir_transform/src/nrvo.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub struct RenameReturnPlace;
3434

3535
impl<'tcx> MirPass<'tcx> for RenameReturnPlace {
3636
fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
37-
// #111005
37+
// unsound: #111005
3838
sess.mir_opt_level() > 0 && sess.opts.unstable_opts.unsound_mir_opts
3939
}
4040

0 commit comments

Comments
 (0)