<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rust/compiler/rustc_const_eval/src/interpret/validity.rs, branch beta</title>
<subtitle>https://github.com/rust-lang/rust
</subtitle>
<id>http://git.dreamy.place/mirrors/rust/atom?h=beta</id>
<link rel='self' href='http://git.dreamy.place/mirrors/rust/atom?h=beta'/>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/'/>
<updated>2025-08-19T11:42:09+00:00</updated>
<entry>
<title>Rollup merge of #145306 - Stypox:tracing-misc, r=RalfJung</title>
<updated>2025-08-19T11:42:09+00:00</updated>
<author>
<name>许杰友 Jieyou Xu (Joe)</name>
<email>39484203+jieyouxu@users.noreply.github.com</email>
</author>
<published>2025-08-19T11:42:09+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=ba20d77a444a7125a764e9d69024c6377023b45f'/>
<id>urn:sha1:ba20d77a444a7125a764e9d69024c6377023b45f</id>
<content type='text'>
Add tracing to various miscellaneous functions

This PR adds tracing to:
- `ty.fn_sig()`. There is only one place where `fn_sig` is called for real within `rustc_const_eval`. There are three other places where it's called, but one is inside `ConstCx::fn_sig` (which does not seem to be used anywhere), another is under `if cfg!(debug_assertions)`, and the last is within `call_main` and thus gets called only once.
- the two possible things `find_mir_or_eval_fn` can do: "emulate_foreign_item" and "load_mir"
- all calls to `Const.eval()` within the Miri or the `rustc_const_eval` codebase.
- a separate commit also fixes the style of some tracing macros

Those are all quite long-lived operations, that in total make up for 6-7% of the total time spent in the program. I found out about them by looking for long periods of time that were previously not traced at all, using this SQL query in ui.perfetto.dev:

```sql
with ordered as (select s1.*, row_number() over (order by s1.ts) as rn from slices as s1 where s1.parent_id is null and s1.dur &gt; 0 and s1.name != "frame" and s1.name != "step" and s1.name != "backtrace") select a.ts+a.dur as ts, b.ts-a.ts-a.dur as dur, a.id, a.track_id, a.category, a.depth, a.stack_id, a.parent_stack_id, a.parent_id, a.arg_set_id, a.thread_ts, a.thread_instruction_count, a.thread_instruction_delta, a.cat, a.slice_id, "empty" as name from ordered as a inner join ordered as b on a.rn=b.rn-1 /*where b.ts-a.ts-a.dur &gt; 5000*/ order by b.ts-a.ts-a.dur desc
```

&lt;details&gt;
&lt;summary&gt;How the table was obtained&lt;/summary&gt;

The above image was obtained in ui.perfetto.dev with the following SQL query after obtaining a trace file by running Miri on the following Rust code with `n=100`.

```sql
select "TOTAL PROGRAM DURATION" as name, count(*), max(ts + dur) as "sum(dur)", 100.0 as "%", null as "min(dur)", null as "max(dur)", null as "avg(dur)", null as "stddev(dur)" from slices union select "TOTAL OVER ALL SPANS (excluding events)" as name, count(*), sum(dur), cast(cast(sum(dur) as float) / (select max(ts + dur) from slices) * 1000 as int) / 10.0 as "%", min(dur), max(dur), cast(avg(dur) as int) as "avg(dur)", cast(sqrt(avg(dur*dur)-avg(dur)*avg(dur)) as int) as "stddev(dur)" from slices where parent_id is null and name != "frame" and name != "step" and dur &gt; 0 union select name, count(*), sum(dur), cast(cast(sum(dur) as float) / (select max(ts + dur) from slices) * 1000 as int) / 10.0 as "%", min(dur), max(dur), cast(avg(dur) as int) as "avg(dur)", cast(sqrt(avg(dur*dur)-avg(dur)*avg(dur)) as int) as "stddev(dur)" from slices where parent_id is null and name != "frame" and name != "step" group by name order by sum(dur) desc, count(*) desc
```

```rust
fn main() {
    let n: usize = std::env::args().nth(1).unwrap().parse().unwrap();
    let mut v = (0..n).into_iter().collect::&lt;Vec&lt;_&gt;&gt;();
    for i in &amp;mut v {
        *i += 1;
    }
}
```

&lt;/details&gt;

&lt;img width="1689" height="317" alt="image" src="https://github.com/user-attachments/assets/ee2c81f5-d74a-4da5-b4b6-ab2770175b14" /&gt;
</content>
</entry>
<entry>
<title>Add tracing to various miscellaneous functions</title>
<updated>2025-08-18T19:43:27+00:00</updated>
<author>
<name>Stypox</name>
<email>stypox@pm.me</email>
</author>
<published>2025-08-12T10:16:43+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=dc72692591c937e15cb016c57d4dee6a81340bbd'/>
<id>urn:sha1:dc72692591c937e15cb016c57d4dee6a81340bbd</id>
<content type='text'>
Also use tracing macro syntax instead of format()
</content>
</entry>
<entry>
<title>Auto merge of #144081 - RalfJung:const-ptr-fragments, r=oli-obk</title>
<updated>2025-08-17T04:33:31+00:00</updated>
<author>
<name>bors</name>
<email>bors@rust-lang.org</email>
</author>
<published>2025-08-17T04:33:31+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=99ba5565678a51c2488322a5e75d5b59e323b498'/>
<id>urn:sha1:99ba5565678a51c2488322a5e75d5b59e323b498</id>
<content type='text'>
const-eval: full support for pointer fragments

