Commit graph

170422 commits

Author SHA1 Message Date
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 bd071bf5b2 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 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
andylizi a8370d4460
Fix false positive for never_loop struct expression fields 2022-06-15 18:02:59 +08:00
Frank Steffahn eb14dd863a Test NLL fix of bad lifetime inference for reference captured in closure. 2022-06-15 11:54:59 +02: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 844c06a7c7 Auto merge of #8964 - tamaroning:read_zero_byte_vec, r=dswij
Warn about read into zero-length `Vec`

Closes #8886

- \[x] Followed [lint naming conventions][lint_naming]
- \[x] Added passing UI tests (including committed `.stderr` file)
- \[x] `cargo test` passes locally
- \[x] Executed `cargo dev update_lints`
- \[x] Added lint documentation
- \[x] Run `cargo dev fmt`

changelog: none
2022-06-15 06:16:14 +00: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
EdwinRy c8b411ebf1 rename function and remove return type 2022-06-15 01:06:40 +01:00
Jacob Pratt fb05b53745
Remove rustc_deprecated diagnostics 2022-06-14 19:46:13 -04:00
Dan Gohman 1237232aba Add a stability attribute to WASI's try_clone(). 2022-06-14 14:46:22 -07:00
Dan Gohman 67ed99e6d2 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-14 14:46:22 -07:00
bors 2d1e075079 Auto merge of #96285 - flip1995:pk-vfe, r=nagisa
Introduce `-Zvirtual-function-elimination` codegen flag

Fixes #68262

This PR adds a codegen flag `-Zvirtual-function-elimination` to enable the VFE optimization in LLVM. To make this work, additonal  information has to be added to vtables ([`!vcall_visibility` metadata](https://llvm.org/docs/TypeMetadata.html#vcall-visibility-metadata) and a `typeid` of the trait). Furthermore, instead of just `load`ing functions, the [`llvm.type.checked.load` intrinsic](https://llvm.org/docs/LangRef.html#llvm-type-checked-load-intrinsic) has to be used to map functions to vtables.

For technical details of the changes, see the commit messages.

I also tested this flag on https://github.com/tock/tock on different boards to verify that this fixes the issue https://github.com/tock/tock/issues/2594. This flag is able to improve the size of the resulting binary by about 8k-9k bytes by removing the unused debug print functions.

[Rendered documentation update](https://github.com/flip1995/rust/blob/pk-vfe/src/doc/rustc/src/codegen-options/index.md#virtual-function-elimination)
2022-06-14 21:37:11 +00:00
Michael Howell f1d24beb68 rustdoc: add test case for "variadic tuple" search notation 2022-06-14 14:17:20 -07:00
Erik Desjardins 50f6a9ed87 use unchecked mul to compute slice sizes
...since slice sizes can't signed wrap

see https://doc.rust-lang.org/std/slice/fn.from_raw_parts.html

> The total size len * mem::size_of::<T>() of the slice must be no larger than isize::MAX.
2022-06-14 17:09:07 -04:00
Michael Howell 2bbf44f655 rustdoc: change "variadic tuple" notation to look less like real syntax 2022-06-14 12:21:38 -07:00
Guillaume Gomez a70c14aecc Add GUI test for sidebar items expand/collapse 2022-06-14 20:09:09 +02:00
Jacob Hughes 1f7023a519 btreemap-alloc: adjust ui test 2022-06-14 13:54:10 -04:00
Jacob Hughes 417b20835d btreemap-alloc: fix clear impl 2022-06-14 13:54:10 -04:00
Jacob Hughes dc5951a6e5 BTreeMap: Add alloc param 2022-06-14 13:54:03 -04:00
bors 1f34da9ec8 Auto merge of #96591 - b-naber:transition-to-valtrees-in-type-system, r=lcnr
Use valtrees as the type-system representation for constant values

This is not quite ready yet, there are still some problems with pretty printing and symbol mangling and `deref_const` seems to not work correctly in all cases.

Mainly opening now for a perf-run (which should be good to go, despite the still existing problems).

r? `@oli-obk`

cc `@lcnr` `@RalfJung`
2022-06-14 17:19:38 +00:00
bors 32a86c086e Auto merge of #8999 - Alexendoo:error-pattern, r=xFrednet
Remove error-pattern comments

The `clippy_lints` one [is unused](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/.60error-pattern.60), the others in `ui-toml` also appear not to have an effect

changelog: none
2022-06-14 16:54:13 +00:00
Alex Macleod 08cfb8ddc3 Remove error-pattern comments 2022-06-14 16:28:34 +00:00
b-naber 15c1c06522 rebase 2022-06-14 17:57:51 +02:00
Takayuki Maeda d29915af79 add a test case for decl_macro 2022-06-15 00:42:10 +09:00