]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoMake some functions private that don't need to be public
Joshua Nelson [Sun, 11 Oct 2020 03:50:45 +0000 (23:50 -0400)]
Make some functions private that don't need to be public

3 years agoAuto merge of #77717 - tmiasko:posix-spawn-error-check, r=cuviper
bors [Sat, 10 Oct 2020 10:59:20 +0000 (10:59 +0000)]
Auto merge of #77717 - tmiasko:posix-spawn-error-check, r=cuviper

Fix error checking in posix_spawn implementation of Command

* Check for errors returned from posix_spawn*_init functions
* Check for non-zero return value from posix_spawn functions

3 years agoAuto merge of #77580 - petrochenkov:norestarg, r=matthewjasper
bors [Sat, 10 Oct 2020 09:07:35 +0000 (09:07 +0000)]
Auto merge of #77580 - petrochenkov:norestarg, r=matthewjasper

rustc_target: Refactor away `TargetResult`

Follow-up to https://github.com/rust-lang/rust/pull/77202.

Construction of a built-in target is always infallible now, so `TargetResult` is no longer necessary.

The second commit contains some further cleanup based on built-in target construction being infallible.

3 years agoAuto merge of #77336 - pietroalbini:pkgname, r=Mark-Simulacrum
bors [Sat, 10 Oct 2020 06:59:49 +0000 (06:59 +0000)]
Auto merge of #77336 - pietroalbini:pkgname, r=Mark-Simulacrum

Always use the Rust version in package names

The format of the tarballs produced by CI is roughly the following:

    {component}-{release}-{target}.{ext}

While on the beta and nightly channels `{release}` is just the channel name, on the stable channel is either the Rust version or the version of the component we're shipping:

    cargo-0.47.0-x86_64-unknown-linux-gnu.tar.xz
    clippy-0.0.212-x86_64-unknown-linux-gnu.tar.xz
    llvm-tools-1.46.0-x86_64-unknown-linux-gnu.tar.xz
    miri-0.1.0-x86_64-unknown-linux-gnu.tar.xz
    rls-1.41.0-x86_64-unknown-linux-gnu.tar.xz
    rust-1.46.0-x86_64-unknown-linux-gnu.tar.xz
    ...

This makes it really hard to get the package URL without having access to the manifest (and there is no manifest on ci-artifacts.rlo), as there is no consistent version number to use.

This PR addresses the problem by always using the Rust version number as `{release}` for the stable channel, regardless of the version number of the component we're shipping. I chose that instead of "stable" to avoid breaking the URL scheme *that* much.

Rustup should not be affected by this change, as it fetches the URLs from the manifest. Unfortunately we don't have a way to test other clients before making a stable release, as this change only affects the stable channel.

r? `@Mark-Simulacrum`

3 years agoAuto merge of #77276 - GuillaumeGomez:reexported-item-lints, r=jyn514,ollie27
bors [Fri, 9 Oct 2020 21:01:51 +0000 (21:01 +0000)]
Auto merge of #77276 - GuillaumeGomez:reexported-item-lints, r=jyn514,ollie27

Warn on broken intra-doc links added to cross-crate re-exports

This emits `broken_intra_doc_links` for docs applied to pub use statements that point to external items and are inlined.
Does not address #77200 - any existing broken links from the original crate will not show warnings.

r? `@jyn514`

3 years agoAuto merge of #77674 - cuviper:direntry-diet, r=dtolnay
bors [Fri, 9 Oct 2020 19:06:45 +0000 (19:06 +0000)]
Auto merge of #77674 - cuviper:direntry-diet, r=dtolnay

unix/vxworks: make DirEntry slightly smaller

`DirEntry` contains a `ReadDir` handle, which used to just be a wrapper
on `Arc<InnerReadDir>`. Commit af75314ecdbc5 added `end_of_stream: bool`
which is not needed by `DirEntry`, but adds 8 bytes after padding. We
can let `DirEntry` have an `Arc<InnerReadDir>` directly to avoid that.

3 years agoDon't filter out imports added by the compiler for the moment
Guillaume Gomez [Mon, 5 Oct 2020 09:04:08 +0000 (11:04 +0200)]
Don't filter out imports added by the compiler for the moment

3 years agoRemove unneeded ImportItem on glob ones
Guillaume Gomez [Tue, 29 Sep 2020 18:23:02 +0000 (20:23 +0200)]
Remove unneeded ImportItem on glob ones

3 years agoSimplify included import items handling
Guillaume Gomez [Tue, 29 Sep 2020 15:04:40 +0000 (17:04 +0200)]
Simplify included import items handling

3 years agoAdd test to ensure that external items aren't lint-checked
Guillaume Gomez [Sun, 27 Sep 2020 22:19:31 +0000 (00:19 +0200)]
Add test to ensure that external items aren't lint-checked

3 years agoCorrectly handle "pub use" reexports
Guillaume Gomez [Sun, 27 Sep 2020 22:18:09 +0000 (00:18 +0200)]
Correctly handle "pub use" reexports

3 years agoAdd test for reexported items lints
Guillaume Gomez [Sun, 27 Sep 2020 19:22:39 +0000 (21:22 +0200)]
Add test for reexported items lints

3 years agoDon't remove export items so that we can run lints on them
Guillaume Gomez [Sun, 27 Sep 2020 19:22:11 +0000 (21:22 +0200)]
Don't remove export items so that we can run lints on them

3 years agosimplify the cfg in ReadDir construction
Josh Stone [Fri, 9 Oct 2020 17:54:50 +0000 (10:54 -0700)]
simplify the cfg in ReadDir construction

Co-authored-by: David Tolnay <dtolnay@gmail.com>
3 years agoAuto merge of #77747 - flip1995:clippyup, r=Manishearth
bors [Fri, 9 Oct 2020 17:14:39 +0000 (17:14 +0000)]
Auto merge of #77747 - flip1995:clippyup, r=Manishearth

Update Clippy

Biweekly Clippy update.

This includes a `Cargo.lock` update: 7ea42be

r? `@Manishearth`

3 years agoremove ReadDir.end_of_stream on targets that don't use it
Josh Stone [Fri, 9 Oct 2020 16:59:39 +0000 (09:59 -0700)]
remove ReadDir.end_of_stream on targets that don't use it

