103047 Commits

Author SHA1 Message Date
Tyler Mandry
6a1fe67cac
Rollup merge of #66777 - GuillaumeGomez:tidy-err-codes, r=Mark-Simulacrum
Put back tidy check on error codes

I just realized that the tidy checks were not run anymore on the error code long explanations. This add it back.

cc @Dylan-DPC
r? @Mark-Simulacrum
2019-11-27 15:28:50 -06:00
Tyler Mandry
ae49770918
Rollup merge of #66774 - GuillaumeGomez:cleanup-err-codes-2, r=Dylan-DPC
Clean up error codes

r? @Dylan-DPC
2019-11-27 15:28:48 -06:00
Tyler Mandry
4c51d58de0
Rollup merge of #66769 - fusion-engineering-forks:tau-constant, r=dtolnay
Add core::{f32,f64}::consts::TAU.

### **`τ`**
2019-11-27 15:28:47 -06:00
Tyler Mandry
b05f14cc40
Rollup merge of #66761 - yuyoyuppe:rust_llvm_minor_fix, r=alexcrichton
Use LLVMDisposePassManager instead of raw delete in rustllvm

LLVM has a dedicated API call which wraps the destructor invocation for the PassManager.
Rust invokes it [otherwhere](d63b24ffcc/src/librustc_codegen_llvm/back/write.rs (L446-L447)), but not in the `LLVMRustWriteOutputFile`.

Since `LLVMDisposePassManager` might be extended to perform additional cleanup actions in the future, this change replaces raw destructor invocation with that API call.
2019-11-27 15:28:45 -06:00
Tyler Mandry
a3a8ee0636
Rollup merge of #66744 - chrisduerr:master, r=Dylan-DPC
Fix shrink_to panic documentation

While the potential for panicking is already documented for the
`Vec::shrink_to` method, it is not clearly labeled with the usual
`# Panics` heading.

r? @steveklabnik
2019-11-27 15:28:44 -06:00
Tyler Mandry
61b810511c
Rollup merge of #66722 - matthewjasper:non_exhaustive_borrowck, r=varkor
Handle non_exhaustive in borrow checking

Borrow check can tell whether a pattern is exhaustive or not, make sure that `non_exhaustive` prevents this.
2019-11-27 15:28:42 -06:00
Tyler Mandry
71f20b89ef
Rollup merge of #66718 - VirrageS:use_comma, r=Centril
Refactor `parse_enum_item` to use `parse_delim_comma_seq`

Followup after https://github.com/rust-lang/rust/pull/66641

Some errors got more verbose but I think they make sense with the help message.
2019-11-27 15:28:40 -06:00
Tyler Mandry
ddb616df90
Rollup merge of #66704 - GuillaumeGomez:intra-doc-enum-variant-field, r=kinnison
Intra doc enum variant field

Part of #43466.

Add intra-doc link support for this:

```rust
enum Foo {
    X {
        y: u8, // can be found with Foo::X::y
    }
}
```

r? @kinnison
2019-11-27 15:28:39 -06:00
Tyler Mandry
48b0fd2060
Rollup merge of #66700 - VirrageS:master, r=matthewjasper
Fix pointing at arg for fulfillment errors in function calls

Closes: https://github.com/rust-lang/rust/issues/66258
2019-11-27 15:28:37 -06:00
Tyler Mandry
8a7a9f2e80
Rollup merge of #66534 - immunant:multiple_global_decls, r=eddyb
Allow global references via ForeignItem and Item for the same symbol name during LLVM codegen

Combining CGUs can result in code that references a static variable through both
an Item and a ForeignItem with the same name. We don't care that the global was
already created by a ForeignItem reference when we see the Item reference, as
long as the LLVM types of the ForeignItem and Item match.

Fixes #66464
2019-11-27 15:28:36 -06:00
Tyler Mandry
5139b53836
Rollup merge of #66399 - eddyb:rmeta-table-cleanup, r=Mark-Simulacrum
rustc_metadata: simplify the interactions between Lazy and Table.

These are small post-#59953 cleanups (including undoing some contrivances from that PR).

