]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoRollup merge of #79365 - richkadel:llvm-cov-map-version-4, r=wesleywiser
Jonas Schievink [Thu, 26 Nov 2020 12:39:09 +0000 (13:39 +0100)]
Rollup merge of #79365 - richkadel:llvm-cov-map-version-4, r=wesleywiser

Upgrades the coverage map to Version 4

Changes the coverage map injected into binaries compiled with
`-Zinstrument-coverage` to LLVM Coverage Mapping Format, Version 4 (from
Version 3). Note, binaries compiled with this version will require LLVM
tools from at least LLVM Version 11.

r? ``@wesleywiser``

3 years agoRollup merge of #79362 - cjgillot:relou, r=oli-obk
Jonas Schievink [Thu, 26 Nov 2020 12:39:07 +0000 (13:39 +0100)]
Rollup merge of #79362 - cjgillot:relou, r=oli-obk

Lower patterns before using the bound variable

So as to avoid having to lower patterns twice.

3 years agoRollup merge of #79000 - sivadeilra:user/ardavis/lev_distance, r=wesleywiser
Jonas Schievink [Thu, 26 Nov 2020 12:39:05 +0000 (13:39 +0100)]
Rollup merge of #79000 - sivadeilra:user/ardavis/lev_distance, r=wesleywiser

Move lev_distance to rustc_ast, make non-generic

rustc_ast currently has a few dependencies on rustc_lexer. Ideally, an AST
would not have any dependency its lexer, for minimizing
design-time dependencies. Breaking this dependency would also have practical
benefits, since modifying rustc_lexer would not trigger a rebuild of rustc_ast.

This commit does not remove the rustc_ast --> rustc_lexer dependency,
but it does remove one of the sources of this dependency, which is the
code that handles fuzzy matching between symbol names for making suggestions
in diagnostics. Since that code depends only on Symbol, it is easy to move
it to rustc_span. It might even be best to move it to a separate crate,
since other tools such as Cargo use the same algorithm, and have simply
contain a duplicate of the code.

This changes the signature of find_best_match_for_name so that it is no
longer generic over its input. I checked the optimized binaries, and this
function was duplicated for nearly every call site, because most call sites
used short-lived iterator chains, generic over Map and such. But there's
no good reason for a function like this to be generic, since all it does
is immediately convert the generic input (the Iterator impl) to a concrete
Vec<Symbol>. This has all of the costs of generics (duplicated method bodies)
with no benefit.

Changing find_best_match_for_name to be non-generic removed about 10KB of
code from the optimized binary. I know it's a drop in the bucket, but we have
to start reducing binary size, and beginning to tame over-use of generics
is part of that.

3 years agoRollup merge of #77758 - Stupremee:turbofish-help-for-const, r=varkor
Jonas Schievink [Thu, 26 Nov 2020 12:39:00 +0000 (13:39 +0100)]
Rollup merge of #77758 - Stupremee:turbofish-help-for-const, r=varkor

suggest turbofish syntax for uninferred const arguments

