Skip to content

Commit 8a8b357

Browse files
committed
Auto merge of #3709 - RalfJung:docs-clarifications, r=saethlin
clarify the warning shown when optimizations are enabled, and the status of Tree Borrows
2 parents 4f8dc8f + ba61c8f commit 8a8b357

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/tools/miri/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,12 @@ to Miri failing to detect cases of undefined behavior in a program.
425425
value from a load. This can help diagnose problems that disappear under
426426
`-Zmiri-disable-weak-memory-emulation`.
427427
* `-Zmiri-tree-borrows` replaces [Stacked Borrows] with the [Tree Borrows] rules.
428-
The soundness rules are already experimental without this flag, but even more
429-
so with this flag.
428+
Tree Borrows is even more experimental than Stacked Borrows. While Tree Borrows
429+
is still sound in the sense of catching all aliasing violations that current versions
430+
of the compiler might exploit, it is likely that the eventual final aliasing model
431+
of Rust will be stricter than Tree Borrows. In other words, if you use Tree Borrows,
432+
even if your code is accepted today, it might be declared UB in the future.
433+
This is much less likely with Stacked Borrows.
430434
* `-Zmiri-force-page-size=<num>` overrides the default page size for an architecture, in multiples of 1k.
431435
`4` is default for most targets. This value should always be a power of 2 and nonzero.
432436
* `-Zmiri-unique-is-unique` performs additional aliasing checks for `core::ptr::Unique` to ensure

src/tools/miri/src/bin/miri.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,9 @@ impl rustc_driver::Callbacks for MiriCompilerCalls {
9898
}
9999

100100
if tcx.sess.opts.optimize != OptLevel::No {
101-
tcx.dcx().warn("Miri does not support optimizations. If you have enabled optimizations \
102-
by selecting a Cargo profile (such as --release) which changes other profile settings \
103-
such as whether debug assertions and overflow checks are enabled, those settings are \
104-
still applied.");
101+
tcx.dcx().warn("Miri does not support optimizations: the opt-level is ignored. The only effect \
102+
of selecting a Cargo profile that enables optimizations (such as --release) is to apply \
103+
its remaining settings, such as whether debug assertions and overflow checks are enabled.");
105104
}
106105
if tcx.sess.mir_opt_level() > 0 {
107106
tcx.dcx().warn("You have explicitly enabled MIR optimizations, overriding Miri's default \

0 commit comments

Comments
 (0)