<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rust/compiler/rustc_hir_analysis/src/structured_errors, branch 1.77.2</title>
<subtitle>https://github.com/rust-lang/rust
</subtitle>
<id>http://git.dreamy.place/mirrors/rust/atom?h=1.77.2</id>
<link rel='self' href='http://git.dreamy.place/mirrors/rust/atom?h=1.77.2'/>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/'/>
<updated>2024-01-28T20:41:41+00:00</updated>
<entry>
<title>Stop using `String` for error codes.</title>
<updated>2024-01-28T20:41:41+00:00</updated>
<author>
<name>Nicholas Nethercote</name>
<email>n.nethercote@gmail.com</email>
</author>
<published>2024-01-13T23:57:07+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=5d9dfbd08f38c2a9bc71d39de8f5c7776afe0f9e'/>
<id>urn:sha1:5d9dfbd08f38c2a9bc71d39de8f5c7776afe0f9e</id>
<content type='text'>
Error codes are integers, but `String` is used everywhere to represent
them. Gross!

This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.

With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123)  // macro call

struct_span_code_err!(dcx, span, E0123, "msg");  // bare ident arg to macro call

\#[diag(name, code = "E0123")]  // string
struct Diag;
```

With the new code, they all use the `E0123` constant.
```
E0123  // constant

struct_span_code_err!(dcx, span, E0123, "msg");  // constant

\#[diag(name, code = E0123)]  // constant
struct Diag;
```

The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
  used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
  moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
  code constants and the `DIAGNOSTIC_TABLES`. This is in its new
  `codes.rs` file.
</content>
</entry>
<entry>
<title>Rework how diagnostic lints are stored.</title>
<updated>2024-01-14T03:04:25+00:00</updated>
<author>
<name>Nicholas Nethercote</name>
<email>n.nethercote@gmail.com</email>
</author>
<published>2024-01-13T02:11:56+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=d71f535a6f39e82313b46ac3157c4ed9267a2e40'/>
<id>urn:sha1:d71f535a6f39e82313b46ac3157c4ed9267a2e40</id>
<content type='text'>
`Diagnostic::code` has the type `DiagnosticId`, which has `Error` and
`Lint` variants. Plus `Diagnostic::is_lint` is a bool, which should be
redundant w.r.t. `Diagnostic::code`.

Seems simple. Except it's possible for a lint to have an error code, in
which case its `code` field is recorded as `Error`, and `is_lint` is
required to indicate that it's a lint. This is what happens with
`derive(LintDiagnostic)` lints. Which means those lints don't have a
lint name or a `has_future_breakage` field because those are stored in
the `DiagnosticId::Lint`.

It's all a bit messy and confused and seems unintentional.

This commit:
- removes `DiagnosticId`;
- changes `Diagnostic::code` to `Option&lt;String&gt;`, which means both
  errors and lints can straightforwardly have an error code;
- changes `Diagnostic::is_lint` to `Option&lt;IsLint&gt;`, where `IsLint` is a
  new type containing a lint name and a `has_future_breakage` bool, so
  all lints can have those, error code or not.
</content>
</entry>
<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>Remove all eight `DiagnosticBuilder::*_with_code` methods.</title>
<updated>2024-01-08T05:00:34+00:00</updated>
<author>
<name>Nicholas Nethercote</name>
<email>n.nethercote@gmail.com</email>
</author>
<published>2024-01-03T10:50:36+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=6682f243dcb9babd67525bbf9798dca302f60588'/>
<id>urn:sha1:6682f243dcb9babd67525bbf9798dca302f60588</id>
<content type='text'>
These all have relatively low use, and can be perfectly emulated with
a simpler construction method combined with `code` or `code_mv`.
</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>Move some methods from `tcx.hir()` to `tcx`</title>
<updated>2023-12-12T14:40:29+00:00</updated>
<author>
<name>zetanumbers</name>
<email>dariasukhonina@gmail.com</email>
</author>
<published>2023-12-01T13:28:34+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=24f009c5e55d18c12563dd74681ca33b8a349936'/>
<id>urn:sha1:24f009c5e55d18c12563dd74681ca33b8a349936</id>
<content type='text'>
Renamings:
- find -&gt; opt_hir_node
- get -&gt; hir_node
- find_by_def_id -&gt; opt_hir_node_by_def_id
- get_by_def_id -&gt; hir_node_by_def_id

Fix rebase changes using removed methods

Use `tcx.hir_node_by_def_id()` whenever possible in compiler

Fix clippy errors

Fix compiler

Apply suggestions from code review

Co-authored-by: Vadim Petrochenkov &lt;vadim.petrochenkov@gmail.com&gt;

Add FIXME for `tcx.hir()` returned type about its removal

Simplify with with `tcx.hir_node_by_def_id`
</content>
</entry>
<entry>
<title>Rollup merge of #116553 - gurry:116464-assoc-type-invalid-suggestion, r=compiler-errors</title>
<updated>2023-10-25T21:37:09+00:00</updated>
<author>
<name>Matthias Krüger</name>
<email>matthias.krueger@famsik.de</email>
</author>
<published>2023-10-25T21:37:09+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=824dbb53fbdea5dc3eec644f775de5ec125c7fba'/>
<id>urn:sha1:824dbb53fbdea5dc3eec644f775de5ec125c7fba</id>
<content type='text'>
Do not suggest 'Trait&lt;Assoc=arg&gt;' when in trait impl

Fixes #116464

We now skip the suggestion if we're in an impl of the trait.
</content>
</entry>
<entry>
<title>Do not suggest 'Trait&lt;Assoc=arg&gt;' when in trait impl</title>
<updated>2023-10-25T03:41:16+00:00</updated>
<author>
<name>Gurinder Singh</name>
<email>frederick.the.fool@gmail.com</email>
</author>
<published>2023-10-25T03:41:16+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=079b29043976afd44cf49eec74486bf2fc15973d'/>
<id>urn:sha1:079b29043976afd44cf49eec74486bf2fc15973d</id>
<content type='text'>
because that would be illegal syntax
</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>
</feed>
