Commit graph

139135 commits

Author SHA1 Message Date
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 returning 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
Simonas Kazlauskas
7130e462ee 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.
2021-02-22 01:05:17 +02:00
Simon Vandel Sillesen
2d1e0adfe9 New pass to deduplicate blocks 2021-02-21 21:51:54 +01:00
Simon Vandel Sillesen
1e865709a6 Make MatchBranchSimplification clean up after itself 2021-02-21 21:22:04 +01:00
Simon Vandel Sillesen
ccecc4f6bf Drive-by formatting of comment 2021-02-21 21:22:04 +01:00
Nixon Enraght-Moony
ba22a69d96 Extract string_to_value to its own function 2021-02-21 20:10:57 +00:00
Nixon Enraght-Moony
a22d948eb0
Apply suggestions from code review
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2021-02-21 19:45:32 +00:00
Matthias Krüger
da9a588d4f remove redundant wrapping of return types of allow_internal_unstable() and rustc_allow_const_fn_unstable() 2021-02-21 18:11:27 +01:00
Michael Howell
575c75b324
Update src/test/rustdoc/description.rs
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2021-02-21 09:31:39 -07:00
Michael Howell
a6b85fbc78
Update src/test/rustdoc/description.rs
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2021-02-21 09:31:23 -07:00
Ralf Jung
12608832c3 improve UnsafeCell docs 2021-02-21 17:24:19 +01:00
bors
728f3976f0 Auto merge of #6771 - MortenLohne:master, r=flip1995
Fix FP in inherent_to_string when the function has generic parameters

Minimal example of the false positive:
````
struct G;

impl G {
    fn to_string<const _N: usize>(&self) -> String {
        "G.to_string()".to_string()
    }
}

fn main() {
    let g = G;
    g.to_string::<1>();
}
````
Clippy emits an `inherent_to_string` warning, and suggests that we implement `Display` for `G` instead. However, this is not possible, since the generic parameter _N only exists in this function, not in `G` itself. This particular example uses const generics, which is where the issue is most likely to come up, but this PR skips the lint if the `to_string` function has any kind of generic parameters.

changelog: Fix FP in `inherent_to_string`
2021-02-21 16:10:03 +00:00
bors
208e95781b Auto merge of #6770 - ThibsG:PostfixEnumVariant, r=flip1995
Fix camel case postfix for `enum_variant_names` lint

Fix camel case postfix

Fixes: #4639

changelog: none
2021-02-21 15:58:47 +00:00
bors
8a47901bac Auto merge of #6765 - camsteffen:unnecessary-wraps-pedantic, r=flip1995
Change unnecessary_wraps to pedantic

changelog: Change unnecessary_wraps to pedantic

There seems to be enough evidence that this lint is not wanted as warn-by-default. Attempted before at #6380. False positives at #6721 and #6427. Actually requested to change the category at #6726.

Closes #6726
2021-02-21 15:33:50 +00:00
bors
d2ddf9c796 Auto merge of #6754 - camsteffen:spanlesseq-res, r=flip1995
Teach SpanlessEq binding IDs

changelog: Fix collapsible_match false positive

Fixes #6740

This PR changes the way `SpanlessEq` determines whether two local variables are the same. Instead of checking that the names match, it checks that the `HirId`s match. If local bindings are declared within the expressions that are being compared, `SpanlessEq` will remember bindings that correspond to each other in a `FxHashMap<HirId, HirId>`. This makes `SpanlessEq` more flexible while also fixing false positives.

Example: `{ let x = 1; x + 2 }` is equal to `{ let y = 1; y + 2 }`.

CC `@xFrednet` I think this will resolve some concerns in #6463
2021-02-21 15:22:35 +00:00
0yoyoyo
ce1a521012 Apply tidy check 2021-02-21 22:51:49 +09:00
Guillaume Gomez
20f2497efd Update CI scripts 2021-02-21 14:27:22 +01:00
Guillaume Gomez
8005092cf0 Add rustdoc gui tests 2021-02-21 14:25:12 +01:00