3 years agounix/vxworks: make DirEntry slightly smaller
Josh Stone [Wed, 7 Oct 2020 21:35:51 +0000 (14:35 -0700)]
unix/vxworks: make DirEntry slightly smaller

`DirEntry` contains a `ReadDir` handle, which used to just be a wrapper
on `Arc<InnerReadDir>`. Commit af75314ecdbc5 added `end_of_stream: bool`
which is not needed by `DirEntry`, but adds 8 bytes after padding. We
can let `DirEntry` have an `Arc<InnerReadDir>` directly to avoid that.

3 years agoAuto merge of #77609 - ortem:fix-lldb-commands, r=Mark-Simulacrum
bors [Fri, 9 Oct 2020 15:18:41 +0000 (15:18 +0000)]
Auto merge of #77609 - ortem:fix-lldb-commands, r=Mark-Simulacrum

Remove redundant backslashes from `lldb_commands`

3 years agobootstrap: always use the Rust version in package names
Pietro Albini [Tue, 29 Sep 2020 13:33:25 +0000 (15:33 +0200)]
bootstrap: always use the Rust version in package names

The format of the tarballs produced by CI is roughly the following:

    {component}-{release}-{target}.{ext}

While on the beta and nightly channels `{release}` is just the channel
name, on the stable channel is either the Rust version or the version of
the component we're shipping:

    cargo-0.47.0-x86_64-unknown-linux-gnu.tar.xz
    clippy-0.0.212-x86_64-unknown-linux-gnu.tar.xz
    llvm-tools-1.46.0-x86_64-unknown-linux-gnu.tar.xz
    miri-0.1.0-x86_64-unknown-linux-gnu.tar.xz
    rls-1.41.0-x86_64-unknown-linux-gnu.tar.xz
    rust-1.46.0-x86_64-unknown-linux-gnu.tar.xz
    ...

This makes it really hard to get the package URL without having access
to the manifest (and there is no manifest on ci-artifacts.rlo), as there
is no consistent version number to use.

This commit addresses the problem by always using the Rust version
number as `{release}` for the stable channel, regardless of the version
number of the component we're shipping. I chose that instead of "stable"
to avoid breaking the URL scheme *that* much.

Rustup should not be affected by this change, as it fetches the URLs
from the manifest. Unfortunately we don't have a way to test other
clients before making a stable release, as this change only affects the
stable channel.

3 years agoAuto merge of #77690 - est31:llvm_8_required, r=matthewjasper
bors [Fri, 9 Oct 2020 12:23:49 +0000 (12:23 +0000)]
Auto merge of #77690 - est31:llvm_8_required, r=matthewjasper

Simplify some code in rustc_llvm/build.rs now that LLVM 8 is required

LLVM 8 is required since 8506bb006040cf8e8cb004202706c81e62ddacee
so this is safe to do.

3 years agoUpdate Cargo.lock
flip1995 [Fri, 9 Oct 2020 10:46:26 +0000 (12:46 +0200)]
Update Cargo.lock

3 years agoMerge commit '2f6439ae6a6803d030cceb3ee14c9150e91b328b' into clippyup
flip1995 [Fri, 9 Oct 2020 10:45:29 +0000 (12:45 +0200)]
Merge commit '2f6439ae6a6803d030cceb3ee14c9150e91b328b' into clippyup

3 years agoAuto merge of #77698 - vandenheuvel:chalkup, r=jackh726
bors [Fri, 9 Oct 2020 10:32:52 +0000 (10:32 +0000)]
Auto merge of #77698 - vandenheuvel:chalkup, r=jackh726

Update chalk to 0.32.0

r? `@jackh726`

3 years agoAuto merge of #6136 - dtolnay:serve, r=flip1995
bors [Fri, 9 Oct 2020 08:58:19 +0000 (08:58 +0000)]
Auto merge of #6136 - dtolnay:serve, r=flip1995

Clippy dev subcommand to build and serve website

This PR adds `clippy dev serve` which will pop open a browser with a local rendered 'ALL the Clippy Lints' website, and re-render as you edit stuff.

---

changelog: none

3 years agoAuto merge of #77687 - est31:hash_shorter_path, r=davidtwco
bors [Fri, 9 Oct 2020 08:09:32 +0000 (08:09 +0000)]
Auto merge of #77687 - est31:hash_shorter_path, r=davidtwco

Use shorter path for std::hash::Hash

3 years agoAuto merge of #6115 - ebroto:changelog_1_48, r=flip1995
bors [Fri, 9 Oct 2020 08:09:23 +0000 (08:09 +0000)]
Auto merge of #6115 - ebroto:changelog_1_48, r=flip1995

Add changelog for 1.48 beta

