Commit graph

2363 commits

Author SHA1 Message Date
Aman Arora e2efdd156b Use precise places when lowering Closures in THIR
- Closures now use closure_min_captures to figure out captured paths
- Build upvar_mutbls using closure_min_captures
- Change logic in limit_capture_mutability to differentiate b/w
  capturing parent's local variable or capturing a variable that is
  captured by the parent (in case of nested closure) using PlaceBase.

Co-authored-by: Roxane Fruytier <roxane.fruytier@hotmail.com>
2020-12-09 22:34:15 -05:00
Aman Arora 6a1d0699a4 Use Places for captures in MIR
- Use closure_min_capture maps to capture precise paths
- PlaceBuilder now searches for ancestors in min_capture list
- Add API to `Ty` to allow access to the n-th element in a
  tuple in O(1) time.

Co-authored-by: Roxane Fruytier <roxane.fruytier@hotmail.com>
2020-12-09 22:33:33 -05:00
Aman Arora d9523622ff Move handling UpvarRef to PlaceBuilder
- This allows us to delay figuring out the index of a capture
  in the closure structure when all projections to atleast form
  a capture have been applied to the builder

Co-authored-by: Roxane Fruytier <roxane.fruytier@hotmail.com>
2020-12-06 18:30:23 -05:00
Aman Arora 6e5cca79fc Use min_captures for creating UpvarSusbts::tupled_upvar_tys
- final_upvar_tys now reads types from places instead of using `node_ty`

Co-authored-by: Roxane Fruytier <roxane.fruytier@hotmail.com>
2020-12-06 15:48:20 -05:00
Aman Arora 76c68aa182 Writeback min_capture map to TypeckResults
- Derive TypeFoldable on `hir::place::Place` and associated
  structs, to them to be written into typeck results.

Co-authored-by: Jennifer Wills <wills.jenniferg@gmail.com>
Co-authored-by: Logan Mosier <logmosier@gmail.com>
2020-12-06 15:48:19 -05:00
bors 5bb68c31f8 Auto merge of #79445 - SNCPlay42:struct-tail-recursion-limit, r=oli-obk
check the recursion limit when finding a struct's tail

fixes #79437

