<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rust/compiler/rustc_parse/src/parser/attr_wrapper.rs, branch 1.85.0</title>
<subtitle>https://github.com/rust-lang/rust
</subtitle>
<id>http://git.dreamy.place/mirrors/rust/atom?h=1.85.0</id>
<link rel='self' href='http://git.dreamy.place/mirrors/rust/atom?h=1.85.0'/>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/'/>
<updated>2024-11-20T21:16:54+00:00</updated>
<entry>
<title>Introduce `InvisibleOrigin` on invisible delimiters.</title>
<updated>2024-11-20T21:16:54+00:00</updated>
<author>
<name>Nicholas Nethercote</name>
<email>n.nethercote@gmail.com</email>
</author>
<published>2024-04-16T23:59:27+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=afe238f66fc9348b8c4a1daacefb93c0ec36296a'/>
<id>urn:sha1:afe238f66fc9348b8c4a1daacefb93c0ec36296a</id>
<content type='text'>
It's not used meaningfully yet, but will be needed to get rid of
interpolated tokens.
</content>
</entry>
<entry>
<title>Revert "Avoid nested replacement ranges" from #129346.</title>
<updated>2024-11-04T04:57:35+00:00</updated>
<author>
<name>Nicholas Nethercote</name>
<email>n.nethercote@gmail.com</email>
</author>
<published>2024-11-04T04:41:32+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=981dc02eaf876a25b95581411e841ba664dc9e97'/>
<id>urn:sha1:981dc02eaf876a25b95581411e841ba664dc9e97</id>
<content type='text'>
It caused a test regression in the `cfg_eval.rs` crate. (The bugfix
in #129346 was in a different commit; this commit was just a code
simplification.)
</content>
</entry>
<entry>
<title>Rollup merge of #130551 - nnethercote:fix-break-last-token, r=petrochenkov</title>
<updated>2024-09-23T14:54:44+00:00</updated>
<author>
<name>Jubilee</name>
<email>workingjubilee@gmail.com</email>
</author>
<published>2024-09-23T14:54:44+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=515bdcda01fb56609600d2f6214a382511046341'/>
<id>urn:sha1:515bdcda01fb56609600d2f6214a382511046341</id>
<content type='text'>
Fix `break_last_token`.

It currently doesn't handle the three-char tokens `&gt;&gt;=` and `&lt;&lt;=` correctly. These can be broken twice, resulting in three individual tokens. This is a latent bug that currently doesn't cause any problems, but does cause problems for #124141, because that PR increases the usage of lazy token streams.

r? `@petrochenkov`
</content>
</entry>
<entry>
<title>Fix `break_last_token`.</title>
<updated>2024-09-22T23:14:30+00:00</updated>
<author>
<name>Nicholas Nethercote</name>
<email>n.nethercote@gmail.com</email>
</author>
<published>2024-09-19T09:32:17+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=73cc5751773d4c49cc9d938548762520037926ba'/>
<id>urn:sha1:73cc5751773d4c49cc9d938548762520037926ba</id>
<content type='text'>
It currently doesn't handle the three-char tokens `&gt;&gt;=` and `&lt;&lt;=`
correctly. These can be broken twice, resulting in three individual
tokens. This is a latent bug that currently doesn't cause any problems,
but does cause problems for #124141, because that PR increases the usage
of lazy token streams.
</content>
</entry>
<entry>
<title>Reformat using the new identifier sorting from rustfmt</title>
<updated>2024-09-22T23:11:29+00:00</updated>
<author>
<name>Michael Goulet</name>
<email>michael@errs.io</email>
</author>
<published>2024-09-22T23:05:04+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=c682aa162b0d41e21cc6748f4fecfe01efb69d1f'/>
<id>urn:sha1:c682aa162b0d41e21cc6748f4fecfe01efb69d1f</id>
<content type='text'>
</content>
</entry>
<entry>
<title>clippy::useless_conversion</title>
<updated>2024-09-11T21:52:53+00:00</updated>
<author>
<name>Michael Goulet</name>
<email>michael@errs.io</email>
</author>
<published>2024-09-11T18:58:08+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=6d064295c8fb7413cb0500289f922f8d7feb38dc'/>
<id>urn:sha1:6d064295c8fb7413cb0500289f922f8d7feb38dc</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Optimize `collect_tokens` a little.</title>
<updated>2024-08-23T20:58:35+00:00</updated>
<author>
<name>Nicholas Nethercote</name>
<email>n.nethercote@gmail.com</email>
</author>
<published>2024-08-22T03:14:40+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=d4bf28c014772f7233fc396992164c72c08fbfd9'/>
<id>urn:sha1:d4bf28c014772f7233fc396992164c72c08fbfd9</id>
<content type='text'>
Use `Cow` to avoid cloning `ret.attrs()` unless necessary. This requires
moving some things around to satisfy the borrow checker.
</content>
</entry>
<entry>
<title>Avoid double-handling of attributes in `collect_tokens`.</title>
<updated>2024-08-23T20:57:47+00:00</updated>
<author>
<name>Nicholas Nethercote</name>
<email>n.nethercote@gmail.com</email>
</author>
<published>2024-08-21T04:16:42+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=1fdabfbebbb12b2836f91aeec3157fd092f9a8ad'/>
<id>urn:sha1:1fdabfbebbb12b2836f91aeec3157fd092f9a8ad</id>
<content type='text'>
By keeping track of attributes that have been previously processed.

