<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rust/compiler/rustc_expand/src/module.rs, branch 1.77.0</title>
<subtitle>https://github.com/rust-lang/rust
</subtitle>
<id>http://git.dreamy.place/mirrors/rust/atom?h=1.77.0</id>
<link rel='self' href='http://git.dreamy.place/mirrors/rust/atom?h=1.77.0'/>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/'/>
<updated>2024-01-08T04:24:49+00:00</updated>
<entry>
<title>Make `DiagnosticBuilder::emit` consuming.</title>
<updated>2024-01-08T04:24:49+00:00</updated>
<author>
<name>Nicholas Nethercote</name>
<email>n.nethercote@gmail.com</email>
</author>
<published>2024-01-03T01:17:35+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=b1b9278851a9512a0c934c12f9c1800169c336f7'/>
<id>urn:sha1:b1b9278851a9512a0c934c12f9c1800169c336f7</id>
<content type='text'>
This works for most of its call sites. This is nice, because `emit` very
much makes sense as a consuming operation -- indeed,
`DiagnosticBuilderState` exists to ensure no diagnostic is emitted
twice, but it uses runtime checks.

For the small number of call sites where a consuming emit doesn't work,
the commit adds `DiagnosticBuilder::emit_without_consuming`. (This will
be removed in subsequent commits.)

Likewise, `emit_unless` becomes consuming. And `delay_as_bug` becomes
consuming, while `delay_as_bug_without_consuming` is added (which will
also be removed in subsequent commits.)

All this requires significant changes to `DiagnosticBuilder`'s chaining
methods. Currently `DiagnosticBuilder` method chaining uses a
non-consuming `&amp;mut self -&gt; &amp;mut Self` style, which allows chaining to
be used when the chain ends in `emit()`, like so:
```
    struct_err(msg).span(span).emit();
```
But it doesn't work when producing a `DiagnosticBuilder` value,
requiring this:
```
    let mut err = self.struct_err(msg);
    err.span(span);
    err
```
This style of chaining won't work with consuming `emit` though. For
that, we need to use to a `self -&gt; Self` style. That also would allow
`DiagnosticBuilder` production to be chained, e.g.:
```
    self.struct_err(msg).span(span)
```
However, removing the `&amp;mut self -&gt; &amp;mut Self` style would require that
individual modifications of a `DiagnosticBuilder` go from this:
```
    err.span(span);
```
to this:
```
    err = err.span(span);
```
There are *many* such places. I have a high tolerance for tedious
refactorings, but even I gave up after a long time trying to convert
them all.

Instead, this commit has it both ways: the existing `&amp;mut self -&gt; Self`
chaining methods are kept, and new `self -&gt; Self` chaining methods are
added, all of which have a `_mv` suffix (short for "move"). Changes to
the existing `forward!` macro lets this happen with very little
additional boilerplate code. I chose to add the suffix to the new
chaining methods rather than the existing ones, because the number of
changes required is much smaller that way.

This doubled chainging is a bit clumsy, but I think it is worthwhile
because it allows a *lot* of good things to subsequently happen. In this
commit, there are many `mut` qualifiers removed in places where
diagnostics are emitted without being modified. In subsequent commits:
- chaining can be used more, making the code more concise;
- more use of chaining also permits the removal of redundant diagnostic
  APIs like `struct_err_with_code`, which can be replaced easily with
  `struct_err` + `code_mv`;
- `emit_without_diagnostic` can be removed, which simplifies a lot of
  machinery, removing the need for `DiagnosticBuilderState`.
