Commit graph

1824 commits

Author SHA1 Message Date
Dylan DPC
abaa78baeb
Rollup merge of #78748 - fanzier:tuple-assignment, r=petrochenkov
Implement destructuring assignment for tuples

This is the first step towards implementing destructuring assignment (RFC: https://github.com/rust-lang/rfcs/pull/2909, tracking issue: #71126). This PR is the first part of #71156, which was split up to allow for easier review.

Quick summary: This change allows destructuring the LHS of an assignment if it's a (possibly nested) tuple.
It is implemented via a desugaring (AST -> HIR lowering) as follows:
```rust
(a,b) = (1,2)
```
... becomes ...
```rust
{
  let (lhs0,lhs1) = (1,2);
  a = lhs0;
  b = lhs1;
}
```

Thanks to `@varkor` who helped with the implementation, particularly around default binding modes.

r? `@petrochenkov`
2020-11-09 01:13:44 +01:00
Dylan DPC
b4589a86cc
Rollup merge of #78674 - tmiasko:inline-substs-for-mir-body, r=oli-obk
inliner: Use substs_for_mir_body

Changes from 68965 extended the kind of instances that are being
inlined. For some of those, the `instance_mir` returns a MIR body that
is already expressed in terms of the types found in substitution array,
and doesn't need further substitution.

Use `substs_for_mir_body` to take that into account.

Resolves #78529.
Resolves #78560.
2020-11-09 01:13:42 +01:00
Dylan DPC
12c5f786ea
Rollup merge of #78345 - jyn514:proper-names, r=varkor
Fix handling of item names for HIR

- Handle variants, fields, macros in `Node::ident()`
- Handle the crate root in `opt_item_name`
- Rewrite `item_name` in terms of `opt_item_name`

I need this for both https://github.com/rust-lang/rust/pull/77820 and https://github.com/rust-lang/rust/pull/78082, so splitting it out into a separate PR so it can land early.
2020-11-09 01:13:35 +01:00
Dylan DPC
b9671ae5f8
Rollup merge of #78114 - jyn514:private, r=oli-obk
Recognize `private_intra_doc_links` as a lint

Previously, trying to allow this would give another error!

```
warning: unknown lint: `private_intra_doc_links`
 --> private.rs:1:10
  |
1 | #![allow(private_intra_doc_links)]
  |          ^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean: `broken_intra_doc_links`
  |
  = note: `#[warn(unknown_lints)]` on by default

warning: public documentation for `DocMe` links to private item `DontDocMe`
 --> private.rs:2:11
  |
2 | /// docs [DontDocMe]
  |           ^^^^^^^^^ this item is private
  |
  = note: `#[warn(private_intra_doc_links)]` on by default
  = note: this link will resolve properly if you pass `--document-private-items`
```

Fixes the issue found in https://github.com/rust-lang/rust/pull/77249#issuecomment-712339227.

r? ````````@Manishearth````````

Does anyone know why this additional step is necessary? It seems weird this has to be declared in 3 different places.
2020-11-09 01:13:31 +01:00
Dylan DPC
d69ee57f97
Rollup merge of #77640 - ethanboxx:int_error_matching_attempt_2, r=KodrAus
Refactor IntErrorKind to avoid "underflow" terminology

This PR is a continuation of #76455

# Changes

- `Overflow` renamed to `PosOverflow` and `Underflow` renamed to `NegOverflow` after discussion in #76455
- Changed some of the parsing code to return `InvalidDigit` rather than `Empty` for strings "+" and "-". https://users.rust-lang.org/t/misleading-error-in-str-parse-for-int-types/49178
- Carry the problem `char` with the `InvalidDigit` variant.
- Necessary changes were made to the compiler as it depends on `int_error_matching`.
- Redid tests to match on specific errors.

r? ```@KodrAus```
2020-11-09 01:13:25 +01:00
bors
1773f60ea5 Auto merge of #78712 - petrochenkov:visitok, r=Aaron1011
rustc_ast: Visit tokens stored in AST nodes in mutable visitor

After #77271 token visiting is enabled only for one visitor in `rustc_expand\src\mbe\transcribe.rs` which applies hygiene marks to tokens produced by declarative macros (`macro_rules` or `macro`), so this change doesn't affect anything else.

When a macro has some interpolated token from an outer macro in its output
```rust
macro inner() {
    $interpolated
}
```
we can use the usual interpretation of interpolated tokens in token-based model - a None-delimited group - to write this macro in an equivalent form
```rust
macro inner() {
    ⟪ a b c d ⟫
}
```

When we are expanding the macro `inner` we need to apply hygiene marks to all tokens produced by it, including the tokens inside the group.

Before this PR we did this by visiting the AST piece inside the interpolated token and applying marks to all spans in it.
I'm not sure this is 100% correct (ideally we should apply the marks to tokens and then re-parse the AST from tokens), but it's a very good approximation at least.
We didn't however apply the marks to actual tokens stored in the nonterminal, so if we used the nonterminal as a token rather than as an AST piece (e.g. passed it to a proc macro), then we got hygiene bugs.
This PR applies the marks to tokens in addition to the AST pieces thus fixing the issue.

r? `@Aaron1011`
2020-11-08 20:00:51 +00:00
bors
b1277d04db Auto merge of #78874 - m-ou-se:rollup-3jp1ijj, r=m-ou-se
Rollup of 19 pull requests

Successful merges:

 - #76097 (Stabilize hint::spin_loop)
 - #76227 (Stabilize `Poll::is_ready` and `is_pending` as const)
 - #78065 (make concurrency helper more pleasant to read)
 - #78570 (Remove FIXME comment in print_type_sizes ui test suite)
 - #78572 (Use SOCK_CLOEXEC and accept4() on more platforms.)
 - #78658 (Add a tool to run `x.py` from any subdirectory)
 - #78706 (Fix run-make tests running when LLVM is disabled)
 - #78728 (Constantify `UnsafeCell::into_inner` and related)
 - #78775 (Bump Rustfmt and RLS)
 - #78788 (Correct unsigned equivalent of isize to be usize)
 - #78811 (Make some std::io functions `const`)
 - #78828 (use single char patterns for split() (clippy::single_char_pattern))
 - #78841 (Small cleanup in `TypeFoldable` derive macro)
 - #78842 (Honor the rustfmt setting in config.toml)
 - #78843 (Less verbose debug logging from inlining integrator)
 - #78852 (Convert a bunch of intra-doc links)
 - #78860 (rustc_resolve: Use `#![feature(format_args_capture)]`)
 - #78861 (typo and formatting)
 - #78865 (Don't fire `CONST_ITEM_MUTATION` lint when borrowing a deref)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2020-11-08 13:49:17 +00:00
Mara Bos
91759b2de5
Rollup merge of #78865 - Aaron1011:fix/const-item-mut-reborrow, r=varkor
Don't fire `CONST_ITEM_MUTATION` lint when borrowing a deref

Fixes #78819

This extends the check for dereferences added in PR #77324
to cover mutable borrows, as well as direct writes. If we're operating
on a dereference of a `const` item, we shouldn't be firing the lint.
2020-11-08 13:36:33 +01:00
Mara Bos
c4e262ee6f
Rollup merge of #78861 - o752d:patch-1, r=jonas-schievink
typo and formatting

fixed a typo and modified some line formatting justification while I'm here :)
2020-11-08 13:36:32 +01:00
Mara Bos
829e88032a
Rollup merge of #78860 - petrochenkov:resolvefmt, r=Mark-Simulacrum
rustc_resolve: Use `#![feature(format_args_capture)]`

This is the best new sugar for quite some time.

(I only changed places that already used named arguments.)
2020-11-08 13:36:30 +01:00
Mara Bos
e5230fdf96
Rollup merge of #78843 - tmiasko:inline-trace, r=wesleywiser
Less verbose debug logging from inlining integrator

The inlining integrator produces relatively verbose and uninteresting
logs.  Move them from a debug log level to a trace level, so that they
can be easily isolated from others.
2020-11-08 13:36:26 +01:00
Mara Bos
2489ff7123
Rollup merge of #78841 - LeSeulArtichaut:foldable-derive, r=lcnr
Small cleanup in `TypeFoldable` derive macro

r? ```@lcnr```
2020-11-08 13:36:23 +01:00
Mara Bos
5cffa8f531
Rollup merge of #78828 - matthiaskrgr:sing_chr, r=lcnr
use single char patterns for split() (clippy::single_char_pattern)
2020-11-08 13:36:21 +01:00
bors
87a0997ef9 Auto merge of #78410 - lcnr:revert75443, r=nikomatsakis
revert #75443, update mir validator

This PR reverts rust-lang#75443 to fix rust-lang#75992 and instead uses rust-lang#75419 to fix rust-lang#75313.

Adapts rust-lang#75419 to correctly deal with unevaluated constants as otherwise some `feature(const_evaluatable_checked)` tests would ICE.

Note that rust-lang#72793 was also fixed by rust-lang#75443, but as that issue only concerns `feature(type_alias_impl_trait)` I deleted that test case for now and would reopen that issue.

rust-lang#75443 may have also allowed some other code to now successfully compile which would make this revert a breaking change after 2 stable versions, but I hope that this is a purely theoretical concern.

See https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/generator.20upvars/near/214617274 for more reasoning about this.

r? `@nikomatsakis` `@eddyb` `@RalfJung`
2020-11-08 11:27:06 +00:00
bors
f2ea2f648e Auto merge of #77729 - petrochenkov:mergetarg, r=Mark-Simulacrum
rustc_target: Move some target options from `Target` to `TargetOptions`

The only reason for `Target` to `TargetOptions` to be separate structures is that options in `TargetOptions` have reasonable defaults and options in `Target` don't.
(Otherwise all the options logically belong to a single `Target` struct.)

This PR moves a number of options with reasonable defaults from `Target` to `TargetOptions`, so they no longer needs to be specified explicitly for majority of the targets.
The move also allows to inherit the options from `rustc_target/src/spec/*_base.rs` files in a nicer way.
I didn't change any specific option values here.

The moved options are `target_c_int_width` (defaults to `"32"`), `target_endian` (defaults to `"little"`), `target_os` (defaults to `"none"`), `target_env` (defaults to `""`), `target_vendor` (defaults to `"unknown"`) and `linker_flavor` (defaults to `LinkerFlavor::Gcc`).

Next steps (in later PRs):
- Find a way to merge `TargetOptions` into `Target`
- If not, always access `TargetOptions` fields through `Deref` making it a part of `Target` at least logically (`session.target.target.options.foo` -> `session.target.target.foo`)
- ~Eliminate `session::config::Config` and use `Target` instead (`session.target.target.foo` -> `session.target.foo`)~ Done in https://github.com/rust-lang/rust/pull/77943.
- Avoid tautologies in option names (`target.target_os` -> `target.os`)
- Resolve _ https://github.com/rust-lang/rust/issues/77730 (rustc_target: The differences between `target_os = "none"` and `target_os = "unknown"`, and `target_vendor = "unknown"` and `target_vendor = ""` are unclear) noticed during implementation of this PR.
2020-11-08 02:21:55 +00:00
Aaron Hill
bd3f3fa32a
Use a semicolon instead of a dash in lint note 2020-11-07 20:39:35 -05:00
Aaron Hill
e4e9bb4a24
Don't fire CONST_ITEM_MUTATION lint when borrowing a deref
Fixes #78819

This extends the check for dereferences added in PR #77324
to cover mutable borrows, as well as direct writes. If we're operating
on a dereference of a `const` item, we shouldn't be firing the lint.
2020-11-07 20:11:53 -05:00
o752d
2550e887b3
typo and formatting
fixed a typo and modified some line formatting justification while I'm here :)
2020-11-07 23:25:10 +00:00
Vadim Petrochenkov
907b87fafa rustc_resolve: Use #![feature(format_args_capture)] 2020-11-08 01:38:11 +03:00
bors
771cc7ffc3 Auto merge of #78784 - Mark-Simulacrum:revert-77421, r=petrochenkov
Revert "Revert "resolve: Avoid "self-confirming" import resolutions in one more case""

Specifically, this reverts commit b20bce8ce5 from #77421 to fix #77586.

The lang team has decided that for the time being we want to avoid the breakage here (perhaps for a future edition; though almost certainly not the upcoming one), though a future PR may want to add a lint around this case (and perhaps others) which are unlikely to be readable code.

r? `@petrochenkov` to confirm this is the right way to fix #77586.
2020-11-07 21:57:02 +00:00
Tomasz Miąsko
425675da42 Less verbose debug logging from inlining integrator
The inlining integrator produces relatively verbose and uninteresting
logs.  Move them from a debug log level to a trace level, so that they
can be easily isolated from others.
2020-11-07 19:56:08 +01:00
LeSeulArtichaut
087a9340d5 Small cleanup in TypeFoldable derive macro 2020-11-07 18:20:42 +01:00
Joshua Nelson
f60fd49632 Remove unused from_hir call 2020-11-07 10:37:18 -05:00
Joshua Nelson
67d0db6b00 Fix handling of item names for HIR
- Handle variants, fields, macros in `Node::ident()`
- Handle the crate root in `opt_item_name`
- Factor out `item_name_from_def_id` to reduce duplication
- Look at HIR before the DefId for `opt_item_name`

  This gives accurate spans, which are not available from serialized
  metadata.

- Don't panic on the crate root in `opt_item_name`
- Add comments
2020-11-07 10:37:12 -05:00
Fabian Zaiser
3a7a997323 Implement destructuring assignment for tuples
Co-authored-by: varkor <github@varkor.com>
2020-11-07 13:17:19 +00:00
Vadim Petrochenkov
c0c0597e09 Update recently added targets 2020-11-07 14:34:44 +03:00
Vadim Petrochenkov
d41fe05d1a rustc_target: Move linker_flavor from Target to TargetOptions 2020-11-07 14:27:48 +03:00
Vadim Petrochenkov
b294cc71a2 rustc_target: Move target_vendor from Target to TargetOptions 2020-11-07 14:27:47 +03:00
Vadim Petrochenkov
d5fd31197f rustc_target: Move target_env from Target to TargetOptions 2020-11-07 14:27:47 +03:00
Vadim Petrochenkov
74ffb9b4a2 rustc_target: Move target_os from Target to TargetOptions 2020-11-07 14:27:47 +03:00
Vadim Petrochenkov
91533cf10e rustc_target: Move target_endian from Target to TargetOptions 2020-11-07 14:27:46 +03:00
Vadim Petrochenkov
ffe65f825b rustc_target: Move target_c_int_width from Target to TargetOptions 2020-11-07 14:27:46 +03:00
Matthias Krüger
020ed653a3 use single char patterns for split() (clippy::single_char_pattern) 2020-11-07 07:27:44 +01:00
Bastian Kauschke
e06785b676 improve fixme 2020-11-06 22:37:16 +01:00
Mark Rousskov
ae4f80b4be Revert "Revert "resolve: Avoid "self-confirming" import resolutions in one more case""
This reverts commit b20bce8ce5.

It retains the test added in that commit as a check-pass test, intended to
prevent future (unintentional) regressions.
2020-11-06 11:22:13 -05:00
Yuki Okushi
af50c796fa
Rollup merge of #78798 - ankushduacodes:fixing-typo, r=jonas-schievink
Fixing Spelling Typos

Fixing #78787
2020-11-07 01:02:30 +09:00
Yuki Okushi
5b16a66faf
Rollup merge of #78795 - est31:node_id_assignment_doc_fix, r=oli-obk
The renumber pass is long gone

Originally, there has been a dedicated pass for renumbering
AST NodeIds to have actual values. This pass had been added by
commit a5ad4c3794.

Then, later, this step was moved to where it resides now,
macro expansion. See commit c86c8d41a2
or PR #36438.

The comment snippet, added by the original commit, has
survived the times without any change, becoming outdated
at removal of the dedicated pass.

Nowadays, grepping for the next_node_id function will show up
multiple places in the compiler that call it, but the main
rewriting that the comment talks about is still done in the
expansion step, inside an innocious looking visit_id function
that's called during macro invocation collection.
2020-11-07 01:02:28 +09:00
Yuki Okushi
09a40af85e
Rollup merge of #78794 - est31:collect_bang, r=oli-obk
rustc_expand: use collect_bang helper instead of manual reimplementation
2020-11-07 01:02:26 +09:00
Yuki Okushi
0a89d7bd7e
Rollup merge of #78771 - tmiasko:inline-consts, r=oli-obk
inliner: Copy unevaluated constants only after successful inlining

Inliner copies the unevaluated constants from the callee body to the
caller at the point where decision to inline is yet to be made. The
constants will be unnecessary if inlining were to fail.

Organize the code moving items from callee to the caller together in one
place to avoid the issue.
2020-11-07 01:02:24 +09:00
Yuki Okushi
55bf7911c3
Rollup merge of #78760 - jyn514:deny-invalid-codeblocks, r=GuillaumeGomez
`deny(invalid_codeblock_attributes)` for rustc_error_codes

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

r? ``@GuillaumeGomez``
2020-11-07 01:02:22 +09:00
Yuki Okushi
7931b2454d
Rollup merge of #78666 - sasurau4:fix/shellcheck-error, r=jyn514
Fix shellcheck error

## Overview

Helps with #77290

This pr fix only errors of shellcheck, the result of `git ls-files '*.sh' | xargs shellcheck --severity=error`.

Fixing error are following.

- https://github.com/koalaman/shellcheck/wiki/SC2148
- https://github.com/koalaman/shellcheck/wiki/SC1008

Disable error following.
- https://github.com/koalaman/shellcheck/wiki/SC2068
2020-11-07 01:02:14 +09:00
Yuki Okushi
91153d5009
Rollup merge of #78167 - Nadrieril:fix-76836_, r=varkor
Fix unreachable sub-branch detection in or-patterns

The previous implementation was too eager to avoid unnecessary "unreachable pattern" warnings. I feel more confident about this implementation than I felt about the previous one.
Fixes https://github.com/rust-lang/rust/issues/76836.

``@rustbot`` modify labels: +A-exhaustiveness-checking
2020-11-07 01:02:05 +09:00
Daiki Ihara
a1af001a55 fix shellcheck error of SC2068 2020-11-06 20:33:12 +09:00
Daiki Ihara
f197da655f fix shellcheck error of SC2148 2020-11-06 20:33:12 +09:00
bors
8532e742fc Auto merge of #78267 - richkadel:llvm-coverage-counters-2.0.3r1, r=tmandry
Working expression optimization, and some improvements to branch-level source coverage

This replaces PR #78040 after reorganizing the original commits (by request) into a more logical sequence of major changes.

Most of the work is in the MIR `transform/coverage/` directory (originally, `transform/instrument_coverage.rs`).

Note this PR includes some significant additional debugging capabilities, to help myself and any future developer working on coverage improvements or issues.

In particular, there's a new Graphviz (.dot file) output for the coverage graph (the `BasicCoverageBlock` control flow graph) that provides ways to get some very good insight into the relationships between the MIR, the coverage graph BCBs, coverage spans, and counters. (There are also some cool debugging options, available via environment variable, to alter how some data in the graph appears.)

And the code for this Graphviz view is actually generic... it can be used by any implementation of the Rust `Graph` traits.

Finally (for now), I also now output information from `llvm-cov` that shows the actual counters and spans it found in the coverage map, and their counts (from the `--debug` flag). I found this to be enormously helpful in debugging some coverage issues, so I kept it in the test results as well for additional context.

`@tmandry` `@wesleywiser`

r? `@tmandry`

Here's an example of the new coverage graph:

* Within each `BasicCoverageBlock` (BCB), you can see each `CoverageSpan` and its contributing statements (MIR `Statement`s and/or `Terminator`s)
* Each `CoverageSpan` has a `Counter` or and `Expression`, and `Expression`s show their Add/Subtract operation with nested operations. (This can be changed to show the Counter and Expression IDs instead, or in addition to, the BCB.)
* The terminators of all MIR `BasicBlock`s in the BCB, including one final `Terminator`
* If an "edge counter" is required (because we need to count an edge between blocks, in some cases) the edge's Counter or Expression is shown next to its label. (Not shown in the example below.) (FYI, Edge Counters are converted into a new MIR `BasicBlock` with `Goto`)

<img width="1116" alt="Screen Shot 2020-10-17 at 12 23 29 AM" src="https://user-images.githubusercontent.com/3827298/96331095-616cb480-100f-11eb-8212-60f2d433e2d8.png">

r? `@tmandry`
FYI: `@wesleywiser`
2020-11-06 06:59:44 +00:00
bors
f92b931045 Auto merge of #77856 - GuillaumeGomez:automatic-links-lint, r=jyn514,ollie27
Add non_autolinks lint

Part of #77501.

r? `@jyn514`
2020-11-06 04:17:41 +00:00
ankushduacodes
0af959d3a2 Fixing Spelling Typos 2020-11-06 09:25:58 +05:30
Rich Kadel
a7d956583c Responded to all feedback as of 2020-10-30 2020-11-05 18:24:18 -08:00
Rich Kadel
1973f84ebb Addressed all feedback to date 2020-11-05 18:24:17 -08:00
Rich Kadel
5545c56e9d Added comments on remapping expression IDs, and URL to spanviews 2020-11-05 18:24:16 -08:00