<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rust/compiler/rustc_middle/src/thir, branch try-perf</title>
<subtitle>https://github.com/rust-lang/rust
</subtitle>
<id>http://git.dreamy.place/mirrors/rust/atom?h=try-perf</id>
<link rel='self' href='http://git.dreamy.place/mirrors/rust/atom?h=try-perf'/>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/'/>
<updated>2025-07-01T13:53:50+00:00</updated>
<entry>
<title>loop match: run exhaustiveness check</title>
<updated>2025-07-01T13:53:50+00:00</updated>
<author>
<name>Folkert de Vries</name>
<email>folkert@folkertdev.nl</email>
</author>
<published>2025-07-01T13:29:09+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=aa7cc5d2f453853a4025cf029f3e42625c7e1e18'/>
<id>urn:sha1:aa7cc5d2f453853a4025cf029f3e42625c7e1e18</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Add `#[loop_match]` for improved DFA codegen</title>
<updated>2025-06-23T18:43:04+00:00</updated>
<author>
<name>bjorn3</name>
<email>17426603+bjorn3@users.noreply.github.com</email>
</author>
<published>2025-02-18T13:16:57+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=ba5556d239c11232dc8d95123ea70a2783019476'/>
<id>urn:sha1:ba5556d239c11232dc8d95123ea70a2783019476</id>
<content type='text'>
Co-authored-by: Folkert de Vries &lt;folkert@folkertdev.nl&gt;
</content>
</entry>
<entry>
<title>Improve some `Visitor` comments.</title>
<updated>2025-06-04T06:40:00+00:00</updated>
<author>
<name>Nicholas Nethercote</name>
<email>n.nethercote@gmail.com</email>
</author>
<published>2025-06-04T06:40:00+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=ed300d8ad881acc54f56a965e9c8f8a9e75a06d8'/>
<id>urn:sha1:ed300d8ad881acc54f56a965e9c8f8a9e75a06d8</id>
<content type='text'>
For AST/HIR/THIR visitors, explain the use of deconstruction.
</content>
</entry>
<entry>
<title>Deconstruct values in the THIR visitor</title>
<updated>2025-06-03T10:29:42+00:00</updated>
<author>
<name>ArtemIsmagilov</name>
<email>artem.ismagilov.2000@mail.ru</email>
</author>
<published>2025-06-02T15:32:02+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=ee99fba21d724c9db9b57aed1af03fa53b711dc4'/>
<id>urn:sha1:ee99fba21d724c9db9b57aed1af03fa53b711dc4</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Add `{ast,hir,thir}::PatKind::Missing` variants.</title>
<updated>2025-03-27T22:18:57+00:00</updated>
<author>
<name>Nicholas Nethercote</name>
<email>n.nethercote@gmail.com</email>
</author>
<published>2025-03-26T22:33:02+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=9f089e080c47bc282aa98f1e8c72ff44076afbb9'/>
<id>urn:sha1:9f089e080c47bc282aa98f1e8c72ff44076afbb9</id>
<content type='text'>
"Missing" patterns are possible in bare fn types (`fn f(u32)`) and
similar places. Currently these are represented in the AST with
`ast::PatKind::Ident` with no `by_ref`, no `mut`, an empty ident, and no
sub-pattern. This flows through to `{hir,thir}::PatKind::Binding` for
HIR and THIR.

This is a bit nasty. It's very non-obvious, and easy to forget to check
for the exceptional empty identifier case.

This commit adds a new variant, `PatKind::Missing`, to do it properly.

The process I followed:
- Add a `Missing` variant to `{ast,hir,thir}::PatKind`.
- Chang `parse_param_general` to produce `ast::PatKind::Missing`
  instead of `ast::PatKind::Missing`.
- Look through `kw::Empty` occurrences to find functions where an
  existing empty ident check needs replacing with a `PatKind::Missing`
  check: `print_param`, `check_trait_item`, `is_named_param`.
- Add a `PatKind::Missing =&gt; unreachable!(),` arm to every exhaustive
  match identified by the compiler.
- Find which arms are actually reachable by running the test suite,
  changing them to something appropriate, usually by looking at what
  would happen to a `PatKind::Ident`/`PatKind::Binding` with no ref, no
  `mut`, an empty ident, and no subpattern.

Quite a few of the `unreachable!()` arms were never reached. This makes
sense because `PatKind::Missing` can't happen in every pattern, only
in places like bare fn tys and trait fn decls.

