<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rust/tests/ui/parser/attribute/multiple-tail-expr-behind-cfg.rs, branch 1.90.0</title>
<subtitle>https://github.com/rust-lang/rust
</subtitle>
<id>http://git.dreamy.place/mirrors/rust/atom?h=1.90.0</id>
<link rel='self' href='http://git.dreamy.place/mirrors/rust/atom?h=1.90.0'/>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/'/>
<updated>2025-04-03T21:41:58+00:00</updated>
<entry>
<title>Use `cfg(false)` in UI tests</title>
<updated>2025-04-03T21:41:58+00:00</updated>
<author>
<name>clubby789</name>
<email>jamie@hill-daniel.co.uk</email>
</author>
<published>2025-03-29T17:24:03+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=303c1b45c29f8bb186a9a95cb56643d1aef773fa'/>
<id>urn:sha1:303c1b45c29f8bb186a9a95cb56643d1aef773fa</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Unify all the always-false cfgs under the `FALSE` cfg</title>
<updated>2024-04-06T23:16:45+00:00</updated>
<author>
<name>Urgau</name>
<email>urgau@numericable.fr</email>
</author>
<published>2024-04-06T22:43:00+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=c4a97d9407556081c5a8d8927ef86529b3bf4572'/>
<id>urn:sha1:c4a97d9407556081c5a8d8927ef86529b3bf4572</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Handle attempts to have multiple `cfg`d tail expressions</title>
<updated>2023-11-16T21:21:26+00:00</updated>
<author>
<name>Esteban Küber</name>
<email>esteban@kuber.com.ar</email>
</author>
<published>2023-11-16T21:21:26+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=a16722d2210caa5eea941ffa20837859e249fd05'/>
<id>urn:sha1:a16722d2210caa5eea941ffa20837859e249fd05</id>
<content type='text'>
When encountering code that seems like it might be trying to have
multiple tail expressions depending on `cfg` information, suggest
alternatives that will success to parse.

```rust
fn foo() -&gt; String {
    #[cfg(feature = "validation")]
    [1, 2, 3].iter().map(|c| c.to_string()).collect::&lt;String&gt;()
    #[cfg(not(feature = "validation"))]
    String::new()
}
```

```
error: expected `;`, found `#`
  --&gt; $DIR/multiple-tail-expr-behind-cfg.rs:5:64
   |
LL |     #[cfg(feature = "validation")]
   |     ------------------------------ only `;` terminated statements or tail expressions are allowed after this attribute
LL |     [1, 2, 3].iter().map(|c| c.to_string()).collect::&lt;String&gt;()
   |                                                                ^ expected `;` here
LL |     #[cfg(not(feature = "validation"))]
   |     - unexpected token
   |
help: add `;` here
   |
LL |     [1, 2, 3].iter().map(|c| c.to_string()).collect::&lt;String&gt;();
   |                                                                +
help: alternatively, consider surrounding the expression with a block
   |
LL |     { [1, 2, 3].iter().map(|c| c.to_string()).collect::&lt;String&gt;() }
   |     +                                                             +
help: it seems like you are trying to provide different expressions depending on `cfg`, consider using `if cfg!(..)`
   |
LL ~     if cfg!(feature = "validation") {
LL ~         [1, 2, 3].iter().map(|c| c.to_string()).collect::&lt;String&gt;()
LL ~     } else if cfg!(not(feature = "validation")) {
LL ~         String::new()
LL +     }
   |
```

Fix #106020.
</content>
</entry>
</feed>
