<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rust/compiler/rustc_parse/src/parser/path.rs, branch 1.77.1</title>
<subtitle>https://github.com/rust-lang/rust
</subtitle>
<id>http://git.dreamy.place/mirrors/rust/atom?h=1.77.1</id>
<link rel='self' href='http://git.dreamy.place/mirrors/rust/atom?h=1.77.1'/>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/'/>
<updated>2024-01-09T20:40:00+00:00</updated>
<entry>
<title>Rename consuming chaining methods on `DiagnosticBuilder`.</title>
<updated>2024-01-09T20:40:00+00:00</updated>
<author>
<name>Nicholas Nethercote</name>
<email>n.nethercote@gmail.com</email>
</author>
<published>2024-01-08T22:08:49+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=ed76b0b882d0acff9295bcd76c2b119cf83e7219'/>
<id>urn:sha1:ed76b0b882d0acff9295bcd76c2b119cf83e7219</id>
<content type='text'>
In #119606 I added them and used a `_mv` suffix, but that wasn't great.

A `with_` prefix has three different existing uses.
- Constructors, e.g. `Vec::with_capacity`.
- Wrappers that provide an environment to execute some code, e.g.
  `with_session_globals`.
- Consuming chaining methods, e.g. `Span::with_{lo,hi,ctxt}`.

The third case is exactly what we want, so this commit changes
`DiagnosticBuilder::foo_mv` to `DiagnosticBuilder::with_foo`.

Thanks to @compiler-errors for the suggestion.
</content>
</entry>
<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 `ParseSess` methods that duplicate `DiagCtxt` methods.</title>
<updated>2023-12-23T20:59:21+00:00</updated>
<author>
<name>Nicholas Nethercote</name>
<email>n.nethercote@gmail.com</email>
</author>
<published>2023-12-18T10:14:02+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=d51db05d7ee1a12ee168f2d1ccc93ccc11b216c7'/>
<id>urn:sha1:d51db05d7ee1a12ee168f2d1ccc93ccc11b216c7</id>
<content type='text'>
Also add missing `#[track_caller]` attributes to `DiagCtxt` methods as
necessary to keep tests working.
</content>
</entry>
<entry>
<title>Remove `Parser` methods that duplicate `DiagCtxt` methods.</title>
<updated>2023-12-23T20:48:47+00:00</updated>
<author>
<name>Nicholas Nethercote</name>
<email>n.nethercote@gmail.com</email>
</author>
<published>2023-12-18T10:09:22+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=ec9af0d6cb6386c7be6056a71366d275d5ca3e1e'/>
<id>urn:sha1:ec9af0d6cb6386c7be6056a71366d275d5ca3e1e</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Auto merge of #119163 - fmease:refactor-ast-trait-bound-modifiers, r=compiler-errors</title>
<updated>2023-12-22T02:00:55+00:00</updated>
<author>
<name>bors</name>
<email>bors@rust-lang.org</email>
</author>
<published>2023-12-22T02:00:55+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=aaef5fe4971c42bae088b18e765339f3ec8853d0'/>
<id>urn:sha1:aaef5fe4971c42bae088b18e765339f3ec8853d0</id>
<content type='text'>
Refactor AST trait bound modifiers

Instead of having two types to represent trait bound modifiers in the parser / the AST (`parser::ty::BoundModifiers` &amp; `ast::TraitBoundModifier`), only to map one to the other later, just use `parser::ty::BoundModifiers` (moved &amp; renamed to `ast::TraitBoundModifiers`).

The struct type is more extensible and easier to deal with (see [here](https://github.com/rust-lang/rust/pull/119099/files#r1430749981) and [here](https://github.com/rust-lang/rust/pull/119099/files#r1430752116) for context) since it more closely models what it represents: A compound of two kinds of modifiers, constness and polarity. Modeling this as an enum (the now removed `ast::TraitBoundModifier`) meant one had to add a new variant per *combination* of modifier kind, which simply isn't scalable and which lead to a lot of explicit non-DRY matches.

NB: `hir::TraitBoundModifier` being an enum is fine since HIR doesn't need to worry representing invalid modifier kind combinations as those get rejected during AST validation thereby immensely cutting down the number of possibilities.
</content>
</entry>
<entry>
<title>Refactor AST trait bound modifiers</title>
<updated>2023-12-20T18:39:46+00:00</updated>
<author>
<name>León Orell Valerian Liehr</name>
<email>me@fmease.dev</email>
</author>
<published>2023-12-20T14:22:06+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=5e4f12b41a13d6adf883cfeae8a17724ea457faf'/>
<id>urn:sha1:5e4f12b41a13d6adf883cfeae8a17724ea457faf</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Use `.into_diagnostic()` less.</title>
<updated>2023-12-18T09:46:13+00:00</updated>
<author>
<name>Nicholas Nethercote</name>
<email>n.nethercote@gmail.com</email>
</author>
<published>2023-12-18T03:00:17+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=cea683c08f775f980e5e8de408ea3b47235329c7'/>
<id>urn:sha1:cea683c08f775f980e5e8de408ea3b47235329c7</id>
<content type='text'>
This commit replaces this pattern:
```
err.into_diagnostic(dcx)
```
with this pattern:
```
dcx.create_err(err)
```
in a lot of places.

It's a little shorter, makes the error level explicit, avoids some
`IntoDiagnostic` imports, and is a necessary prerequisite for the next
commit which will add a `level` arg to `into_diagnostic`.

This requires adding `track_caller` on `create_err` to avoid mucking up
the output of `tests/ui/track-diagnostics/track4.rs`. It probably should
have been there already.
</content>
</entry>
<entry>
<title>Rename `Parser::span_diagnostic` as `Parser::dcx`.</title>
<updated>2023-12-18T05:06:21+00:00</updated>
<author>
<name>Nicholas Nethercote</name>
<email>n.nethercote@gmail.com</email>
</author>
<published>2023-12-17T20:37:58+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=73bac456d413378b25210731c64eccc52c2201f7'/>
<id>urn:sha1:73bac456d413378b25210731c64eccc52c2201f7</id>
<content type='text'>
</content>
</entry>
<entry>
<title>More detail when expecting expression but encountering bad macro argument</title>
<updated>2023-11-16T16:19:04+00:00</updated>
<author>
<name>Esteban Küber</name>
<email>esteban@kuber.com.ar</email>
</author>
<published>2023-07-31T14:55:47+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=4e418805da5867bc48d82ba1cc7eff2ba68be575'/>
<id>urn:sha1:4e418805da5867bc48d82ba1cc7eff2ba68be575</id>
<content type='text'>
Partially address #71039.
</content>
</entry>
<entry>
<title>Minimize `pub` usage in `source_map.rs`.</title>
<updated>2023-11-02T08:35:00+00:00</updated>
<author>
<name>Nicholas Nethercote</name>
<email>n.nethercote@gmail.com</email>
</author>
<published>2023-11-02T03:10:12+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=f405ce86c2a5daab5972876e5b7600afdc308643'/>
<id>urn:sha1:f405ce86c2a5daab5972876e5b7600afdc308643</id>
<content type='text'>
Most notably, this commit changes the `pub use crate::*;` in that file
to `use crate::*;`. This requires a lot of `use` items in other crates
to be adjusted, because everything defined within `rustc_span::*` was
also available via `rustc_span::source_map::*`, which is bizarre.

The commit also removes `SourceMap::span_to_relative_line_string`, which
is unused.
</content>
</entry>
</feed>
