Commit Graph

139205 Commits

Author SHA1 Message Date
bors b02a6193b3 Auto merge of #81937 - ssomers:btree_drainy_refactor_9b, r=Mark-Simulacrum
BTree: move more shared iterator code into navigate.rs

The functions in navigate.rs only exist to support iterators, and these look easier on my eyes if there is a shared `struct` with the recurring pair of handles.

r? `@Mark-Simulacrum`
2021-02-23 00:30:37 +00:00
Dan Gohman e8dcc02dc5 Add a `size()` function to WASI's `MetadataExt`.
WASI's `filestat` type includes a size field, so expose it in
`MetadataExt` via a `size()` function, similar to the corresponding Unix
function.
2021-02-22 14:42:59 -08:00
Vadim Petrochenkov fc9d578bc5 expand: Preserve order of inert attributes during expansion 2021-02-23 01:07:22 +03:00
Vadim Petrochenkov c02d21033d Add tests 2021-02-23 00:45:53 +03:00
bors 11f838d64a Auto merge of #81978 - tmiasko:head-ctor, r=Mark-Simulacrum
Inline hot part of PatStack::head_ctor

When building rustc with `-Codegen-units=1` this inline hint ensures
that obtaining already initialized head constructor does not involve
a function call overhead and reduces the instruction count in
match-stress-enum-check full benchmark from 11.9G to 9.8G.

It shouldn't have significant impact on the currently default
configuration where it reflects existing inlining decisions.
2021-02-22 21:45:50 +00:00
Eric Huss 7d99d6d10b Update for review comments. 2021-02-22 13:39:15 -08:00
Simon Vandel Sillesen a6dccfeb23 New mir-opt pass to simplify gotos with const values
Fixes #77355
2021-02-22 21:03:57 +01:00
Jonas Schievink 7bc501687b Avoid `cfg_if` in `std::os` 2021-02-22 19:56:20 +01:00
Camelid e4ac499b7e Remove many RefCells from DocContext
I left some of them so this change doesn't balloon in size and because
removing the RefCell in `DocContext.resolver` would require compiler
changes.

Thanks to `@jyn514` for making this a lot easier with #82020!
2021-02-22 10:02:56 -08:00
bors a15f484b91 Auto merge of #81362 - ssomers:btree_drainy_refactor_8, r=Mark-Simulacrum
BTreeMap: gather and decompose reusable tree fixing functions

This is kind of pushing it as a standalone refactor, probably only useful for #81075 (or similar).
r? `@Mark-Simulacrum`
2021-02-22 17:56:43 +00:00
Simonas Kazlauskas 24c23f5404 Test hexagon-enum only when llvm target is present
See https://github.com/rust-lang/rust/pull/82379#issuecomment-783439754
2021-02-22 19:10:02 +02:00
Felix S. Klock II 9fafffd50b Print out env vars related to Rust on (sufficiently verbose) rustc invocations.
Fix issue 38686.

(update: placated tidy.)
2021-02-22 11:43:13 -05:00
0yoyoyo 75d1e303af Update test cases 2021-02-22 23:39:06 +09:00
Ömer Sinan Ağacan 2145a8770c Fix mir-cfg dumps
Fixes #81918
Fixes #82326 (duplicate)
Fixes #82325
2021-02-22 17:36:30 +03:00
Takayuki Nakata e05965eb13 Remove unneeded blank lines from doc 2021-02-22 23:02:04 +09:00
Ömer Sinan Ağacan c0c4436011 Remove a redundant macro
Turn the macro into a function. Also remove unused 'span' argument.
2021-02-22 16:55:20 +03:00
Richard Dodd 0d6640a5b0 Add impl `Error` for `Arc` 2021-02-22 12:49:42 +00:00
bors 15598a83db Auto merge of #77551 - simonvandel:extend-simplify-branch-same, r=oli-obk
MIR-OPT: Pass to deduplicate blocks

This pass finds basic blocks that are completely equal,
and replaces all uses with just one of them.