This fixes https://github.com/rust-lang/const-eval/issues/72 and makes `swap_nonoverlapping` fully work in const-eval by enhancing per-byte provenance tracking with tracking of *which* of the bytes of the pointer this one is. Later, if we see all the same bytes in the exact same order, we can treat it like a whole pointer again without ever risking a leak of the data bytes (that encode the offset into the allocation). This lifts the limitation that was discussed quite a bit in https://github.com/rust-lang/rust/pull/137280.

For a concrete piece of code that used to fail and now works properly consider this example doing a byte-for-byte memcpy in const without using intrinsics:
```rust
use std::{mem::{self, MaybeUninit}, ptr};

type Byte = MaybeUninit&lt;u8&gt;;

const unsafe fn memcpy(dst: *mut Byte, src: *const Byte, n: usize) {
    let mut i = 0;
    while i &lt; n {
        *dst.add(i) = *src.add(i);
        i += 1;
    }
}

const _MEMCPY: () = unsafe {
    let ptr = &amp;42;
    let mut ptr2 = ptr::null::&lt;i32&gt;();
    // Copy from ptr to ptr2.
    memcpy(&amp;mut ptr2 as *mut _ as *mut _, &amp;ptr as *const _ as *const _, mem::size_of::&lt;&amp;i32&gt;());
    assert!(*ptr2 == 42);
};
```
What makes this code tricky is that pointers are "opaque blobs" in const-eval, we cannot just let people look at the individual bytes since *we don't know what those bytes look like* -- that depends on the absolute address the pointed-to object will be placed at. The code above "breaks apart" a pointer into individual bytes, and then puts them back together in the same order elsewhere. This PR implements the logic to properly track how those individual bytes relate to the original pointer, and to recognize when they are in the right order again.

We still reject constants where the final value contains a not-fully-put-together pointer: I have no idea how one could construct an LLVM global where one byte is defined as "the 3rd byte of a pointer to that other global over there" -- and even if LLVM supports this somehow, we can leave implementing that to a future PR. It seems unlikely to me anyone would even want this, but who knows.^^

This also changes the behavior of Miri, by tracking the order of bytes with provenance and only considering a pointer to have valid provenance if all bytes are in the original order again. This is related to https://github.com/rust-lang/unsafe-code-guidelines/issues/558. It means one cannot implement XOR linked lists with strict provenance any more, which is however only of theoretical interest. Practically I am curious if anyone will show up with any code that Miri now complains about - that would be interesting data. Cc `@rust-lang/opsem`
</content>
</entry>
<entry>
<title>Turn _span into _trace as trace span name</title>
<updated>2025-08-11T12:45:46+00:00</updated>
<author>
<name>Stypox</name>
<email>stypox@pm.me</email>
</author>
<published>2025-08-11T12:45:46+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=cd4676c40dad98fffb3910854454e58303370f0a'/>
<id>urn:sha1:cd4676c40dad98fffb3910854454e58303370f0a</id>
<content type='text'>
_span could possibly be confused with the Span type in rustc
</content>
</entry>
<entry>
<title>const-eval: full support for pointer fragments</title>
<updated>2025-07-30T06:13:58+00:00</updated>
<author>
<name>Ralf Jung</name>
<email>post@ralfj.de</email>
</author>
<published>2025-07-17T18:00:19+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=ba5b6b9ec472dc32bdaa8b18c22d30bd6abf7ebc'/>
<id>urn:sha1:ba5b6b9ec472dc32bdaa8b18c22d30bd6abf7ebc</id>
<content type='text'>
</content>
</entry>
<entry>
<title>use let chains in ast, borrowck, codegen, const_eval</title>
<updated>2025-07-28T01:08:48+00:00</updated>
<author>
<name>Kivooeo</name>
<email>Kivooeo123@gmail.com</email>
</author>
<published>2025-07-26T01:21:22+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=43725ed819c57b86b32a66c40572246b1f5b8952'/>
<id>urn:sha1:43725ed819c57b86b32a66c40572246b1f5b8952</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Report the range of uninit bytes in CTFE errors</title>
<updated>2025-07-17T20:00:51+00:00</updated>
<author>
<name>Oli Scherer</name>
<email>github333195615777966@oli-obk.de</email>
</author>
<published>2025-06-18T12:51:47+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=12eedafc38b1d3af02c9c15333d0ba2f1aee1253'/>
<id>urn:sha1:12eedafc38b1d3af02c9c15333d0ba2f1aee1253</id>
<content type='text'>
</content>
</entry>
<entry>
<title>const heap: fix ICE on forgotten make_global</title>
<updated>2025-07-16T13:29:52+00:00</updated>
<author>
<name>Ralf Jung</name>
<email>post@ralfj.de</email>
</author>
<published>2025-07-16T13:11:11+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=8f854d9cb2d108a2d4f980ccb4d5909e214e6ef0'/>
<id>urn:sha1:8f854d9cb2d108a2d4f980ccb4d5909e214e6ef0</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Add opaque TypeId handles for CTFE</title>
<updated>2025-07-09T16:37:11+00:00</updated>
<author>
<name>Oli Scherer</name>
<email>github333195615777966@oli-obk.de</email>
</author>
<published>2025-03-12T10:26:37+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=486ffda9dcd0d4ef0a09d81e6ce5f241e77526a1'/>
<id>urn:sha1:486ffda9dcd0d4ef0a09d81e6ce5f241e77526a1</id>
<content type='text'>
</content>
</entry>
<entry>
<title>setup CI and tidy to use typos for spellchecking and fix few typos</title>
<updated>2025-07-03T07:51:06+00:00</updated>
<author>
<name>klensy</name>
<email>klensy@users.noreply.github.com</email>
</author>
<published>2024-12-07T10:51:08+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=c76d032f0144b650a438ee1efba89c475e0b115b'/>
<id>urn:sha1:c76d032f0144b650a438ee1efba89c475e0b115b</id>
<content type='text'>
</content>
</entry>
</feed>
