]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoRollup merge of #81940 - jhpratt:stabilize-str_split_once, r=m-ou-se
Guillaume Gomez [Fri, 26 Feb 2021 14:52:29 +0000 (15:52 +0100)]
Rollup merge of #81940 - jhpratt:stabilize-str_split_once, r=m-ou-se

Stabilize str_split_once

Closes #74773

3 years agoAuto merge of #78429 - casey:doctest-attribute-splitting, r=jyn514
bors [Fri, 26 Feb 2021 00:17:22 +0000 (00:17 +0000)]
Auto merge of #78429 - casey:doctest-attribute-splitting, r=jyn514

[librustdoc] Only split lang string on `,`, ` `, and `\t`

Split markdown lang strings into tokens on `,`.

The previous behavior was to split lang strings into tokens on any
character that wasn't a `_`, `_`, or alphanumeric.

This is a potentially breaking change, so please scrutinize! See discussion in #78344.

I noticed some test cases that made me wonder if there might have been some reason for the original behavior:

```
t("{.no_run .example}", false, true, Ignore::None, true, false, false, false, v(), None);
t("{.sh .should_panic}", true, false, Ignore::None, false, false, false, false, v(), None);
t("{.example .rust}", false, false, Ignore::None, true, false, false, false, v(), None);
t("{.test_harness .rust}", false, false, Ignore::None, true, true, false, false, v(), None);
```

It seemed pretty peculiar to specifically test lang strings in braces, with all the tokens prefixed by `.`.

