]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoAdd additional semicolon test
Aaron Hill [Wed, 25 Nov 2020 21:58:10 +0000 (16:58 -0500)]
Add additional semicolon test

3 years agoOnly eat semicolons for statements that need them
Aaron Hill [Wed, 25 Nov 2020 21:52:24 +0000 (16:52 -0500)]
Only eat semicolons for statements that need them

When parsing a statement (e.g. inside a function body),
we now consider `struct Foo {};` and `$stmt;` to each consist
of two statements: `struct Foo {}` and `;`, and `$stmt` and `;`.

As a result, an attribute macro invoke as
`fn foo() { #[attr] struct Bar{}; }` will see `struct Bar{}` as its
input. Additionally, the 'unused semicolon' lint now fires in more
places.

3 years agoProperly handle attributes on statements
Aaron Hill [Tue, 17 Nov 2020 19:27:44 +0000 (14:27 -0500)]
Properly handle attributes on statements

We now collect tokens for the underlying node wrapped by `StmtKind`
instead of storing tokens directly in `Stmt`.

`LazyTokenStream` now supports capturing a trailing semicolon after it
is initially constructed. This allows us to avoid refactoring statement
parsing to wrap the parsing of the semicolon in `parse_tokens`.

Attributes on item statements
(e.g. `fn foo() { #[bar] struct MyStruct; }`) are now treated as
item attributes, not statement attributes, which is consistent with how
we handle attributes on other kinds of statements. The feature-gating
code is adjusted so that proc-macro attributes are still allowed on item
statements on stable.

Two built-in macros (`#[global_allocator]` and `#[test]`) needed to be
adjusted to support being passed `Annotatable::Stmt`.

3 years agoAuto merge of #77671 - flip1995:lint_list_always_plugins, r=oli-obk,Manishearth
bors [Thu, 26 Nov 2020 18:51:45 +0000 (18:51 +0000)]
Auto merge of #77671 - flip1995:lint_list_always_plugins, r=oli-obk,Manishearth

Always print lints from plugins, if they're available

Currently you can get a list of lints and lint groups by running `rustc
-Whelp`. This prints an additional line at the end:
```
Compiler plugins can provide additional lints and lint groups. To see a listing of these, re-run `rustc -W help` with a crate filename.
```

Clippy is such a "compiler plugin", that provides additional lints.
Running `clippy-driver -Whelp` (`rustc` wrapper) still only prints the
rustc lints with the above message at the end. But when running
`clippy-driver -Whelp main.rs`, where `main.rs` is any rust file, it
also prints Clippy lints. I don't think this is a good approach from a
UX perspective: Why is a random file necessary to print a help message?

This PR changes this behavior: Whenever a compiler callback
registers lints, it is assumed that these lints come from a plugin and
are printed without having to specify a Rust source file.

Fixes rust-lang/rust-clippy#6122

cc `@Manishearth` `@ebroto` for the Clippy changes.

3 years agoAuto merge of #77467 - jyn514:query-docs, r=oli-obk
bors [Thu, 26 Nov 2020 16:31:12 +0000 (16:31 +0000)]
Auto merge of #77467 - jyn514:query-docs, r=oli-obk

Normalize `<X as Y>::T` for rustdoc

- Only run for `QPath::Resolved` with `Some` self parameter (`<X as Y>::T`)
- Fall back to the previous behavior if the path can't be resolved

The first commit is a pure refactor and should probably be reviewed by `@GuillaumeGomez.` I recommend reviewing the second commit on its own.

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

r? `@eddyb`
cc `@danielhenrymantilla` , `@lcnr`

3 years agoAuto merge of #79441 - jonas-schievink:rollup-l9v00bl, r=jonas-schievink
bors [Thu, 26 Nov 2020 14:14:57 +0000 (14:14 +0000)]
Auto merge of #79441 - jonas-schievink:rollup-l9v00bl, r=jonas-schievink

Rollup of 10 pull requests

Successful merges:

 - #77758 (suggest turbofish syntax for uninferred const arguments)
 - #79000 (Move lev_distance to rustc_ast, make non-generic)
 - #79362 (Lower patterns before using the bound variable)
 - #79365 (Upgrades the coverage map to Version 4)
 - #79402 (Fix typos)
 - #79412 (Clean up rustdoc tests by removing unnecessary features)
 - #79413 (Fix persisted doctests on Windows / when using workspaces)
 - #79420 (Fixes a word typo in librustdoc)
 - #79421 (Fix docs formatting for `thir::pattern::_match`)
 - #79428 (Fixup compiler docs)