```bash
$ RUSTC_LOG=rustc_mir::transform::deduplicate_blocks ./x.py build --stage 2 | grep "SUCCESS: Replacing: " > log
...
$ cat log | wc -l
23875
```
2021-02-22 12:14:23 +00:00
bors 697f3b6d4f Auto merge of #6775 - matthiaskrgr:upper_case_pedantic, r=flip1995
upper_case_acronyms: move lint from style to pedantic lint group

The lint does point out inconsistency with the Rust naming convention,
but the fact that rustc does not warn about the inconsistency by default
means that clippy probably should not warn by default either.

changelog: move upper_case_acronyms lint from style to pedantic group.
2021-02-22 11:40:20 +00:00
Matthias Krüger 0eefa6169d upper_case_acronyms: move lint from style to pedantic lint group
The lint does point out inconsistency with the Rust naming convention,
but the fact that rustc does not warn about the inconsistency by default
means that clippy probably should not warn by default either.

changelog: move upper_case_acronyms lint from style to pedantic group.
2021-02-22 12:30:28 +01:00
Ivan Tham 888811b059
Add Future trait for doc_spotlight feature doc 2021-02-22 19:02:02 +08:00
Ivan Tham bff4e937ab Add missing "see its documentation for more" stdio
StdoutLock and StderrLock does not have example, it would be better
to leave "see its documentation for more" like iter docs.
2021-02-22 18:48:32 +08:00
Nixon Enraght-Moony 4c949a455d Simplify Error Handling. 2021-02-22 10:33:33 +00:00
Laurențiu Nicola 5f7d6631f9 ⬆️ rust-analyzer 2021-02-22 12:02:37 +02:00
bors 8a9f7862bc Auto merge of #82393 - JohnTitor:rollup-5c8jryl, r=JohnTitor
Rollup of 9 pull requests

Successful merges:

 - #82098 (Add internal `collect_into_array[_unchecked]` to remove duplicate code)
 - #82228 (Provide NonZero_c_* integers)
 - #82287 (Make "missing field" error message more natural)
 - #82351 (Use the first paragraph, instead of cookie-cutter text, for rustdoc descriptions)
 - #82353 (rustdoc: Remove unnecessary `Cell` around `param_env`)
 - #82367 (remove redundant option/result wrapping of return values)
 - #82372 (improve UnsafeCell docs)
 - #82379 (Fix sizes of repr(C) enums on hexagon)
 - #82382 (rustdoc: Remove `fake_def_ids` RefCell)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-02-22 09:33:31 +00:00
bors fe01ddc8bc Auto merge of #6769 - Y-Nak:inconsistent-struct-constructor, r=matthiaskrgr
Inconsistent struct constructor

fixes: #6352
r? `@matthiaskrgr`

I added the lint that checks for the struct constructors where the order of the field init shorthands is inconsistent with that in the struct definition.

changelog: Add style lint: `inconsistent_struct_constructor`
2021-02-22 09:29:20 +00:00
Yuki Okushi 86940bed98
Rollup merge of #82382 - camelid:remove-fake_def_ids-refcell, r=jyn514
rustdoc: Remove `fake_def_ids` RefCell
2021-02-22 18:26:14 +09:00
Yuki Okushi 50a2de233a
Rollup merge of #82379 - nagisa:nagisa/hexagon-enums, r=estebank
Fix sizes of repr(C) enums on hexagon

Enums on hexagon use a smallest size (but at least 1 byte) that fits all
the enumeration values. This is unlike many other ABIs where enums are
at least 32 bits.

Fixes #82100
2021-02-22 18:26:13 +09:00
Yuki Okushi 7958166300
Rollup merge of #82372 - RalfJung:unsafe-cell, r=KodrAus
improve UnsafeCell docs

