Commit Graph

1885 Commits

Author SHA1 Message Date
Vadim Petrochenkov
dc004d4809 rustc_target: Rename some target options to avoid tautology
`target.target_endian` -> `target.endian`
`target.target_c_int_width` -> `target.c_int_width`
`target.target_os` -> `target.os`
`target.target_env` -> `target.env`
`target.target_vendor` -> `target.vendor`
`target.target_family` -> `target.os_family`
`target.target_mcount` -> `target.mcount`
2020-11-08 17:29:13 +03:00
Vadim Petrochenkov
bf66988aa1 Collapse all uses of target.options.foo into target.foo
with an eye on merging `TargetOptions` into `Target`.

`TargetOptions` as a separate structure is mostly an implementation detail of `Target` construction, all its fields logically belong to `Target` and available from `Target` through `Deref` impls.
2020-11-08 17:29:13 +03: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
Bastian Kauschke
439171e094 look at assoc ct, check the type of nodes 2020-11-07 12:39:52 +01: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
Bastian Kauschke
103f7a499b fix super_visit_with for Terminator 2020-11-07 11:56:31 +01:00
Matthias Krüger
020ed653a3 use single char patterns for split() (clippy::single_char_pattern) 2020-11-07 07:27:44 +01:00
Tomasz Miąsko
89c3582d59 Assert that a return place is not used for indexing during integration
The inliner integrates call destination place with callee return place
by remapping the local and adding extra projections as necessary.