This does a `delay_span_bug` (via `ty_error_with_message`) rather than emit a new error message, under the assumption that there will be an error elsewhere (even if the type isn't infinitely recursive, just deeper than the recursion limit, this appears to be the case).
2020-12-05 15:58:06 +00:00
Matthew Jasper 4fef39113a Avoid leaking block expression values 2020-12-04 23:07:46 +00:00
Matthew Jasper 7f3e8551dd Use record_operands_moved more aggresively 2020-12-04 22:22:52 +00:00
Matthew Jasper b766abc88f Simplify unscheduling of drops after moves 2020-12-04 22:19:28 +00:00
SNCPlay42 98fc02d6fa check the recursion limit when finding struct tail 2020-12-04 16:37:23 +00:00
bors 2218520b8a Auto merge of #79680 - Nadrieril:fix-regression-79284, r=jonas-schievink
Fix perf regression caused by #79284

https://github.com/rust-lang/rust/pull/79284 only moved code around but this changed inlining and caused a large perf regression. This fixes it for me, though I'm less confident than usual because the regression was not observable with my usual (i.e. incremental) compilation settings.

r? `@Mark-Simulacrum`
2020-12-04 11:21:35 +00:00
bors e6225434ff Auto merge of #78177 - benjaminp:cleanups, r=jyn514
A few miscellaneous comment fixes and a tiny code clarification.
2020-12-04 07:11:41 +00:00
Benjamin Peterson 504f136c74 Writeback walks the HIR not the AST. 2020-12-03 23:38:36 -06:00
Benjamin Peterson 76ff0f408a The details of higher-rank sub are in the rustc book not a doc module. 2020-12-03 23:38:36 -06:00
Benjamin Peterson 4d8a7c2829 Unnest some .chain calls, so it's clearer what's going on. 2020-12-03 23:37:26 -06:00
Benjamin Peterson cb56b1a7e9 Fix comment that refers to dead enforce_object_limitations function. 2020-12-03 23:37:26 -06:00
bors e9dd18ca74 Auto merge of #79686 - Dylan-DPC:rollup-leama5f, r=Dylan-DPC
Rollup of 11 pull requests

Successful merges:

 - #77686 (Render Markdown in search results)
 - #79541 (Doc keyword lint pass)
 - #79602 (Fix SGX CI)
 - #79611 (Use more std:: instead of core:: in docs for consistency)
 - #79623 (Pass around Symbols instead of Idents in doctree)
 - #79627 (Update cargo)
 - #79631 (disable a ptr equality test on Miri)
 - #79638 (Use `item_name` instead of pretty printing for resolving `Self` on intra-doc links)
 - #79646 (rustc_metadata: Remove some dead code)
 - #79664 (move interpret::MemoryKind::Heap to const eval)
 - #79678 (Fix some clippy lints)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2020-12-04 04:51:49 +00:00
bors 6513f50291 Auto merge of #79109 - richkadel:llvm-coverage-counters-2.0.5, r=tmandry
Coverage tests for remaining TerminatorKinds and async, improve Assert

Tested and validate results for panic unwind, panic abort, assert!()
macro, TerminatorKind::Assert (for example, numeric overflow), and
async/await.

Implemented a previous documented idea to change Assert handling to be
the same as FalseUnwind and Goto, so it doesn't get its own
BasicCoverageBlock anymore. This changed a couple of coverage regions,
but I validated those changes are not any worse than the prior results,
and probably help assure some consistency (even if some people might
disagree with how the code region is consistently computed).

Fixed issue with async/await. AggregateKind::Generator needs to be
handled like AggregateKind::Closure; coverage span for the outer async
function should not "cover" the async body, which is actually executed
in a separate "closure" MIR.
2020-12-04 02:31:11 +00:00
Dylan DPC 5cebbaa6a1
Rollup merge of #79678 - jyn514:THE-PAPERCLIP-COMETH, r=varkor
Fix some clippy lints

Happy to revert these if you think they're less readable, but personally I like them better now (especially the `else { if { ... } }` to `else if { ... }` change).
2020-12-04 03:30:39 +01:00
Dylan DPC a2aa3d6e49
Rollup merge of #79664 - vn-ki:move-memkind-heap, r=oli-obk
move interpret::MemoryKind::Heap to const eval

r? ``@oli-obk``
2020-12-04 03:30:37 +01:00
Dylan DPC 0fbbe94662
Rollup merge of #79646 - petrochenkov:inclean, r=davidtwco
rustc_metadata: Remove some dead code

Follow up to https://github.com/rust-lang/rust/pull/74967
2020-12-04 03:30:36 +01:00
Dylan DPC f4060521a9
Rollup merge of #79541 - GuillaumeGomez:doc-keyword-lint-pass, r=lcnr
Doc keyword lint pass

`x.py test` doesn't seem to work locally for multiple reasons so simpler to just run CI...
2020-12-04 03:30:19 +01:00
Nadrieril 793c40e0bd Inline is_covered_by 2020-12-04 01:45:34 +00:00
Joshua Nelson 0ad3dce83a Fix some clippy lints 2020-12-03 17:08:19 -05:00
bors 5be3f9f10e Auto merge of #79620 - JohnTitor:label-name-sugg, r=davidtwco
Tweak diagnostics on shadowing lifetimes/labels

Fixes #79610

Skip adding a new test assuming we have already sufficient tests.
2020-12-03 18:55:01 +00:00
Rich Kadel d96f351fa3 Addressed feedback from 2020-12-01
Added one more test (two files) showing coverage of generics and unused
functions across crates.

Created and referenced new Issues, as requested.

Added comments.

Added a note about the possible effects of compiler options on LLVM
coverage maps.
2020-12-03 09:50:10 -08:00
Rich Kadel def932ca86 Combination of commits
Fixes multiple issue with counters, with simplification

  Includes a change to the implicit else span in ast_lowering, so coverage
  of the implicit else no longer spans the `then` block.

  Adds coverage for unused closures and async function bodies.

  Fixes: #78542

Adding unreachable regions for known MIR missing from coverage map

Cleaned up PR commits, and removed link-dead-code requirement and tests

  Coverage no longer depends on Issue #76038 (`-C link-dead-code` is
  no longer needed or enforced, so MSVC can use the same tests as
  Linux and MacOS now)

