Commit graph

134001 commits

Author SHA1 Message Date
bors
72da5a9d85 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.
2020-11-26 18:51:45 +00:00
bors
65ecc481fa 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`
2020-11-26 16:31:12 +00:00
bors
0beba93337 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
2020-11-26 14:14:57 +00:00
Joshua Nelson
277bdbc0ed Remove redundant lift_to_tcx
... and fix some fuzzy wording in the debug logging.
2020-11-26 07:59:51 -05:00
Jonas Schievink
89ab56344d
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.
2020-11-26 13:39:20 +01:00
Jonas Schievink
815d96111d
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.
2020-11-26 13:39:18 +01:00
Jonas Schievink
116ba95888
Rollup merge of #79420 - njasm:patch_rustdoc, r=GuillaumeGomez
Fixes a word typo in librustdoc

Fixes a word typo in librustdoc
2020-11-26 13:39:16 +01:00
Jonas Schievink
eb74eb7761
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`
2020-11-26 13:39:15 +01:00
Jonas Schievink
7b723795ef
Rollup merge of #79412 - GuillaumeGomez:cleanup-rustdoc-tests, r=jyn514
Clean up rustdoc tests by removing unnecessary features

r? ``@jyn514``
2020-11-26 13:39:13 +01:00
Jonas Schievink
005a3e5986
Rollup merge of #79402 - bugadani:typos, r=matthewjasper
Fix typos
2020-11-26 13:39:11 +01:00
Jonas Schievink
0ae653a531
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``
2020-11-26 13:39:09 +01:00
Jonas Schievink
85c11de2f2
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.
2020-11-26 13:39:07 +01:00
Jonas Schievink
6fcd589025
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.
2020-11-26 13:39:05 +01:00
Jonas Schievink
9b2117d1f6
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``
2020-11-26 13:39:00 +01:00
bors
aefcf1f342 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.
2020-11-26 11:59:17 +00:00
bors
0d9651648d Auto merge of #79435 - Mark-Simulacrum:fix-powerpc, r=Mark-Simulacrum
Mirror centos vault to S3
2020-11-26 03:04:20 +00:00
Mark Rousskov
457329a77b Mirror centos vault to S3 2020-11-25 22:01:15 -05:00
Aaron Hill
0b64110b10
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.
2020-11-25 18:41:10 -05:00
Rich Kadel
fdbc121620
fix URLs in doc comment
The angle brackets were confusing my IDE and I thought they were unnecessary. I was wrong.
2020-11-25 13:30:33 -08:00
Camelid
c5c70d4017 Fix docs formatting for thir::pattern::_match
A list was being rendered all on one line and there were other
formatting issues as well.
2020-11-25 13:23:06 -08:00
bors
b48cafd9eb 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.
2020-11-25 21:22:46 +00:00
Camelid
46a750e35b Fixup compiler docs
The sublist was being rendered as a code block because it was indented 4
spaces.
2020-11-25 13:15:48 -08:00
Rich Kadel
d334f589c4
Update compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs 2020-11-25 11:41:23 -08:00
Rich Kadel
b1df6c0e63
replace assert with condition and fatal error 2020-11-25 11:38:09 -08:00
Dániel Buga
29e8e72675 Fix typos 2020-11-25 20:18:36 +01:00
Nelson J Morais
f4d99d3aeb fixes a word typo in librustdoc 2020-11-25 19:09:11 +00:00
bors
192c7dbb6d 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.
2020-11-25 18:37:55 +00:00
Rich Kadel
b4668ecb73 Improved version check 2020-11-25 09:45:33 -08:00
Aaron Hill
baefba80b7
Adjust pretty-print compat hack to work with item statements 2020-11-25 11:32:08 -05:00
bors
db79d2f637 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.
2020-11-25 16:22:11 +00:00
Arpad Borsos
1d587d8c4c 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`
2020-11-25 15:40:13 +01:00
bors
36018a4d06 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.
2020-11-25 14:08:47 +00:00
Guillaume Gomez
d61ea56884 Clean up rustdoc tests by removing unnecessary features 2020-11-25 14:27:51 +01:00
flip1995
e54c0600b4
Reword message at the end of the output if not run with a lint tool 2020-11-25 13:16:36 +01:00
bors
20dcbf0df0 Auto merge of #79397 - camelid:polonious-incr-comp, r=jonas-schievink
TRACK '-Z polonius' flag

Fixes #79316.

r? `@jonas-schievink`
2020-11-25 11:54:04 +00:00
bors
773ddbada7 Auto merge of #79388 - tmiasko:naked-def-only, r=lcnr
Validate that `#[naked]` is applied to a function definition
2020-11-25 09:41:15 +00:00
bors
ec039bd075 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)
2020-11-25 07:25:19 +00:00
bors
b387f62d4d 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.
2020-11-25 05:10:53 +00:00
Camelid
c4caf5ad36 TRACK '-Z polonius' flag 2020-11-24 20:08:54 -08:00
Camelid
50c2739bb4 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.
2020-11-24 19:54:41 -08:00
bors
3f7ccb4cf5 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.
2020-11-25 02:49:28 +00:00
Rich Kadel
b5fef37d23
Apply suggestions from code review
Co-authored-by: Wesley Wiser <wwiser@gmail.com>
2020-11-24 18:34:10 -08:00
Camelid
82dc99ba7a Use the name "auto traits" everywhere in the compiler
Goodbye, OIBIT!
2020-11-24 16:25:43 -08:00
Arlie Davis
5481c1bd6d 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.
2020-11-24 16:12:23 -08:00
Tomasz Miąsko
22d3431221 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.
2020-11-25 00:00:00 +00:00
Aaron Hill
9c9f40656d
Invoke attributes on the statement for statement items 2020-11-24 16:38:58 -05:00
bors
1c389ffeff 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`
2020-11-24 20:58:20 +00:00
Rich Kadel
51268d2735 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
2020-11-24 11:50:24 -08:00
Joshua Nelson
6278daac54 Track ParamEnvs 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.
2020-11-24 14:10:18 -05:00
Joshua Nelson
a192e5d9c2 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`
2020-11-24 14:10:18 -05:00