Commit Graph

139104 Commits

Author SHA1 Message Date
Aaron Hill 239e41df31
Rollup merge of #82431 - Aaron1011:fix/bug-env, r=jyn514
Set RUST_BACKTRACE=0 when running `treat-err-as-bug` tests

These ensure that these tests pass regardless of what RUST_BACKTRACE is
set to in the user's shell.
2021-02-25 16:06:17 -05:00
Aaron Hill 8c0119da77
Rollup merge of #82269 - LeSeulArtichaut:cleanup-ppmode, r=spastorino
Cleanup `PpMode` and friends

This PR:
 - Separates `PpSourceMode` and `PpHirMode` to remove invalid states
 - Renames the variant to remove the redundant `Ppm` prefix
 - Adds basic documentation for the different pretty-print modes
 - Cleanups some code to make it more idiomatic

Not sure if this is actually useful, but it looks cleaner to me.
2021-02-25 16:06:16 -05:00
bors 98f8cce6db Auto merge of #82447 - Amanieu:legacy_const_generics, r=oli-obk
Add #[rustc_legacy_const_generics]

This is the first step towards removing `#[rustc_args_required_const]`: a new attribute is added which rewrites function calls of the form `func(a, b, c)` to `func::<{b}>(a, c)`. This allows previously stabilized functions in `stdarch` which use `rustc_args_required_const` to use const generics instead.

This new attribute is not intended to ever be stabilized, it is only intended for use in `stdarch` as a replacement for `#[rustc_args_required_const]`.

```rust
#[rustc_legacy_const_generics(1)]
pub fn foo<const Y: usize>(x: usize, z: usize) -> [usize; 3] {
    [x, Y, z]
}

fn main() {
    assert_eq!(foo(0 + 0, 1 + 1, 2 + 2), [0, 2, 4]);
    assert_eq!(foo::<{1 + 1}>(0 + 0, 2 + 2), [0, 2, 4]);
}
```

r? `@oli-obk`
2021-02-25 18:14:50 +00:00
Esteban Küber 1d24f07271 Detect match statement intended to be tail expression
CC #24157
2021-02-25 09:16:48 -08:00
bors 0ab7c1d56f Auto merge of #82517 - Dylan-DPC:rollup-a1958gb, r=Dylan-DPC
Rollup of 16 pull requests

Successful merges:

 - #75807 (Convert core/num/mod.rs to intra-doc links)
 - #80534 (Use #[doc = include_str!()] in std)
 - #80553 (Add an impl of Error on `Arc<impl Error>`.)
 - #81167 (Make ptr::write const)
 - #81575 (rustdoc: Name fields of `ResolutionFailure::WrongNamespace`)
 - #81713 (Account for associated consts in the "unstable assoc item name colission" lint)
 - #82078 (Make char and u8 methods const)
 - #82087 (Fix ICE caused by suggestion with no code substitutions)
 - #82090 (Do not consider using a semicolon inside of a different-crate macro)
 - #82213 (Slices for vecs)
 - #82214 (Remove redundant to_string calls)
 - #82220 (fix the false 'defined here' messages)
 - #82313 (Update normalize.css to 8.0.1)
 - #82321 (AST: Remove some unnecessary boxes)
 - #82364 (Improve error msgs when found type is deref of expected)
 - #82514 (Update Clippy)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-02-25 15:15:59 +00:00
Dylan DPC ebe67d9810
Rollup merge of #82514 - flip1995:clippyup, r=Manishearth
Update Clippy

Bi-weekly Clippy update.

This updates `Cargo.lock`, so probably needs rollup=never. (0046d7c33e)

a6dd9b9606 fixes things in Clippy, so that it can be build and tested. This needs proper fixing in Clippy, but I didn't want this to block the sync.

r? `@Manishearth`
2021-02-25 14:34:05 +01:00
Dylan DPC 12ea0f6112
Rollup merge of #82364 - osa1:issue82361, r=estebank
Improve error msgs when found type is deref of expected