Sometimes [questions like this come up](https://rust-lang.zulipchat.com/#narrow/stream/136281-t-lang.2Fwg-unsafe-code-guidelines/topic/UnsafeCells.20as.20raw.20pointers) because the UnsafeCell docs say "it's the only legal way to obtain aliasable data that is considered mutable". That is not entirely correct, since raw pointers also provide that option. So I propose we focus the docs on the interaction of `UnsafeCell` and *shared references* specifically, which is really where they are needed.
2021-02-22 18:26:11 +09:00
Yuki Okushi 1870b3bac6
Rollup merge of #82367 - matthiaskrgr:wraps, r=petrochenkov
remove redundant option/result wrapping of return values

If a function always returns `Ok(something)`, we can return `something` directly and remove the corresponding error handling in the callers.
clippy::unnecessary_wraps
2021-02-22 18:26:10 +09:00
Yuki Okushi 4dfe69a6e6
Rollup merge of #82353 - camelid:no-more-param_env-cell, r=jyn514
rustdoc: Remove unnecessary `Cell` around `param_env`

r? `@jyn514`
2021-02-22 18:26:09 +09:00
Yuki Okushi 1dba8ce8a5
Rollup merge of #82351 - notriddle:docs-meta-description, r=jyn514
Use the first paragraph, instead of cookie-cutter text, for rustdoc descriptions

Partially addresses #82283.
2021-02-22 18:26:08 +09:00
Yuki Okushi 20c1fa1770
Rollup merge of #82287 - r00ster91:field_name_and, r=petrochenkov
Make "missing field" error message more natural

```rust
struct A {
    x: i32,
    y: i32,
    z: i32,
}

fn main() {
    A { };
}
```
```
error[E0063]: missing fields `x`, `y`, `z` in initializer of `A`
 --> src/main.rs:8:5
  |
8 |     A { };
  |     ^ missing `x`, `y`, `z`
```
This error is now:
```
error[E0063]: missing fields `x`, `y` and `z` in initializer of `A`
 --> src/main.rs:8:5
  |
8 |     A { };
  |     ^ missing `x`, `y` and `z`
```
I thought it looked nicer and more natural this way. Also, if there is >3 fields missing, there is an "and" as well ("missing \`x\`, \`y\`, \`z\` *and* 1 other field"), but for <=3 there is not. As such it improves consistency too.

As for the implementation, originally I ended up with a chunky `push_str` algorithm but then I figured I could just do the formatting manually since it's just 3 field names at maximum. It is comparatively readable.

As a sidenote, one thing I was wondering about is, isn't there more cases where you have a list of things like field names? Maybe this whole thing can at some point later be made into a more general function to be used in multiple areas.
2021-02-22 18:26:07 +09:00
Yuki Okushi a5f6668920
Rollup merge of #82228 - ijackson:nonzero-cint, r=KodrAus
Provide NonZero_c_* integers

I'm pretty sure I am going want this for #73125 and it seems like an
omission that would be in any case good to remedy.

<strike>Because the raw C types are in `std`, not `core`, to achieve this we
must export the relevant macros from `core` so that `std` can use
them.  That's done with a new `num_internals` perma-unstable feature.

The macros need to take more parameters for the module to get the
types from and feature attributes to use.

I have eyeballed the docs output for core, to check that my changes to
these macros have made no difference to the core docs output.</strike>
2021-02-22 18:26:06 +09:00
Yuki Okushi 3cf201fb81
Rollup merge of #82098 - LukasKalbertodt:add-collect-into-array, r=dtolnay
Add internal `collect_into_array[_unchecked]` to remove duplicate code

Unlike the similar PRs  #69985, #75644 and #79659, this PR only adds private functions and does not propose any new public API. The change is just for the purpose of avoiding duplicate code.

Many array methods already contained the same kind of code and there are still many array related methods to come (e.g. `Iterator::{chunks, map_windows, next_n, ...}`, `[T; N]::{cloned, copied, ...}`, ...) which all basically need this functionality. Writing custom `unsafe` code for each of those doesn't seem like a good idea. I added two functions in this PR (and not just the `unsafe` version) because I already know that I need the `Option`-returning version for `Iterator::map_windows`.

This is closely related to https://github.com/rust-lang/rust/issues/81615. I think that all options listed in that issue can be implemented using the function added in this PR. The only instance where `collect_array_into` might not be general enough is when the caller want to handle incomplete arrays manually. Currently, if `iter` yields fewer than `N` items, `None` is returned and the already yielded items are dropped. But as this is just a private function, it can be made more general in future PRs.

And while this was not the goal, this seems to lead to better assembly for `array::map`: https://rust.godbolt.org/z/75qKTa (CC ``@JulianKnodt)``

Let me know what you think :)