Restrict adding unreachable regions to covered files

  Improved the code that adds coverage for uncalled functions (with MIR
  but not-codegenned) to avoid generating coverage in files not already
  included in the files with covered functions.

Resolved last known issue requiring --emit llvm-ir workaround

  Fixed bugs in how unreachable code spans were added.
2020-12-03 09:50:10 -08:00
Rich Kadel c45ee4bb29 Coverage tests for remaining TerminatorKinds and async, improve Assert
Tested and validate results for panic unwind, panic abort, assert!()
macro, TerminatorKind::Assert (for example, numeric overflow), and
async/await.

Implemented a previous documented idea to change Assert handling to be
the same as FalseUnwind and Goto, so it doesn't get its own
BasicCoverageBlock anymore. This changed a couple of coverage regions,
but I validated those changes are not any worse than the prior results,
and probably help assure some consistency (even if some people might
disagree with how the code region is consistently computed).

Fixed issue with async/await. AggregateKind::Generator needs to be
handled like AggregateKind::Closure; coverage span for the outer async
function should not "cover" the async body, which is actually executed
in a separate "closure" MIR.
2020-12-03 09:50:09 -08:00
Vishnunarayan K I ff0ebd27a4 move interpret::MemoryKind::Heap to const eval 2020-12-03 21:42:11 +05:30
Guillaume Gomez 50eb3a89f8 Only deny doc_keyword in std and set it as "allow" by default 2020-12-03 16:48:17 +01:00
bors 1f95c91c88 Auto merge of #79613 - GuillaumeGomez:doc-keyword-checks, r=oli-obk
Add checks for #[doc(keyword = "...")] attribute

The goal here is to extend check for `#[doc(keyword = "...")]`.

cc `@jyn514`
r? `@oli-obk`
2020-12-03 14:34:20 +00:00
bors 220352781c Auto merge of #79586 - jyn514:crate-name, r=davidtwco
Fix `unknown-crate` when using -Z self-profile with rustdoc

... by removing a duplicate `crate_name` field in `interface::Config`,
making it clear that rustdoc should be passing it to `config::Options` instead.

Unblocks https://github.com/rust-lang/rustc-perf/issues/797.
2020-12-03 12:14:29 +00:00
bors d015f0d921 Auto merge of #79594 - vn-ki:const-eval-intrinsic, r=oli-obk
add const_allocate intrinsic

r? `@oli-obk`

fixes #75390
2020-12-03 09:44:07 +00:00
Guillaume Gomez 56c64f871e Add lint pass for doc keyword 2020-12-03 10:42:15 +01:00
Vishnunarayan K I bc6eb6fa5d move intrinsic to CTFE, add FIXME 2020-12-03 12:21:47 +05:30
bors c7cff213e9 Auto merge of #79533 - sasurau4:feature/add-long-explanation-E0546, r=GuillaumeGomez
Add long explanation of E0546

Helps with #61137
2020-12-03 05:18:36 +00:00
bors b4def89d76 Auto merge of #79637 - spastorino:revert-trait-inheritance-self, r=Mark-Simulacrum
Revert "Auto merge of #79209

r? `@nikomatsakis`

