Commit graph

170293 commits

Author SHA1 Message Date
Martin Nordholts 94477e3323 Fixup missing renames from #[main] to #[rustc_main]
In fc357039f9 `#[main]` was removed and replaced with `#[rustc_main]`.
In some place the rename was forgotten, which makes the current code
confusing, because at first glance it seems that `#[main]` is still
around. Perform the renames also in these places.
2022-06-22 18:24:09 +02:00
bors 6ec3993ef4 Auto merge of #97842 - notriddle:notriddle/tuple-docs, r=jsha,GuillaumeGomez
Improve the tuple and unit trait docs

* Reduce duplicate impls; show only the `(T,)` and include a sentence saying that there exists ones up to twelve of them.
* Show `Copy` and `Clone`.
* Show auto traits like `Send` and `Sync`, and blanket impls like `Any`.

Here's the new version:

* <https://notriddle.com/notriddle-rustdoc-test/std/primitive.tuple.html>
* <https://notriddle.com/notriddle-rustdoc-test/std/primitive.unit.html>
2022-06-16 11:13:30 +00:00
bors d40f24e956 Auto merge of #98161 - matthiaskrgr:rollup-8csenk9, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #97757 (Support lint expectations for `--force-warn` lints (RFC 2383))
 - #98125 (Entry and_modify doc)
 - #98137 (debuginfo: Fix NatVis for Rc and Arc with unsized pointees.)
 - #98147 (Make #[cfg(bootstrap)] not error in proc macros on later stages )

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-06-16 07:45:03 +00:00
Matthias Krüger 97a7a3c9ea
Rollup merge of #98147 - est31:bootstrap_cfg_flag, r=Mark-Simulacrum
Make #[cfg(bootstrap)] not error in proc macros on later stages

As was discovered in https://github.com/rust-lang/rust/pull/93628#issuecomment-1154697627,
adding #[cfg(bootstrap)] to a rust-internal proc macro crate
would yield an unexpected cfg name error, at least on later
stages wher the bootstrap cfg arg wasn't set.

rustc already passes arguments to mark bootstrap as expected,
however the means of delivery through the RUSTFLAGS env var
is unable to reach proc macro crates, as described
in the issue linked in the code this commit touches.

This wouldn't be an issue for cfg args that get passed through
RUSTFLAGS, as they would never become *active* either, so
any usage of one of these flags in a proc macro's code would
legitimately yield a lint warning. But since dc30258,
rust takes extra measures to pass --cfg=bootstrap even in
proc macros, by passing it via the wrapper. Thus, we need
to send the flags to mark bootstrap as expected also from the
wrapper, so that #[cfg(bootstrap)] also works from proc macros.

I want to thank `Urgau` and `jplatte` for helping me find the cause of this. ❤️
2022-06-16 09:10:23 +02:00
Matthias Krüger ae58a55d03
Rollup merge of #98137 - michaelwoerister:fix-unsized-rc-arc-natvis, r=wesleywiser
debuginfo: Fix NatVis for Rc and Arc with unsized pointees.

Currently, the NatVis for `Rc<T>` and `Arc<T>` does not support unsized `T`. For both `Rc<T>` and `Rc<dyn SomeTrait>` the visualizers fail:

```txt
    [Reference count] : -> must be used on pointers and . on structures
    [Weak reference count] : -> must be used on pointers and . on structures
```

This PR fixes the visualizers. For slices we can even give show the elements, so one now gets something like:

```txt
slice_rc         : { len=3 }
    [Length]         : 3
    [Reference count] : 41
    [Weak reference count] : 2
    [0]              : 1
    [1]              : 2
    [2]              : 3
```

r? `@wesleywiser`
2022-06-16 09:10:22 +02:00
Matthias Krüger f4297b06e8
Rollup merge of #98125 - KarlWithK:entry_add_modify_doc, r=Dylan-DPC
Entry and_modify doc