r? @michaelwoerister
2019-11-27 15:28:34 -06:00
Tyler Mandry
2f1a4b3748
Rollup merge of #66305 - elichai:2019-11-array_ffi, r=eddyb
Add by-value arrays to `improper_ctypes` lint

Hi,
C doesn't have a notion of passing arrays by value, only by reference/pointer.
Rust currently will pass it correctly by reference by it looks very misleading, and can confuse the borrow checker to think a move had occurred.

Fixes #58905 and fixes #24578.

We could also improve the borrow checker here but I think it's kinda a waste of work if we instead just tell the user it's an invalid FFI call.

(My first PR to `rustc` so if I missed some test or formatting guideline please tell me :) )
2019-11-27 15:28:33 -06:00
Tyler Mandry
b92b7052b7
Rollup merge of #66222 - Aaron1011:fix/opaque-closure, r=pnkfelix
Use `eq_opaque_type_and_type` when type-checking closure signatures

This handles the case where a user explicitly annotations a closure
signature with a opaque return type.

Fixes #63263
2019-11-27 15:28:31 -06:00
Tyler Mandry
cb2deb8a9f
Rollup merge of #64325 - cramertj:nested-self-types, r=mikeyhew
Stabilize nested self receivers in 1.41.0

Previously, only `Self`, `&Self`, `&mut Self`, `Arc<Self>`, `Rc<Self>`,
and `Box<Self>` were available as stable method receivers.

This commit stabilizes nested uses of all the above types.
However, nested receivers remain non-object-safe.
2019-11-27 15:28:29 -06:00
Matthew Jasper
5bc15866d7 Move ExprUseVisitor and mem_categorization to rustc_typeck
`MemCategorizationContext` is now private, the remaining types and
traits remain public for Clippy.
2019-11-27 19:47:12 +00:00
Matthew Jasper
c87de41f99 Remove remaining uses of "cmt" 2019-11-27 19:47:12 +00:00
Matthew Jasper
1d53e43744 Simplify mem_categorization
* `Place` is no longer recursive.
* The `cmt` type alias is removed
* `Upvar` places no longer include the dereferences of the environment
  closure or of by reference captures.
* All non-dereference projections are combined to a single variant.
* Various unnecessary types and methods have been removed.
2019-11-27 19:47:12 +00:00
Matthew Jasper
a5b8a3088a Simplify fields of MemCategorizationContext 2019-11-27 19:28:15 +00:00
Matthew Jasper
4195b60323 Rename cmt_ to Place 2019-11-27 19:28:15 +00:00
bors
e87a205c2e Auto merge of #56231 - eddyb:mir-debuginfo, r=oli-obk
rustc: move debug info from LocalDecl and UpvarDecl into a dedicated VarDebugInfo.

This PR introduces a MIR "user variable" debuginfo system, which amounts to mapping a variable name, in some `SourceScope`, to a `Place`, so that:

* each name can appear multiple times (e.g. due to macro hygiene), even in the same scope
* each `Place` can appear multiple times (e.g. in the future from optimizations like NRVO, which collapse multiple MIR locals into one)
* the `Place`s aren't limited to just locals, so they can describe the (right now quite ad-hoc) closure upvars and generator saved state fields, and can be properly transformed by optimizations (e.g. inlining - see `src/test/mir-opt/inline-closure-captures.rs`)

The main motivation for this was that #48300 and further optimizations were blocked on being able to describe complex debuginfo transformations (see https://github.com/rust-lang/rust/pull/48300#discussion_r170020762).

<hr/>