If a call destination place contains any projections (which is already
possible) and a return place is used in an indexing projection (most
likely doesn't happen yet) the end result would be incorrect.

Add an assertion to ensure that potential issue won't go unnoticed in
the presence of more sophisticated copy propagation scheme.
2020-11-07 00:00:00 +00:00
Tomasz Miąsko
f78f36cdb7 Monomorphize a type argument of size-of operation during codegen
This wasn't necessary until MIR inliner started to consider drop glue as
a candidate for inlining; introducing for the first time a generic use
of size-of operation.

No test at this point since this only happens with a custom inlining
threshold.
2020-11-07 00:00:00 +00:00
Vadim Petrochenkov
922107919d resolve: Collapse macro_rules scope chains on the fly 2020-11-07 02:18:29 +03: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
Rich Kadel
198ba3bd1c Injecting expressions in place of counters where helpful
Implementing the Graph traits for the BasicCoverageBlock
graph.

optimized replacement of counters with expressions plus new BCB graphviz

* Avoid adding coverage to unreachable blocks.
* Special case for Goto at the end of the body. Make it non-reportable.

Improved debugging and formatting options (from env)

Don't automatically add counters to BCBs without CoverageSpans. They may
still get counters but only if there are dependencies from
other BCBs that have spans, I think.

Make CodeRegions optional for Counters too. It is
possible to inject counters (`llvm.instrprof.increment` intrinsic calls
without corresponding code regions in the coverage map. An expression
can still uses these counter values.

Refactored instrument_coverage.rs -> instrument_coverage/mod.rs, and
then broke up the mod into multiple files.

Compiling with coverage, with the expression optimization, works on
the json5format crate and its dependencies.

Refactored debug features from mod.rs to debug.rs
2020-11-05 18:24:15 -08:00
Rich Kadel
3291d28e9a Adds coverage graphviz 2020-11-05 18:24:14 -08:00
Rich Kadel
b5020648fe Implemented CoverageGraph of BasicCoverageBlocks 2020-11-05 18:24:13 -08:00
Rich Kadel
c7ae4c2cb6 Splitting transform/instrument_coverage.rs into transform/coverage/... 2020-11-05 18:24:12 -08:00
Rich Kadel
c7747cc772 Rust coverage before splitting instrument_coverage.rs 2020-11-05 18:24:12 -08:00
est31
dfa5e46fd5 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-06 03:18:01 +01:00
est31
de2940ff63 rustc_expand: use collect_bang helper instead of manual reimplementation 2020-11-06 03:16:56 +01:00
Tomasz Miąsko
8a8ee1a3ed 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.
2020-11-06 00:00:00 +00:00
Nadrieril
107a29a901 Emit lints in the order in which they occur in the file. 2020-11-05 22:17:26 +00:00
Nadrieril
25e272e388 Fix unreachable sub-branch detection
This fixes https://github.com/rust-lang/rust/issues/76836
2020-11-05 22:02:35 +00:00
Vadim Petrochenkov
8def2fc122 rustc_ast: Never clone empty token streams in mutable visitor 2020-11-06 00:59:08 +03:00
Vadim Petrochenkov
1e15606547 rustc_ast: Visit tokens stored in AST nodes in mutable visitor 2020-11-06 00:30:52 +03:00
Guillaume Gomez
99200f760b Fix even more URLs 2020-11-05 20:11:29 +01:00
Joshua Nelson
eed0cebea3 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`
```
2020-11-05 12:55:10 -05:00
Joshua Nelson
9d9292cfda deny(invalid_codeblock_attributes) 2020-11-05 12:13:28 -05:00
bors
b1d9f31e04 Auto merge of #78638 - vn-ki:bindigs-after-at-issue-69971, r=oli-obk
reverse binding order in matches to allow the subbinding of copyable fields in bindings after @

Fixes #69971

### TODO

- [x] Regression tests

r? `@oli-obk`
2020-11-05 13:26:08 +00:00
Mara Bos
8416e13d88
Rollup merge of #78758 - eltociear:patch-1, r=jyn514
Fixed typo in comment

paramter -> parameter
2020-11-05 10:30:04 +01:00
Mara Bos
5ffccc4dfa
Rollup merge of #78742 - vn-ki:fix-issue-78655, r=oli-obk
make intern_const_alloc_recursive return error

fix #78655

r? ``@oli-obk``
2020-11-05 10:29:59 +01:00
Mara Bos
171d29c9c5
Rollup merge of #78739 - hameerabbasi:issue-78654, r=nikomatsakis
Fix ICE on type error in async function

Fixes #78654
2020-11-05 10:29:57 +01:00
Mara Bos
8640360870
Rollup merge of #78733 - matthiaskrgr:cl11ppy, r=jyn514
fix a couple of clippy warnings:

filter_next
manual_strip
redundant_static_lifetimes
single_char_pattern
unnecessary_cast
unused_unit
op_ref
redundant_closure
useless_conversion
2020-11-05 10:29:53 +01:00
Guillaume Gomez
16ed8501ef Fix more URLs 2020-11-05 10:23:39 +01:00
Guillaume Gomez
9d114506c6 Rename lint to non_autolinks 2020-11-05 10:22:08 +01:00
Guillaume Gomez
60caf51b0d Rename automatic_links to url_improvements 2020-11-05 10:22:08 +01:00
Guillaume Gomez
55b4d21e25 Fix automatic_links warnings 2020-11-05 10:22:08 +01:00
Guillaume Gomez
7f839b2ece Improve automatic_links globally 2020-11-05 10:22:08 +01:00
Guillaume Gomez
a54f043733 Add documentation for automatic_links lint 2020-11-05 10:22:08 +01:00
Guillaume Gomez
2980367030 Add new lint for automatic_links improvements 2020-11-05 10:22:08 +01:00
Ikko Ashimine
873ebcb243
Fixed typo in comment
paramter -> parameter
2020-11-05 12:08:32 +09:00
Tomasz Miąsko
6ca43aca1d 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-05 00:00:00 +00:00
bors
0fb00251a5 Auto merge of #78662 - sexxi-goose:add_expr_id_to_delegate, r=nikomatsakis
Provide diagnostic suggestion in ExprUseVisitor Delegate

The [Delegate trait](981346fc07/compiler/rustc_typeck/src/expr_use_visitor.rs (L28-L38)) currently use `PlaceWithHirId` which is composed of Hir `Place` and the
corresponding expression id.

Even though this is an accurate way of expressing how a Place is used,
it can cause confusion during diagnostics.

Eg:

```
let arr : [String; 5];

let [a, ...]     =   arr;
 ^^^ E1 ^^^      =  ^^E2^^
 ```

 Here `arr` is moved because of the binding created E1. However, when we
 point to E1 in diagnostics with the message `arr` was moved, it can be
 confusing.  Rather we would like to report E2 to the user.

 Closes: https://github.com/rust-lang/project-rfc-2229/issues/20

r? `@ghost`
2020-11-04 22:45:15 +00:00
Vishnunarayan K I
bd7229daf0 make intern_const_alloc_recursive return error fix #78655 2020-11-04 23:22:14 +05:30
bors
89631663b7 Auto merge of #78280 - bugadani:span, r=lcnr
Codegen: Query span as late as possible
2020-11-04 17:17:01 +00:00
Hameer Abbasi
a70e0c20c3 Fix issue 78654. 2020-11-04 16:04:32 +00:00
bors
75f1db1102 Auto merge of #77227 - oli-obk:const_val_🌳_prelude, r=RalfJung
Refactorings in preparation for const value trees

cc #72396

This PR changes the `Scalar::Bits { data: u128, size: u8 }` variant to `Scalar::Bits(ScalarInt)` where `ScalarInt` contains the same information, but is `repr(packed)`. The reason for using a packed struct is to allow enum variant packing to keep the original size of `Scalar` instead of adding another word to its size due to padding.
Other than that the PR just gets rid of all the inspection of the internal fields of `Scalar::Bits` which were frankly scary. These fields have invariants that we need to uphold and we can't do that without making the fields private.

r? `@ghost`
2020-11-04 14:26:03 +00:00
Oli Scherer
332750f9eb
Update compiler/rustc_target/src/abi/mod.rs
Co-authored-by: Ralf Jung <post@ralfj.de>
2020-11-04 15:13:06 +01:00
Oli Scherer
5f087f089f
Update compiler/rustc_target/src/abi/mod.rs
Co-authored-by: Ralf Jung <post@ralfj.de>
2020-11-04 15:12:44 +01:00
oli
6e6c8a86e9 u64::try_from will now fail if ScalarInt isn't exactly 64 bits, thus we use to_bits with the correct size 2020-11-04 13:59:11 +00:00
oli
97bfff1f56 Make ScalarInt entirely independent of MIR interpretation 2020-11-04 13:55:29 +00:00
oli
2e53625421 Document an unwrap 2020-11-04 13:44:17 +00:00
oli
abacaf2aef u128 truncation and sign extension are not just interpreter related 2020-11-04 13:41:58 +00:00
Matthias Krüger
bcd2f2df67 fix a couple of clippy warnings:
filter_next
manual_strip
redundant_static_lifetimes
single_char_pattern
unnecessary_cast
unused_unit
op_ref
redundant_closure
useless_conversion
2020-11-04 13:48:50 +01:00
bors
601c13c6fd Auto merge of #78677 - Aaron1011:fix/capture-inner-attrs, r=petrochenkov
Use reparsed `TokenStream` if we captured any inner attributes

Fixes #78675

We now bail out of `prepend_attrs` if we ended up capturing any inner
attributes (which can happen in several places, due to token capturing
for `macro_rules!` arguments.
2020-11-04 11:37:36 +00:00
oli
e67c768110 Move ZST constant to the top of the impl block 2020-11-04 10:15:54 +00:00
Oli Scherer
cb1cf6ae95 Update compiler/rustc_middle/src/ty/consts/int.rs
Co-authored-by: Ralf Jung <post@ralfj.de>
2020-11-04 10:15:40 +00:00
oli
98b70c9ac0 Simplify assert_bits impl 2020-11-04 10:15:09 +00:00
oli
dad0036cb4 Do not raise interp errors from the scalar int module 2020-11-04 10:14:40 +00:00
oli
500af76831 Add helper for getting an int out of a Scalar 2020-11-04 10:13:59 +00:00
oli
f03b18b99b Add is_null helper
This is cheaper than creating a null-`ScalarInt` and comparing
and then just throwing it away.
2020-11-04 10:13:22 +00:00
oli
0347ca7d02 Explain why we forward to self-printing during self-printing 2020-11-04 10:13:09 +00:00