I also tried an alternative approach: modifying `ast::Param::pat` to
hold an `Option&lt;P&lt;Pat&gt;&gt;` instead of a `P&lt;Pat&gt;`, but that quickly turned
into a very large and painful change. Adding `PatKind::Missing` is much
easier.
</content>
</entry>
<entry>
<title>Extract `for_each_immediate_subpat` from THIR pattern visitors</title>
<updated>2025-03-18T04:55:47+00:00</updated>
<author>
<name>Zalathar</name>
<email>Zalathar@users.noreply.github.com</email>
</author>
<published>2025-02-24T07:03:49+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=8bb8d74182c08df2c01eefaf856fb63af7c301c5'/>
<id>urn:sha1:8bb8d74182c08df2c01eefaf856fb63af7c301c5</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Implement .use keyword as an alias of clone</title>
<updated>2025-03-06T20:58:32+00:00</updated>
<author>
<name>Santiago Pastorino</name>
<email>spastorino@gmail.com</email>
</author>
<published>2024-10-02T19:35:37+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=05c516446a0f6105ce695da00d5cf5a0eb54e808'/>
<id>urn:sha1:05c516446a0f6105ce695da00d5cf5a0eb54e808</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Rollup merge of #137180 - compiler-errors:sym-regions, r=oli-obk</title>
<updated>2025-02-22T23:16:19+00:00</updated>
<author>
<name>Matthias Krüger</name>
<email>matthias.krueger@famsik.de</email>
</author>
<published>2025-02-22T23:16:19+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=4115f51d15015c83c29d69e21156445e12324690'/>
<id>urn:sha1:4115f51d15015c83c29d69e21156445e12324690</id>
<content type='text'>
Give `global_asm` a fake body to store typeck results, represent `sym fn` as a hir expr to fix `sym fn` operands with lifetimes

There are a few intertwined problems with `sym fn` operands in both inline and global asm macros.

Specifically, unlike other anon consts, they may evaluate to a type with free regions in them without actually having an item-level type annotation to give them a "proper" type. This is in contrast to named constants, which always have an item-level type annotation, or unnamed constants which are constrained by their position (e.g. a const arg in a turbofish, or a const array length).

Today, we infer the type of the operand by looking at the HIR typeck results; however, those results are region-erased, so during borrowck we ICE since we don't expect to encounter erased regions. We can't just fill this type with something like `'static`, since we may want to use real (free) regions:

```rust
fn foo&lt;'a&gt;() {
  asm!("/* ... */", sym bar::&lt;&amp;'a ()&gt;);
}
```

The first idea may be to represent `sym fn` operands using *inline* consts instead of anon consts. This makes sense, since inline consts can reference regions from the parent body (like the `'a` in the example above). However, this introduces a problem with `global_asm!`, which doesn't *have* a parent body; inline consts *must* be associated with a parent body since they are not a body owner of their own. In #116087, I attempted to fix this by using two separate `sym` operands for global and inline asm. However, this led to a lot of confusion and also some unattractive code duplication.

In this PR, I adjust the lowering of `global_asm!` so that it's lowered in a "fake" HIR body. This body contains a single expression which is `ExprKind::InlineAsm`; we don't *use* this HIR body, but it's used in typeck and borrowck so that we can properly infer and validate the the lifetimes of `sym fn` operands.

I then adjust the lowering of `sym fn` to instead be represented with a HIR expression. This is both because it's no longer necessary to represent this operand as an anon const, since it's *just* a path expression, and also more importantly to sidestep yet another ICE (https://github.com/rust-lang/rust/issues/137179), which has to do with the existing code breaking an invariant of def-id creation and anon consts. Specifically, we are not allowed to synthesize a def-id for an anon const when that anon const contains expressions with def-ids whose parent is *not* that anon const. This is somewhat related to https://github.com/rust-lang/rust/pull/130443#issuecomment-2445678945, which is also a place in the compiler where synthesizing anon consts leads to def-id parenting issue.

As a side-effect, this consolidates the type checking for inline and global asm, so it allows us to simplify `InlineAsmCtxt` a bit. It also allows us to delete a bit of hacky code from anon const `type_of` which was there to detect `sym fn` operands specifically. This also could be generalized to support `const` asm operands with types with lifetimes in them. Since we specifically reject these consts today, I'm not going to change the representation of those consts (but they'd just be turned into inline consts).

r? oli-obk -- mostly b/c you're patient and also understand the breadth of the code that this touches, please reassign if you don't want to review this.

Fixes #111709
Fixes #96304
Fixes #137179
</content>
</entry>
<entry>
<title>Fix binding mode problems</title>
<updated>2025-02-22T00:13:19+00:00</updated>
<author>
<name>Michael Goulet</name>
<email>michael@errs.io</email>
</author>
<published>2025-02-20T18:28:48+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=3d5438accdd111b4e507bbfae5e2df6062fb5689'/>
<id>urn:sha1:3d5438accdd111b4e507bbfae5e2df6062fb5689</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Make a fake body to store typeck results for global_asm</title>
<updated>2025-02-22T00:12:07+00:00</updated>
<author>
<name>Michael Goulet</name>
<email>michael@errs.io</email>
</author>
<published>2025-02-17T16:09:46+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=6ba39f7dc709a90bcb125974964a7e464ed86ff2'/>
<id>urn:sha1:6ba39f7dc709a90bcb125974964a7e464ed86ff2</id>
<content type='text'>
</content>
</entry>
</feed>