[Rendered](https://github.com/ebroto/rust-clippy/blob/changelog_1_48/CHANGELOG.md)

I've not added the PRs fixing `same_item_push` because those were backported, namely:
* [#5908](https://github.com/rust-lang/rust-clippy/pull/5908)
* [#5997](https://github.com/rust-lang/rust-clippy/pull/5997)
* [#6016](https://github.com/rust-lang/rust-clippy/pull/6016)

The following PR was reverted, so I've ignored it too:
* [#5984](https://github.com/rust-lang/rust-clippy/pull/5984)

~~Also, I took the liberty of adding a "Thanks" section, naming all the contributors to this release. I think they deserve visibility in the changelog. Please tell me if we want to add this or maybe it's redundant given we link to the PRs?~~

changelog: none

r? `@flip1995`

3 years agoAuto merge of #6145 - flip1995:backport_remerge, r=flip1995
bors [Fri, 9 Oct 2020 06:53:55 +0000 (06:53 +0000)]
Auto merge of #6145 - flip1995:backport_remerge, r=flip1995

Backport remerge

Step 1 in the release process.

r? `@ghost`

changelog: none

3 years agoMerge remote-tracking branch 'upstream/beta' into backport_remerge
flip1995 [Fri, 9 Oct 2020 06:52:06 +0000 (08:52 +0200)]
Merge remote-tracking branch 'upstream/beta' into backport_remerge

3 years agoAuto merge of #77627 - richkadel:rust-demangler, r=tmandry
bors [Fri, 9 Oct 2020 06:15:09 +0000 (06:15 +0000)]
Auto merge of #77627 - richkadel:rust-demangler, r=tmandry

rust-demangler tool strips crate disambiguators with < 16 digits

Addresses Issue #77615.

3 years agoAuto merge of #77578 - euclio:max-suggestion, r=davidtwco
bors [Fri, 9 Oct 2020 04:22:18 +0000 (04:22 +0000)]
Auto merge of #77578 - euclio:max-suggestion, r=davidtwco

suggest `MAX` constant if -1 is assigned to unsigned type

Fixes #76413.
Fixes #77416.

3 years agoAuto merge of #77519 - jyn514:track-doc-er, r=GuillaumeGomez
bors [Fri, 9 Oct 2020 02:27:33 +0000 (02:27 +0000)]
Auto merge of #77519 - jyn514:track-doc-er, r=GuillaumeGomez

Resolve intra-doc links on additional documentation for re-exports in lexical scope

Fixes https://github.com/rust-lang/rust/issues/77254.

- Preserve the parent module of `DocFragment`s
  + Add `parent_module` to `DocFragment`
  + Require the `parent_module` of the item being inlined
  + Preserve the hir_id for ExternCrates so rustdoc can find the parent module later
  + Take an optional `parent_module` for `build_impl` and `merge_attrs`.
    Preserve the difference between parent modules for each doc-comment.
  + Support a single additional re-exports in from_ast. Originally this took a vec but I ended up not using it.
  + Don't require the parent_module for all `impl`s, just inlined items

    In particular, this will be `None` whenever the attribute is not on a
    re-export.

  + Only store the parent_module, not the HirId

    When re-exporting a re-export, the HirId is not available. Fortunately,
    `collect_intra_doc_links` doesn't actually need all the info from a
    HirId, just the parent module.

- Introduce `Divider`

  This distinguishes between documentation on the original from docs on  the re-export.

- Use the new module information for intra-doc links

  + Make the parent module conditional on whether the docs are on a re-export
  + Make `resolve_link` take `&Item` instead of `&mut Item`

    Previously the borrow checker gave an error about multiple mutable
    borrows, because `dox` borrowed from `item`.

  + Fix `crate::` for re-exports

    `crate` means something different depending on where the attribute
    came from.

  + Make it work for `#[doc]` attributes too

    This required combining several attributes as one so they would keep
    the links.

r? `@GuillaumeGomez`

3 years agoAuto merge of #76260 - xd009642:rfc/2867, r=jonas-schievink
bors [Fri, 9 Oct 2020 00:29:47 +0000 (00:29 +0000)]
Auto merge of #76260 - xd009642:rfc/2867, r=jonas-schievink

Implementation of RFC2867

https://github.com/rust-lang/rust/issues/74727

So I've started work on this, I think my next steps are to make use of the `instruction_set` value in the llvm codegen but this is the point where I begin to get a bit lost. I'm looking at the code but it would be nice to have some guidance on what I've currently done and what I'm doing next :smile:

3 years agoFix typo in error code
xd009642 [Thu, 8 Oct 2020 22:56:59 +0000 (23:56 +0100)]
Fix typo in error code

3 years agoAuto merge of #6133 - JPTIZ:no-box-for-c-ffi, r=ebroto
bors [Thu, 8 Oct 2020 22:50:29 +0000 (22:50 +0000)]
Auto merge of #6133 - JPTIZ:no-box-for-c-ffi, r=ebroto

clippy_lints: Do not warn against Box parameter in C FFI

changelog: [`boxed_local`]: don't lint in `extern fn` arguments

Fixes #5542.

When using C FFI, to handle pointers in parameters it is needed to
declare them as `Box` in its Rust-side signature. However, the current
linter warns against the usage of Box stating that "local variable
doesn't need to be boxed here".

This commit fixes it by ignoring functions whose Abi is C.

3 years agoAuto merge of #77723 - jonas-schievink:rollup-htz44r4, r=jonas-schievink
bors [Thu, 8 Oct 2020 22:37:37 +0000 (22:37 +0000)]
Auto merge of #77723 - jonas-schievink:rollup-htz44r4, r=jonas-schievink

Rollup of 8 pull requests

Successful merges:

 - #76750 (Don't discourage implementing `core::fmt::Write`)
 - #77449 (BTreeMap: comment why drain_filter's size_hint is somewhat pessimistic)
 - #77660 ((docs): make mutex error comment consistent with codebase)
 - #77663 (Add compile fail test for issue 27675)
 - #77673 (Remove unnecessary lamda on emitter map.)
 - #77701 (Make `max_log_info` easily greppable (for figuring out why debug logging is disabled))
 - #77702 (Remove not needed lambda.)
 - #77710 (Update submodule llvm to get LVI bugfix)

Failed merges:

r? `@ghost`

3 years agoImplement the instruction_set attribute
xd009642 [Thu, 8 Oct 2020 22:23:27 +0000 (23:23 +0100)]
Implement the instruction_set attribute

3 years agoCheck for errors returned from posix_spawn*_init functions
Tomasz Miąsko [Thu, 8 Oct 2020 00:00:00 +0000 (00:00 +0000)]
Check for errors returned from posix_spawn*_init functions

The posix_spawnattr_init & posix_spawn_file_actions_init might fail,
but their return code is not checked.

Check for non-zero return code and destroy only succesfully initialized
objects.

3 years agoCheck for non-zero return value from posix_spawn functions
Tomasz Miąsko [Thu, 8 Oct 2020 00:00:00 +0000 (00:00 +0000)]
Check for non-zero return value from posix_spawn functions

The cvt function compares the argument with -1 and when equal returns a new
io::Error constructed from errno. It is used together posix_spawn_* functions.
This is incorrect. Those functions do not set errno. Instead they return
non-zero error code directly.

Check for non-zero return code and use it to construct a new io::Error.

3 years agotests: Add test function that does not specify ABI
João Paulo Taylor Ienczak Zanette [Thu, 8 Oct 2020 21:50:52 +0000 (18:50 -0300)]
tests: Add test function that does not specify ABI

3 years agoAuto merge of #6117 - dtolnay:string_lit_as_bytes, r=ebroto
bors [Thu, 8 Oct 2020 21:33:32 +0000 (21:33 +0000)]
Auto merge of #6117 - dtolnay:string_lit_as_bytes, r=ebroto

Downgrade string_lit_as_bytes to nursery

Between #1402 (regarding `to_owned`) and #4494 (regarding `impl Read`), as well as other confusion I've seen hit in my work codebase involving string_lit_as_bytes (`"...".as_bytes().into()`), I don't think this lint is at a quality to be enabled by default.

I would consider re-enabling this lint after it is updated to understand when the surrounding type information is sufficient to unsize `b"..."` to &\[u8\] without causing a type error.

As currently implemented, this lint is pushing people to write `&b"_"[..]` which is not an improvement over `"_".as_bytes()` as far as I am concerned.

---

changelog: Remove string_lit_as_bytes from default set of enabled lints

3 years agoRollup merge of #77710 - fortanix:raoul/bugfix-lvi, r=nikic
Jonas Schievink [Thu, 8 Oct 2020 21:23:19 +0000 (23:23 +0200)]
Rollup merge of #77710 - fortanix:raoul/bugfix-lvi, r=nikic

Update submodule llvm to get LVI bugfix

The LLVM LVI mitigations used register %rcs as a clobber register. This is problematic when rust uses this register to return (part of) function values. The problem was fixed upstream in:

    https://reviews.llvm.org/D88924
    https://reviews.llvm.org/D88925

PR https://github.com/rust-lang/llvm-project/pull/79 merged it in the llvm_project. This PR updates the submodule

Bug report: https://bugs.llvm.org/show_bug.cgi?id=47740
Fixes #77607

cc: @jethrogb

3 years agoRollup merge of #77702 - heckad:patch-3, r=lcnr
Jonas Schievink [Thu, 8 Oct 2020 21:23:17 +0000 (23:23 +0200)]
Rollup merge of #77702 - heckad:patch-3, r=lcnr

Remove not needed lambda.

3 years agoRollup merge of #77701 - jyn514:debug-logging, r=Mark-Simulacrum
Jonas Schievink [Thu, 8 Oct 2020 21:23:15 +0000 (23:23 +0200)]
Rollup merge of #77701 - jyn514:debug-logging, r=Mark-Simulacrum

Make `max_log_info` easily greppable (for figuring out why debug logging is disabled)

Follow-up to https://github.com/rust-lang/rust/pull/77678#issuecomment-705545608. I'll make a PR to the dev-guide shortly changing `debug = true` to `debug-logging = true` and using this text.

Ideally wouldn't be merged before https://github.com/rust-lang/rust/pull/77678, but it practice it won't hurt anything.

r? @Mark-Simulacrum

3 years agoRollup merge of #77673 - heckad:patch-2, r=lcnr
Jonas Schievink [Thu, 8 Oct 2020 21:23:13 +0000 (23:23 +0200)]
Rollup merge of #77673 - heckad:patch-2, r=lcnr

Remove unnecessary lamda on emitter map.

3 years agoRollup merge of #77663 - HeroicKatora:regression-tests-27675-object-safe, r=Aaron1011
Jonas Schievink [Thu, 8 Oct 2020 21:23:12 +0000 (23:23 +0200)]
Rollup merge of #77663 - HeroicKatora:regression-tests-27675-object-safe, r=Aaron1011

Add compile fail test for issue 27675

A recently merged PR (#73905) strengthened the checks on bounds of associated items. This rejects the attack path of #27675 which consisted of constructing a `dyn Trait<Item=T>` where `T` would not fulfill the bounds required on `Item` of the `Trait` behind the dyn object.

This regression test, extracted from [the weaponized instance](https://github.com/rust-lang/rust/issues/27675#issuecomment-696956878), checks that this is rejected.

3 years agoRollup merge of #77660 - nilslice:patch-1, r=jyn514
Jonas Schievink [Thu, 8 Oct 2020 21:23:10 +0000 (23:23 +0200)]
Rollup merge of #77660 - nilslice:patch-1, r=jyn514

(docs): make mutex error comment consistent with codebase

Although exceptionally minor, I found this stands out from other error reporting language used in doc comments. With the existence of the `failure` crate, I suppose this could be slightly ambiguous. In any case, this change brings the particular comment into a consistent state with other mentions of returning errors.

3 years agoRollup merge of #77449 - ssomers:btree_drain_filter_size_hint, r=Mark-Simulacrum
Jonas Schievink [Thu, 8 Oct 2020 21:23:08 +0000 (23:23 +0200)]
Rollup merge of #77449 - ssomers:btree_drain_filter_size_hint, r=Mark-Simulacrum

BTreeMap: comment why drain_filter's size_hint is somewhat pessimistic

The `size_hint` of the `DrainFilter` iterator doesn't adjust as you iterate. This hardly seems important to me, but there has been a comparable PR #64383 in the past. I guess a scenario is that you first iterate half the map manually and keep most of the key/value pairs in the map, and then tell the predicate to drain most of the key/value pairs and `.collect` the iterator over the remaining half of the map.

I am totally ambivalent whether this is better or not.

r? @Mark-Simulacrum

3 years agoRollup merge of #76750 - camelid:dont-discourage-core-fmt-write, r=Mark-Simulacrum
Jonas Schievink [Thu, 8 Oct 2020 21:23:07 +0000 (23:23 +0200)]
Rollup merge of #76750 - camelid:dont-discourage-core-fmt-write, r=Mark-Simulacrum

Don't discourage implementing `core::fmt::Write`

Fixes #76729.

Explain when you should use it and when you should not.

3 years agoAuto merge of #77110 - lzutao:e0596-amp_mut, r=davidtwco
bors [Thu, 8 Oct 2020 20:43:01 +0000 (20:43 +0000)]
Auto merge of #77110 - lzutao:e0596-amp_mut, r=davidtwco

Suggest removing `&mut` from a `&mut borrow`

Modify the code added in #54720.

Closes  #75871

3 years agorust-demangler tool strips crate disambiguators with < 16 digits
Rich Kadel [Tue, 6 Oct 2020 19:47:19 +0000 (12:47 -0700)]
rust-demangler tool strips crate disambiguators with < 16 digits

Addresses Issue #77615.

3 years agoDon't discourage implementing `core::fmt::Write`
Camelid [Tue, 15 Sep 2020 17:22:48 +0000 (10:22 -0700)]
Don't discourage implementing `core::fmt::Write`

Explain when you should use it and when you should not.

3 years agoAuto merge of #77346 - Caduser2020:master, r=Mark-Simulacrum
bors [Thu, 8 Oct 2020 17:36:25 +0000 (17:36 +0000)]
Auto merge of #77346 - Caduser2020:master, r=Mark-Simulacrum

`#[deny(unsafe_op_in_unsafe_fn)]` in sys/sgx

This is part of #73904.

Enclose unsafe operations in unsafe blocks in `libstd/sys/sgx`.

3 years agosuggest `MAX` constant if -1 is assigned to unsigned type
Andy Russell [Mon, 5 Oct 2020 16:23:36 +0000 (12:23 -0400)]
suggest `MAX` constant if -1 is assigned to unsigned type

3 years agoAuto merge of #6138 - giraffate:note_that_we_follow_rustc_no_merge_policy, r=Manishearth
bors [Thu, 8 Oct 2020 16:56:14 +0000 (16:56 +0000)]
Auto merge of #6138 - giraffate:note_that_we_follow_rustc_no_merge_policy, r=Manishearth

Add note that we follow a rustc no merge-commit policy

I think it would be better to add a note that we follow a rustc no merge-commit policy. For example, it was mentioned at https://github.com/rust-lang/rust-clippy/pull/5694#issuecomment-641871096.

changelog: none

3 years agoUpdate submodule llvm to get LVI bugfix
Raoul Strackx [Thu, 8 Oct 2020 15:43:26 +0000 (17:43 +0200)]
Update submodule llvm to get LVI bugfix

3 years ago`#[deny(unsafe_op_in_unsafe_fn)]` in sys/sgx
Caduser2020 [Tue, 29 Sep 2020 20:27:56 +0000 (15:27 -0500)]
`#[deny(unsafe_op_in_unsafe_fn)]` in sys/sgx

Run `./x.py` fmt

Add reference link

Fix reference link

Apply review suggestions.

3 years agoSuggest removing &mut from borrow of &mut
Lzu Tao [Thu, 8 Oct 2020 14:21:12 +0000 (14:21 +0000)]
Suggest removing &mut from borrow of &mut

Fix a typo: minding -> binding
Add test for &mut &mut

3 years agoAdd note that we follow a rustc no merge-commit policy
Takayuki Nakata [Thu, 8 Oct 2020 14:13:06 +0000 (23:13 +0900)]
Add note that we follow a rustc no merge-commit policy

3 years agoClippy dev subcommand to build and serve website
David Tolnay [Thu, 8 Oct 2020 12:18:22 +0000 (05:18 -0700)]
Clippy dev subcommand to build and serve website

3 years agoAuto merge of #77678 - jyn514:tracing, r=Mark-Simulacrum
bors [Thu, 8 Oct 2020 13:38:29 +0000 (13:38 +0000)]
Auto merge of #77678 - jyn514:tracing, r=Mark-Simulacrum

Upgrade to tracing-subscriber 0.2.13

The primary motivation is to get the changes from
https://github.com/tokio-rs/tracing/pull/990. Example output:

```
$ RUSTDOC_LOG=debug rustdoc +rustc2
warning: some trace filter directives would enable traces that are disabled statically
 | `debug` would enable the DEBUG level for all targets
 = note: the static max level is `info`
 = help: to enable DEBUG logging, remove the `max_level_info` feature
```

r? `@Mark-Simulacrum`
cc `@hawkw` ❤️

3 years agoRemove not needed lambda.
Kazantcev Andrey [Thu, 8 Oct 2020 13:22:31 +0000 (16:22 +0300)]
Remove not needed lambda.

3 years agoMake `max_log_info` easily greppable
Joshua Nelson [Thu, 8 Oct 2020 13:16:27 +0000 (09:16 -0400)]
Make `max_log_info` easily greppable

3 years agoclippy_lint: extern definition is in Rust, not C
João Paulo Taylor Ienczak Zanette [Thu, 8 Oct 2020 12:07:24 +0000 (09:07 -0300)]
clippy_lint: extern definition is in Rust, not C

3 years agoclippy_lint: Fix typo (now -> not)
João Paulo Taylor Ienczak Zanette [Thu, 8 Oct 2020 12:06:19 +0000 (09:06 -0300)]
clippy_lint: Fix typo (now -> not)

3 years agoclippy_lint: Extend BoxedLocal ignored ABI to all non-rust ABIs.
João Paulo Taylor Ienczak Zanette [Thu, 8 Oct 2020 12:03:11 +0000 (09:03 -0300)]
clippy_lint: Extend BoxedLocal ignored ABI to all non-rust ABIs.

3 years agoMake clippy_lints's doc tests succeed
David Tolnay [Thu, 8 Oct 2020 11:54:17 +0000 (04:54 -0700)]
Make clippy_lints's doc tests succeed

3 years agoDocument string_lit_as_bytes known problems
David Tolnay [Thu, 8 Oct 2020 11:50:24 +0000 (04:50 -0700)]
Document string_lit_as_bytes known problems

3 years agoAuto merge of #77581 - ecstatic-morse:dataflow-dump-mir-graphviz, r=davidtwco
bors [Thu, 8 Oct 2020 11:42:24 +0000 (11:42 +0000)]
Auto merge of #77581 - ecstatic-morse:dataflow-dump-mir-graphviz, r=davidtwco

Use `pretty::create_dump_file` for dumping dataflow results

The old code wasn't incorporating promoteds into the path, meaning other `dot` files could get clobbered. Use the MIR dump infrastructure to generate paths so that this doesn't occur in the future.

3 years agoUpdate chalk to 0.32.0
Bram van den Heuvel [Thu, 8 Oct 2020 11:17:01 +0000 (13:17 +0200)]
Update chalk to 0.32.0

3 years agoCommit suggestion
Kazantcev Andrey [Thu, 8 Oct 2020 10:58:51 +0000 (13:58 +0300)]
Commit suggestion

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoAuto merge of #77682 - Mark-Simulacrum:bump-stage0, r=pietroalbini
bors [Thu, 8 Oct 2020 09:50:35 +0000 (09:50 +0000)]
Auto merge of #77682 - Mark-Simulacrum:bump-stage0, r=pietroalbini

Bump to 1.48 bootstrap compiler

r? `@pietroalbini` (but anyone can feel free to review)

3 years agoAuto merge of #6132 - rust-lang:regex-unicode, r=ebroto
bors [Thu, 8 Oct 2020 08:48:12 +0000 (08:48 +0000)]
Auto merge of #6132 - rust-lang:regex-unicode, r=ebroto

Fix unicode regexen with bytes::Regex

fixes #6005

The rationale for this is that since we wrote that lint, `bytes::Regex` was extended to be able to use unicode character classes.

---

changelog: [`invalid_regex`]: allow unicode character classes in bytes regex.

3 years agoAuto merge of #77644 - GuillaumeGomez:fix-tooltip-text-display, r=jyn514
bors [Thu, 8 Oct 2020 07:55:19 +0000 (07:55 +0000)]
Auto merge of #77644 - GuillaumeGomez:fix-tooltip-text-display, r=jyn514

Fix tooltip text display

Currently, when we hover the icon, the text doesn't show up:

![Screenshot from 2020-10-07 11-30-44](https://user-images.githubusercontent.com/3050060/95313768-cc402200-0890-11eb-95a4-a1ae8e38aee1.png)

The bug was spotted by `@Nemo157`

r? `@jyn514`

3 years agoAdd compile fail test for issue 27675
Andreas Molzer [Wed, 7 Oct 2020 17:49:52 +0000 (19:49 +0200)]
Add compile fail test for issue 27675

3 years agoAuto merge of #77631 - jyn514:helpful-changelog, r=RalfJung
bors [Thu, 8 Oct 2020 05:50:49 +0000 (05:50 +0000)]
Auto merge of #77631 - jyn514:helpful-changelog, r=RalfJung

Make src/bootstrap/CHANGELOG.md more helpful

Addresses https://github.com/rust-lang/rust/commit/fe6fc555acd51bd7ba8755d9fbc7060feb67be25#r42949241.

r? `@RalfJung`
cc `@Mark-Simulacrum`

3 years agoUse the new module information for intra-doc links
Joshua Nelson [Sun, 4 Oct 2020 15:56:55 +0000 (11:56 -0400)]
Use the new module information for intra-doc links

- Make the parent module conditional on whether the docs are on a re-export
- Make `resolve_link` take `&Item` instead of `&mut Item`

  Previously the borrow checker gave an error about multiple mutable
  borrows, because `dox` borrowed from `item`.

- Fix `crate::` for re-exports

  `crate` means something different depending on where the attribute
  came from.

- Make it work for `#[doc]` attributes too

  This required combining several attributes as one so they would keep
  the links.

3 years agoIntroduce `Divider`
Joshua Nelson [Sun, 4 Oct 2020 15:15:45 +0000 (11:15 -0400)]
Introduce `Divider`

This distinguishes between documentation on the original from docs on
the re-export

3 years agoPreserve the parent module of `DocFragment`s
Joshua Nelson [Sun, 4 Oct 2020 00:06:30 +0000 (20:06 -0400)]
Preserve the parent module of `DocFragment`s

- Add `parent_module` to `DocFragment`
- Require the `parent_module` of the item being inlined
- Preserve the hir_id for ExternCrates so rustdoc can find the parent module later
- Take an optional `parent_module` for `build_impl` and `merge_attrs`.
  Preserve the difference between parent modules for each doc-comment.
- Support arbitrarily many re-exports in from_ast. In retrospect this is
  probably not used and could be simplified to a single
  `Option<(Attrs, DefId)>`.
- Don't require the parent_module for all `impl`s, just inlined items

  In particular, this will be `None` whenever the attribute is not on a
  re-export.

- Only store the parent_module, not the HirId

  When re-exporting a re-export, the HirId is not available. Fortunately,
  `collect_intra_doc_links` doesn't actually need all the info from a
  HirId, just the parent module.

3 years agoSimplify some code in rustc_llvm/build.rs now that LLVM 8 is required
est31 [Thu, 8 Oct 2020 04:18:11 +0000 (06:18 +0200)]
Simplify some code in rustc_llvm/build.rs now that LLVM 8 is required

LLVM 8 is required since 8506bb006040cf8e8cb004202706c81e62ddacee
so this is safe to do.

3 years agoAuto merge of #77683 - jyn514:git-hook, r=Mark-Simulacrum
bors [Thu, 8 Oct 2020 03:58:55 +0000 (03:58 +0000)]
Auto merge of #77683 - jyn514:git-hook, r=Mark-Simulacrum

Unset GIT_DIR in pre-commit hook

Works around https://github.com/rust-lang/rust/issues/77620. This won't help any other hooks you write manually, but hopefully people won't feel the need to do that now there's an 'official' one.

r? `@Mark-Simulacrum`
cc `@caass`

3 years agoclippy_lint: Test for BoxedLocal false-positive in C-FFI and fix C-FFI Abi comparison.
João Paulo Taylor Ienczak Zanette [Thu, 8 Oct 2020 01:49:50 +0000 (22:49 -0300)]
clippy_lint: Test for BoxedLocal false-positive in C-FFI and fix C-FFI Abi comparison.

3 years agoAuto merge of #75470 - estebank:bare-type-expr, r=davidtwco
bors [Thu, 8 Oct 2020 01:37:27 +0000 (01:37 +0000)]
Auto merge of #75470 - estebank:bare-type-expr, r=davidtwco

Detect blocks that could be struct expr bodies

This approach lives exclusively in the parser, so struct expr bodies
that are syntactically correct on their own but are otherwise incorrect
will still emit confusing errors, like in the following case:

```rust
fn foo() -> Foo {
    bar: Vec::new()
}
```

```
error[E0425]: cannot find value `bar` in this scope
 --> src/file.rs:5:5
  |
5 |     bar: Vec::new()
  |     ^^^ expecting a type here because of type ascription

error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
 --> src/file.rs:5:15
  |
5 |     bar: Vec::new()
  |               ^^^^^ only `Fn` traits may use parentheses

error[E0107]: wrong number of type arguments: expected 1, found 0
 --> src/file.rs:5:10
  |
5 |     bar: Vec::new()
  |          ^^^^^^^^^^ expected 1 type argument
  ```

If that field had a trailing comma, that would be a parse error and it
would trigger the new, more targetted, error:

```
error: struct literal body without path
 --> file.rs:4:17
  |
4 |   fn foo() -> Foo {
  |  _________________^
5 | |     bar: Vec::new(),
6 | | }
  | |_^
  |
help: you might have forgotten to add the struct literal inside the block
  |
4 | fn foo() -> Foo { Path {
5 |     bar: Vec::new(),
6 | } }
  |
```

Partially address last remaining part of #34255.

3 years agoUse shorter path for std::hash::Hash
est31 [Thu, 8 Oct 2020 01:25:01 +0000 (03:25 +0200)]
Use shorter path for std::hash::Hash

3 years agoclippy_lints: Do not warn against Box parameter in C FFI
João Paulo Taylor Ienczak Zanette [Thu, 8 Oct 2020 00:41:54 +0000 (21:41 -0300)]
clippy_lints: Do not warn against Box parameter in C FFI

Fixes #5542.

When using C FFI, to handle pointers in parameters it is needed to
declare them as `Box` in its Rust-side signature. However, the current
linter warns against the usage of Box stating that "local variable
doesn't need to be boxed here".

This commit fixes it by ignoring functions whose Abi is Cdecl.

3 years agoBump to 1.48 bootstrap compiler
Mark Rousskov [Wed, 7 Oct 2020 22:56:26 +0000 (18:56 -0400)]
Bump to 1.48 bootstrap compiler

3 years agoUnset GIT_DIR in pre-commit hook
Joshua Nelson [Wed, 7 Oct 2020 23:50:27 +0000 (19:50 -0400)]
Unset GIT_DIR in pre-commit hook

Works around https://github.com/rust-lang/rust/issues/77620

3 years agoAuto merge of #77597 - simonvandel:uninhabited-hashset, r=jonas-schievink
bors [Wed, 7 Oct 2020 23:44:57 +0000 (23:44 +0000)]
Auto merge of #77597 - simonvandel:uninhabited-hashset, r=jonas-schievink

perf: UninhabitedEnumBranching avoid n^2

Avoid n² complexity. This showed up in a profile for match-stress-enum that has 8192 variants

I have only profiled locally against `match-stress-enum`, so we should have it perf tested to make sure it does not regress other crates.

3 years agoUpgrade to tracing 0.2.13
Joshua Nelson [Wed, 7 Oct 2020 22:45:59 +0000 (18:45 -0400)]
Upgrade to tracing 0.2.13

The primary motivation is to get the changes from
https://github.com/tokio-rs/tracing/pull/990. Example output:

```
$ RUSTDOC_LOG=debug rustdoc +rustc2
warning: some trace filter directives would enable traces that are disabled statically
 | `debug` would enable the DEBUG level for all targets
 = note: the static max level is `info`
 = help: to enable DEBUG logging, remove the `max_level_info` feature
```

- Remove useless test

  This was testing for an ICE when passing `RUST_LOG=rustc_middle`.  I
  noticed it because it started giving the tracing warning (because tests
  are not run with debug-logging enabled). Since this bug seems unlikely
  to re-occur, I just removed it altogether.

3 years agoAuto merge of #6128 - dtolnay:rc_buffer, r=yaahc
bors [Wed, 7 Oct 2020 23:10:34 +0000 (23:10 +0000)]
Auto merge of #6128 - dtolnay:rc_buffer, r=yaahc

Downgrade rc_buffer to restriction

I think Arc\<Vec\<T\>\> and Arc\<String\> and similar are a totally reasonable data structure, as observed by others in the comments on [#6044](https://github.com/rust-lang/rust-clippy/pull/6044#event-3799579830) as well. Doing `Arc::make_mut(&mut self.vec).push(...)` or `Arc::make_mut(&mut self.string).push_str("...")` is a terrific and well performing copy-on-write pattern. Linting this with an enabled-by-default <kbd>performance</kbd> lint strikes me as an unacceptable false positive balance.

As of #6090 the documentation of this lint now contains:

> **Known problems:** This pattern can be desirable ...

which should indicate that we shouldn't be linting against correct, reasonable, well-performing patterns with an enabled-by-default lint.

Mentioning #6044, #6090.
r? `@yaahc,` who reviewed the lint.

---

changelog: Remove rc_buffer from default set of enabled lints

3 years agoFix unicode regexen with bytes::Regex
Andre Bogus [Wed, 7 Oct 2020 23:07:00 +0000 (01:07 +0200)]
Fix unicode regexen with bytes::Regex

fixes #6005

3 years agoAuto merge of #76985 - hbina:clone_check, r=estebank
bors [Wed, 7 Oct 2020 21:51:12 +0000 (21:51 +0000)]
Auto merge of #76985 - hbina:clone_check, r=estebank

Prevent stack overflow in deeply nested types.

Related issue #75577 (?)

Unfortunately, I am unable to test whether this actually solves the problem because apparently, 12GB RAM + 2GB swap is not enough to compile the (admittedly toy) source file.

3 years agoRemove unnecessary lamda on emitter map.
Kazantcev Andrey [Wed, 7 Oct 2020 21:29:20 +0000 (00:29 +0300)]
Remove unnecessary lamda on emitter map.

3 years agoDetect blocks that could be struct expr bodies
Esteban Küber [Wed, 12 Aug 2020 22:39:15 +0000 (15:39 -0700)]
Detect blocks that could be struct expr bodies

This approach lives exclusively in the parser, so struct expr bodies
that are syntactically correct on their own but are otherwise incorrect
will still emit confusing errors, like in the following case:

```rust
fn foo() -> Foo {
    bar: Vec::new()
}
```

```
error[E0425]: cannot find value `bar` in this scope
 --> src/file.rs:5:5
  |
5 |     bar: Vec::new()
  |     ^^^ expecting a type here because of type ascription

error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
 --> src/file.rs:5:15
  |
5 |     bar: Vec::new()
  |               ^^^^^ only `Fn` traits may use parentheses

error[E0107]: wrong number of type arguments: expected 1, found 0
 --> src/file.rs:5:10
  |
5 |     bar: Vec::new()
  |          ^^^^^^^^^^ expected 1 type argument
  ```

If that field had a trailing comma, that would be a parse error and it
would trigger the new, more targetted, error:

```
error: struct literal body without path
 --> file.rs:4:17
  |
4 |   fn foo() -> Foo {
  |  _________________^
5 | |     bar: Vec::new(),
6 | | }
  | |_^
  |
help: you might have forgotten to add the struct literal inside the block
  |
4 | fn foo() -> Foo { Path {
5 |     bar: Vec::new(),
6 | } }
  |
```

Partially address last part of #34255.

3 years agoperf: UninhabitedEnumBranching void n^2
Simon Vandel Sillesen [Mon, 5 Oct 2020 21:58:46 +0000 (23:58 +0200)]
perf: UninhabitedEnumBranching void n^2

Avoid n² complexity. This showed up in a profile for match-stress-enum that has 8192 variants

3 years agoAuto merge of #77464 - ecstatic-morse:const-fn-impl-trait, r=oli-obk
bors [Wed, 7 Oct 2020 19:59:52 +0000 (19:59 +0000)]
Auto merge of #77464 - ecstatic-morse:const-fn-impl-trait, r=oli-obk

Give `impl Trait` in a `const fn` its own feature gate

...previously it was gated under `#![feature(const_fn)]`.

I think we actually want to do this in all const-contexts? If so, this should be `#![feature(const_impl_trait)]` instead. I don't think there's any way to make use of `impl Trait` within a `const` initializer.

cc #77463

r? `@oli-obk`

3 years ago(docs): make mutex error comment consistent with codebase
Steve Manuel [Wed, 7 Oct 2020 17:48:26 +0000 (11:48 -0600)]
(docs): make mutex error comment consistent with codebase

3 years agoAuto merge of #77617 - AnthonyMikh:slice_windows_no_bounds_checking, r=lcnr
bors [Wed, 7 Oct 2020 17:31:56 +0000 (17:31 +0000)]
Auto merge of #77617 - AnthonyMikh:slice_windows_no_bounds_checking, r=lcnr

Eliminate bounds checking in slice::Windows

This is how `<core::slice::Windows as Iterator>::next` looks right now:

```rust
fn next(&mut self) -> Option<&'a [T]> {
    if self.size > self.v.len() {
        None
    } else {
        let ret = Some(&self.v[..self.size]);
        self.v = &self.v[1..];
        ret
    }
}
```

The line with `self.v = &self.v[1..];` relies on assumption that `self.v` is definitely not empty at this point. Else branch is taken when `self.size <= self.v.len()`, so `self.v` can be empty if `self.size` is zero. In practice, since `Windows` is never created directly but rather trough `[T]::windows` which panics when `size` is zero, `self.size` is never zero. However, the compiler doesn't know about this check, so it keeps the code which checks bounds and panics.

Using `NonZeroUsize` lets the compiler know about this invariant and reliably eliminate bounds checking without `unsafe` on `-O2`. Here is assembly of `Windows<'a, u32>::next` before and after this change ([goldbolt](https://godbolt.org/z/xrefzx)):

<details>
<summary>Before</summary>

```
example::next:
        push    rax
        mov     rcx, qword ptr [rdi + 8]
        mov     rdx, qword ptr [rdi + 16]
        cmp     rdx, rcx
        jbe     .LBB0_2
        xor     eax, eax
        pop     rcx
        ret
.LBB0_2:
        test    rcx, rcx
        je      .LBB0_5
        mov     rax, qword ptr [rdi]
        mov     rsi, rax
        add     rsi, 4
        add     rcx, -1
        mov     qword ptr [rdi], rsi
        mov     qword ptr [rdi + 8], rcx
        pop     rcx
        ret
.LBB0_5:
        lea     rdx, [rip + .L__unnamed_1]
        mov     edi, 1
        xor     esi, esi
        call    qword ptr [rip + core::slice::slice_index_order_fail@GOTPCREL]
        ud2

.L__unnamed_2:
        .ascii  "./example.rs"

.L__unnamed_1:
        .quad   .L__unnamed_2
        .asciz  "\f\000\000\000\000\000\000\000\016\000\000\000\027\000\000"
```

</details>

<details>
<summary>After</summary>

```
example::next:
        mov     rcx, qword ptr [rdi + 8]
        mov     rdx, qword ptr [rdi + 16]
        cmp     rdx, rcx
        jbe     .LBB0_2
        xor     eax, eax
        ret
.LBB0_2:
        mov     rax, qword ptr [rdi]
        lea     rsi, [rax + 4]
        add     rcx, -1
        mov     qword ptr [rdi], rsi
        mov     qword ptr [rdi + 8], rcx
        ret
```

</details>

Note the lack of call to `core::slice::slice_index_order_fail` in second snippet.

#### Possible reasons _not_ to merge this PR:

* this changes the error message on panic in `[T]::windows`. However, AFAIK this messages are not covered by backwards compatibility policy.

3 years agoAuto merge of #77341 - davidtwco:issue-73427-you-might-have-meant-variant, r=estebank
bors [Wed, 7 Oct 2020 15:37:47 +0000 (15:37 +0000)]
Auto merge of #77341 - davidtwco:issue-73427-you-might-have-meant-variant, r=estebank

resolve: improve "try using the enum's variant"

Fixes #73427.

This PR improves the "try using the enum's variant" suggestion:

- Variants in suggestions would not result in more errors (e.g. use of a struct variant is only suggested if the suggestion can trivially construct that variant). Therefore, suggestions are only   emitted for variants that have no fields (since the suggestion can't know what value fields would have).
- Suggestions include the syntax for constructing the variant. If a struct or tuple variant is suggested, then it is constructed in the suggestion - unless in pattern-matching or when arguments are already provided.
- A help message is added which mentions the variants which are no longer suggested.

All of the diagnostic logic introduced by this PR is separated from the normal code path for a successful compilation.

r? `@estebank`

3 years agoAdd codegen test
AnthonyMikh [Tue, 6 Oct 2020 17:18:10 +0000 (20:18 +0300)]
Add codegen test

3 years agoAuto merge of #77595 - petrochenkov:asmident, r=oli-obk
bors [Wed, 7 Oct 2020 11:51:51 +0000 (11:51 +0000)]
Auto merge of #77595 - petrochenkov:asmident, r=oli-obk

builtin_macros: Fix use of interpolated identifiers in `asm!`

Fixes https://github.com/rust-lang/rust/issues/77584