This PR modifies the documentation for [HashMap](https://doc.rust-lang.org/std/collections/struct.HashMap.html#) and [BTreeMap](https://doc.rust-lang.org/std/collections/struct.BTreeMap.html#) by introducing examples for `and_modify`. `and_modify` is a function that tends to give more idiomatic rust code when dealing with these data structures -- yet it lacked examples and was hidden away. This PR adds that and addresses #98122.

I've made some choices which I tried to explain in my commits. This is my first time contributing to rust, so hopefully, I made the right choices.
2022-06-16 09:10:21 +02:00
Matthias Krüger 95be954af4
Rollup merge of #97757 - xFrednet:rfc-2383-expect-with-force-warn, r=wesleywiser,flip1995
Support lint expectations for `--force-warn` lints (RFC 2383)

Rustc has a `--force-warn` flag, which overrides lint level attributes and forces the diagnostics to always be warn. This means, that for lint expectations, the diagnostic can't be suppressed as usual. This also means that the expectation would not be fulfilled, even if a lint had been triggered in the expected scope.

This PR now also tracks the expectation ID in the `ForceWarn` level. I've also made some minor adjustments, to possibly catch more bugs and make the whole implementation more robust.

This will probably conflict with https://github.com/rust-lang/rust/pull/97718. That PR should ideally be reviewed and merged first. The conflict itself will be trivial to fix.

---

r? `@wesleywiser`

cc: `@flip1995` since you've helped with the initial review and also discussed this topic with me. 🙃

Follow-up of: https://github.com/rust-lang/rust/pull/87835

Issue: https://github.com/rust-lang/rust/issues/85549

Yeah, and that's it.
2022-06-16 09:10:20 +02:00
xFrednet 8527a3d369
Support lint expectations for --force-warn lints (RFC 2383) 2022-06-16 08:16:43 +02:00
bors 392d272868 Auto merge of #98108 - SpriteOvO:doc_auto_cfg-feature-rmv-fix, r=notriddle,GuillaumeGomez
Rustdoc: Fix stab disappearing and exclude cfg "doc" and "doctest"

Fixes #98065 Context: https://github.com/rust-lang/rust/issues/43781#issuecomment-1154226733

r? `@GuillaumeGomez`
2022-06-16 05:02:10 +00:00
bors 1b9daa6964 Auto merge of #98103 - exrook:btreemap-alloc, r=Amanieu
BTreeMap: Support custom allocators (v1.5)

Related:
https://github.com/rust-lang/wg-allocators/issues/7
https://github.com/TimDiekmann/alloc-wg

Blocked on:
~~#77187~~
~~#78459~~
~~#95036~~

previous: #77438
2022-06-16 02:15:55 +00:00
bors 5bc82c0b94 Auto merge of #98152 - JohnTitor:rollup-osr17j6, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #97202 (os str capacity documentation)
 - #97964 (Fix suggestions for `&a: T` parameters)
 - #98053 (Fix generic impl rustdoc json output)
 - #98059 (Inline `const_eval_select`)
 - #98092 (Fix sidebar items expand collapse)
 - #98119 (Refactor path segment parameter error)
 - #98135 (Add regression test for #93775)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-06-15 23:49:06 +00:00
Wesley Wiser 95adaa22e0 The type of the slice length field is architecture dependent 2022-06-15 18:35:41 -04:00
Yuki Okushi 4ab704e12b
Rollup merge of #98135 - JohnTitor:issue-93022-93775, r=compiler-errors
Add regression test for #93775

Closes #93775, also closes #93022 as it should have the same root cause
r? ```@compiler-errors```

Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2022-06-16 07:24:44 +09:00
Yuki Okushi bfc6c90115
Rollup merge of #98119 - EdwinRy:path-parenthesized-type-error, r=estebank
Refactor path segment parameter error

This PR attempts to rewrite the error handling for an unexpected parenthesised type parameters to:
- Use provided data instead of re-parsing the whole span
- Add a multipart suggestion to reflect on the changes with an underline
- Remove the unnecessary "if" nesting
2022-06-16 07:24:43 +09:00
Yuki Okushi ad61ae59bf
Rollup merge of #98092 - GuillaumeGomez:fix-sidebar-items-expand-collapse, r=notriddle
Fix sidebar items expand collapse

The collapse/expand event was not working for the items in the source code viewer sidebar (talking about these items:

![Screenshot from 2022-06-14 11-21-58](https://user-images.githubusercontent.com/3050060/173543346-af056928-e921-458f-b918-60f6fd0ecbde.png)

).

This PR fixes it and adds a GUI test to prevent another regression.

r? ```@notriddle```
2022-06-16 07:24:42 +09:00
Yuki Okushi b91c4d5b45
Rollup merge of #98059 - tmiasko:inline-const-eval-select, r=Amanieu
Inline `const_eval_select`

To avoid circular link time dependency between core and compiler
builtins when building with `-Zshare-generics`.

r? ```@Amanieu```
2022-06-16 07:24:41 +09:00
Yuki Okushi 4ee78a686f
Rollup merge of #98053 - GuillaumeGomez:fix-generic-impl-json-ice, r=notriddle
Fix generic impl rustdoc json output

Fixes #97986.

The problem in case of generic trait impl is that the trait's items are the same for all the types afterward. But since they're the same, it's safe for rustdoc-json to just ignore them.

A little representation of what's going on:

```rust
trait T {
    fn f(); // <- defid 0
}

impl<Y> T for Y {
    fn f() {} // <- defid 1
}

struct S; // <- defid 1 (since it matches `impl<Y> T for Y`
```

cc ```@Urgau```

r? ```@CraftSpider```
2022-06-16 07:24:40 +09:00
Yuki Okushi 52afa3a70c
Rollup merge of #97964 - WaffleLapkin:fix_borrow_par_suggestions, r=compiler-errors
Fix suggestions for `&a: T` parameters

I've accidentally discovered that we have broken suggestions for `&a: T` parameters:
```rust
fn f(&mut bar: u32) {}

fn main() {
    let _ = |&mut a| ();
}
```
```text
error[E0308]: mismatched types
 --> ./t.rs:1:6
  |
1 | fn f(&mut bar: u32) {}
  |      ^^^^^^^^-----
  |      |         |
  |      |         expected due to this
  |      expected `u32`, found `&mut _`
  |      help: did you mean `bar`: `&u32`
  |
  = note:           expected type `u32`
          found mutable reference `&mut _`

error[E0308]: mismatched types
 --> ./t.rs:4:23
  |
4 |     let _: fn(u32) = |&mut a| ();
  |                       ^^^^^--
  |                       |    |
  |                       |    expected due to this
  |                       expected `u32`, found `&mut _`
  |                       help: did you mean `a`: `&u32`
  |
  = note:           expected type `u32`
          found mutable reference `&mut _`
```

It's hard to see, but
1. The help span is overlapping with "expected" spans
2. It suggests `fn f( &u32) {}` (no `mut` and lost parameter name) and `|&u32 ()` (no closing `|` and lost parameter name)

I've tried to fix this.

r? ``@compiler-errors``
2022-06-16 07:24:39 +09:00
Yuki Okushi b37e4e043e
Rollup merge of #97202 - joshtriplett:os-str-capacity-documentation, r=dtolnay
os str capacity documentation

This is based on https://github.com/rust-lang/rust/pull/95394 , with expansion and consolidation
to address comments from `@dtolnay` and other `@rust-lang/libs-api` team members.
2022-06-16 07:24:38 +09:00
est31 471fa05fef Make #[cfg(bootstrap)] not error in proc macros on later stages
As was discovered in https://github.com/rust-lang/rust/pull/93628#issuecomment-1154697627 ,
adding #[cfg(bootstrap)] to a rust-internal proc macro crate
would yield an unexpected cfg name error, at least on later
stages wher the bootstrap cfg arg wasn't set.

rustc already passes arguments to mark bootstrap as expected,
however the means of delivery through the RUSTFLAGS env var
is unable to reach proc macro crates, as described
in the issue linked in the code this commit touches.

This wouldn't be an issue for cfg args that get passed through
RUSTFLAGS, as they would never become *active* either, so
any usage of one of these flags in a proc macro's code would
legitimately yield a lint warning. But since dc302587e2,
rust takes extra measures to pass --cfg=bootstrap even in
proc macros, by passing it via the wrapper. Thus, we need
to send the flags to mark bootstrap as expected also from the
wrapper, so that #[cfg(bootstrap)] also works from proc macros.

I want to thank Urgau and jplatte for helping me find the cause of this. ❤️
2022-06-16 00:03:27 +02:00
bors b31f9cc22b Auto merge of #97178 - sunfishcode:ownedfd-and-dup, r=joshtriplett
Add a `BorrowedFd::try_clone_to_owned` and accompanying documentation

Add a `BorrowedFd::try_clone_to_owned`, which returns a new `OwnedFd` sharing the underlying file description. And similar for `BorrowedHandle` and `BorrowedSocket` on WIndows.

This is similar to the existing `OwnedFd::try_clone`, but it's named differently to reflect that it doesn't return `Result<Self, ...>`. I'm open to suggestions for better names.

Also, extend the `unix::io` documentation to mention that `dup` is permitted on `BorrowedFd`.

This was originally requsted [here](https://github.com/rust-lang/rust/issues/88564#issuecomment-910786081). At the time I wasn't sure whether it was desirable, but it does have uses and it helps clarify the API. The documentation previously didn't rule out using `dup` on a `BorrowedFd`, but the API only offered convenient ways to do it from an `OwnedFd`. With this patch, the API allows one to do `try_clone` on any type where it's permitted.
2022-06-15 21:08:08 +00:00
bors ca983054e1 Auto merge of #97665 - c410-f3r:assert-compiler, r=oli-obk
[RFC 2011] Minimal initial implementation

Tracking issue: #44838
Third step of #96496

Implementation has ~290 LOC with the bare minimum to be in a functional state. Currently only searches for binary operations to mimic what `assert_eq!` and `assert_ne!` already do.

r? `@oli-obk`
2022-06-15 17:43:01 +00:00
Sprite 713578b827 Exclude cfg "doc" and "doctest" from feature doc_auto_cfg 2022-06-16 01:11:29 +08:00
Sprite 9aa1ccdae8 Fix cfg(not) and cfg(all) causing Rustdoc stab to disappear 2022-06-16 01:11:26 +08:00
Dan Gohman ee49d65fc3 Add the new stability attributes, for Windows. 2022-06-15 09:46:56 -07:00
Dan Gohman 007cbfd1db Revise the documentation for try_clone.
On Unix, describe these in terms of the underlying "file description". On
Windows, describe them in terms of the underlying "object".
2022-06-15 08:55:11 -07:00
Dan Gohman 5d0eae81ae Add BorrowedFd::try_clone_to_owned.
And `BorrowedHandle::try_clone_to_owned` and
`BorrowedSocket::try_clone_to_owned` on Windows.
2022-06-15 08:54:06 -07:00
Dan Gohman eb37bbcebc Document that BorrowedFd may be used to do a dup. 2022-06-15 08:52:42 -07:00
Michael Woerister 2b5efa4f79 debuginfo: Fix NatVis for Rc and Arc with unsized pointees. 2022-06-15 16:49:52 +02:00
bors c3605f8c80 Auto merge of #95897 - AzureMarker:feature/horizon-std, r=nagisa
STD support for the Nintendo 3DS

Rustc already supports compiling for the Nintendo 3DS using the `armv6k-nintendo-3ds` target (Tier 3). Until now though, only `core` and `alloc` were supported. This PR adds standard library support for the Nintendo 3DS. A notable exclusion is `std::thread` support, which will come in a follow-up PR as it requires more complicated changes.

This has been a joint effort by `@Meziu,` `@ian-h-chamberlain,` myself, and prior work by `@rust3ds` members.

### Background

The Nintendo 3DS (Horizon OS) is a mostly-UNIX looking system, with the caveat that it does not come with a full libc implementation out of the box. On the homebrew side (I'm not under NDA), the libc interface is partially implemented by the [devkitPro](https://devkitpro.org/wiki/devkitPro_pacman) toolchain and a user library like [`libctru`](https://github.com/devkitPro/libctru). This is important because there are [some possible legal barriers](https://github.com/rust-lang/rust/pull/88529#issuecomment-919938396) to linking directly to a library that uses the underlying platform APIs, since they might be considered a trade secret or under NDA.

To get around this, the standard library impl for the 3DS does not directly depend on any platform-level APIs. Instead, it expects standard libc functions to be linked in. The implementation of these libc functions is left to the user. Some functions are provided by the devkitPro toolchain, but in our testing, we used the following to fill in the other functions:
- [`libctru`] - provides more basic APIs, such as `nanosleep`. Linked in by way of [`ctru-sys`](https://github.com/Meziu/ctru-rs/tree/master/ctru-sys).
- [`pthread-3ds`](https://github.com/Meziu/pthread-3ds) - provides pthread APIs for `std::thread`. Implemented using [`libctru`].
- [`linker-fix-3ds`](https://github.com/Meziu/rust-linker-fix-3ds) - fulfills some other missing libc APIs. Implemented using [`libctru`].

For more details, see the `src/doc/rustc/src/platform-support/armv6k-nintendo-3ds.md` file added in this PR.

### Notes
We've already upstreamed changes to the [`libc`] crate to support this PR, as well as the upcoming threading PR. These changes have all been released as of 0.2.121, so we bump the crate version in this PR.
Edit: After some rebases, the version bump has already been merged so it doesn't appear in this PR.

A lot of the changes in this PR are straightforward, and follow in the footsteps of the ESP-IDF target: https://github.com/rust-lang/rust/pull/87666.

The 3DS does not support user space process spawning, so these APIs are unimplemented (similar to ESP-IDF).

[`libctru`]: https://github.com/devkitPro/libctru
[`libc`]: https://github.com/rust-lang/libc
2022-06-15 14:21:28 +00:00
Yuki Okushi 5028d20589
Add regression test for #93775
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2022-06-15 21:31:47 +09:00
bors a4cec9742b Auto merge of #98131 - JohnTitor:rollup-c17vjdy, r=JohnTitor
Rollup of 3 pull requests

Successful merges:

 - #95118 (Implement stabilization of `#[feature(io_safety)]`.)
 - #98110 (Make `ExprKind::Closure` a struct variant.)
 - #98115 (Remove `rustc_deprecated` diagnostics)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-06-15 11:04:23 +00:00
Caio 605c64a91e [RFC 2011] Minimal initial implementation 2022-06-15 07:37:40 -03:00
Yuki Okushi b1e5472349
Rollup merge of #98115 - jhpratt:remove-rustc_deprecated, r=compiler-errors
Remove `rustc_deprecated` diagnostics

Follow-up on #95960. The diagnostics will remain until the next bootstrap, at which point people will have had six weeks to adjust.

``@rustbot`` label +A-diagnostics

r? ``@compiler-errors``
2022-06-15 19:37:15 +09:00
Yuki Okushi 87e373e82f
Rollup merge of #98110 - cjgillot:closure-brace, r=Aaron1011
Make `ExprKind::Closure` a struct variant.

Simple refactor since we both need it to introduce additional fields in `ExprKind::Closure`.

r? ``@Aaron1011``
2022-06-15 19:37:14 +09:00
Yuki Okushi 40912e12f1
Rollup merge of #95118 - sunfishcode:sunfishcode/stabilize-io-safety, r=joshtriplett
Implement stabilization of `#[feature(io_safety)]`.

Implement stabilization of [I/O safety], aka `#[feature(io_safety)]`.

Fixes #87074.

[I/O safety]: https://github.com/rust-lang/rfcs/blob/master/text/3128-io-safety.md
2022-06-15 19:37:13 +09:00
bors ebe184a693 Auto merge of #98084 - nnethercote:rm-thread-local-IGNORED_ATTRIBUTES, r=michaelwoerister
Remove thread-local `IGNORED_ATTRIBUTES`.

It's just a copy of the read-only global `ich::IGNORED_ATTRIBUTES`, and
can be removed without any effect.

r? `@michaelwoerister`
2022-06-15 08:20:19 +00:00
KarlWithK 791923aacb
change "1" to "c" to pass test
Incorrectly wrote "1" twice when writing test.
2022-06-15 03:19:22 -05:00
KarlWithK cec72acdca
Add examples using add_modify to btree
Updated the btree's documentation to include two references to
add_modify.

The first is when the `Entry` API is mentioned at the beginning. With
the same reasoning as HashMap's documentation, I thought it would best
to keep `attack`, but show the `mana` example.

The second is with the `entry` function that is used for the `Entry`
API. The code example was a perfect use for `add_modify`, which is why
it was changed to reflect that.
2022-06-15 02:04:18 -05:00
KarlWithK d3d22e1e66
Add examples using add_modify to HashMap
Updated the HashMap's documentation to include two references to
add_modify.

The first is when the `Entry` API is mentioned at the beginning. I was
hesitant to change the "attack" example (although I believe that it is
perfect example of where `add_modify` should be used) because both uses
work equally, but one is more idiomatic (`add_modify`).

The second is with the `entry` function that is used for the `Entry`
API. The code example was a perfect use for `add_modify`, which is why
it was changed to reflect that.
2022-06-15 01:41:56 -05:00
bors 389352c4bb Auto merge of #98123 - JohnTitor:rollup-rfg1a4s, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #97822 (Filter out intrinsics if we have other import candidates to suggest)
 - #98026 (Move some tests to more reasonable directories)
 - #98067 (compiler: remove unused deps)
 - #98078 (Use unchecked mul to compute slice sizes)
 - #98083 (Rename rustc_serialize::opaque::Encoder as MemEncoder.)
 - #98087 (Suggest adding a `#[macro_export]` to a private macro)
 - #98113 (Fix misspelling of "constraint" as "contraint")

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-06-15 05:39:29 +00:00
Yuki Okushi 1b8fc2f8f6
Rollup merge of #98113 - EdwinRy:constraint-misspelling, r=compiler-errors
Fix misspelling of "constraint" as "contraint"

I misspelled a function name a while back
2022-06-15 12:02:06 +09:00
Yuki Okushi b2d0e7838e
Rollup merge of #98087 - TaKO8Ki:suggest-adding-macro-export, r=oli-obk
Suggest adding a `#[macro_export]` to a private macro

fixes #97628
2022-06-15 12:02:05 +09:00
Yuki Okushi 97b9347c93
Rollup merge of #98083 - nnethercote:rename-Encoder, r=bjorn3
Rename rustc_serialize::opaque::Encoder as MemEncoder.

This avoids the name clash with `rustc_serialize::Encoder` (a trait),
and allows lots qualifiers to be removed and imports to be simplified
(e.g. fewer `as` imports).

(This was previously merged as commit 5 in #94732 and then was reverted
in #97905 because of a perf regression caused by commit 4 in #94732.)

r? ```@bjorn3```
2022-06-15 12:02:04 +09:00
Yuki Okushi 2722c2aa33
Rollup merge of #98078 - erikdesjardins:uncheckedsize, r=petrochenkov
Use unchecked mul to compute slice sizes

This allows LLVM to realize that `slice.len() > 0` iff `slice.len() * size_of::<T>() > 0`, allowing a branch on the latter to be folded into the former when dropping vecs and boxed slices, in some cases.

Fixes (partially) #96497
2022-06-15 12:02:03 +09:00
Yuki Okushi bb4805118a
Rollup merge of #98067 - klensy:compiler-deps2, r=Dylan-DPC
compiler: remove unused deps

Removed unused dependencies in compiler crates and moves few `libc` under `target.cfg(unix)` .
2022-06-15 12:02:02 +09:00
Yuki Okushi b770012202
Rollup merge of #98026 - c410-f3r:z-errors, r=petrochenkov
Move some tests to more reasonable directories

r? ```@petrochenkov```
2022-06-15 12:02:02 +09:00
Yuki Okushi 0ee15040d5
Rollup merge of #97822 - compiler-errors:hesitate-to-suggest-intrinsics, r=oli-obk
Filter out intrinsics if we have other import candidates to suggest

Fixes #97618

Also open to just sorting these candidates to be last. Pretty easy to modify the code to do that, too.
2022-06-15 12:02:01 +09:00
bors ddb6cc8524 Auto merge of #97474 - compiler-errors:if-cond-and-block, r=oli-obk
Improve parsing errors and suggestions for bad `if` statements

1. Parses `if {}` as `if <err> {}` (block-like conditions that are missing a "then" block), and `if true && {}` as `if true && <err> {}` (unfinished binary operation), which is a more faithful recovery and leads to better typeck errors later on.
1. Points out the span of the condition if we don't see a "then" block after it, to help the user understand what is being parsed as a condition (and by elimination, what isn't).
1. Allow `if cond token else { }` to be fixed properly to `if cond { token } else { }`.
1. Fudge with the error messages a bit. This is somewhat arbitrary and I can revert my rewordings if they're useless.

----

Also this PR addresses a strange parsing regression (1.20 -> 1.21) where we chose to reject this piece of code somewhat arbitrarily, even though we should parse it fine:

```rust
fn main() {
    if { if true { return } else { return }; } {}
}
```

For context, all of these other expressions parse correctly:

```rust
fn main() {
    if { if true { return } else { return } } {}
    if { return; } {}
    if { return } {}
    if { return if true { } else { }; } {}
}
```

The parser used a heuristic to determine if the "the parsed `if` condition makes sense as a condition" that did like a one-expr-deep reachability analysis. This should not be handled by the parser though.
2022-06-15 02:58:44 +00:00
EdwinRy 71a98e1a4e Refactor path segment parameter error 2022-06-15 02:50:34 +01:00