Skip to content

Commit 2b96ddc

Browse files
committed
Auto merge of rust-lang#141305 - matthiaskrgr:rollup-l6nwaht, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#140972 (Add TRACING_ENABLED to Machine and add enter_trace_span!()) - rust-lang#141282 (`core_float_math`: Move functions to `math` module) - rust-lang#141288 (Get rid of unnecessary `BufDisplay` abstraction) - rust-lang#141289 (use `Self` alias in self types rather than manually substituting it) - rust-lang#141291 (link tracking issue in explicit-extern-abis.md) - rust-lang#141294 (triagebot: ping me if rustdoc js is modified) - rust-lang#141303 (Fix pagetoc inactive color in rustc book) r? `@ghost` `@rustbot` modify labels: rollup
2 parents bc82152 + 13f3f31 commit 2b96ddc

File tree

20 files changed

+1064
-995
lines changed

20 files changed

+1064
-995
lines changed

compiler/rustc_const_eval/src/interpret/machine.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,12 @@ pub trait Machine<'tcx>: Sized {
147147
/// already been checked before.
148148
const ALL_CONSTS_ARE_PRECHECKED: bool = true;
149149

150+
/// Determines whether rustc_const_eval functions that make use of the [Machine] should make
151+
/// tracing calls (to the `tracing` library). By default this is `false`, meaning the tracing
152+
/// calls will supposedly be optimized out. This flag is set to `true` inside Miri, to allow
153+
/// tracing the interpretation steps, among other things.
154+
const TRACING_ENABLED: bool = false;
155+
150156
/// Whether memory accesses should be alignment-checked.
151157
fn enforce_alignment(ecx: &InterpCx<'tcx, Self>) -> bool;
152158

compiler/rustc_const_eval/src/interpret/util.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,22 @@ pub(crate) fn create_static_alloc<'tcx>(
4545
assert!(ecx.memory.alloc_map.insert(alloc_id, (MemoryKind::Stack, alloc)).is_none());
4646
interp_ok(ecx.ptr_to_mplace(Pointer::from(alloc_id).into(), layout))
4747
}
48+
49+
/// This struct is needed to enforce `#[must_use]` on [tracing::span::EnteredSpan]
50+
/// while wrapping them in an `Option`.
51+
#[must_use]
52+
pub enum MaybeEnteredSpan {
53+
Some(tracing::span::EnteredSpan),
54+
None,
55+
}
56+
57+
#[macro_export]
58+
macro_rules! enter_trace_span {
59+
($machine:ident, $($tt:tt)*) => {
60+
if $machine::TRACING_ENABLED {
61+
$crate::interpret::tracing_utils::MaybeEnteredSpan::Some(tracing::info_span!($($tt)*).entered())
62+
} else {
63+
$crate::interpret::tracing_utils::MaybeEnteredSpan::None
64+
}
65+
}
66+
}

library/alloc/src/str.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ impl str {
234234
#[stable(feature = "str_box_extras", since = "1.20.0")]
235235
#[must_use = "`self` will be dropped if the result is not used"]
236236
#[inline]
237-
pub fn into_boxed_bytes(self: Box<str>) -> Box<[u8]> {
237+
pub fn into_boxed_bytes(self: Box<Self>) -> Box<[u8]> {
238238
self.into()
239239
}
240240

@@ -501,7 +501,7 @@ impl str {
501501
#[rustc_allow_incoherent_impl]
502502
#[must_use = "`self` will be dropped if the result is not used"]
503503
#[inline]
504-
pub fn into_string(self: Box<str>) -> String {
504+
pub fn into_string(self: Box<Self>) -> String {
505505
let slice = Box::<[u8]>::from(self);
506506
unsafe { String::from_utf8_unchecked(slice.into_vec()) }
507507
}

0 commit comments

Comments
 (0)