This improves help messages in two cases:

- When expected type is `T` and found type is `&T`, we now look through blocks
  and suggest dereferencing the expression of the block, rather than the whole
  block.

- In the above case, if the expression is an `&`, we not suggest removing the
  `&` instead of adding `*`.

Both of these are demonstrated in the regression test. Before this patch the
first error in the test would be:

    error[E0308]: `if` and `else` have incompatible types
     --> test.rs:8:9
      |
    5 | /     if true {
    6 | |         a
      | |         - expected because of this
    7 | |     } else {
    8 | |         b
      | |         ^ expected `usize`, found `&usize`
    9 | |     };
      | |_____- `if` and `else` have incompatible types
      |
    help: consider dereferencing the borrow
      |
    7 |     } else *{
    8 |         b
    9 |     };
      |

Now:

    error[E0308]: `if` and `else` have incompatible types
     --> test.rs:8:9
      |
    5 | /     if true {
    6 | |         a
      | |         - expected because of this
    7 | |     } else {
    8 | |         b
      | |         ^
      | |         |
      | |         expected `usize`, found `&usize`
      | |         help: consider dereferencing the borrow: `*b`
    9 | |     };
      | |_____- `if` and `else` have incompatible types

The second error:

    error[E0308]: `if` and `else` have incompatible types
      --> test.rs:14:9
       |
    11 | /     if true {
    12 | |         1
       | |         - expected because of this
    13 | |     } else {
    14 | |         &1
       | |         ^^ expected integer, found `&{integer}`
    15 | |     };
       | |_____- `if` and `else` have incompatible types
       |
    help: consider dereferencing the borrow
       |
    13 |     } else *{
    14 |         &1
    15 |     };
       |

now:

    error[E0308]: `if` and `else` have incompatible types
      --> test.rs:14:9
       |
    11 | /     if true {
    12 | |         1
       | |         - expected because of this
    13 | |     } else {
    14 | |         &1
       | |         ^-
       | |         ||
       | |         |help: consider removing the `&`: `1`
       | |         expected integer, found `&{integer}`
    15 | |     };
       | |_____- `if` and `else` have incompatible types

Fixes #82361

---

r? ````@estebank````
2021-02-25 14:34:04 +01:00
Dylan DPC 20928e0cbf
Rollup merge of #82321 - bugadani:ast3, r=varkor
AST: Remove some unnecessary boxes
2021-02-25 14:34:03 +01:00
Dylan DPC 05ed0814b9
Rollup merge of #82313 - jsha:update-normalize-css, r=GuillaumeGomez
Update normalize.css to 8.0.1

From From https://github.com/necolas/normalize.css/releases/tag/8.0.1.

The old version was 3.0.0, from 2014. The new version is from 2018.

I noticed when looking at frontend performance for rustdoc that this file was out of date. The URL in the 3.0.0 license header now resolves to an incorrect destination. And generally it seems good to be up-to-date.

Before-and-after images, plus diff, under details. TL;DR: Nothing changes except a slight adjustment to line height.

<details>