</content>
</entry>
<entry>
<title>Remove `Session` methods that duplicate `DiagCtxt` methods.</title>
<updated>2023-12-23T21:05:28+00:00</updated>
<author>
<name>Nicholas Nethercote</name>
<email>n.nethercote@gmail.com</email>
</author>
<published>2023-12-18T11:21:37+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=99472c7049783605444ab888a97059d0cce93a12'/>
<id>urn:sha1:99472c7049783605444ab888a97059d0cce93a12</id>
<content type='text'>
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier
access.
</content>
</entry>
<entry>
<title>Give `DiagnosticBuilder` a default type.</title>
<updated>2023-12-23T02:23:10+00:00</updated>
<author>
<name>Nicholas Nethercote</name>
<email>n.nethercote@gmail.com</email>
</author>
<published>2023-12-19T04:26:24+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=757d6f6ef8567ec846a62f16e3691b7555f2545f'/>
<id>urn:sha1:757d6f6ef8567ec846a62f16e3691b7555f2545f</id>
<content type='text'>
`IntoDiagnostic` defaults to `ErrorGuaranteed`, because errors are the
most common diagnostic level. It makes sense to do likewise for the
closely-related (and much more widely used) `DiagnosticBuilder` type,
letting us write `DiagnosticBuilder&lt;'a, ErrorGuaranteed&gt;` as just
`DiagnosticBuilder&lt;'a&gt;`. This cuts over 200 lines of code due to many
multi-line things becoming single line things.
</content>
</entry>
<entry>
<title>Fix `clippy::needless_borrow` in the compiler</title>
<updated>2023-11-21T19:13:40+00:00</updated>
<author>
<name>Nilstrieb</name>
<email>48135649+Nilstrieb@users.noreply.github.com</email>
</author>
<published>2023-11-21T19:07:32+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=21a870515b18e5b2b90435d0f1a6d3089b5217ae'/>
<id>urn:sha1:21a870515b18e5b2b90435d0f1a6d3089b5217ae</id>
<content type='text'>
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`.

Then I had to remove a few unnecessary parens and muts that were exposed
now.
</content>
</entry>
<entry>
<title>Format all the let chains in compiler</title>
<updated>2023-10-13T08:59:36+00:00</updated>
<author>
<name>Michael Goulet</name>
<email>michael@errs.io</email>
</author>
<published>2023-10-13T08:58:33+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=b2d2184edea578109a48ec3d8decbee5948e8f35'/>
<id>urn:sha1:b2d2184edea578109a48ec3d8decbee5948e8f35</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Use `ThinVec` in a few more AST types.</title>
<updated>2023-02-21T00:51:56+00:00</updated>
<author>
<name>Nicholas Nethercote</name>
<email>n.nethercote@gmail.com</email>
</author>
<published>2023-01-30T04:39:22+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=7e855d5f3112f59fea95c900297daff8d342056f'/>
<id>urn:sha1:7e855d5f3112f59fea95c900297daff8d342056f</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Migrate parts of `rustc_expand` to session diagnostics</title>
<updated>2022-12-10T10:02:41+00:00</updated>
<author>
<name>nils</name>
<email>48135649+Nilstrieb@users.noreply.github.com</email>
</author>
<published>2022-11-15T13:24:33+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=2f9f097cb8b6c27a7e0d7a916e6911fc1f5ecd81'/>
<id>urn:sha1:2f9f097cb8b6c27a7e0d7a916e6911fc1f5ecd81</id>
<content type='text'>
This migrates everything but the `mbe` and `proc_macro` modules. It also
contains a few cleanups and drive-by/accidental diagnostic improvements
which can be seen in the diff for the UI tests.
</content>
</entry>
<entry>
<title>Use `AttrVec` in more places.</title>
<updated>2022-08-21T21:35:33+00:00</updated>
<author>
<name>Nicholas Nethercote</name>
<email>n.nethercote@gmail.com</email>
</author>
<published>2022-08-17T02:34:33+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=619b8abaa65efd7fcc05453381e532ed8b716cf0'/>
<id>urn:sha1:619b8abaa65efd7fcc05453381e532ed8b716cf0</id>
<content type='text'>
In some places we use `Vec&lt;Attribute&gt;` and some places we use
`ThinVec&lt;Attribute&gt;` (a.k.a. `AttrVec`). This results in various points
where we have to convert between `Vec` and `ThinVec`.

This commit changes the places that use `Vec&lt;Attribute&gt;` to use
`AttrVec`. A lot of this is mechanical and boring, but there are
some interesting parts:
- It adds a few new methods to `ThinVec`.
- It implements `MapInPlace` for `ThinVec`, and introduces a macro to
  avoid the repetition of this trait for `Vec`, `SmallVec`, and
  `ThinVec`.

Overall, it makes the code a little nicer, and has little effect on
performance. But it is a precursor to removing
`rustc_data_structures::thin_vec::ThinVec` and replacing it with
`thin_vec::ThinVec`, which is implemented more efficiently.
</content>
</entry>
<entry>
<title>avoid some `Symbol` to `String` conversions</title>
<updated>2022-07-16T19:09:20+00:00</updated>
<author>
<name>Takayuki Maeda</name>
<email>takoyaki0316@gmail.com</email>
</author>
<published>2022-07-16T19:09:20+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=c54d4ada26c6a92346076bcc27d628398345ed9e'/>
<id>urn:sha1:c54d4ada26c6a92346076bcc27d628398345ed9e</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Remove `crate` visibility usage in compiler</title>
<updated>2022-05-21T00:04:54+00:00</updated>
<author>
<name>Jacob Pratt</name>
<email>jacob@jhpratt.dev</email>
</author>
<published>2022-05-20T23:51:09+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=49c82f31a85f04a709810de4ccfb8ba765c1377b'/>
<id>urn:sha1:49c82f31a85f04a709810de4ccfb8ba765c1377b</id>
<content type='text'>
</content>
</entry>
</feed>
