Skip to content

Rollup of 7 pull requests #141305

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
f4bc4cd
Add TRACING_ENABLED to Machine trait
Stypox May 12, 2025
29d97cd
Make some fns return `fmt::Result` to get rid of a few `unwrap`s
yotamofek May 20, 2025
7a68021
Replace some `unwrap`s with `?`s where possible
yotamofek May 20, 2025
8682dfc
Get rid of unnecessary `BufDisplay` abstraction
yotamofek May 20, 2025
7b5ea0e
use Self alias in self types rather than manually substituting it
compiler-errors May 20, 2025
b68ebd0
link tracking issue in explicit-extern-abis.md
ComputerDruid May 20, 2025
c506046
triagebot: ping me if rustdoc js is modified
lolbinarycat May 20, 2025
28db348
Add enter_trace_span!() that checks if tracing is enabled
Stypox May 13, 2025
f6709bb
`core_float_math`: Move functions to `math` folder
DJMcNab May 20, 2025
b8732aa
Fix pagetoc inactive color in rustc book
Urgau May 20, 2025
221d6c7
Rollup merge of #140972 - Stypox:machine-tracing-flag, r=RalfJung
matthiaskrgr May 20, 2025
8e1ce20
Rollup merge of #141282 - DJMcNab:core-float-math-math, r=tgross35
matthiaskrgr May 20, 2025
7412a7c
Rollup merge of #141288 - yotamofek:pr/rustdoc/nuke-bufdisplay, r=Gui…
matthiaskrgr May 20, 2025
c052d26
Rollup merge of #141289 - compiler-errors:more-self, r=jhpratt
matthiaskrgr May 20, 2025
a4a398d
Rollup merge of #141291 - ComputerDruid:patch-1, r=workingjubilee
matthiaskrgr May 20, 2025
74636b0
Rollup merge of #141294 - lolbinarycat:triagebot-js-ping, r=aDotInThe…
matthiaskrgr May 20, 2025
13f3f31
Rollup merge of #141303 - Urgau:pagetoc-fix-color, r=ehuss
matthiaskrgr May 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions compiler/rustc_const_eval/src/interpret/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ pub trait Machine<'tcx>: Sized {
/// already been checked before.
const ALL_CONSTS_ARE_PRECHECKED: bool = true;

/// Determines whether rustc_const_eval functions that make use of the [Machine] should make
/// tracing calls (to the `tracing` library). By default this is `false`, meaning the tracing
/// calls will supposedly be optimized out. This flag is set to `true` inside Miri, to allow
/// tracing the interpretation steps, among other things.
const TRACING_ENABLED: bool = false;

/// Whether memory accesses should be alignment-checked.
fn enforce_alignment(ecx: &InterpCx<'tcx, Self>) -> bool;

Expand Down
19 changes: 19 additions & 0 deletions compiler/rustc_const_eval/src/interpret/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,22 @@ pub(crate) fn create_static_alloc<'tcx>(
assert!(ecx.memory.alloc_map.insert(alloc_id, (MemoryKind::Stack, alloc)).is_none());
interp_ok(ecx.ptr_to_mplace(Pointer::from(alloc_id).into(), layout))
}

/// This struct is needed to enforce `#[must_use]` on [tracing::span::EnteredSpan]
/// while wrapping them in an `Option`.
#[must_use]
pub enum MaybeEnteredSpan {
Some(tracing::span::EnteredSpan),
None,
}

#[macro_export]
macro_rules! enter_trace_span {
($machine:ident, $($tt:tt)*) => {
if $machine::TRACING_ENABLED {
$crate::interpret::tracing_utils::MaybeEnteredSpan::Some(tracing::info_span!($($tt)*).entered())
} else {
$crate::interpret::tracing_utils::MaybeEnteredSpan::None
}
}
}
4 changes: 2 additions & 2 deletions library/alloc/src/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ impl str {
#[stable(feature = "str_box_extras", since = "1.20.0")]
#[must_use = "`self` will be dropped if the result is not used"]
#[inline]
pub fn into_boxed_bytes(self: Box<str>) -> Box<[u8]> {
pub fn into_boxed_bytes(self: Box<Self>) -> Box<[u8]> {
self.into()
}

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