This has caused some issues (#79560) so better to revert and try to come up with a proper fix without rush.
2020-12-03 02:00:46 +00:00
Vadim Petrochenkov 908bf5a310 rustc_metadata: Remove some dead code 2020-12-03 00:05:24 +03:00
bors f4db9ffb22 Auto merge of #79364 - nico-abram:unstable-or-pat-suggestion, r=matthewjasper
Fixes #79357 unstable or-pat suggestions

Fixes #79357
2020-12-02 20:33:55 +00:00
Santiago Pastorino 37354ebc97
Revert "Auto merge of #79209 - spastorino:trait-inheritance-self, r=nikomatsakis"
This reverts commit 349b3b324d, reversing
changes made to b776d1c3e3.
2020-12-02 12:19:38 -03:00
bors a094ff9590 Auto merge of #79547 - erikdesjardins:byval, r=nagisa
Pass arguments up to 2*usize by value

In https://github.com/rust-lang/rust/pull/77434#discussion_r498719533, `@eddyb` said:

> I wonder if it makes sense to limit this to returns [...]

Let's do a perf run and find out.

It seems the `extern "C"` ABI will pass arguments up to 2*usize in registers: https://godbolt.org/z/n8E6zc. (modified from https://github.com/rust-lang/rust/issues/26494#issuecomment-619506345)

r? `@nagisa`
2020-12-02 15:17:32 +00:00
Vishnunarayan K I 899a59e7ca rename MemoryKind::Heap to ConstHeap; bless test 2020-12-02 17:45:11 +05:30
Vishnunarayan K I 1b7fe09025 add comment and bless some tests 2020-12-02 17:19:11 +05:30
Guillaume Gomez 8a35b93c4d Add rustc_lexer as dependency to rustc_passes 2020-12-02 10:42:50 +01:00
Guillaume Gomez dc10ccfe89 Add checks for #[doc(keyword = "...")] and move them into rustc_passes 2020-12-02 10:42:50 +01:00
Guillaume Gomez 5a228263b8 Clean up doc attributes check before adding more 2020-12-02 10:42:50 +01:00
bors d37afad0cc Auto merge of #79606 - ThePuzzlemaker:issue-79458-fix, r=scottmcm
Do not show negative polarity trait implementations in diagnostic messages for similar implementations

This fixes #79458.

Previously, this code:
```rust
#[derive(Clone)]
struct Foo<'a, T> {
    x: &'a mut T,
}
```
would have suggested that `<&mut T as Clone>` was an implementation that was found. This is due to the fact that the standard library now has `impl<'_, T> !Clone for &'_ mut T`, and explicit negative polarity implementations were not filtered out in diagnostic output when suggesting similar implementations.

This PR fixes this issue by filtering out negative polarity trait implementations in `find_similar_impl_candidates` within `rustc_trait_selection::traits::error_reporting::InferCtxtPrivExt<'tcx>`. It also adds a UI regression test for this issue and fixes UI tests that had incorrectly been modified to expect the invalid output.

r? `@scottmcm`
2020-12-02 07:37:40 +00:00
Yuki Okushi cdcce11504 Tweak diagnostics on shadowing lifetimes/labels 2020-12-02 11:39:42 +09:00
bors eb4860c7e1 Auto merge of #78864 - Mark-Simulacrum:warn-on-forbids, r=pnkfelix
Use true previous lint level when detecting overriden forbids

Previously, cap-lints was ignored when checking the previous forbid level, which
meant that it was a hard error to do so. This is different from the normal
behavior of lints, which are silenced by cap-lints; if the forbid would not take
effect regardless, there is not much point in complaining about the fact that we
are reducing its level.

It might be considered a bug that even `--cap-lints deny` would suffice to
silence the error on overriding forbid, depending on if one cares about failing
the build or precisely forbid being set. But setting cap-lints to deny is quite
odd and not really done in practice, so we don't try to handle it specially.

This also unifies the code paths for nested and same-level scopes. However, the
special case for CLI lint flags is left in place (introduced by #70918) to fix
the regression noted in #70819. That means that CLI flags do not lint on forbid
being overridden by a non-forbid level. It is unclear whether this is a bug or a
desirable feature, but it is certainly inconsistent. CLI flags are a
sufficiently different "type" of place though that this is deemed out of scope
for this commit.

r? `@pnkfelix` perhaps?

cc #77713 -- not marking as "Fixes" because of the lack of proper unused attribute handling in this PR
2020-12-02 02:07:45 +00:00
bors 18aa5ee209 Auto merge of #79614 - GuillaumeGomez:rollup-15usd7e, r=GuillaumeGomez
Rollup of 3 pull requests

Successful merges:

 - #79508 (Warn if `dsymutil` returns an error code)
 - #79509 (Improve attribute message error spans)
 - #79600 (std::io: Use sendfile for UnixStream)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2020-12-01 23:44:25 +00:00