When not providing a const generic value, and it can not be inferred, the following suggestion is suggested:
![image](https://user-images.githubusercontent.com/39732259/95616180-af127b80-0a69-11eb-8877-551c815f9627.png)

Resolves #76737

r? ``@varkor``

3 years agoAuto merge of #79435 - Mark-Simulacrum:fix-powerpc, r=Mark-Simulacrum
bors [Thu, 26 Nov 2020 03:04:20 +0000 (03:04 +0000)]
Auto merge of #79435 - Mark-Simulacrum:fix-powerpc, r=Mark-Simulacrum

Mirror centos vault to S3

3 years agoMirror centos vault to S3
Mark Rousskov [Thu, 26 Nov 2020 02:42:39 +0000 (21:42 -0500)]
Mirror centos vault to S3

3 years agofix URLs in doc comment
Rich Kadel [Wed, 25 Nov 2020 21:30:33 +0000 (13:30 -0800)]
fix URLs in doc comment

The angle brackets were confusing my IDE and I thought they were unnecessary. I was wrong.

3 years agoAuto merge of #79411 - tmiasko:naked-params, r=Amanieu
bors [Wed, 25 Nov 2020 21:22:46 +0000 (21:22 +0000)]
Auto merge of #79411 - tmiasko:naked-params, r=Amanieu

Validate use of parameters in naked functions

* Reject use of parameters inside naked function body.
* Reject use of patterns inside function parameters, to emphasize role
  of parameters a signature declaration (mirroring existing behaviour
  for function declarations) and avoid generating code introducing
  specified bindings.

Closes issues below by considering input to be ill-formed.

Closes #75922.
Closes #77848.
Closes #79350.

3 years agoUpdate compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs
Rich Kadel [Wed, 25 Nov 2020 19:41:23 +0000 (11:41 -0800)]
Update compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs

3 years agoreplace assert with condition and `fatal` error
Rich Kadel [Wed, 25 Nov 2020 19:38:09 +0000 (11:38 -0800)]
replace assert with condition and `fatal` error

3 years agoAuto merge of #79326 - Aaron1011:fix/builtin-macro-stmt, r=petrochenkov
bors [Wed, 25 Nov 2020 18:37:55 +0000 (18:37 +0000)]
Auto merge of #79326 - Aaron1011:fix/builtin-macro-stmt, r=petrochenkov

Always invoke statement attributes on the statement itself

This is preparation for PR #78296, which will require us to handle
statement items in addition to normal items.

3 years agoImproved version check
Rich Kadel [Wed, 25 Nov 2020 17:45:33 +0000 (09:45 -0800)]
Improved version check

3 years agoAdjust pretty-print compat hack to work with item statements
Aaron Hill [Wed, 25 Nov 2020 16:31:22 +0000 (11:31 -0500)]
Adjust pretty-print compat hack to work with item statements

3 years agoAuto merge of #79216 - Aaron1011:opt-on-disk-cache, r=pnkfelix
bors [Wed, 25 Nov 2020 16:22:11 +0000 (16:22 +0000)]
Auto merge of #79216 - Aaron1011:opt-on-disk-cache, r=pnkfelix

Only create `OnDiskCache` in incremental compilation mode

This lets us skip doing useless work when we're not in incremental
compilation mode.

3 years agoAuto merge of #79400 - camelid:rustdoc-summary_opts, r=GuillaumeGomez
bors [Wed, 25 Nov 2020 14:08:47 +0000 (14:08 +0000)]
Auto merge of #79400 - camelid:rustdoc-summary_opts, r=GuillaumeGomez

Add `summary_opts()` for Markdown summary rendering options

We have a similar function `opts()` that is for rendering the main body
of the documentation, but until now we just constructed the options for
rendering summaries on the fly. This is a problem if/when we change the
enabled options since the different places can get out-of-sync.

3 years agoAuto merge of #79397 - camelid:polonious-incr-comp, r=jonas-schievink
bors [Wed, 25 Nov 2020 11:54:04 +0000 (11:54 +0000)]
Auto merge of #79397 - camelid:polonious-incr-comp, r=jonas-schievink

TRACK '-Z polonius' flag

Fixes #79316.

r? `@jonas-schievink`

3 years agoAuto merge of #79388 - tmiasko:naked-def-only, r=lcnr
bors [Wed, 25 Nov 2020 09:41:15 +0000 (09:41 +0000)]
Auto merge of #79388 - tmiasko:naked-def-only, r=lcnr

Validate that `#[naked]` is applied to a function definition

3 years agoAuto merge of #79336 - camelid:rename-feature-oibit-to-auto, r=oli-obk
bors [Wed, 25 Nov 2020 07:25:19 +0000 (07:25 +0000)]
Auto merge of #79336 - camelid:rename-feature-oibit-to-auto, r=oli-obk

Rename `optin_builtin_traits` to `auto_traits`

They were originally called "opt-in, built-in traits" (OIBITs), but
people realized that the name was too confusing and a mouthful, and so
they were renamed to just "auto traits". The feature flag's name wasn't
updated, though, so that's what this PR does.

There are some other spots in the compiler that still refer to OIBITs,
but I don't think changing those now is worth it since they are internal
and not particularly relevant to this PR.

Also see <https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/opt-in.2C.20built-in.20traits.20(auto.20traits).20feature.20name>.

r? `@oli-obk` (feel free to re-assign if you're not the right reviewer for this)

3 years agoAuto merge of #77491 - lukaslueg:peek_mut, r=m-ou-se
bors [Wed, 25 Nov 2020 05:10:53 +0000 (05:10 +0000)]
Auto merge of #77491 - lukaslueg:peek_mut, r=m-ou-se

Proposal to add Peekable::peek_mut

A "peekable" iterator has a `peek()`-method which provides an immutable reference to the next item. We currently do not have a method to modify that item, which we could easily add via a `peek_mut()`. See the test for a use-case (alike to my original use case), where a "pristine" iterator is passed on after modifying its state via `peek_mut()`.

If there is interest in this, I can expand on the tests and docs.

3 years agoTRACK '-Z polonius' flag
Camelid [Wed, 25 Nov 2020 02:58:20 +0000 (18:58 -0800)]
TRACK '-Z polonius' flag

3 years agoAdd `summary_opts()` for Markdown summary rendering options
Camelid [Wed, 25 Nov 2020 03:54:41 +0000 (19:54 -0800)]
Add `summary_opts()` for Markdown summary rendering options

We have a similar function `opts()` that is for rendering the main body
of the documentation, but until now we just constructed the options for
rendering summaries on the fly. This is a problem if/when we change the
enabled options since the different places can get out-of-sync.

3 years agoAuto merge of #76688 - yokodake:patch-2, r=kodrAus
bors [Wed, 25 Nov 2020 02:49:28 +0000 (02:49 +0000)]
Auto merge of #76688 - yokodake:patch-2, r=kodrAus

Document unsafety in core::slice::memchr

Contributes to #66219

Note sure if that's good enough, especially for the `align_to` call.
The docs only mention transmuting and I don't think that everything related to reference lifetimes and state validity mentioned in the [nomicon](https://doc.rust-lang.org/nomicon/transmutes.html) are relevant here.

3 years agoApply suggestions from code review
Rich Kadel [Wed, 25 Nov 2020 02:34:10 +0000 (18:34 -0800)]
Apply suggestions from code review

Co-authored-by: Wesley Wiser <wwiser@gmail.com>
3 years agoUse the name "auto traits" everywhere in the compiler
Camelid [Tue, 24 Nov 2020 23:44:04 +0000 (15:44 -0800)]
Use the name "auto traits" everywhere in the compiler

Goodbye, OIBIT!

3 years agoMove lev_distance to rustc_ast, make non-generic
Arlie Davis [Thu, 12 Nov 2020 19:24:10 +0000 (11:24 -0800)]
Move lev_distance to rustc_ast, make non-generic

rustc_ast currently has a few dependencies on rustc_lexer. Ideally, an AST
would not have any dependency its lexer, for minimizing unnecessarily
design-time dependencies. Breaking this dependency would also have practical
benefits, since modifying rustc_lexer would not trigger a rebuild of rustc_ast.

This commit does not remove the rustc_ast --> rustc_lexer dependency,
but it does remove one of the sources of this dependency, which is the
code that handles fuzzy matching between symbol names for making suggestions
in diagnostics. Since that code depends only on Symbol, it is easy to move
it to rustc_span. It might even be best to move it to a separate crate,
since other tools such as Cargo use the same algorithm, and have simply
contain a duplicate of the code.

This changes the signature of find_best_match_for_name so that it is no
longer generic over its input. I checked the optimized binaries, and this
function was duplicated at nearly every call site, because most call sites
used short-lived iterator chains, generic over Map and such. But there's
no good reason for a function like this to be generic, since all it does
is immediately convert the generic input (the Iterator impl) to a concrete
Vec<Symbol>. This has all of the costs of generics (duplicated method bodies)
with no benefit.

Changing find_best_match_for_name to be non-generic removed about 10KB of
code from the optimized binary. I know it's a drop in the bucket, but we have
to start reducing binary size, and beginning to tame over-use of generics
is part of that.

3 years agoValidate use of parameters in naked functions
Tomasz Miąsko [Wed, 25 Nov 2020 00:00:00 +0000 (00:00 +0000)]
Validate use of parameters in naked functions

* Reject use of parameters inside naked function body.
* Reject use of patterns inside function parameters, to emphasize role
  of parameters a signature declaration (mirroring existing behaviour
  for function declarations) and avoid generating code introducing
  specified bindings.

3 years agoInvoke attributes on the statement for statement items
Aaron Hill [Tue, 24 Nov 2020 19:47:49 +0000 (14:47 -0500)]
Invoke attributes on the statement for statement items

3 years agoAuto merge of #78548 - camelid:driver-tty, r=oli-obk
bors [Tue, 24 Nov 2020 20:58:20 +0000 (20:58 +0000)]
Auto merge of #78548 - camelid:driver-tty, r=oli-obk

driver: Only output ANSI logging if connected to a terminal

Fixes #78435.

See #78435 for more.

Cc `@RalfJung` `@oli-obk`

3 years agoCheck for LLVM 11+ when using `-Z instrument-coverage`
Rich Kadel [Tue, 24 Nov 2020 19:50:24 +0000 (11:50 -0800)]
Check for LLVM 11+ when using `-Z instrument-coverage`

* `rustc` should now compile under LLVM 9 or 10
* Compiler generates an error if `-Z instrument-coverage` is specified
  but LLVM version is less than 11
* Coverage tests that require `-Z instrument-coverage` and run codegen
  should be skipped if LLVM version is less than 11

3 years agoHandle `Annotatable::Stmt` in some builtin macros
Aaron Hill [Mon, 23 Nov 2020 00:32:39 +0000 (19:32 -0500)]
Handle `Annotatable::Stmt` in some builtin macros

This is preparation for PR #78296, which will require us to handle
statement items in addition to normal items.

3 years agoAuto merge of #79384 - ehuss:update-cargo, r=ehuss
bors [Tue, 24 Nov 2020 18:32:19 +0000 (18:32 +0000)]
Auto merge of #79384 - ehuss:update-cargo, r=ehuss

Update cargo

10 commits in 2af662e22177a839763ac8fb70d245a680b15214..bfca1cd22bf514d5f2b6c1089b0ded0ba7dfaa6e
2020-11-12 19:04:56 +0000 to 2020-11-24 16:33:21 +0000
- Shrink the progress bar, to give more space after it. (rust-lang/cargo#8892)
- Add some comments to the toml code (rust-lang/cargo#8887)
- Start searching git config at new path (rust-lang/cargo#8886)
- Fix documentation for CARGO_PRIMARY_PACKAGE. (rust-lang/cargo#8891)
- Bump to 0.51.0, update changelog (rust-lang/cargo#8894)
- Publish target's "doc" setting when emitting metadata (rust-lang/cargo#8869)
- Relaxes expectation of `cargo test` tests to accept test execution time (rust-lang/cargo#8884)
- Finish implementation of `-Zextra-link-arg`. (rust-lang/cargo#8441)
- Reproducible crate builds (rust-lang/cargo#8864)
- Allow resolver="1" to explicitly use the old resolver behavior. (rust-lang/cargo#8857)

3 years agoUpdate cargo
Eric Huss [Tue, 24 Nov 2020 17:33:37 +0000 (09:33 -0800)]
Update cargo

3 years agoAuto merge of #79335 - jyn514:doctree-crate, r=GuillaumeGomez
bors [Tue, 24 Nov 2020 16:08:23 +0000 (16:08 +0000)]
Auto merge of #79335 - jyn514:doctree-crate, r=GuillaumeGomez

Get rid of doctree::{ExternalCrate, ForeignItem, Trait, Function}

Closes #79314, closes #79331, closes #79332. Follow-up to #79264 and #79312, continues breaking up #78082.

r? `@GuillaumeGomez`

3 years agoGet rid of doctree::ExternCrate
Joshua Nelson [Mon, 23 Nov 2020 02:51:57 +0000 (21:51 -0500)]
Get rid of doctree::ExternCrate

3 years agoGet rid of doctree::Trait
Joshua Nelson [Mon, 23 Nov 2020 02:32:18 +0000 (21:32 -0500)]
Get rid of doctree::Trait

3 years agoGet rid of doctree::Function
Joshua Nelson [Mon, 23 Nov 2020 02:20:08 +0000 (21:20 -0500)]
Get rid of doctree::Function

3 years agoGet rid of doctree::ForeignItem
Joshua Nelson [Sun, 22 Nov 2020 19:03:02 +0000 (14:03 -0500)]
Get rid of doctree::ForeignItem

3 years agoAuto merge of #79377 - jonas-schievink:rollup-ye81i66, r=jonas-schievink
bors [Tue, 24 Nov 2020 12:27:30 +0000 (12:27 +0000)]
Auto merge of #79377 - jonas-schievink:rollup-ye81i66, r=jonas-schievink

Rollup of 10 pull requests

Successful merges:

 - #76858 (Add exploit mitigations chapter to the rustc book)
 - #79310 (Make `fold_item_recur` non-nullable)
 - #79312 (Get rid of `doctree::Impl`)
 - #79321 (Accept '!' in intra-doc links)
 - #79346 (Allow using `-Z fewer-names=no` to retain value names)
 - #79351 (Fix typo in `keyword` docs for traits)
 - #79354 (BTreeMap: cut out the ceremony around BoxedNode)
 - #79358 (BTreeMap/BTreeSet: make public doc more consistent)
 - #79367 (Allow disabling TrapUnreachable via -Ztrap-unreachable=no)
 - #79374 (Add note to use nightly when using expr in const generics)

Failed merges:

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

3 years agoRollup merge of #79374 - mendess:const-param-expr-diagnostic, r=lcnr
Jonas Schievink [Tue, 24 Nov 2020 12:17:51 +0000 (13:17 +0100)]
Rollup merge of #79374 - mendess:const-param-expr-diagnostic, r=lcnr

Add note to use nightly when using expr in const generics

As recommended by `@Icnr` in #73899 and in zulip, I've added a note saying that const expressions can be used in nightly.

```
error: generic parameters may not be used in const operations
  --> $DIR/issue-61935.rs:10:23
   |
 6 |         Self:FooImpl<{N==0}>
   |                       ^ cannot perform const operation using `N`
   |
   = help: const parameters may only be used as standalone arguments, i.e. `N`
   = note: use feature(const_generics) and feature(const_evaluatable_checked) to enable this

error: aborting due to previous error
```

I hope the note is well written :sweat_smile:

3 years agoRollup merge of #79367 - Dirbaio:trap-unreachable, r=jonas-schievink
Jonas Schievink [Tue, 24 Nov 2020 12:17:49 +0000 (13:17 +0100)]
Rollup merge of #79367 - Dirbaio:trap-unreachable, r=jonas-schievink

Allow disabling TrapUnreachable via -Ztrap-unreachable=no

Currently this is only possible by defining a custom target, which is quite unwieldy.

This is useful for embedded targets where small code size is desired. For example, on my project (thumbv7em-none-eabi) this yields a 0.6% code size reduction: 132892 bytes -> 132122 bytes (770 bytes down).

3 years agoRollup merge of #79358 - ssomers:btree_public_comments, r=Mark-Simulacrum
Jonas Schievink [Tue, 24 Nov 2020 12:17:47 +0000 (13:17 +0100)]
Rollup merge of #79358 - ssomers:btree_public_comments, r=Mark-Simulacrum

BTreeMap/BTreeSet: make public doc more consistent

Tweaks #72876 and #73667 and propagate them to `BTreeSet`.

3 years agoRollup merge of #79354 - ssomers:btree_bereave_BoxedNode, r=Mark-Simulacrum
Jonas Schievink [Tue, 24 Nov 2020 12:17:45 +0000 (13:17 +0100)]
Rollup merge of #79354 - ssomers:btree_bereave_BoxedNode, r=Mark-Simulacrum

BTreeMap: cut out the ceremony around BoxedNode

The opposite direction of #79093.

r? ``@Mark-Simulacrum``

3 years agoRollup merge of #79351 - Takashiidobe:keyword-docs-typo, r=m-ou-se
Jonas Schievink [Tue, 24 Nov 2020 12:17:43 +0000 (13:17 +0100)]
Rollup merge of #79351 - Takashiidobe:keyword-docs-typo, r=m-ou-se

Fix typo in `keyword` docs for traits

This PR fixes a small typo in the `keyword_docs.rs` file, describing the differences between the 2015 and 2018 editions of traits.

3 years agoRollup merge of #79346 - tmiasko:more-names, r=jonas-schievink
Jonas Schievink [Tue, 24 Nov 2020 12:17:41 +0000 (13:17 +0100)]
Rollup merge of #79346 - tmiasko:more-names, r=jonas-schievink

Allow using `-Z fewer-names=no` to retain value names

Change `-Z fewer-names` into an optional boolean flag and allow using it
to either discard value names when true or retain them when false,
regardless of other settings.

3 years agoRollup merge of #79321 - camelid:intra-doc-bang, r=Manishearth
Jonas Schievink [Tue, 24 Nov 2020 12:17:39 +0000 (13:17 +0100)]
Rollup merge of #79321 - camelid:intra-doc-bang, r=Manishearth

Accept '!' in intra-doc links

This will allow linking to things like `Result<T, !>`.

*See <https://github.com/rust-lang/rust/pull/77832#discussion_r528409079>.*

r? ``@jyn514``

3 years agoRollup merge of #79312 - jyn514:doctree-impl, r=GuillaumeGomez
Jonas Schievink [Tue, 24 Nov 2020 12:17:37 +0000 (13:17 +0100)]
Rollup merge of #79312 - jyn514:doctree-impl, r=GuillaumeGomez

Get rid of `doctree::Impl`

Follow-up to https://github.com/rust-lang/rust/pull/79264, continues breaking up https://github.com/rust-lang/rust/pull/78082. At some point I want to introduce `MaybeInlined`, but I think I'll wait until I need `MaybeInlined::InlinedWithOriginal` because it's not very useful in other situations.

r? ``@GuillaumeGomez``

3 years agoRollup merge of #79310 - jyn514:fold-item-cleanup, r=GuillaumeGomez
Jonas Schievink [Tue, 24 Nov 2020 12:17:35 +0000 (13:17 +0100)]
Rollup merge of #79310 - jyn514:fold-item-cleanup, r=GuillaumeGomez

Make `fold_item_recur` non-nullable

This gets rid of a bunch of `unwrap()`s and makes it a little more clear
what's going on.

Originally I wanted to make `fold_item` non-nullable too, which would
have been a lot nicer to work with, but unfortunately `stripper` does
actually return `None` in some places. I might make a follow-up moving
stripper to be special and not a pass so that passes can be
non-nullable.

Found while working on https://github.com/rust-lang/rust/issues/76998.

3 years agoRollup merge of #76858 - rcvalle:rust-lang-exploit-mitigations, r=steveklabnik
Jonas Schievink [Tue, 24 Nov 2020 12:17:28 +0000 (13:17 +0100)]
Rollup merge of #76858 - rcvalle:rust-lang-exploit-mitigations, r=steveklabnik

Add exploit mitigations chapter to the rustc book

This section documents the exploit mitigations applicable to the Rust compiler when building programs for the Linux operating system on the AMD64 architecture and equivalent. This was done for a project I'm currently working on, and I hope it'll also be helpful to others.

3 years agoSwap note for help
mendess [Tue, 24 Nov 2020 11:05:55 +0000 (11:05 +0000)]
Swap note for help

3 years agoRequested changes
mendess [Tue, 24 Nov 2020 10:28:18 +0000 (10:28 +0000)]
Requested changes

3 years agoAdd note to use nightly when using expr in const generics
mendess [Tue, 24 Nov 2020 09:35:08 +0000 (09:35 +0000)]
Add note to use nightly when using expr in const generics

3 years agoAuto merge of #79294 - petrochenkov:determ, r=varkor
bors [Tue, 24 Nov 2020 09:17:33 +0000 (09:17 +0000)]
Auto merge of #79294 - petrochenkov:determ, r=varkor

resolve: Do not put macros into `module.unexpanded_invocations` unless necessary

Macro invocations in modules <sup>(*)</sup> need to be tracked because they can produce named items when expanded.
We cannot give definite answer to queries like "does this module declare name `n`?" until all macro calls in that module are expanded.

Previously we marked too many macros as potentially producing named items.
E.g. in this example
```rust
mod m {
    const C: u32 = line!();
}
```
`line!()` cannot emit any items into module `m`, but it was still marked.
This PR fixes that and marks macro calls as "unexpanded in module" only if they can actually emit named items into that module.

Diagnostics in UI test outputs have different order now because this change affects macro expansion order.

<sup>*</sup> Any containers for named items are called modules in resolve (that includes blocks, traits and enums in addition to `mod` items).

3 years agoAuto merge of #79228 - flip1995:clippyup, r=oli-obk
bors [Tue, 24 Nov 2020 06:56:02 +0000 (06:56 +0000)]
Auto merge of #79228 - flip1995:clippyup, r=oli-obk

Update Clippy

Biweekly Clippy update

r? `@Manishearth`

3 years agoAdd exploit mitigations chapter to the rustc book
Ramon de C Valle [Fri, 18 Sep 2020 00:47:56 +0000 (17:47 -0700)]
Add exploit mitigations chapter to the rustc book

This section documents the exploit mitigations applicable to the Rust
compiler when building programs for the Linux operating system on the
AMD64 architecture and equivalent.

3 years agoUpdated links to LLVM 11 docs and types
Rich Kadel [Tue, 24 Nov 2020 03:11:56 +0000 (19:11 -0800)]
Updated links to LLVM 11 docs and types

3 years agoAuto merge of #78953 - mzohreva:mz/from_raw_fd, r=Mark-Simulacrum
bors [Tue, 24 Nov 2020 03:12:20 +0000 (03:12 +0000)]
Auto merge of #78953 - mzohreva:mz/from_raw_fd, r=Mark-Simulacrum

Add Metadata in std::os::fortanix_sgx::io::FromRawFd

Needed for https://github.com/fortanix/rust-sgx/pull/291

cc `@jethrogb`

3 years agoUse `early_error`
Camelid [Tue, 24 Nov 2020 01:38:20 +0000 (17:38 -0800)]
Use `early_error`

3 years agoAuto merge of #78636 - dtolnay:puncteq, r=petrochenkov
bors [Tue, 24 Nov 2020 00:30:25 +0000 (00:30 +0000)]
Auto merge of #78636 - dtolnay:puncteq, r=petrochenkov

Add PartialEq<char> for proc_macro::Punct

`punct.as_char() == '░'` is pervasive when parsing anything involving punct. I think `punct == '░'` is sufficiently unambiguous that it makes sense to provide the impl.

https://github.com/rust-lang/rust/blob/1899c489d4c30b2640d30b77ac04f0a548834d81/library/proc_macro/src/quote.rs#L79
https://github.com/rust-lang/rust/blob/1899c489d4c30b2640d30b77ac04f0a548834d81/library/proc_macro/src/quote.rs#L83
https://github.com/rust-lang/rust/blob/1899c489d4c30b2640d30b77ac04f0a548834d81/src/test/ui/suggestions/auxiliary/issue-61963.rs#L26
https://github.com/rust-lang/rust/blob/1899c489d4c30b2640d30b77ac04f0a548834d81/src/test/ui/proc-macro/auxiliary/three-equals.rs#L23

3 years agoAllow disabling TrapUnreachable via -Ztrap-unreachable=no
Dario Nieuwenhuis [Mon, 23 Nov 2020 23:55:10 +0000 (00:55 +0100)]
Allow disabling TrapUnreachable via -Ztrap-unreachable=no

This is useful for embedded targets where small code size is desired.
For example, on my project (thumbv7em-none-eabi) this yields a 0.6% code size reduction.

3 years agoValidate that `#[naked]` is applied to a function definition
Tomasz Miąsko [Tue, 24 Nov 2020 00:00:00 +0000 (00:00 +0000)]
Validate that `#[naked]` is applied to a function definition

3 years agoDon't mark #[naked] as used when checking #[track_caller]
Tomasz Miąsko [Tue, 24 Nov 2020 00:00:00 +0000 (00:00 +0000)]
Don't mark #[naked] as used when checking #[track_caller]

3 years agoUpgrades the coverage map to Version 4
Rich Kadel [Mon, 23 Nov 2020 20:56:07 +0000 (12:56 -0800)]
Upgrades the coverage map to Version 4

Changes the coverage map injected into binaries compiled with
`-Zinstrument-coverage` to LLVM Coverage Mapping Format, Version 4 (from
Version 3). Note, binaries compiled with this version will require LLVM
tools from at least LLVM Version 11.

3 years agoAdd Peekable::peek_mut
Lukas Lueg [Mon, 23 Nov 2020 22:52:19 +0000 (23:52 +0100)]
Add Peekable::peek_mut

3 years agoRename `optin_builtin_traits` to `auto_traits`
Camelid [Mon, 23 Nov 2020 03:54:31 +0000 (19:54 -0800)]
Rename `optin_builtin_traits` to `auto_traits`

They were originally called "opt-in, built-in traits" (OIBITs), but
people realized that the name was too confusing and a mouthful, and so
they were renamed to just "auto traits". The feature flag's name wasn't
updated, though, so that's what this PR does.

There are some other spots in the compiler that still refer to OIBITs,
but I don't think changing those now is worth it since they are internal
and not particularly relevant to this PR.

Also see <https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/opt-in.2C.20built-in.20traits.20(auto.20traits).20feature.20name>.

3 years agoAuto merge of #78343 - camelid:macros-qualify-panic, r=m-ou-se
bors [Mon, 23 Nov 2020 22:05:28 +0000 (22:05 +0000)]
Auto merge of #78343 - camelid:macros-qualify-panic, r=m-ou-se

Qualify `panic!` as `core::panic!` in non-built-in `core` macros

Fixes #78333.

-----

Otherwise code like this

    #![no_implicit_prelude]

    fn main() {
        ::std::todo!();
        ::std::unimplemented!();
    }

will fail to compile, which is unfortunate and presumably unintended.

This changes many invocations of `panic!` in a `macro_rules!` definition
to invocations of `$crate::panic!`, which makes the invocations hygienic.

Note that this does not make the built-in macro `assert!` hygienic.

3 years agoClean up `core` macros documentation
Camelid [Sun, 25 Oct 2020 01:38:25 +0000 (18:38 -0700)]
Clean up `core` macros documentation

* Switch a couple links over to intra-doc links
* Clean up some formatting/typography

3 years agoQualify `panic!` as `core::panic!` in non-built-in `core` macros
Camelid [Sun, 25 Oct 2020 01:35:46 +0000 (18:35 -0700)]
Qualify `panic!` as `core::panic!` in non-built-in `core` macros

Otherwise code like this

    #![no_implicit_prelude]

    fn main() {
        ::std::todo!();
        ::std::unimplemented!();
    }

will fail to compile, which is unfortunate and presumably unintended.

This changes many invocations of `panic!` in a `macro_rules!` definition
to invocations of `$crate::panic!`, which makes the invocations hygienic.

Note that this does not make the built-in macro `assert!` hygienic.

3 years agoAuto merge of #78439 - lzutao:rm-clouldabi, r=Mark-Simulacrum
bors [Mon, 23 Nov 2020 19:01:19 +0000 (19:01 +0000)]
Auto merge of #78439 - lzutao:rm-clouldabi, r=Mark-Simulacrum

Drop support for all cloudabi targets

`cloudabi` is a tier-3 target, and [it is no longer being maintained upstream][no].

This PR drops supports for cloudabi targets. Those targets are:
* aarch64-unknown-cloudabi
* armv7-unknown-cloudabi
* i686-unknown-cloudabi
* x86_64-unknown-cloudabi

Since this drops supports for a target, I'd like somebody to tag `relnotes` label to this PR.

Some other issues:
* The tidy exception for `cloudabi` crate is still remained because
  * `parking_lot v0.9.0` and `parking_lot v0.10.2` depends on `cloudabi v0.0.3`.
  * `parking_lot v0.11.0` depends on `cloudabi v0.1.0`.

[no]: https://github.com/NuxiNL/cloudabi#note-this-project-is-unmaintained

3 years agoBTreeMap/BTreeSet: make public doc more consistent
Stein Somers [Mon, 23 Nov 2020 18:09:23 +0000 (19:09 +0100)]
BTreeMap/BTreeSet: make public doc more consistent

3 years agoRemove Pat pre-lowering.
Camille GILLOT [Sun, 15 Nov 2020 22:19:55 +0000 (23:19 +0100)]
Remove Pat pre-lowering.

3 years agoLower `if let` before the arms.
Camille GILLOT [Sun, 15 Nov 2020 19:29:01 +0000 (20:29 +0100)]
Lower `if let` before the arms.

3 years agoAuto merge of #79345 - jonas-schievink:rollup-1yhhzx9, r=jonas-schievink
bors [Mon, 23 Nov 2020 16:33:03 +0000 (16:33 +0000)]
Auto merge of #79345 - jonas-schievink:rollup-1yhhzx9, r=jonas-schievink

Rollup of 10 pull requests

Successful merges:

 - #76829 (stabilize const_int_pow)
 - #79080 (MIR visitor: Don't treat debuginfo field access as a use of the struct)
 - #79236 (const_generics: assert resolve hack causes an error)
 - #79287 (Allow using generic trait methods in `const fn`)
 - #79324 (Use Option::and_then instead of open-coding it)
 - #79325 (Reduce boilerplate with the `?` operator)
 - #79330 (Fix typo in comment)
 - #79333 (doc typo)
 - #79337 (Use Option::map instead of open coding it)
 - #79343 (Add my (`@flip1995)` work mail to the mailmap)

Failed merges:

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

3 years agoBTreeMap: cut out the ceremony around BoxedNode
Stein Somers [Mon, 23 Nov 2020 15:40:48 +0000 (16:40 +0100)]
BTreeMap: cut out the ceremony around BoxedNode

3 years agoFix typo in keyword docs for traits
takashiidobe [Mon, 23 Nov 2020 15:48:19 +0000 (10:48 -0500)]
Fix typo in keyword docs for traits

3 years agoRollup merge of #79343 - flip1995:mailmap, r=Mark-Simulacrum
Jonas Schievink [Mon, 23 Nov 2020 14:25:55 +0000 (15:25 +0100)]
Rollup merge of #79343 - flip1995:mailmap, r=Mark-Simulacrum

Add my (@flip1995) work mail to the mailmap

3 years agoRollup merge of #79337 - LingMan:map, r=jyn514
Jonas Schievink [Mon, 23 Nov 2020 14:25:53 +0000 (15:25 +0100)]
Rollup merge of #79337 - LingMan:map, r=jyn514

Use Option::map instead of open coding it

r?  `@jonas-schievink` since you're frequently sniping these minor cleanups anyway.
`@rustbot` modify labels +C-cleanup  +T-compiler

3 years agoRollup merge of #79333 - o752d:patch-3, r=Mark-Simulacrum
Jonas Schievink [Mon, 23 Nov 2020 14:25:51 +0000 (15:25 +0100)]
Rollup merge of #79333 - o752d:patch-3, r=Mark-Simulacrum

doc typo

plus a small edit for clarity

3 years agoRollup merge of #79330 - jyn514:typo, r=jyn514
Jonas Schievink [Mon, 23 Nov 2020 14:25:49 +0000 (15:25 +0100)]
Rollup merge of #79330 - jyn514:typo, r=jyn514

Fix typo in comment

This is trivial enough I'm just going to merge without review.

r? `@ghost`

3 years agoRollup merge of #79325 - LingMan:try_op, r=jonas-schievink
Jonas Schievink [Mon, 23 Nov 2020 14:25:47 +0000 (15:25 +0100)]
Rollup merge of #79325 - LingMan:try_op, r=jonas-schievink

Reduce boilerplate with the `?` operator

`@rustbot` modify labels to +C-cleanup.

3 years agoRollup merge of #79324 - LingMan:and_then, r=jonas-schievink
Jonas Schievink [Mon, 23 Nov 2020 14:25:46 +0000 (15:25 +0100)]
Rollup merge of #79324 - LingMan:and_then, r=jonas-schievink

Use Option::and_then instead of open-coding it

`@rustbot` modify labels to +C-cleanup.

3 years agoRollup merge of #79287 - jonas-schievink:const-trait-impl, r=oli-obk
Jonas Schievink [Mon, 23 Nov 2020 14:25:44 +0000 (15:25 +0100)]
Rollup merge of #79287 - jonas-schievink:const-trait-impl, r=oli-obk

Allow using generic trait methods in `const fn`

Next step for https://github.com/rust-lang/rust/issues/67792, this now also allows code like the following:

```rust
struct S;

impl const PartialEq for S {
    fn eq(&self, _: &S) -> bool {
        true
    }
}

const fn equals_self<T: PartialEq>(t: &T) -> bool {
    *t == *t
}

pub const EQ: bool = equals_self(&S);
```

This works by threading const-ness of trait predicates through trait selection, in particular through `ParamCandidate`, and exposing it in the resulting `ImplSource`.

Since this change makes two bounds `T: Trait` and `T: ?const Trait` that only differ in their const-ness be treated like different bounds, candidate winnowing has been changed to drop the `?const` candidate in favor of the const candidate, to avoid ambiguities when both a const and a non-const bound is present.

3 years agoRollup merge of #79236 - lcnr:mcg-resolve-dsb, r=eddyb
Jonas Schievink [Mon, 23 Nov 2020 14:25:42 +0000 (15:25 +0100)]
Rollup merge of #79236 - lcnr:mcg-resolve-dsb, r=eddyb

const_generics: assert resolve hack causes an error

prevent the min_const_generics `HACK`s in resolve from triggering a fallback path which successfully compiles so that we don't have to worry about future compat issues when removing it

r? `@eddyb` cc `@varkor`

3 years agoRollup merge of #79080 - camelid:mir-visit-debuginfo-project, r=jonas-schievink
Jonas Schievink [Mon, 23 Nov 2020 14:25:40 +0000 (15:25 +0100)]
Rollup merge of #79080 - camelid:mir-visit-debuginfo-project, r=jonas-schievink

MIR visitor: Don't treat debuginfo field access as a use of the struct

Fixes #77454.

r? `@jonas-schievink`

3 years agoRollup merge of #76829 - tspiteri:const-int-pow, r=oli-obk
Jonas Schievink [Mon, 23 Nov 2020 14:25:38 +0000 (15:25 +0100)]
Rollup merge of #76829 - tspiteri:const-int-pow, r=oli-obk

stabilize const_int_pow

This also requires stabilizing constctlz for const ctlz_nonzero.

3 years agoAuto merge of #79186 - JulianKnodt:str_from, r=Mark-Simulacrum
bors [Mon, 23 Nov 2020 14:20:22 +0000 (14:20 +0000)]
Auto merge of #79186 - JulianKnodt:str_from, r=Mark-Simulacrum

Change slice::to_vec to not use extend_from_slice

I saw this [Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/String.3A.3Afrom%28.26str%29.20wonky.20codegen/near/216164455), and didn't see any update from it, so I thought I'd try to fix it. This converts `to_vec` to no longer use `extend_from_slice`, but relies on knowing that the allocated capacity is the same size as the input.

[Godbolt new v1](https://rust.godbolt.org/z/1bcWKG)
[Godbolt new v2 w/ drop guard](https://rust.godbolt.org/z/5jn76K)
[Godbolt old version](https://rust.godbolt.org/z/e4ePav)

After some amount of iteration, there are now two specializations for `to_vec`, one for `Copy` types that use memcpy, and one for clone types which is the original from this PR.

This is then used inside of `impl<T: Clone> FromIterator<Iter::Slice<T>> for Vec<T>` which is essentially equivalent to `&[T] -> Vec<T>`, instead of previous specialization of the `extend` function. This is because extend has to reason more about existing capacity by calling `reserve` on an existing vec, and thus produces worse asm.

Downsides: This allocates the exact capacity, so I think if many items are added to this `Vec` after, it might need to allocate whereas extending may not. I also noticed the number of faults went up in the benchmarks, but not sure where from exactly.

3 years agoAdd my (@flip1995) work mail to the mailmap
flip1995 [Mon, 23 Nov 2020 13:11:56 +0000 (14:11 +0100)]
Add my (@flip1995) work mail to the mailmap

3 years agoFix ICE in utils::implements_trait
flip1995 [Mon, 23 Nov 2020 12:52:27 +0000 (13:52 +0100)]
Fix ICE in utils::implements_trait

This only happend when debug_assertions were enabled in rustc

3 years agoMerge commit '3e7c6dec244539970b593824334876f8b6ed0b18' into clippyup
flip1995 [Mon, 23 Nov 2020 12:51:04 +0000 (13:51 +0100)]
Merge commit '3e7c6dec244539970b593824334876f8b6ed0b18' into clippyup

3 years agoAuto merge of #77893 - petertodd:2020-impl-default-for-phantompinned, r=dtolnay
bors [Mon, 23 Nov 2020 07:00:30 +0000 (07:00 +0000)]
Auto merge of #77893 - petertodd:2020-impl-default-for-phantompinned, r=dtolnay

Impl Default for PhantomPinned

`PhantomPinned` is just a marker type, with an obvious default value (the only value). So I can't think of a reason not to do this. Sure, it's used in exotic situations with unsafe code. But the people writing that code can decide for themselves if they can derive `Default`, and in many situations the derived impl will make sense:

```rust
#[derive(Default)]
struct NeedsPin {
   marker: PhantomPinned,
   buf: [u8; 1024],
   ptr_to_data: Option<*const u8>,
}
```

3 years agoAuto merge of #76226 - CDirkx:const-ipaddr, r=dtolnay
bors [Mon, 23 Nov 2020 04:47:25 +0000 (04:47 +0000)]
Auto merge of #76226 - CDirkx:const-ipaddr, r=dtolnay

Stabilize `IpAddr::is_ipv4` and `is_ipv6` as const

Insta-stabilize the methods `is_ipv4` and `is_ipv6` of `std::net::IpAddr` as const, in the same way as [PR#76198](https://github.com/rust-lang/rust/pull/76198).

Possible because of the recent stabilization of const control flow.

Part of #76225 and #76205.

3 years agoUse Option::map instead of open coding it
LingMan [Mon, 23 Nov 2020 03:58:21 +0000 (04:58 +0100)]
Use Option::map instead of open coding it

3 years agodoc typo
oliver [Mon, 23 Nov 2020 02:47:45 +0000 (02:47 +0000)]
doc typo

plus a small edit for clarity

3 years agoAuto merge of #79172 - a1phyr:cold_abort, r=Mark-Simulacrum
bors [Mon, 23 Nov 2020 02:25:13 +0000 (02:25 +0000)]
Auto merge of #79172 - a1phyr:cold_abort, r=Mark-Simulacrum

Add #[cold] attribute to `std::process::abort` and `alloc::alloc::handle_alloc_error`

3 years agoAdd comment and remove obsolete special case
Camelid [Mon, 23 Nov 2020 01:33:06 +0000 (17:33 -0800)]
Add comment and remove obsolete special case

3 years agoFix typo in comment
Joshua Nelson [Mon, 23 Nov 2020 01:32:36 +0000 (20:32 -0500)]
Fix typo in comment

3 years agoconst_int_pow will be stabilized in 1.50.0, not in 1.49.0
Trevor Spiteri [Mon, 23 Nov 2020 01:04:37 +0000 (02:04 +0100)]
const_int_pow will be stabilized in 1.50.0, not in 1.49.0

Same for constctlz.

3 years agostabilize const_int_pow
Trevor Spiteri [Fri, 2 Oct 2020 17:30:16 +0000 (19:30 +0200)]
stabilize const_int_pow

Also stabilize constctlz for const ctlz_nonzero.

The public methods stabilized const by this commit are:

  * `{i*,u*}::checked_pow`
  * `{i*,u*}::saturating_pow`
  * `{i*,u*}::wrapping_pow`
  * `{i*,u*}::overflowing_pow`
  * `{i*,u*}::pow`
  * `u*::next_power_of_two`
  * `u*::checked_next_power_of_two`
  * `u*::wrapping_next_power_of_two` (the method itself is still unstable)

3 years agoBump version to 1.50.0
Christiaan Dirkx [Mon, 23 Nov 2020 00:40:26 +0000 (01:40 +0100)]
Bump version to 1.50.0

3 years agoStabilize `IpAddr::is_ipv4` and `is_ipv6` as const
Christiaan Dirkx [Wed, 2 Sep 2020 00:05:42 +0000 (02:05 +0200)]
Stabilize `IpAddr::is_ipv4` and `is_ipv6` as const

Insta-stabilize the methods `is_ipv4` and `is_ipv6` of `IpAddr`.

Possible because of the recent stabilization of const control flow.

Also adds a test for these methods in a const context.

3 years agoAllow using `-Z fewer-names=no` to retain value names
Tomasz Miąsko [Mon, 23 Nov 2020 00:00:00 +0000 (00:00 +0000)]
Allow using `-Z fewer-names=no` to retain value names

Change `-Z fewer-names` into an optional boolean flag and allow using it
to either discard value names when true or retain them when false,
regardless of other settings.