<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rust/compiler/rustc_parse/src/parser/expr.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-30T10:19:19+00:00</updated>
<entry>
<title>Rollup merge of #120460 - nnethercote:fix-120397, r=compiler-errors</title>
<updated>2024-01-30T10:19:19+00:00</updated>
<author>
<name>Guillaume Gomez</name>
<email>guillaume1.gomez@gmail.com</email>
</author>
<published>2024-01-30T10:19:19+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=c00192ae2a9a20125df082576e2d6c0587da3836'/>
<id>urn:sha1:c00192ae2a9a20125df082576e2d6c0587da3836</id>
<content type='text'>
Be more careful about interpreting a label/lifetime as a mistyped char literal.

Currently the parser interprets any label/lifetime in certain positions as a mistyped char literal, on the assumption that the trailing single quote was accidentally omitted. In such cases it gives an error with a suggestion to add the trailing single quote, and then puts the appropriate char literal into the AST. This behaviour was introduced in #101293.

This is reasonable for a case like this:
```
let c = 'a;
```
because `'a'` is a valid char literal. It's less reasonable for a case like this:
```
let c = 'abc;
```
because `'abc'` is not a valid char literal.

Prior to #120329 this could result in some sub-optimal suggestions in error messages, but nothing else. But #120329 changed `LitKind::from_token_lit` to assume that the char/byte/string literals it receives are valid, and to assert if not. This is reasonable because the lexer does not produce invalid char/byte/string literals in general. But in this "interpret label/lifetime as unclosed char literal" case the parser can produce an invalid char literal with contents such as `abc`, which triggers an assertion failure.

This PR changes the parser so it's more cautious about interpreting labels/lifetimes as unclosed char literals.

Fixes #120397.

r? `@compiler-errors`
</content>
</entry>
<entry>
<title>Be more careful about interpreting a label/lifetime as a mistyped char literal.</title>
<updated>2024-01-29T00:25:09+00:00</updated>
<author>
<name>Nicholas Nethercote</name>
<email>n.nethercote@gmail.com</email>
</author>
<published>2024-01-28T22:47:02+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=306612ea60850249e0ad9e7a14fb1ce75fcd944e'/>
<id>urn:sha1:306612ea60850249e0ad9e7a14fb1ce75fcd944e</id>
<content type='text'>
Currently the parser will interpret any label/lifetime in certain
positions as a mistyped char literal, on the assumption that the
trailing single quote was accidentally omitted. This is reasonable for a
something like 'a (because 'a' would be valid) but not reasonable for a
something like 'abc (because 'abc' is not valid).

This commit restricts this behaviour only to labels/lifetimes that would
be valid char literals, via the new `could_be_unclosed_char_literal`
function. The commit also augments the `label-is-actually-char.rs` test
in a couple of ways:
- Adds testing of labels/lifetimes with identifiers longer than one
  char, e.g. 'abc.
- Adds a new match with simpler patterns, because the
  `recover_unclosed_char` call in `parse_pat_with_range_pat` was not
  being exercised (in this test or any other ui tests).

Fixes #120397, an assertion failure, which was caused by this behaviour
in the parser interacting with some new stricter char literal checking
added in #120329.
</content>
</entry>
<entry>
<title>Tweak comment and naming for `recover_unclosed_char`.</title>
<updated>2024-01-28T22:33:49+00:00</updated>
<author>
<name>Nicholas Nethercote</name>
<email>n.nethercote@gmail.com</email>
</author>
<published>2024-01-28T22:28:10+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=5bda589ff333dc324963bc653ce9e13bb176e6a5'/>
<id>urn:sha1:5bda589ff333dc324963bc653ce9e13bb176e6a5</id>
<content type='text'>
Because it can be used for a lifetime or a label.
</content>
</entry>
<entry>
<title>Handle methodcalls &amp; operators in patterns</title>
<updated>2024-01-28T15:12:21+00:00</updated>
<author>
<name>Lieselotte</name>
<email>52315535+she3py@users.noreply.github.com</email>
</author>
<published>2024-01-28T15:12:21+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=6f014a81b2466c2abdae4c06ff81fae7e1bc006c'/>
<id>urn:sha1:6f014a81b2466c2abdae4c06ff81fae7e1bc006c</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Rollup merge of #119342 - sjwang05:issue-112254, r=wesleywiser</title>
<updated>2024-01-26T22:15:49+00:00</updated>
<author>
<name>Matthias Krüger</name>
<email>matthias.krueger@famsik.de</email>
</author>
<published>2024-01-26T22:15:49+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=7f1936556083dd93cfe4b1640f2f6eba50ed3995'/>
<id>urn:sha1:7f1936556083dd93cfe4b1640f2f6eba50ed3995</id>
<content type='text'>
Emit suggestion when trying to write exclusive ranges as `..&lt;`

Closes #112254
</content>
</entry>
<entry>
<title>Rollup merge of #120063 - clubby789:remove-box-handling, r=Nilstrieb</title>
<updated>2024-01-20T19:06:34+00:00</updated>
<author>
<name>Guillaume Gomez</name>
<email>guillaume1.gomez@gmail.com</email>
</author>
<published>2024-01-20T19:06:34+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=8f5f967031b7f304a3b966df793b818b541a32cc'/>
<id>urn:sha1:8f5f967031b7f304a3b966df793b818b541a32cc</id>
<content type='text'>
Remove special handling of `box` expressions from parser

#108471 added a temporary hack to parse `box expr`. It's been almost a year since then, so I think it's safe to remove the special handling.

As a drive-by cleanup, move `parser/removed-syntax*` tests to their own directory.
</content>
</entry>
<entry>
<title>Suggest wrapping mac args in parens rather than the whole expression</title>
<updated>2024-01-18T00:01:13+00:00</updated>
<author>
<name>Michael Goulet</name>
<email>michael@errs.io</email>
</author>
<published>2023-12-18T03:01:05+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=ec263df5e440598159f19a42c104c3b5f13888a0'/>
<id>urn:sha1:ec263df5e440598159f19a42c104c3b5f13888a0</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Remove `box &lt;expr&gt;` recovery</title>
<updated>2024-01-17T21:16:22+00:00</updated>
<author>
<name>clubby789</name>
<email>jamie@hill-daniel.co.uk</email>
</author>
<published>2024-01-17T21:16:22+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=b9ebeee4da258f1ed8bb93f0273180572a839058'/>
<id>urn:sha1:b9ebeee4da258f1ed8bb93f0273180572a839058</id>
<content type='text'>
</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>Rename `{create,emit}_warning` as `{create,emit}_warn`.</title>
<updated>2024-01-09T20:33:06+00:00</updated>
<author>
<name>Nicholas Nethercote</name>
<email>n.nethercote@gmail.com</email>
</author>
<published>2024-01-04T00:28:14+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=3c4f1d85af07f394da922f0bd9ff7c0a91e81f45'/>
<id>urn:sha1:3c4f1d85af07f394da922f0bd9ff7c0a91e81f45</id>
<content type='text'>
For consistency with `warn`/`struct_warn`, and also `{create,emit}_err`,
all of which use an abbreviated form.
</content>
</entry>
</feed>