This fixes the `macro-rules-derive-cfg.stdout` test, and is necessary
for #124141 which removes nonterminals.

Also shrink the `SmallVec` inline size used in `IntervalSet`. 2 gives
slightly better perf than 4 now that there's an `IntervalSet` in
`Parser`, which is cloned reasonably often.
</content>
</entry>
<entry>
<title>Avoid nested replacement ranges.</title>
<updated>2024-08-23T04:40:08+00:00</updated>
<author>
<name>Nicholas Nethercote</name>
<email>n.nethercote@gmail.com</email>
</author>
<published>2024-08-20T02:28:39+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=0bae33fcd503473aec70aef28b0e08abce965557'/>
<id>urn:sha1:0bae33fcd503473aec70aef28b0e08abce965557</id>
<content type='text'>
In a case like this:
```
mod a {
    mod b {
        #[cfg_attr(unix, inline)]
        fn f() {
            #[cfg_attr(linux, inline)]
            fn g1() {}
            #[cfg_attr(linux, inline)]
            fn g2() {}
        }
    }
}
```
We currently end up with the following replacement ranges.
- The lazy tokens for `f` has replacement ranges for `g1` and `g2`.
- The lazy tokens for `a` has replacement ranges for `f`, `g1`, and
  `g2`.

I.e. the replacement ranges for `g1` and `g2` are duplicated. In
general, replacement ranges for inner AST nodes are duplicated up the
chain for each nested `collect_tokens` call. And the code that processes
the replacements is careful about the ordering in which the replacements
are applied, to ensure that inner replacements are applied before outer
replacements.

But all of this is unnecessary. If you apply an inner replacement and
then an outer replacement, the outer replacement completely overwrites
the inner replacement.

This commit avoids the duplication by removing replacements from
`self.capture_state.parser_replacements` when they are used. (The effect
on the example above is that the lazy tokesn for `a` no longer include
replacement ranges for `g1` and `g2`.) This eliminates the possibility
of nested replacements on individual AST nodes, which avoids the need
for careful ordering of replacements.
</content>
</entry>
<entry>
<title>Return earlier in some cases in `collect_token`.</title>
<updated>2024-08-23T04:40:08+00:00</updated>
<author>
<name>Nicholas Nethercote</name>
<email>n.nethercote@gmail.com</email>
</author>
<published>2024-08-20T07:47:53+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=1ae521e9d57ba3a67b1007204da2836d8b19b4a2'/>
<id>urn:sha1:1ae521e9d57ba3a67b1007204da2836d8b19b4a2</id>
<content type='text'>
This example triggers an assertion failure:
```
fn f() -&gt; u32 {
    #[cfg_eval] #[cfg(not(FALSE))] 0
}
```
The sequence of events:
- `configure_annotatable` calls `parse_expr_force_collect`, which calls
  `collect_tokens`.
- Within that, we end up in `parse_expr_dot_or_call`, which again calls
  `collect_tokens`.
  - The return value of the `f` call is the expression `0`.
  - This inner call collects tokens for `0` (parser range 10..11) and
    creates a replacement covering `#[cfg(not(FALSE))] 0` (parser range
    0..11).
- We return to the outer `collect_tokens` call. The return value of the
  `f` call is *again* the expression `0`, again with the range 10..11,
  but the replacement from earlier covers the range 0..11. The code
  mistakenly assumes that any attributes from an inner `collect_tokens`
  call fit entirely within the body of the result of an outer
  `collect_tokens` call. So it adjusts the replacement parser range
  0..11 to a node range by subtracting 10, resulting in -10..1. This is
  an invalid range and triggers an assertion failure.

It's tricky to follow, but basically things get complicated when an AST
node is returned from an inner `collect_tokens` call and then returned
again from an outer `collect_token` node without being wrapped in any
kind of additional layer.

This commit changes `collect_tokens` to return early in some extra cases,
avoiding the construction of lazy tokens. In the example above, the
outer `collect_tokens` returns earlier because the `0` token already has
tokens and `self.capture_state.capturing` is `Capturing::No`. This early
return avoids the creation of the invalid range and the assertion
failure.

Fixes #129166. Note: these invalid ranges have been happening for a long
time. #128725 looks like it's at fault only because it introduced the
assertion that catches the invalid ranges.
</content>
</entry>
</feed>
