<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rust/compiler/rustc_session/src/errors.rs, 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>Rollup merge of #119172 - nnethercote:earlier-NulInCStr, r=petrochenkov</title>
<updated>2024-01-18T09:34:17+00:00</updated>
<author>
<name>Matthias Krüger</name>
<email>matthias.krueger@famsik.de</email>
</author>
<published>2024-01-18T09:34:17+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=ff8c7a7816fa1ca3507bf708efece6222b7b48b0'/>
<id>urn:sha1:ff8c7a7816fa1ca3507bf708efece6222b7b48b0</id>
<content type='text'>
Detect `NulInCStr` error earlier.

By making it an `EscapeError` instead of a `LitError`. This makes it like the other errors produced when checking string literals contents, e.g. for invalid escape sequences or bare CR chars.

NOTE: this means these errors are issued earlier, before expansion, which changes behaviour. It will be possible to move the check back to the later point if desired. If that happens, it's likely that all the string literal contents checks will be delayed together.

One nice thing about this: the old approach had some code in `report_lit_error` to calculate the span of the nul char from a range. This code used a hardwired `+2` to account for the `c"` at the start of a C string literal, but this should have changed to a `+3` for raw C string literals to account for the `cr"`, which meant that the caret in `cr"` nul error messages was one short of where it should have been. The new approach doesn't need any of this and avoids the off-by-one error.

r? ```@fee1-dead```
</content>
</entry>
<entry>
<title>Add check for ui_testing via promoting parameters from `ParseSess` to `Session`</title>
<updated>2024-01-13T17:11:13+00:00</updated>
<author>
<name>George-lewis</name>
<email>george-lewis@user.noreply.github.com</email>
</author>
<published>2024-01-10T05:37:30+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=36a69e9d39b3dd49fefa2f84b2787a50230e0a32'/>
<id>urn:sha1:36a69e9d39b3dd49fefa2f84b2787a50230e0a32</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Add suggestion to upgrade the compiler</title>
<updated>2024-01-13T17:11:12+00:00</updated>
<author>
<name>George-lewis</name>
<email>george-lewis@user.noreply.github.com</email>
</author>
<published>2023-12-16T21:23:18+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=b55faad3149ecf196a498ea1c0cf6195f22c9d89'/>
<id>urn:sha1:b55faad3149ecf196a498ea1c0cf6195f22c9d89</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Detect `NulInCStr` error earlier.</title>
<updated>2024-01-12T05:19:37+00:00</updated>
<author>
<name>Nicholas Nethercote</name>
<email>n.nethercote@gmail.com</email>
</author>
<published>2023-12-06T22:53:08+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=9018d2c455df78d3f2900b4ced3ed63962e4f11e'/>
<id>urn:sha1:9018d2c455df78d3f2900b4ced3ed63962e4f11e</id>
<content type='text'>
By making it an `EscapeError` instead of a `LitError`. This makes it
like the other errors produced when checking string literals contents,
e.g. for invalid escape sequences or bare CR chars.

NOTE: this means these errors are issued earlier, before expansion,
which changes behaviour. It will be possible to move the check back to
the later point if desired. If that happens, it's likely that all the
string literal contents checks will be delayed together.

One nice thing about this: the old approach had some code in
`report_lit_error` to calculate the span of the nul char from a range.
This code used a hardwired `+2` to account for the `c"` at the start of
a C string literal, but this should have changed to a `+3` for raw C
string literals to account for the `cr"`, which meant that the caret in
`cr"` nul error messages was one short of where it should have been. The
new approach doesn't need any of this and avoids the off-by-one error.
</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>Use chaining in `DiagnosticBuilder` construction.</title>
<updated>2024-01-08T04:43:07+00:00</updated>
<author>
<name>Nicholas Nethercote</name>
<email>n.nethercote@gmail.com</email>
</author>
<published>2024-01-03T05:00:29+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=589591efde6c54baa8b7932ec3be6f45dc9d781f'/>
<id>urn:sha1:589591efde6c54baa8b7932ec3be6f45dc9d781f</id>
<content type='text'>
To avoid the use of a mutable local variable, and because it reads more
nicely.
</content>
</entry>
<entry>
<title>Rename some `Diagnostic` setters.</title>
<updated>2024-01-03T08:40:20+00:00</updated>
<author>
<name>Nicholas Nethercote</name>
<email>n.nethercote@gmail.com</email>
</author>
<published>2023-12-23T22:08:41+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=505c1371d070ba6c9e15db7d331f2d6a2b167b68'/>
<id>urn:sha1:505c1371d070ba6c9e15db7d331f2d6a2b167b68</id>
<content type='text'>
`Diagnostic` has 40 methods that return `&amp;mut Self` and could be
considered setters. Four of them have a `set_` prefix. This doesn't seem
necessary for a type that implements the builder pattern. This commit
removes the `set_` prefixes on those four methods.
</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>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>
</feed>