Failed merges:

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

3 years agoRemove redundant `lift_to_tcx`
Joshua Nelson [Thu, 26 Nov 2020 12:59:51 +0000 (07:59 -0500)]
Remove redundant `lift_to_tcx`

... and fix some fuzzy wording in the debug logging.

3 years agoRollup merge of #79428 - camelid:fixup-compiler-docs, r=davidtwco
Jonas Schievink [Thu, 26 Nov 2020 12:39:20 +0000 (13:39 +0100)]
Rollup merge of #79428 - camelid:fixup-compiler-docs, r=davidtwco

Fixup compiler docs

The sublist was being rendered as a code block because it was indented 4
spaces.

3 years agoRollup merge of #79421 - camelid:_match-docs-fmt, r=petrochenkov
Jonas Schievink [Thu, 26 Nov 2020 12:39:18 +0000 (13:39 +0100)]
Rollup merge of #79421 - camelid:_match-docs-fmt, r=petrochenkov

Fix docs formatting for `thir::pattern::_match`

They were being rendered all on one line.

3 years agoRollup merge of #79420 - njasm:patch_rustdoc, r=GuillaumeGomez
Jonas Schievink [Thu, 26 Nov 2020 12:39:16 +0000 (13:39 +0100)]
Rollup merge of #79420 - njasm:patch_rustdoc, r=GuillaumeGomez

Fixes a word typo in librustdoc

Fixes a word typo in librustdoc

3 years agoRollup merge of #79413 - Swatinem:rustdoc-persist-crate, r=GuillaumeGomez
Jonas Schievink [Thu, 26 Nov 2020 12:39:15 +0000 (13:39 +0100)]
Rollup merge of #79413 - Swatinem:rustdoc-persist-crate, r=GuillaumeGomez

Fix persisted doctests on Windows / when using workspaces

When using the unstable `--persist-doctests` option,
Windows path separators were not escaped properly. Also when running
the command in a workspace, crate files can overwrite each other.

Before: `src\lib_rs_1_0\rust_out`
After: `\crate_a_src_lib_rs_1_0\rust_out`, `\crate_b_src_lib_rs_1_0\rust_out`

3 years agoRollup merge of #79412 - GuillaumeGomez:cleanup-rustdoc-tests, r=jyn514
Jonas Schievink [Thu, 26 Nov 2020 12:39:13 +0000 (13:39 +0100)]
Rollup merge of #79412 - GuillaumeGomez:cleanup-rustdoc-tests, r=jyn514

Clean up rustdoc tests by removing unnecessary features

r? ``@jyn514``

3 years agoRollup merge of #79402 - bugadani:typos, r=matthewjasper
Jonas Schievink [Thu, 26 Nov 2020 12:39:11 +0000 (13:39 +0100)]
Rollup merge of #79402 - bugadani:typos, r=matthewjasper

Fix typos

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 #79427 - Aaron1011:fix/const-array-index, r=oli-obk
bors [Thu, 26 Nov 2020 11:59:17 +0000 (11:59 +0000)]
Auto merge of #79427 - Aaron1011:fix/const-array-index, r=oli-obk

Resolve inference variables before trying to remove overloaded indexing

Fixes #79152

This code was already set up to handle indexing an array. However, it
appears that we never end up with an inference variable for the slice
case, so the missing call to `resolve_vars_if_possible` had no effect
until now.

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 agoResolve inference variables before trying to remove overloaded indexing
Aaron Hill [Wed, 25 Nov 2020 21:03:10 +0000 (16:03 -0500)]
Resolve inference variables before trying to remove overloaded indexing

Fixes #79152

This code was already set up to handle indexing an array. However, it
appears that we never end up with an inference variable for the slice
case, so the missing call to `resolve_vars_if_possible` had no effect
until now.

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 agoFix docs formatting for `thir::pattern::_match`
Camelid [Wed, 25 Nov 2020 20:05:04 +0000 (12:05 -0800)]
Fix docs formatting for `thir::pattern::_match`

A list was being rendered all on one line and there were other
formatting issues as well.

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 agoFixup compiler docs
Camelid [Wed, 25 Nov 2020 21:15:48 +0000 (13:15 -0800)]
Fixup compiler docs