![with-normalize-8 0 1](https://user-images.githubusercontent.com/220205/108581849-bd5c8800-72e4-11eb-9150-78c8d67ca37a.png)

![with-normalize-3 0 0](https://user-images.githubusercontent.com/220205/108581848-bcc3f180-72e4-11eb-8b45-0cd1415a51e5.png)

![diff](https://user-images.githubusercontent.com/220205/108581890-dfeea100-72e4-11eb-93c5-6284492f54a9.png)

</details>
2021-02-25 14:34:02 +01:00
Dylan DPC 6bf486711b
Rollup merge of #82220 - henryboisdequin:fixes-80853, r=varkor
fix the false 'defined here' messages

Closes #80853.

Take this code:

```rust
struct S;

fn repro_ref(thing: S) {
    thing();
}
```

Previously, the error message would be this:

```
error[E0618]: expected function, found `S`
 --> src/lib.rs:4:5
  |
3 | fn repro_ref(thing: S) {
  |              ----- `S` defined here
4 |     thing();
  |     ^^^^^--
  |     |
  |     call expression requires function

error: aborting due to previous error
```

This is incorrect as `S` is not defined in the function arguments, `thing` is defined there. With this change, the following is emitted:

```
error[E0618]: expected function, found `S`
  --> $DIR/80853.rs:4:5
   |
LL | fn repro_ref(thing: S) {
   |              ----- is of type `S`
LL |     thing();
   |     ^^^^^--
   |     |
   |     call expression requires function
   |
   = note: local variable `S` is not a function

error: aborting due to previous error
```

As you can see, this error message points out that `thing` is of type `S` and later in a note, that `S` is not a function. This change does seem like a downside for some error messages. Take this example:

```
LL | struct Empty2;
   | -------------- is of type `Empty2`
```

As you can see, the error message shows that the definition of `Empty2` is of type `Empty2`. Although this isn't wrong, it would be more helpful if it would say something like this (which was there previously):

```
LL | struct Empty2;
   | -------------- `Empty2` defined here
```

If there is a better way of doing this, where the `Empty2` example would stay the same as without this change, please inform me.

**Update: This is now fixed**

CC `@camelid`
2021-02-25 14:34:00 +01:00
Dylan DPC 00aa3e6880
Rollup merge of #82214 - est31:no_to_string, r=oli-obk
Remove redundant to_string calls
2021-02-25 14:33:59 +01:00
Dylan DPC 199095afc6
Rollup merge of #82213 - est31:slices_for_vecs, r=jyn514
Slices for vecs
2021-02-25 14:33:58 +01:00
Dylan DPC 6b06e57f5f
Rollup merge of #82090 - notriddle:consider-using-a-semicolon-here, r=estebank
Do not consider using a semicolon inside of a different-crate macro

Fixes #81943
2021-02-25 14:33:57 +01:00
Dylan DPC 568ae3aee7
Rollup merge of #82087 - estebank:abolish-ice, r=oli-obk
Fix ICE caused by suggestion with no code substitutions

Change suggestion logic to filter and checking _before_ creating
specific resolution suggestion.

Assert earlier that suggestions contain code substitions to make it
easier in the future to debug invalid uses. If we find this becomes too
noisy in the wild, we can always make the emitter resilient to these
cases and remove the assertions.

Fix #78651.
2021-02-25 14:33:56 +01:00
Dylan DPC f891af9de5
Rollup merge of #82078 - lopopolo:char-u8-const-fn, r=m-ou-se
Make char and u8 methods const

char methods `len_utf8`, `len_utf16`, `to_ascii_lowercase`, `eq_ignore_ascii_case` can be made const.

`u8` methods `to_ascii_lowercase`, `to_ascii_uppercase` are required to be const as well.

`u8::eq_ignore_ascii_case` was additionally made const.

Rebase of https://github.com/rust-lang/rust/pull/79549 originally authored by ``@YenForYang.`` Changes from that PR:

- Squashed all commits from #79549.
- rebased to latest upstream master.
- Removed const attributes for `char::escape_unicode` and `char::escape_default`.
- Updated `since` attributes for `const` stabilization to 1.52.0.

cc ``@m-ou-se.``
2021-02-25 14:33:55 +01:00
Dylan DPC c5629131fa
Rollup merge of #81713 - estebank:unstable-assoc-item-lint, r=oli-obk
Account for associated consts in the "unstable assoc item name colission" lint

Fix #81663.
2021-02-25 14:33:53 +01:00
Dylan DPC 749d70ae69
Rollup merge of #81575 - camelid:rustdoc-wrongnamespace-cleanup, r=jyn514
rustdoc: Name fields of `ResolutionFailure::WrongNamespace`

It makes it clearer that the `Namespace` is the one requested by the
disambiguator, rather than the actual namespace of the item. It said
that in the docs before, but now you can tell in the code so it reduces
the potential for confusion.
2021-02-25 14:33:52 +01:00
Dylan DPC 4b9c213d6f
Rollup merge of #81167 - usbalbin:const_write, r=oli-obk
Make ptr::write const

~~The code in this PR as of right now is not much more than an experiment.~~

~~This should, if I am not mistaken, in theory compile and pass the tests once the bootstraping compiler is updated. Thus the PR is blocked on that which should happen some time after the February the 9th. Also we might want to wait for #79989 to avoid regressing performance due to using `mem::forget` over `intrinsics::forget`~~.
2021-02-25 14:33:51 +01:00
Dylan DPC 351d947e54
Rollup merge of #80553 - derekdreery:arc_error, r=m-ou-se
Add an impl of Error on `Arc<impl Error>`.

`Display` already exists so this should be a non-controversial change (famous last words).

Would have to be insta-stable.
2021-02-25 14:33:50 +01:00
Dylan DPC cb2b4ff714
Rollup merge of #80534 - LeSeulArtichaut:doc-include, r=jyn514
Use #[doc = include_str!()] in std

cc https://github.com/rust-lang/rust/issues/78835#issuecomment-742531894
r? `````@jyn514`````
2021-02-25 14:33:47 +01:00
Dylan DPC c9cf92226c
Rollup merge of #75807 - jyn514:num-intra-link, r=poliorcetics
Convert core/num/mod.rs to intra-doc links

Helps with #75080.
This can't convert the associated constants `MAX` and `MIN` until #74489 is merged.

r? `@poliorcetics`
2021-02-25 14:33:44 +01:00
bors b36f77012d Auto merge of #82265 - GuillaumeGomez:cleanup-attrs-twice, r=jyn514
Prevent to compute Item attributes twice

I came across this case when working on another part of rustdoc. Not a game changer but a nice little improvement.

cc `@camelid`

r? `@jyn514`
2021-02-25 12:33:21 +00:00
Henry Boisdequin d7cb66d389 add helpful error notes and fix the false 'defined here' messages 2021-02-25 16:11:18 +05:30
flip1995 0046d7c33e
Update Cargo.lock 2021-02-25 11:26:23 +01:00
flip1995 a6dd9b9606
Fix Clippy build and test 2021-02-25 11:25:45 +01:00
flip1995 81af3468fe
Merge commit '928e72dd10749875cbd412f74bfbfd7765dbcd8a' into clippyup 2021-02-25 11:25:22 +01:00
bors 928e72dd10 Auto merge of #6789 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: None
2021-02-25 09:49:12 +00:00
flip1995 8f8c7c293c
Bump nightly version -> 2021-02-25 2021-02-25 10:40:24 +01:00
flip1995 c6408a47bd
Merge remote-tracking branch 'upstream/master' into rustup 2021-02-25 10:40:00 +01:00
Amanieu d'Antras 00afbe70f2 Improve checking for attribute 2021-02-25 09:04:43 +00:00
bors ef41f2baf7 Auto merge of #6788 - matthiaskrgr:upper_case_acronyms, r=flip1995
move upper_case_acronyms back to style, but make the default behaviour less aggressive by default (can be unleashed via config option)

Previous discussion in the bi-weekly clippy meeting for reference: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Meeting.202021-02-23/near/227458019

Move the `upper_case_acronyms` lint back to the style group.
Only warn on fully-capitalized names by default.
Add add a clippy-config option `upper-case-acronyms-aggressive: true/false` to enabled more aggressive linting on
all substrings that could be capitalized acronyms.

---
changelog: reenable upper_case_acronyms by default but make the more aggressive linting opt-in via config option
2021-02-25 09:01:41 +00:00
Matthias Krüger 2a6b06108d run cargo dev update_lints
fix sentence / address review comments
2021-02-25 09:59:39 +01:00
bors 89d32eb1ea Auto merge of #82338 - RalfJung:interp-error-allocs, r=oli-obk
all InterpError allocate now, so adjust alloc-error-check

Cc https://github.com/rust-lang/rust/pull/82116#discussion_r578310770
r? `@oli-obk`
2021-02-25 08:27:09 +00:00
Jacob Hoffman-Andrews 51a14c7265 Fix back-forward cache in rustdoc frontend.
Rustdoc's frontend set a no-op unload handler, specifically to disable
Firefox's back-forward cache because it caused a bug. It's nice to
allow the back-forward cache because it permits faster navigations.

This change addresses the issues that were caused by back-forward cache.

https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/1.5/Using_Firefox_1.5_caching
https://web.dev/bfcache/
2021-02-24 22:16:26 -08:00
Joshua Nelson 0ae4bf912e Fix typo in `param_env_reveal_all_normalized` #82510
This made the generated docs look strange: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.param_env_reveal_all_normalized
2021-02-25 00:41:38 -05:00
Nell Shamrell 356beb3084 clarifies error when finding mismatched returned types for async functions
Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
2021-02-24 18:46:54 -08:00
Esteban Küber fb24a10ad3 Properly account for non-shorthand pattern field in unused variable lint
Fix #82488
2021-02-24 18:08:37 -08:00
klensy 08b1e8004b fix review 2021-02-25 04:21:12 +03:00
Amanieu d'Antras 22184a0f5d Add a cache for rustc_legacy_const_generics 2021-02-25 00:37:56 +00:00
Amanieu d'Antras cccd77955b Fix tests 2021-02-25 00:37:42 +00:00
bors 63bacf14cd Auto merge of #82162 - cuviper:flat-fold, r=Mark-Simulacrum
Expand FlattenCompat folds

The former `chain`+`chain`+`fold` implementation looked nice from a
functional-programming perspective, but it introduced unnecessary layers
of abstraction on every `flat_map`/`flatten` fold. It's straightforward
to just fold each part in turn, and this makes it look like a simplified
version of the existing `try_fold` implementation.

For the `iter::bench_flat_map*` benchmarks, I get a large improvement in
`bench_flat_map_chain_sum`, from 1,598,473 ns/iter to 499,889 ns/iter,
and the rest are unchanged.
2021-02-25 00:36:05 +00:00
bors 76a689d8c2 Auto merge of #6783 - avitex:add-opendns-ident, r=giraffate
Add OpenDNS to `doc-valid-idents`

changelog: This commit adds `"OpenDNS"` to doc-valid-idents to avoid `doc_markdown` false positives.
2021-02-25 00:22:39 +00:00
Amanieu d'Antras 2451f124c9 Address review comments 2021-02-25 00:09:33 +00:00
katelyn martin f06896ca7a
fix typo in `pre-commit.sh` 2021-02-24 18:37:13 -05:00
Esteban Küber e655941241 Account for associated consts in the "unstable assoc item name colission" lint
Fix #81663.
2021-02-24 15:35:16 -08:00
Joshua Nelson 97ab01219c Only look for `tidy` when running rustdoc tests
This avoids printing lots of unnecessary errors, as well as making the
test suite slightly faster.
2021-02-24 18:14:43 -05:00
Matthias Krüger 913c71018c upper_case_acronyms: add io-toml tests and bless previous tests 2021-02-24 23:50:55 +01:00
Matthias Krüger 59750dceb8 upper_case_acronyms: add optional aggressive mode and relax default
Moves the lint back from pedantic to style group.
The lint default now only warns on names that are completely capitalized, like "WORD"
and only if the name is longer than 2 chars (so that names where each of the letter represents a word are still distinguishable).
For example: FP (false positive) would still be "valid" and not warned about (but EOF would warn).

A "upper_case_acronyms_aggressive: true/false" config option was added that restores the original lint behaviour to warn
on any kind of camel case name that had more than one capital letter following another capital letter.
2021-02-24 23:50:53 +01:00
avitex b0d18e93d6
add test coverage for all `doc-valid-idents` 2021-02-25 09:30:33 +11:00
avitex 72e3335684
Add OpenDNS to `doc-valid-idents` 2021-02-25 09:30:33 +11:00