I did some digging, and it looks like the test cases were added way back in [this commit from 2014](https://github.com/rust-lang/rust/commit/3fef7a74ca9a) by `@skade.`

It looks like they were added just to make sure that the splitting was permissive, and aren't testing that those strings in particular are accepted.

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

3 years agoAuto merge of #82530 - Aaron1011:rollup-aalwq15, r=Aaron1011
bors [Thu, 25 Feb 2021 21:34:55 +0000 (21:34 +0000)]
Auto merge of #82530 - Aaron1011:rollup-aalwq15, r=Aaron1011

Rollup of 11 pull requests

Successful merges:

 - #82269 (Cleanup `PpMode` and friends)
 - #82431 (Set RUST_BACKTRACE=0 when running `treat-err-as-bug` tests)
 - #82441 (Fix typo in sanitizer flag in unstable book.)
 - #82463 (panic_bounds_checks should be panic_bounds_check)
 - #82464 (Update outdated comment in unix Command.)
 - #82467 (library: Normalize safety-for-unsafe-block comments)
 - #82468 (Move pick_by_value_method docs above function header)
 - #82484 (rustdoc: Remove duplicate "List of all items")
 - #82502 (Only look for HTML `tidy` when running rustdoc tests)
 - #82503 (fix typo in `pre-commit.sh`)
 - #82510 (Fix typo in `param_env_reveal_all_normalized`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agoRollup merge of #82510 - jyn514:fix-typo, r=Dylan-DPC
Aaron Hill [Thu, 25 Feb 2021 21:06:26 +0000 (16:06 -0500)]
Rollup merge of #82510 - jyn514:fix-typo, r=Dylan-DPC

Fix typo in `param_env_reveal_all_normalized`

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

3 years agoRollup merge of #82503 - cratelyn:patch-1, r=Mark-Simulacrum
Aaron Hill [Thu, 25 Feb 2021 21:06:25 +0000 (16:06 -0500)]
Rollup merge of #82503 - cratelyn:patch-1, r=Mark-Simulacrum

fix typo in `pre-commit.sh`

This updates a small typo I found, no more no less :slightly_smiling_face:

3 years agoRollup merge of #82502 - jyn514:tidy, r=petrochenkov
Aaron Hill [Thu, 25 Feb 2021 21:06:24 +0000 (16:06 -0500)]
Rollup merge of #82502 - jyn514:tidy, r=petrochenkov

Only look for HTML `tidy` when running rustdoc tests

This avoids printing lots of unnecessary errors, as well as making the
test suite slightly faster. This doesn't fix the windows bug tracked by https://github.com/rust-lang/rust/issues/82501, though.

r? `@petrochenkov`

3 years agoRollup merge of #82484 - bugadani:docfix, r=jyn514
Aaron Hill [Thu, 25 Feb 2021 21:06:23 +0000 (16:06 -0500)]
Rollup merge of #82484 - bugadani:docfix, r=jyn514

rustdoc: Remove duplicate "List of all items"

Closes #82477

r? `@jyn514`

3 years agoRollup merge of #82468 - osa1:pick_by_value_method_docs, r=petrochenkov
Aaron Hill [Thu, 25 Feb 2021 21:06:22 +0000 (16:06 -0500)]
Rollup merge of #82468 - osa1:pick_by_value_method_docs, r=petrochenkov

Move pick_by_value_method docs above function header

- Currently style triggers #81183 so we can't add `#[instrument]` to
  this function.

- Having docs above the header is more consistent with the rest of the
  code base.

3 years agoRollup merge of #82467 - ojeda:tidy-normalize-safety-comments, r=kennytm
Aaron Hill [Thu, 25 Feb 2021 21:06:21 +0000 (16:06 -0500)]
Rollup merge of #82467 - ojeda:tidy-normalize-safety-comments, r=kennytm

library: Normalize safety-for-unsafe-block comments

Almost all safety comments are of the form `// SAFETY:`,
so normalize the rest and fix a few of them that should
have been a `/// # Safety` section instead.

Furthermore, make `tidy` only allow the uppercase form. While
currently `tidy` only checks `core`, it is a good idea to prevent
`core` from drifting to non-uppercase comments, so that later
we can start checking `alloc` etc. too.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
3 years agoRollup merge of #82464 - ehuss:unix-command-comment, r=kennytm
Aaron Hill [Thu, 25 Feb 2021 21:06:20 +0000 (16:06 -0500)]
Rollup merge of #82464 - ehuss:unix-command-comment, r=kennytm

Update outdated comment in unix Command.

The big comment in the `Command` struct has been incorrect for some time (at least since #46789 which removed `envp`). Rather than try to remove the allocations, this PR just updates the comment to reflect reality. There is an explanation for the reasoning at https://github.com/rust-lang/rust/pull/31409#issuecomment-182122895, discussing the potential of being able to call `Command::exec` after `libc::fork`.  That can still be done in the future, but I think for now it would be good to just correct the comment.

3 years agoRollup merge of #82463 - jrmuizel:patch-1, r=steveklabnik
Aaron Hill [Thu, 25 Feb 2021 21:06:19 +0000 (16:06 -0500)]
Rollup merge of #82463 - jrmuizel:patch-1, r=steveklabnik

panic_bounds_checks should be panic_bounds_check

3 years agoRollup merge of #82441 - frewsxcv:frewsxcv-docs, r=GuillaumeGomez
Aaron Hill [Thu, 25 Feb 2021 21:06:18 +0000 (16:06 -0500)]
Rollup merge of #82441 - frewsxcv:frewsxcv-docs, r=GuillaumeGomez

Fix typo in sanitizer flag in unstable book.

3 years agoRollup merge of #82431 - Aaron1011:fix/bug-env, r=jyn514
Aaron Hill [Thu, 25 Feb 2021 21:06:17 +0000 (16:06 -0500)]
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.

3 years agoRollup merge of #82269 - LeSeulArtichaut:cleanup-ppmode, r=spastorino
Aaron Hill [Thu, 25 Feb 2021 21:06:16 +0000 (16:06 -0500)]
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.

3 years agoAuto merge of #82447 - Amanieu:legacy_const_generics, r=oli-obk
bors [Thu, 25 Feb 2021 18:14:50 +0000 (18:14 +0000)]
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`

3 years agoAuto merge of #82517 - Dylan-DPC:rollup-a1958gb, r=Dylan-DPC
bors [Thu, 25 Feb 2021 15:15:59 +0000 (15:15 +0000)]
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

3 years agoRollup merge of #82514 - flip1995:clippyup, r=Manishearth
Dylan DPC [Thu, 25 Feb 2021 13:34:05 +0000 (14:34 +0100)]
Rollup merge of #82514 - flip1995:clippyup, r=Manishearth

Update Clippy

Bi-weekly Clippy update.

This updates `Cargo.lock`, so probably needs rollup=never. (https://github.com/rust-lang/rust/commit/0046d7c33e944e87a5cabc940f21bacdce5af307)

https://github.com/rust-lang/rust/commit/a6dd9b96068800fd548a72b3aa7ac4712d1d0c49 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`

3 years agoRollup merge of #82364 - osa1:issue82361, r=estebank
Dylan DPC [Thu, 25 Feb 2021 13:34:04 +0000 (14:34 +0100)]
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````

3 years agoRollup merge of #82321 - bugadani:ast3, r=varkor
Dylan DPC [Thu, 25 Feb 2021 13:34:03 +0000 (14:34 +0100)]
Rollup merge of #82321 - bugadani:ast3, r=varkor

AST: Remove some unnecessary boxes

3 years agoRollup merge of #82313 - jsha:update-normalize-css, r=GuillaumeGomez
Dylan DPC [Thu, 25 Feb 2021 13:34:02 +0000 (14:34 +0100)]
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>

3 years agoRollup merge of #82220 - henryboisdequin:fixes-80853, r=varkor
Dylan DPC [Thu, 25 Feb 2021 13:34:00 +0000 (14:34 +0100)]
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`

3 years agoRollup merge of #82214 - est31:no_to_string, r=oli-obk
Dylan DPC [Thu, 25 Feb 2021 13:33:59 +0000 (14:33 +0100)]
Rollup merge of #82214 - est31:no_to_string, r=oli-obk

Remove redundant to_string calls

3 years agoRollup merge of #82213 - est31:slices_for_vecs, r=jyn514
Dylan DPC [Thu, 25 Feb 2021 13:33:58 +0000 (14:33 +0100)]
Rollup merge of #82213 - est31:slices_for_vecs, r=jyn514

Slices for vecs

3 years agoRollup merge of #82090 - notriddle:consider-using-a-semicolon-here, r=estebank
Dylan DPC [Thu, 25 Feb 2021 13:33:57 +0000 (14:33 +0100)]
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

3 years agoRollup merge of #82087 - estebank:abolish-ice, r=oli-obk
Dylan DPC [Thu, 25 Feb 2021 13:33:56 +0000 (14:33 +0100)]
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.

3 years agoRollup merge of #82078 - lopopolo:char-u8-const-fn, r=m-ou-se
Dylan DPC [Thu, 25 Feb 2021 13:33:55 +0000 (14:33 +0100)]
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.``

3 years agoRollup merge of #81713 - estebank:unstable-assoc-item-lint, r=oli-obk
Dylan DPC [Thu, 25 Feb 2021 13:33:53 +0000 (14:33 +0100)]
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.

3 years agoRollup merge of #81575 - camelid:rustdoc-wrongnamespace-cleanup, r=jyn514
Dylan DPC [Thu, 25 Feb 2021 13:33:52 +0000 (14:33 +0100)]
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.

3 years agoRollup merge of #81167 - usbalbin:const_write, r=oli-obk
Dylan DPC [Thu, 25 Feb 2021 13:33:51 +0000 (14:33 +0100)]
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`~~.

3 years agoRollup merge of #80553 - derekdreery:arc_error, r=m-ou-se
Dylan DPC [Thu, 25 Feb 2021 13:33:50 +0000 (14:33 +0100)]
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.

3 years agoRollup merge of #80534 - LeSeulArtichaut:doc-include, r=jyn514
Dylan DPC [Thu, 25 Feb 2021 13:33:47 +0000 (14:33 +0100)]
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`````

3 years agoRollup merge of #75807 - jyn514:num-intra-link, r=poliorcetics
Dylan DPC [Thu, 25 Feb 2021 13:33:44 +0000 (14:33 +0100)]
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`

3 years agoAuto merge of #82265 - GuillaumeGomez:cleanup-attrs-twice, r=jyn514
bors [Thu, 25 Feb 2021 12:33:21 +0000 (12:33 +0000)]
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`

3 years agoadd helpful error notes and fix the false 'defined here' messages
Henry Boisdequin [Wed, 17 Feb 2021 14:50:59 +0000 (20:20 +0530)]
add helpful error notes and fix the false 'defined here' messages

3 years agoUpdate Cargo.lock
flip1995 [Thu, 25 Feb 2021 10:26:23 +0000 (11:26 +0100)]
Update Cargo.lock

3 years agoFix Clippy build and test
flip1995 [Thu, 25 Feb 2021 10:25:45 +0000 (11:25 +0100)]
Fix Clippy build and test

3 years agoMerge commit '928e72dd10749875cbd412f74bfbfd7765dbcd8a' into clippyup
flip1995 [Thu, 25 Feb 2021 10:25:22 +0000 (11:25 +0100)]
Merge commit '928e72dd10749875cbd412f74bfbfd7765dbcd8a' into clippyup

3 years agoAuto merge of #6789 - flip1995:rustup, r=flip1995
bors [Thu, 25 Feb 2021 09:49:12 +0000 (09:49 +0000)]
Auto merge of #6789 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: None

3 years agoBump nightly version -> 2021-02-25
flip1995 [Thu, 25 Feb 2021 09:40:24 +0000 (10:40 +0100)]
Bump nightly version -> 2021-02-25

3 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Thu, 25 Feb 2021 09:40:00 +0000 (10:40 +0100)]
Merge remote-tracking branch 'upstream/master' into rustup

3 years agoImprove checking for attribute
Amanieu d'Antras [Thu, 25 Feb 2021 09:04:43 +0000 (09:04 +0000)]
Improve checking for attribute

3 years agoAuto merge of #6788 - matthiaskrgr:upper_case_acronyms, r=flip1995
bors [Thu, 25 Feb 2021 09:01:41 +0000 (09:01 +0000)]
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

3 years agorun cargo dev update_lints
Matthias Krüger [Wed, 24 Feb 2021 23:10:06 +0000 (00:10 +0100)]
run cargo dev update_lints

fix sentence / address review comments

3 years agoAuto merge of #82338 - RalfJung:interp-error-allocs, r=oli-obk
bors [Thu, 25 Feb 2021 08:27:09 +0000 (08:27 +0000)]
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`

3 years agoFix typo in `param_env_reveal_all_normalized` #82510
Joshua Nelson [Thu, 25 Feb 2021 05:41:38 +0000 (00:41 -0500)]
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

3 years agoAdd a cache for rustc_legacy_const_generics
Amanieu d'Antras [Thu, 25 Feb 2021 00:37:56 +0000 (00:37 +0000)]
Add a cache for rustc_legacy_const_generics

3 years agoFix tests
Amanieu d'Antras [Thu, 25 Feb 2021 00:37:42 +0000 (00:37 +0000)]
Fix tests

3 years agoAuto merge of #82162 - cuviper:flat-fold, r=Mark-Simulacrum
bors [Thu, 25 Feb 2021 00:36:05 +0000 (00:36 +0000)]
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.

3 years agoAuto merge of #6783 - avitex:add-opendns-ident, r=giraffate
bors [Thu, 25 Feb 2021 00:22:39 +0000 (00:22 +0000)]
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.

3 years agoAddress review comments
Amanieu d'Antras [Thu, 25 Feb 2021 00:09:33 +0000 (00:09 +0000)]
Address review comments

3 years agofix typo in `pre-commit.sh`
katelyn martin [Wed, 24 Feb 2021 23:37:13 +0000 (18:37 -0500)]
fix typo in `pre-commit.sh`

3 years agoAccount for associated consts in the "unstable assoc item name colission" lint
Esteban Küber [Wed, 3 Feb 2021 16:38:05 +0000 (08:38 -0800)]
Account for associated consts in the "unstable assoc item name colission" lint

Fix #81663.

3 years agoOnly look for `tidy` when running rustdoc tests
Joshua Nelson [Wed, 24 Feb 2021 23:13:47 +0000 (18:13 -0500)]
Only look for `tidy` when running rustdoc tests

This avoids printing lots of unnecessary errors, as well as making the
test suite slightly faster.

3 years agoupper_case_acronyms: add io-toml tests and bless previous tests
Matthias Krüger [Wed, 24 Feb 2021 22:41:32 +0000 (23:41 +0100)]
upper_case_acronyms: add io-toml tests and bless previous tests

3 years agoupper_case_acronyms: add optional aggressive mode and relax default
Matthias Krüger [Wed, 24 Feb 2021 22:20:49 +0000 (23:20 +0100)]
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.

3 years agoadd test coverage for all `doc-valid-idents`
avitex [Wed, 24 Feb 2021 22:26:11 +0000 (09:26 +1100)]
add test coverage for all `doc-valid-idents`

3 years agoAdd OpenDNS to `doc-valid-idents`
avitex [Wed, 24 Feb 2021 04:04:00 +0000 (15:04 +1100)]
Add OpenDNS to `doc-valid-idents`

3 years agoAuto merge of #82159 - BoxyUwU:uwu, r=varkor
bors [Wed, 24 Feb 2021 21:54:52 +0000 (21:54 +0000)]
Auto merge of #82159 - BoxyUwU:uwu, r=varkor

Use correct param_env in conservative_is_privately_uninhabited

cc `@lcnr`
r? `@varkor` since this is your FIXME that was removed ^^

3 years agoAdd test
Dániel Buga [Wed, 24 Feb 2021 17:14:31 +0000 (18:14 +0100)]
Add test

3 years agoRemove duplicate string
Dániel Buga [Wed, 24 Feb 2021 16:44:37 +0000 (17:44 +0100)]
Remove duplicate string

3 years agoAuto merge of #6786 - smoelius:move-conf-rs-back-into-clippy-lints, r=flip1995
bors [Wed, 24 Feb 2021 14:51:14 +0000 (14:51 +0000)]
Auto merge of #6786 - smoelius:move-conf-rs-back-into-clippy-lints, r=flip1995

Move conf.rs back into clippy_lints

This is an alternative solution to #6785 to fix the CI break caused by #6756.

changelog: none

3 years agoAuto merge of #80914 - GuillaumeGomez:remove-is_spotlight, r=jyn514
bors [Wed, 24 Feb 2021 14:46:18 +0000 (14:46 +0000)]
Auto merge of #80914 - GuillaumeGomez:remove-is_spotlight, r=jyn514

Remove is_spotlight field from `Trait`

Small PR, only the last commit is relevant here. The rest is coming from #80883 because I need the `TyCtxt` stored inside `Cache`.

The point is to make ItemKind looks as close as possible to the compiler type so that it makes the switch simpler (which is why I make all these "small" PRs).

r? `@jyn514`

3 years agoMove conf.rs back into clippy_lints
Samuel E. Moelius III [Wed, 24 Feb 2021 11:12:27 +0000 (06:12 -0500)]
Move conf.rs back into clippy_lints

3 years agoAuto merge of #6756 - smoelius:clippy_utils, r=flip1995,obi-obk
bors [Wed, 24 Feb 2021 09:43:23 +0000 (09:43 +0000)]
Auto merge of #6756 - smoelius:clippy_utils, r=flip1995,obi-obk

Factor out `clippy_utils` crate

As discussed in https://github.com/rust-lang/rust-clippy/pull/6746, this PR factors out `clippy_lints::utils` as its own crate, `clippy_utils` .

This change will allow `clippy_utils` to be used in lints outside of Clippy.

There is no plan to publish this crate on `crates.io` (see https://github.com/rust-lang/rust-clippy/pull/6746#issuecomment-780747522). Dependent crates should obtain it from GitHub.

changelog: Factor out `clippy_utils` so it can be used by external tools (not published)

3 years agoAuto merge of #6782 - ojeda:readme-as-wrapper, r=flip1995
bors [Wed, 24 Feb 2021 09:31:26 +0000 (09:31 +0000)]
Auto merge of #6782 - ojeda:readme-as-wrapper, r=flip1995

README: Add subsection on running Clippy as a rustc wrapper

This is useful for projects that do not use cargo.

changelog: README: Add subsection on running Clippy as a rustc wrapper

3 years agoMake DocContext &mut for clean
Guillaume Gomez [Wed, 24 Feb 2021 09:16:33 +0000 (10:16 +0100)]
Make DocContext &mut for clean

3 years agoPrevent to compute Item attributes twice
Guillaume Gomez [Thu, 18 Feb 2021 16:29:44 +0000 (17:29 +0100)]
Prevent to compute Item attributes twice

3 years agoTurn Pick field comments into documentation
Ömer Sinan Ağacan [Wed, 24 Feb 2021 07:36:43 +0000 (10:36 +0300)]
Turn Pick field comments into documentation

3 years agoAuto merge of #80475 - simonvandel:fix-77355, r=oli-obk
bors [Wed, 24 Feb 2021 07:23:54 +0000 (07:23 +0000)]
Auto merge of #80475 - simonvandel:fix-77355, r=oli-obk

New mir-opt pass to simplify gotos with const values (reopening #77486)

Reopening PR #77486

Fixes #77355

This pass optimizes the following sequence
```rust
bb2: {
    _2 = const true;
    goto -> bb3;
}

bb3: {
    switchInt(_2) -> [false: bb4, otherwise: bb5];
}
```
into
```rust
bb2: {
    _2 = const true;
    goto -> bb5;
}
```

3 years agoProperly reject non-const arguments
Amanieu d'Antras [Wed, 24 Feb 2021 06:46:30 +0000 (06:46 +0000)]
Properly reject non-const arguments

3 years agoMove pick_by_value_method docs above function header
Ömer Sinan Ağacan [Wed, 24 Feb 2021 06:36:07 +0000 (09:36 +0300)]
Move pick_by_value_method docs above function header

- Currently style triggers #81183 so we can't add `#[instrument]` to
  this function.

- Having docs above the header is more consistent with the rest of the
  code base.

3 years agolibrary: Normalize safety-for-unsafe-block comments
Miguel Ojeda [Wed, 24 Feb 2021 04:48:44 +0000 (05:48 +0100)]
library: Normalize safety-for-unsafe-block comments

Almost all safety comments are of the form `// SAFETY:`,
so normalize the rest and fix a few of them that should
have been a `/// # Safety` section instead.

Furthermore, make `tidy` only allow the uppercase form. While
currently `tidy` only checks `core`, it is a good idea to prevent
`core` from drifting to non-uppercase comments, so that later
we can start checking `alloc` etc. too.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
3 years agorustdoc: Name fields of `ResolutionFailure::WrongNamespace`
Camelid [Sat, 30 Jan 2021 23:47:53 +0000 (15:47 -0800)]
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.

3 years agoUpdate outdated comment in unix Command.
Eric Huss [Wed, 24 Feb 2021 04:19:15 +0000 (20:19 -0800)]
Update outdated comment in unix Command.

3 years agopanic_bounds_checks should be panic_bounds_check
Jeff Muizelaar [Wed, 24 Feb 2021 03:27:21 +0000 (22:27 -0500)]
panic_bounds_checks should be panic_bounds_check

3 years agoAuto merge of #80891 - cjgillot:noq, r=Mark-Simulacrum
bors [Wed, 24 Feb 2021 03:29:00 +0000 (03:29 +0000)]
Auto merge of #80891 - cjgillot:noq, r=Mark-Simulacrum

Make the `Query` enum a simple struct.

A lot of code in `rustc_query_system` is generic over it, only to encode an exceptional error case: query cycles.
The delayed computations are now done at cycle detection.

3 years agoTODO -> FIXME
Amanieu d'Antras [Wed, 24 Feb 2021 02:36:45 +0000 (02:36 +0000)]
TODO -> FIXME

3 years agoREADME: Add subsection on running Clippy as a rustc wrapper
Miguel Ojeda [Tue, 23 Feb 2021 14:54:40 +0000 (15:54 +0100)]
README: Add subsection on running Clippy as a rustc wrapper

This is useful for projects that do not use cargo.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
3 years agoMove `declare_clippy_lint` back into clippy_lints
Samuel E. Moelius III [Thu, 18 Feb 2021 17:25:35 +0000 (12:25 -0500)]
Move `declare_clippy_lint` back into clippy_lints

3 years agoUpdate references in doc directory
Samuel E. Moelius III [Thu, 18 Feb 2021 11:08:46 +0000 (06:08 -0500)]
Update references in doc directory

3 years agoUpdate clippy_utils/Cargo.toml
Samuel E. Moelius [Thu, 18 Feb 2021 10:41:37 +0000 (05:41 -0500)]
Update clippy_utils/Cargo.toml

Co-authored-by: Philipp Krones <hello@philkrones.com>
3 years agoTypo
Samuel E. Moelius III [Thu, 18 Feb 2021 02:54:15 +0000 (21:54 -0500)]
Typo

3 years agoRemove file accidentally re-added during rebase
Samuel E. Moelius III [Thu, 18 Feb 2021 02:51:21 +0000 (21:51 -0500)]
Remove file accidentally re-added during rebase

3 years agoUpdate custom_ice_message.stderr
Samuel E. Moelius III [Thu, 18 Feb 2021 02:04:38 +0000 (21:04 -0500)]
Update custom_ice_message.stderr

3 years agoFix update_lints
Samuel E. Moelius III [Thu, 18 Feb 2021 01:54:14 +0000 (20:54 -0500)]
Fix update_lints

3 years agoFix doc test
Samuel E. Moelius III [Wed, 17 Feb 2021 23:53:21 +0000 (18:53 -0500)]
Fix doc test

3 years agoBump clippy_utils version
Samuel E. Moelius III [Wed, 17 Feb 2021 22:05:52 +0000 (17:05 -0500)]
Bump clippy_utils version

3 years agoFix versioncheck test
Samuel E. Moelius III [Wed, 17 Feb 2021 22:05:32 +0000 (17:05 -0500)]
Fix versioncheck test

3 years agoFix one import
Samuel E. Moelius III [Wed, 17 Feb 2021 22:03:29 +0000 (17:03 -0500)]
Fix one import

3 years agoImprove tests
Samuel E. Moelius III [Wed, 17 Feb 2021 17:30:48 +0000 (12:30 -0500)]
Improve tests

3 years agoRemove unused features
Samuel E. Moelius III [Sat, 13 Feb 2021 23:49:22 +0000 (18:49 -0500)]
Remove unused features

3 years agoRemove unused dependencies
Samuel E. Moelius III [Sat, 13 Feb 2021 23:46:11 +0000 (18:46 -0500)]
Remove unused dependencies

3 years agoGet tests to pass
Samuel E. Moelius III [Sat, 13 Feb 2021 14:04:50 +0000 (09:04 -0500)]
Get tests to pass

3 years agoUpdate clippy_utils/src/lib.rs
Samuel E. Moelius III [Thu, 11 Feb 2021 20:03:52 +0000 (15:03 -0500)]
Update clippy_utils/src/lib.rs

3 years agoUpdate clippy_lints/src/lib.rs
Samuel E. Moelius III [Thu, 11 Feb 2021 20:03:28 +0000 (15:03 -0500)]
Update clippy_lints/src/lib.rs

3 years agoFactor out `clippy_utils` crate
Samuel E. Moelius III [Wed, 17 Feb 2021 17:42:21 +0000 (12:42 -0500)]
Factor out `clippy_utils` crate

3 years agoyeet
Ellen [Tue, 23 Feb 2021 23:35:48 +0000 (23:35 +0000)]
yeet

3 years agoAuto merge of #6573 - Jarcho:option_match_map, r=llogiq
bors [Tue, 23 Feb 2021 21:56:25 +0000 (21:56 +0000)]
Auto merge of #6573 - Jarcho:option_match_map, r=llogiq

New lint: option_manual_map

fixes: #6
changelog: Added lint: `match_map`

3 years agoImprove code readability
Guillaume Gomez [Tue, 23 Feb 2021 21:13:48 +0000 (22:13 +0100)]
Improve code readability

3 years ago* Fix some typo
Guillaume Gomez [Sun, 14 Feb 2021 13:47:55 +0000 (14:47 +0100)]
* Fix some typo
* Improve documentation
* Add a test to ensure that spotlighted traits from dependencies are taken into account as expected