The sublist was being rendered as a code block because it was indented 4
spaces.

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 agoFix typos
Dániel Buga [Wed, 25 Nov 2020 08:18:09 +0000 (09:18 +0100)]
Fix typos

3 years agofixes a word typo in librustdoc
Nelson J Morais [Wed, 25 Nov 2020 19:09:11 +0000 (19:09 +0000)]
fixes a word typo in librustdoc

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 agoFix persisted doctests on Windows / when using workspaces
Arpad Borsos [Wed, 25 Nov 2020 14:40:13 +0000 (15:40 +0100)]
Fix persisted doctests on Windows / when using workspaces

When using the unstable `--persist-doctests` option,
Windows path separators were not escaped properly. Also when running
the command in a workspace, crate files can overwrite each other.

Before: `src\lib_rs_1_0\rust_out`
After: `\crate_a_src_lib_rs_1_0\rust_out`, `\crate_b_src_lib_rs_1_0\rust_out`

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 agoClean up rustdoc tests by removing unnecessary features
Guillaume Gomez [Wed, 25 Nov 2020 13:27:51 +0000 (14:27 +0100)]
Clean up rustdoc tests by removing unnecessary features

3 years agoReword message at the end of the output if not run with a lint tool
flip1995 [Wed, 25 Nov 2020 12:16:36 +0000 (13:16 +0100)]
Reword message at the end of the output if not run with a lint tool

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 agoTrack `ParamEnv`s properly
Joshua Nelson [Sun, 18 Oct 2020 15:27:16 +0000 (11:27 -0400)]
Track `ParamEnv`s properly

This uses the same `with_param_env` pattern that late lints use.
Thanks to all the doctree refactors, this was very easy to add.

3 years agoNormalize `<X as Y>::T` for rustdoc
Joshua Nelson [Fri, 2 Oct 2020 20:21:43 +0000 (16:21 -0400)]
Normalize `<X as Y>::T` for rustdoc

- Only run for `QPath::Resolved` with `Some` self parameter (`<X as Y>::T`)
- Fall back to the previous behavior if the path can't be resolved
- Show what the behavior is if the type can't be normalized
- Run `resolve_vars_if_possible`

  It's not clear whether or not this is necessary. See
  https://github.com/rust-lang/rust/pull/77616 for more context.

- Add a test for cross-crate re-exports
- Use the same code for both `hir::Ty` and `Ty`

3 years agoRefactor clean_qpath into a separate function
Joshua Nelson [Fri, 2 Oct 2020 19:10:49 +0000 (15:10 -0400)]
Refactor clean_qpath into a separate function

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 agoclippy: Remove now obsolete lintlist module
flip1995 [Wed, 7 Oct 2020 14:05:13 +0000 (16:05 +0200)]
clippy: Remove now obsolete lintlist module

Also stop updating the lintlist module in clippy_dev update_lints

3 years agoclippy: Let rustc handle describing lints
flip1995 [Wed, 7 Oct 2020 14:04:22 +0000 (16:04 +0200)]
clippy: Let rustc handle describing lints

3 years agoCleanup message at the end of the lint list output
flip1995 [Wed, 7 Oct 2020 13:41:15 +0000 (15:41 +0200)]
Cleanup message at the end of the lint list output

3 years agoAlways print lints from plugins, if they're available
flip1995 [Wed, 7 Oct 2020 13:35:21 +0000 (15:35 +0200)]
Always print lints from plugins, if they're available

Currently you can get a list of lints and lint groups by running `rustc
-Whelp`. This prints an additional line at the end:
```
Compiler plugins can provide additional lints and lint groups. To see a
listing of these, re-run `rustc -W help` with a crate filename.
```

Clippy is such a "compiler plugin", that provides additional lints.
Running `clippy-driver -Whelp` (`rustc` wrapper) still only prints the
rustc lints with the above message at the end. But when running
`clippy-driver -Whelp main.rs`, where `main.rs` is any rust file, it
also prints Clippy lints. I don't think this is a good approach from a
UX perspective: Why is a random file necessary to print a help message?

This commit changes this behavior: Whenever a compiler callback
registers lints, it is assumed that these lints come from a plugin and
are printed without having to specify a Rust source file.

3 years agoAdd method to get the register_lints function from the compiler
flip1995 [Wed, 7 Oct 2020 13:34:06 +0000 (15:34 +0200)]
Add method to get the register_lints function from the compiler

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.