In the textual representation, the "user variable" debuginfo can be found in each scope, and consists of `debug NAME => PLACE;` "declarations", e.g. the MIR for `let x = ...; let y = ...; ...` is now:
```rust
    let _1: T;                           // in scope 0 at ...
    scope 1 {
        debug x => _1;                   // in scope 1 at ...
        let _2: T;                       // in scope 1 at ...
        scope 2 {
            debug y => _2;               // in scope 2 at ...
        }
    }
```
For reference, this is how the information was represented before this PR:
(notably, the scopes in which the variables are visible for debuginfo weren't even shown anywhere, making `scope 2` look pointless, and user variable names were part of MIR locals)
```rust
    let _1: T;                           // "x" in scope 0 at ...
    scope 1 {
        let _2: T;                       // "y" in scope 1 at ...
        scope 2 {
        }
    }
```

cc @nikomatsakis @michaelwoerister
2019-11-27 17:44:49 +00:00
Eduard-Mihai Burtescu
563ed27c01 rustc: move debug info from LocalDecl and UpvarDecl into a dedicated VarDebugInfo. 2019-11-27 19:22:03 +02:00
Guillaume Gomez
5bb70c14be Fix tidy issues 2019-11-27 17:58:54 +01:00
Guillaume Gomez
243fb6f7b2 Put back tidy check on error codes 2019-11-27 17:58:54 +01:00
David Hewitt
a28fbd4608
Correct typo in src/librustc_mir/const_eval.rs
Co-Authored-By: lqd <remy.rakic+github@gmail.com>
2019-11-27 16:44:53 +00:00
Guillaume Gomez
97c427cc5e Use new ErrorKind enum 2019-11-27 14:28:20 +01:00
Eduard-Mihai Burtescu
a0556b3b79 rustc_metadata: use a macro to deduplicate LazyPerDefTables and PerDefTableBuilders. 2019-11-27 15:16:25 +02:00
Eduard-Mihai Burtescu
d7444c122e rustc_metadata: remove Encodable requirements from LazyMeta impls. 2019-11-27 15:16:04 +02:00
Eduard-Mihai Burtescu
ee42979eeb rustc_metadata: use a separate TableBuilder type to build a Table. 2019-11-27 15:15:57 +02:00
Eduard-Mihai Burtescu
67421bdfdf rustc_metadata: replace PerDefTable<T> with Table<DefIndex, T>. 2019-11-27 15:15:57 +02:00
Guillaume Gomez
d05a914b24 Clean up E0071 long explanation 2019-11-27 13:18:00 +01:00
Guillaume Gomez
97a1653f09 Clean up E0077 long explanation 2019-11-27 13:18:00 +01:00
Guillaume Gomez
843869c690 Clean up E0076 long explanation 2019-11-27 13:18:00 +01:00
bors
04e69e4f42 Auto merge of #66691 - dtolnay:fmt0, r=sfackler
Format libcore with rustfmt

I am interested in whether we can begin cautious incremental progress on #66688 and assess along the way whether we can keep the disruption sufficiently small.

This PR applies rustfmt with default settings to files in src/libcore *that are not involved in any currently open PR* to minimize merge conflicts. The list of files involved in open PRs was determined by querying GitHub's GraphQL API  [with this script](https://gist.github.com/dtolnay/aa9c34993dc051a4f344d1b10e4487e8).

With the list of files from the script in `outstanding_files`, the relevant commands were:

```console
$ find src/libcore -name '*.rs' | xargs rustfmt --edition=2018
$ rg libcore outstanding_files | xargs git checkout --
```

Repeating this process several months apart should get us coverage of most of the rest of libcore.
2019-11-27 12:16:52 +00:00
Guillaume Gomez
b91a6fcd5d Replace Iterator::find calls with Iterator::any when better 2019-11-27 13:13:16 +01:00
Guillaume Gomez
4ab8aa3700 Add support for intra-doc link fields of enum variant 2019-11-27 13:13:16 +01:00
Guillaume Gomez
4993807dd9 little intra-doc code cleanup 2019-11-27 13:12:27 +01:00
David Hewitt
539813944d Add memoization for const function evaluations
When a const function is being evaluated, as long as all its
arguments are zero-sized-types (or it has no arguments) then we
can trivially memoize the evaluation result using the existing
query mechanism.
2019-11-27 12:01:04 +00:00
Dylan DPC
ce9b6972c2
Update mod.rs 2019-11-27 10:27:30 +01:00
bors
876a72a251 Auto merge of #66677 - wesleywiser:fix_const_prop_alloc_id_ice, r=oli-obk
[const prop] Fix "alloc id without corresponding allocation" ICE

r? @oli-obk
2019-11-27 08:00:58 +00:00
David Tolnay
166471e7f1
Bless ui tests for libcore reformat 2019-11-26 23:02:11 -08:00
David Tolnay
95e00bfed8
Format libcore with rustfmt
This commit applies rustfmt with default settings to files in
src/libcore *that are not involved in any currently open PR* to minimize
merge conflicts. The list of files involved in open PRs was determined
by querying GitHub's GraphQL API with this script:
https://gist.github.com/dtolnay/aa9c34993dc051a4f344d1b10e4487e8

With the list of files from the script in `outstanding_files`, the
relevant commands were:

    $ find src/libcore -name '*.rs' | xargs rustfmt --edition=2018
    $ rg libcore outstanding_files | xargs git checkout --

Repeating this process several months apart should get us coverage of
most of the rest of libcore.
2019-11-26 23:02:11 -08:00
Joshua Nelson
9617d7c887 Combine similar tests for const match
See https://github.com/rust-lang/rust/pull/66788#issuecomment-558799307
for context.
2019-11-27 00:02:04 -05:00
bors
b5f265eeed Auto merge of #66675 - GuillaumeGomez:support-anchors-intra-doc-links, r=kinnison
Support anchors intra doc links

Fixes #62833
Part of #43466.

cc @ollie27
r? @kinnison
2019-11-27 04:51:31 +00:00
Brian Wignall
16fabd8efd Fix spelling typos 2019-11-26 22:19:54 -05:00
Mark Lodato
9dc3f4b05b Fixes small typo in array docs r? @steveklabnik 2019-11-26 21:04:28 -05:00
bors
809e180a76 Auto merge of #66794 - tmandry:rollup-99qrpr0, r=tmandry
Rollup of 14 pull requests

Successful merges:

 - #66128 (alloc: Add new_zeroed() versions like new_uninit().)
 - #66661 (Add riscv64gc-unknown-linux-gnu target)
 - #66663 (Miri: print leak report even without tracing)
 - #66711 (Add hardware floating point features to aarch64-pc-windows-msvc)
 - #66713 (introduce a target to build the kernel of the unikernel HermitCore)
 - #66717 (tidy: Accommodate rustfmt's preferred layout of stability attributes)
 - #66719 (Store pointer width as u32 on Config)
 - #66720 (Move ErrorReported to rustc_errors)
 - #66737 (Error codes cleanup)
 - #66754 (Various tweaks to diagnostic output)
 - #66763 (Minor edit for documentation-tests.md that increases clarity)
 - #66779 (follow the same function order in the trait)
 - #66786 (Add wildcard test for const_if_match)
 - #66788 (Allow `Unreachable` terminators through `min_const_fn` checks)

Failed merges:

r? @ghost
2019-11-27 00:32:30 +00:00
Tyler Mandry
8547ea32db
Rollup merge of #66788 - ecstatic-morse:const-fn-unreachable, r=Centril
Allow `Unreachable` terminators through `min_const_fn` checks

Resolves #66756.

This allows `Unreachable` terminators through the `min_const_fn` checks if `#![feature(const_if_match)]` is enabled. We could probably just allow them with no feature flag, but it seems okay to be conservative here.

r? @oli-obk
2019-11-26 17:56:25 -06:00
Tyler Mandry
7f166e44ff
Rollup merge of #66786 - jyn514:const-if-match-tests, r=Centril
Add wildcard test for const_if_match

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

Many thanks to @Centril for his help getting me started!
2019-11-26 17:56:23 -06:00
Tyler Mandry
84a2d66374
Rollup merge of #66779 - guanqun:reorder-funcs, r=Dylan-DPC
follow the same function order in the trait

With this change, the function order in both traits and implementation matches.

And this fix removes several warnings in IDE.
2019-11-26 17:56:22 -06:00
Tyler Mandry
339d717776
Rollup merge of #66763 - Parth:patch-2, r=steveklabnik
Minor edit for documentation-tests.md that increases clarity
2019-11-26 17:56:20 -06:00