CC ``@matklad`` ``@bstrie``
2021-02-22 18:26:04 +09:00
Ralf Jung dd9ab160a1 disable atomic_max/min tests in Miri 2021-02-22 10:06:51 +01:00
1000teslas 1847a6c0c1 Extract deref coercion explanation into method 2021-02-22 19:08:44 +11:00
Esteban Küber fc6c19e2dc fix rebase 2021-02-21 23:15:59 -08:00
bors 352238d152 Auto merge of #79979 - GuillaumeGomez:rustdoc-gui-tests, r=Mark-Simulacrum
Rustdoc gui tests

This is a reopening of #70533.

For this first version, there will be no screenshot comparison. Also, a big change compared to the previous version: the tests are now hosted in the rust repository directly. Since there is no image, it's pretty lightweight to say the least.

So now, only remains the nodejs script to run the tests and the tests themselves. Just one thing is missing: where should I put the documentation for these tests? I'm not sure where would be the best place for that. The doc will contain important information like the documentation of the framework used and how to install it (`npm install browser-ui-test`, but still needs to be put somewhere so no one is lost).

We'd also need to install the package when running the CI too. For now, it runs as long as we have nodejs installed, but I think we don't it to run in all nodejs targets?

cc `@jyn514`

r? `@Mark-Simulacrum`
2021-02-22 06:47:59 +00:00
Jason Newcomb 23aa2f880c
Fix dogfood errors 2021-02-21 23:15:28 -05:00
bors e952db8fd0 Auto merge of #81732 - m-ou-se:inherit-overflow-checks, r=Mark-Simulacrum
Use `#[rustc_inherit_overflow_checks]` instead of Add::add etc.

See https://github.com/rust-lang/rust/issues/81721
2021-02-22 04:07:05 +00:00
Yoshitomo Nakanishi 5fe3b6c41a Quick fix cargo dev bless 2021-02-22 12:45:11 +09:00
Jason Newcomb efe33f9fe4
Add: option_manual_map lint 2021-02-21 22:06:03 -05:00
Camelid 45673e2d44 rustdoc: Remove `fake_def_ids` RefCell 2021-02-21 18:45:56 -08:00
Yoshitomo Nakanishi bfdf0fa03f Describe the order of fields in struct ctor doesn't affect the resulted instance 2021-02-22 11:45:25 +09:00
Esteban Küber 86b3f3f2b3 tidy 2021-02-21 16:34:37 -08:00
Esteban Küber d669882f38 Do not suggest `;` if expression is side effect free
When a tail expression isn't unit, we previously always suggested adding
a trailing `;` to turn it into a statement. This suggestion isn't
appropriate for any expression that doesn't have side-effects, as the
user will have likely wanted to call something else or do something with
the resulting value, instead of just discarding it.
2021-02-21 16:34:37 -08:00
Esteban Küber 020edd91a9 reword `;` suggestions to have consistent wording 2021-02-21 16:27:29 -08:00
Esteban Küber 796ce9fcb7 Suggest `return`ing tail expressions that match return type
Some newcomers are confused by the behavior of tail expressions,
interpreting that "leaving out the `;` makes it the return value".
To help them go in the right direction, suggest using `return` instead
when applicable.
2021-02-21 16:27:29 -08:00
bors 24bfcee941 Auto merge of #82295 - jyn514:feature-gate, r=Manishearth
[intra-doc links] Don't check feature gates of items re-exported across crates

It should be never break another crate to re-export a public item.

Note that this doesn't check the feature gate at
*all* for other crates:

- Feature-gates aren't currently serialized, so the only way to check
  the gate is with ad-hoc attribute checking.
- Checking the feature gate twice (once when documenting the original
  crate and one when documenting the current crate) seems not great.

This should still catch using the feature most of the time though, since
people tend to document their own crates.

Closes https://github.com/rust-lang/rust/issues/82284.

r? `@Manishearth`
2021-02-22 00:04:09 +00:00