]> git.lizzy.rs Git - rust.git/log
rust.git
4 years agoAvoid jumping to Rust code with user %rsp (reentry_panic)
Jethro Beekman [Mon, 10 Feb 2020 20:00:22 +0000 (21:00 +0100)]
Avoid jumping to Rust code with user %rsp (reentry_panic)

4 years agosanitize MXCSR/FPU control registers
Raoul Strackx [Fri, 7 Feb 2020 09:49:47 +0000 (10:49 +0100)]
sanitize MXCSR/FPU control registers

4 years agoCorrected ac_mitigation patch. That patch used the untrusted stack to clear rflags...
Raoul Strackx [Fri, 7 Feb 2020 09:37:53 +0000 (10:37 +0100)]
Corrected ac_mitigation patch. That patch used the untrusted stack to clear rflags during enclave (re-)entry

4 years agoAuto merge of #68835 - CAD97:sound-range-inclusive, r=Mark-Simulacrum
bors [Mon, 10 Feb 2020 15:24:59 +0000 (15:24 +0000)]
Auto merge of #68835 - CAD97:sound-range-inclusive, r=Mark-Simulacrum

Remove problematic specialization from RangeInclusive

Fixes #67194 using the approach [outlined by Mark-Simulacrum](https://github.com/rust-lang/rust/issues/67194#issuecomment-581669549).

> I believe the property we want is that if `PartialEq(&self, &other) == true`, then `self.next() == other.next()`. It is true that this is satisfied by removing the specialization and always doing `is_empty.unwrap_or_default()`; the "wrong" behavior there arises from calling `next()` having an effect on initially empty ranges, as we should be in `is_empty = true` but are not (yet) there. It might be possible to detect that the current state is always empty (i.e., `start > end`) and then not fill in the empty slot. I think this might solve the problem without regressing tests; however, this could have performance implications.

> That approach essentially states that we only use the `is_empty` slot for cases where `start <= end`. That means that `Idx: !Step` and `start > end` would both behave the same, and correctly -- we do not need the boolean if we're not ever going to emit any values from the iterator.

This is implemented here by replacing the `is_empty: Option<bool>` slot with an `exhausted: bool` slot. This flag is

- `false` upon construction,
- `false` when iteration has not yielded an element -- importantly, this means it is always `false` for an iterator empty by construction,
- `false` when iteration has yielded an element and the iterator is not exhausted, and
- only `true` when iteration has been used to exhaust the iterator.

For completeness, this also adds a note to the `Debug` representation to note when the range is exhausted.

4 years agoAuto merge of #69012 - Dylan-DPC:rollup-13qn0fq, r=Dylan-DPC
bors [Mon, 10 Feb 2020 10:47:39 +0000 (10:47 +0000)]
Auto merge of #69012 - Dylan-DPC:rollup-13qn0fq, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #68694 (Reduce the number of `RefCell`s in `InferCtxt`.)
 - #68966 (Improve performance of coherence checks)
 - #68976 (Make `num::NonZeroX::new` an unstable `const fn`)
 - #68992 (Correctly parse `mut a @ b`)
 - #69005 (Small graphviz improvements for the new dataflow framework)
 - #69006 (parser: Keep current and previous tokens precisely)

Failed merges:

r? @ghost

4 years agoRollup merge of #69006 - petrochenkov:prevspan2, r=Centril
Dylan DPC [Mon, 10 Feb 2020 00:54:23 +0000 (01:54 +0100)]
Rollup merge of #69006 - petrochenkov:prevspan2, r=Centril

parser: Keep current and previous tokens precisely

...including their unnormalized forms.
Add more documentation for them.

Hopefully, this will help to eliminate footguns like https://github.com/rust-lang/rust/pull/68728#discussion_r373787486.

I'll try to address the FIXMEs in separate PRs during the next week.

r? @Centril

4 years agoRollup merge of #69005 - ecstatic-morse:unified-dataflow-graphviz, r=wesleywiser
Dylan DPC [Mon, 10 Feb 2020 00:54:21 +0000 (01:54 +0100)]
Rollup merge of #69005 - ecstatic-morse:unified-dataflow-graphviz, r=wesleywiser

Small graphviz improvements for the new dataflow framework

Split out from #68241. This prints the correct effect diff for each line (the before-effect and the after-effect) and makes marginal improvements to the graphviz output for the new dataflow framework including using monospaced font and better line breaking. This will only be useful when #68241 is merged and the graphviz output changes from this:

![image](https://user-images.githubusercontent.com/29463364/74107776-5e3c3300-4b28-11ea-9d33-4862228b5e87.png)

to this:

![image](https://user-images.githubusercontent.com/29463364/74107751-20d7a580-4b28-11ea-99ca-24f749386601.png)

r? @wesleywiser

4 years agoRollup merge of #68992 - matthewjasper:imm-binding-after-at, r=Centril
Dylan DPC [Mon, 10 Feb 2020 00:54:20 +0000 (01:54 +0100)]
Rollup merge of #68992 - matthewjasper:imm-binding-after-at, r=Centril

Correctly parse `mut a @ b`

r? @Centril

Closes #67861
Closes #67926

4 years agoRollup merge of #68976 - ecstatic-morse:const-non-zero, r=dtolnay
Dylan DPC [Mon, 10 Feb 2020 00:54:18 +0000 (01:54 +0100)]
Rollup merge of #68976 - ecstatic-morse:const-non-zero, r=dtolnay

Make `num::NonZeroX::new` an unstable `const fn`

cc #53718

These require `#[feature(const_if_match)]`, meaning they must remain unstable for the time being.

4 years agoRollup merge of #68966 - jonas-schievink:coherence-perf, r=varkor
Dylan DPC [Mon, 10 Feb 2020 00:54:17 +0000 (01:54 +0100)]
Rollup merge of #68966 - jonas-schievink:coherence-perf, r=varkor

Improve performance of coherence checks

The biggest perf improvement in here is expected to come from the removal of the remaining #43355 warning code since that effectively runs the expensive parts of coherence *twice*, which can even be visualized by obtaining a flamegraph:

![image](https://user-images.githubusercontent.com/5047365/74091959-e1f41200-4a8b-11ea-969d-2849d3f86c63.png)

4 years agoRollup merge of #68694 - nnethercote:reduce-RefCells-in-InferCtxt, r=varkor
Dylan DPC [Mon, 10 Feb 2020 00:54:15 +0000 (01:54 +0100)]
Rollup merge of #68694 - nnethercote:reduce-RefCells-in-InferCtxt, r=varkor

Reduce the number of `RefCell`s in `InferCtxt`.

`InferCtxt` contains six structures within `RefCell`s. Every time we
create and dispose of (commit or rollback) a snapshot we have to
`borrow_mut` each one of them.

This commit moves the six structures under a single `RefCell`, which
gives significant speed-ups by reducing the number of `borrow_mut`
calls. To avoid runtime errors I had to reduce the lifetimes of dynamic
borrows in a couple of places.

r? @varkor

4 years agoRemove vestigial #43355-compat code
Jonas Schievink [Sat, 8 Feb 2020 18:14:50 +0000 (19:14 +0100)]
Remove vestigial #43355-compat code

This was previously a future-compat warning that has since been turned into
hard error, but without actually removing all the code.

Avoids a call to `traits::overlapping_impls`, which is expensive.

4 years agoDefer error span calculation until needed
Jonas Schievink [Fri, 7 Feb 2020 23:45:03 +0000 (00:45 +0100)]
Defer error span calculation until needed

This was showing up in profiles. Also deduplicates the code to get just
the impl header span.

4 years agoAdd desc to `specialization_graph_of` query
Jonas Schievink [Fri, 7 Feb 2020 23:27:24 +0000 (00:27 +0100)]
Add desc to `specialization_graph_of` query

4 years agoReduce queries/map lookups done by coherence
Jonas Schievink [Fri, 7 Feb 2020 23:27:07 +0000 (00:27 +0100)]
Reduce queries/map lookups done by coherence

This has negligible perf impact, but it does improve the code a bit.

* Only query the specialization graph of any trait once instead of once per
  impl
* Loop over impls only once, precomputing impl DefId and TraitRef

4 years agoAuto merge of #67665 - Patryk27:master, r=zackmdavis
bors [Sun, 9 Feb 2020 22:13:05 +0000 (22:13 +0000)]
Auto merge of #67665 - Patryk27:master, r=zackmdavis

Improve reporting errors and suggestions for trait bounds

Fix #66802

- When printing errors for unsized function parameter, properly point at the parameter instead of function's body.
- Improve `consider further restricting this bound` (and related) messages by separating human-oriented hints from the machine-oriented ones.

4 years agoReduce the number of `RefCell`s in `InferCtxt`.
Nicholas Nethercote [Thu, 30 Jan 2020 21:45:57 +0000 (08:45 +1100)]
Reduce the number of `RefCell`s in `InferCtxt`.

`InferCtxt` contains six structures within `RefCell`s. Every time we
create and dispose of (commit or rollback) a snapshot we have to
`borrow_mut` each one of them.

This commit moves the six structures under a single `RefCell`, which
gives significant speed-ups by reducing the number of `borrow_mut`
calls. To avoid runtime errors I had to reduce the lifetimes of dynamic
borrows in a couple of places.

4 years agoparser: Keep current and previous tokens precisely
Vadim Petrochenkov [Sun, 9 Feb 2020 14:54:38 +0000 (17:54 +0300)]
parser: Keep current and previous tokens precisely

including their unnormalized forms.
Add more documentation for them.

4 years agoAuto merge of #69004 - jonas-schievink:rollup-z2ymler, r=jonas-schievink
bors [Sun, 9 Feb 2020 18:44:39 +0000 (18:44 +0000)]
Auto merge of #69004 - jonas-schievink:rollup-z2ymler, r=jonas-schievink

Rollup of 5 pull requests

Successful merges:

 - #68738 (Derive Clone + Eq for std::string::FromUtf8Error)
 - #68742 (implement AsMut<str> for String)
 - #68881 (rustc_codegen_llvm: always set AlwaysPreserve on all debuginfo variables)
 - #68911 (Speed up the inherent impl overlap check)
 - #68913 (Pretty-print generic params and where clauses on associated types)

Failed merges:

r? @ghost

4 years agoUse nicer alignment when printing state vectors
Dylan MacKenzie [Tue, 21 Jan 2020 21:37:59 +0000 (13:37 -0800)]
Use nicer alignment when printing state vectors

4 years agoDon't break first line
Dylan MacKenzie [Tue, 21 Jan 2020 21:37:02 +0000 (13:37 -0800)]
Don't break first line

4 years agoRemove unnecessary allows
Dylan MacKenzie [Tue, 21 Jan 2020 21:36:34 +0000 (13:36 -0800)]
Remove unnecessary allows

4 years agoAdd option to `dot::render` for monospace font
Dylan MacKenzie [Tue, 21 Jan 2020 21:35:17 +0000 (13:35 -0800)]
Add option to `dot::render` for monospace font

4 years agoPrint `after` effect in default graphviz formatter
Dylan MacKenzie [Tue, 21 Jan 2020 02:36:54 +0000 (18:36 -0800)]
Print `after` effect in default graphviz formatter

Now the line for each statement will show the diff resulting from the
combination of `before_statement_effect` and `statement_effect`. It's
still possible to observe each in isolation via
`borrowck_graphviz_format = "two_phase"`.

4 years agoRollup merge of #68913 - Areredify:gat_pretty, r=cramertj
Jonas Schievink [Sun, 9 Feb 2020 17:23:34 +0000 (18:23 +0100)]
Rollup merge of #68913 - Areredify:gat_pretty, r=cramertj

Pretty-print generic params and where clauses on associated types

closes #67509

4 years agoRollup merge of #68911 - jonas-schievink:inherent-overlap, r=petrochenkov
Jonas Schievink [Sun, 9 Feb 2020 17:23:33 +0000 (18:23 +0100)]
Rollup merge of #68911 - jonas-schievink:inherent-overlap, r=petrochenkov

Speed up the inherent impl overlap check

This gives a ~7% improvement in compile times for the stm32f0(x2) crate.

Also addresses @eddyb's comment in https://github.com/rust-lang/rust/pull/68837#discussion_r375701767.

4 years agoRollup merge of #68881 - eddyb:always-preserve-dbg-vars, r=nagisa
Jonas Schievink [Sun, 9 Feb 2020 17:23:31 +0000 (18:23 +0100)]
Rollup merge of #68881 - eddyb:always-preserve-dbg-vars, r=nagisa

rustc_codegen_llvm: always set AlwaysPreserve on all debuginfo variables

Making this depend on the optimization level appears to have been a copy-paste mistake (other LLVM functions called in this module also take a `bool` argument, but there it means something unrelated).
Also see https://github.com/rust-lang/rust/pull/8855#discussion_r374392128.

I don't believe we have any reason to let LLVM omit user variables from DWARF, and we were already setting this to `true` when LLVM *could* optimize them away, so this PR should have no effect anyway.

r? @michaelwoerister or @nagisa cc @hanna-kruppe @nikomatsakis

4 years agoRollup merge of #68742 - tspiteri:string-as-mut, r=sfackler
Jonas Schievink [Sun, 9 Feb 2020 17:23:30 +0000 (18:23 +0100)]
Rollup merge of #68742 - tspiteri:string-as-mut, r=sfackler

implement AsMut<str> for String

Closes #68741.

4 years agoRollup merge of #68738 - kennytm:derive-clone-eq-for-fromutf8error, r=sfackler
Jonas Schievink [Sun, 9 Feb 2020 17:23:28 +0000 (18:23 +0100)]
Rollup merge of #68738 - kennytm:derive-clone-eq-for-fromutf8error, r=sfackler

Derive Clone + Eq for std::string::FromUtf8Error

Implement `Clone` and `Eq` for `std::string::FromUtf8Error`.

Both the inner `Vec<u8>` and `std::str::Utf8Error` are also `Clone + Eq`, so I don't see why we shouldn't derive them on `FromUtf8Error` as well.

(impl are insta-stable, requiring FCP from T-libs.)

4 years agoAuto merge of #68623 - Zoxc:lld, r=Mark-Simulacrum
bors [Sun, 9 Feb 2020 15:24:50 +0000 (15:24 +0000)]
Auto merge of #68623 - Zoxc:lld, r=Mark-Simulacrum

Add an option to use LLD to link the compiler on Windows platforms

Based on https://github.com/rust-lang/rust/pull/68609.

Using LLD is good way to improve compile times on Windows since `link.exe` is quite slow. The time for `x.py build --stage 1 src/libtest` goes from 0:12:00 to 0:08:29. Compile time for `rustc_driver` goes from 226.34s to 18.5s. `rustc_macros` goes from 28.69s to 7.7s. The size of `rustc_driver` is also reduced from 83.3 MB to 78.7 MB.

r? @Mark-Simulacrum

4 years agoMore comments
John Kåre Alsaker [Sun, 9 Feb 2020 13:35:50 +0000 (14:35 +0100)]
More comments

4 years agoAdd some comments
John Kåre Alsaker [Sun, 9 Feb 2020 13:26:13 +0000 (14:26 +0100)]
Add some comments

4 years agoDon't parse `mut a @ b` as `mut a @ mut b`
Matthew Jasper [Sun, 9 Feb 2020 13:19:06 +0000 (13:19 +0000)]
Don't parse `mut a @ b` as `mut a @ mut b`

4 years agoAuto merge of #68975 - Dylan-DPC:rollup-jzab8oh, r=Dylan-DPC
bors [Sun, 9 Feb 2020 10:20:46 +0000 (10:20 +0000)]
Auto merge of #68975 - Dylan-DPC:rollup-jzab8oh, r=Dylan-DPC

Rollup of 7 pull requests

Successful merges:

 - #68718 (Move `rustc_hir::def_id` to `rustc_span::def_id`)
 - #68834 (Fix and test implementation of BTreeMap's first/last_entry, pop_first/last)
 - #68857 (perf: Reduce Vec allocations in normalization by passing &mut Vec)
 - #68918 (Don't use the word "unwrap" to describe "unwrap" methods)
 - #68946 (Mark several functions and methods in core::cmp as #[must_use])
 - #68958 (Clean up E0277 and E0282 explanations)
 - #68960 (codegen: misc cleanups around debuginfo scopes and locations.)

Failed merges:

r? @ghost

4 years agoImprove reporting errors and suggestions for trait bounds
Patryk Wychowaniec [Thu, 26 Dec 2019 12:43:33 +0000 (13:43 +0100)]
Improve reporting errors and suggestions for trait bounds

4 years agoAuto merge of #68689 - estebank:where-clause-sugg-missing-fn, r=varkor
bors [Sun, 9 Feb 2020 07:11:56 +0000 (07:11 +0000)]
Auto merge of #68689 - estebank:where-clause-sugg-missing-fn, r=varkor

When suggesting associated fn with type parameters, include in the structured suggestion

Address #50734.

```
error[E0046]: not all trait items implemented, missing: `foo`, `bar`, `baz`
  --> file.rs:14:1
   |
14 | impl TraitA<()> for S {
   | ^^^^^^^^^^^^^^^^^^^^^ missing `foo`, `bar`, `baz` in implementation
   |
   = help: implement the missing item: `fn foo<T>(_: T) -> Self where T: TraitB, TraitB::Item = A { unimplemented!() }`
   = help: implement the missing item: `fn bar<T>(_: T) -> Self { unimplemented!() }`
   = help: implement the missing item: `fn baz<T>(_: T) -> Self where T: TraitB, <T as TraitB>::Item: std::marker::Copy { unimplemented!() }`
```

It doesn't work well for associated types with `ty::Predicate::Projection`s as we need to resugar `T: Trait, Trait::Assoc = K` → `T: Trait<Assoc = K>`.

4 years agoreview comment
Esteban Küber [Fri, 31 Jan 2020 19:35:37 +0000 (11:35 -0800)]
review comment

4 years agoAuto merge of #68376 - Centril:move-ref-patterns, r=matthewjasper
bors [Sun, 9 Feb 2020 04:01:28 +0000 (04:01 +0000)]
Auto merge of #68376 - Centril:move-ref-patterns, r=matthewjasper

Initial implementation of `#![feature(move_ref_pattern)]`

Following up on #45600, under the gate `#![feature(move_ref_pattern)]`, `(ref x, mut y)` is allowed subject to restrictions necessary for soundness. The match checking implementation and tests for `#![feature(bindings_after_at)]` is also adjusted as necessary.

Closes #45600.
Tracking issue: #68354.

r? @matthewjasper

4 years agoTest `NonZeroU8::new` in a const context
Dylan MacKenzie [Sun, 9 Feb 2020 00:02:37 +0000 (16:02 -0800)]
Test `NonZeroU8::new` in a const context

4 years agoMake `num::NonZeroX::new` an unstable `const fn`
Dylan MacKenzie [Sun, 9 Feb 2020 00:02:20 +0000 (16:02 -0800)]
Make `num::NonZeroX::new` an unstable `const fn`

4 years agoRollup merge of #68960 - eddyb:llvm-dbg-cleanup, r=nagisa
Dylan DPC [Sat, 8 Feb 2020 23:54:00 +0000 (00:54 +0100)]
Rollup merge of #68960 - eddyb:llvm-dbg-cleanup, r=nagisa

codegen: misc cleanups around debuginfo scopes and locations.

See each commit message. Most of these seem to be leftovers from the transition to MIR codegen.

r? @nagisa cc @bjorn3

4 years agoRollup merge of #68958 - GuillaumeGomez:clean-up-e0277-e0282, r=Dylan-DPC
Dylan DPC [Sat, 8 Feb 2020 23:53:58 +0000 (00:53 +0100)]
Rollup merge of #68958 - GuillaumeGomez:clean-up-e0277-e0282, r=Dylan-DPC

Clean up E0277 and E0282 explanations

r? @Dylan-DPC

4 years agoRollup merge of #68946 - mjbshaw:must_use, r=mjbshaw
Dylan DPC [Sat, 8 Feb 2020 23:53:56 +0000 (00:53 +0100)]
Rollup merge of #68946 - mjbshaw:must_use, r=mjbshaw

Mark several functions and methods in core::cmp as #[must_use]

These functions and methods aren't mutating functions and ignoring the result of them is likely a bug in the user's code.

4 years agoRollup merge of #68918 - brson:unwrapdoc, r=Dylan-DPC
Dylan DPC [Sat, 8 Feb 2020 23:53:55 +0000 (00:53 +0100)]
Rollup merge of #68918 - brson:unwrapdoc, r=Dylan-DPC

Don't use the word "unwrap" to describe "unwrap" methods

It's tautological, and "unwrap" is essentially Rust-specific jargon.

I was teaching a newbie some Rust, and doing the usual hand-waving about error handling using unwrap. They asked what 'unwrap' means. I said look it up in the docs. The docs read (paraphrased) "unwrap unwraps". I was embarrassed.

This changes all the Option/Result functions with unwrapping behavior to use a variation on a single description:

> "Returns the contained `Some/Ok` value [or ...]."

It also renames the closure of `Result::unwrap_or_else` to `default` for consistency with `Option`, and perhaps makes a few other small tweaks.

Previous: https://github.com/rust-lang/rust/pull/68849

4 years agoRollup merge of #68857 - Marwes:allocations, r=matthewjasper
Dylan DPC [Sat, 8 Feb 2020 23:53:53 +0000 (00:53 +0100)]
Rollup merge of #68857 - Marwes:allocations, r=matthewjasper

perf: Reduce Vec allocations in normalization by passing &mut Vec

Complicates the code a bit but allocation/freeing were a few percent of the overall runtime in trait heavy code.

4 years agoRollup merge of #68834 - ssomers:btree_first_last_fix68829, r=KodrAus
Dylan DPC [Sat, 8 Feb 2020 23:53:52 +0000 (00:53 +0100)]
Rollup merge of #68834 - ssomers:btree_first_last_fix68829, r=KodrAus

Fix and test implementation of BTreeMap's first/last_entry, pop_first/last

Properly implement and test `first_entry` & `last_entry` to fix problem report #68829

4 years agoRollup merge of #68718 - Aaron1011:move-def-hir-span, r=petrochenkov
Dylan DPC [Sat, 8 Feb 2020 23:53:50 +0000 (00:53 +0100)]
Rollup merge of #68718 - Aaron1011:move-def-hir-span, r=petrochenkov

Move `rustc_hir::def_id` to `rustc_span::def_id`

This will allow `HygieneData` to refer to `DefId` and `DefIndex`, which
will enable proper serialization of Span hygiene information.

This also reduces the number of things imported from `rustc_hir`, which
might make it easier to remove dependencies on it.

4 years agoDisable failing codegen test
CAD97 [Wed, 5 Feb 2020 20:51:27 +0000 (15:51 -0500)]
Disable failing codegen test

4 years agoRemove problematic specialization from RangeInclusive
CAD97 [Tue, 4 Feb 2020 22:54:16 +0000 (17:54 -0500)]
Remove problematic specialization from RangeInclusive

4 years agoMove librustc_hir/def_id.rs to librustc_span/def_id.rs
Aaron Hill [Sat, 8 Feb 2020 20:06:31 +0000 (15:06 -0500)]
Move librustc_hir/def_id.rs to librustc_span/def_id.rs

For noww, librustc_hir re-exports the `def_id` module from
librustc_span, so the rest of rustc can continue to reference
rustc_hir::def_id

4 years agoAuto merge of #68802 - eddyb:debuginfo-there-can-only-be-one-arg, r=nagisa
bors [Sat, 8 Feb 2020 21:28:05 +0000 (21:28 +0000)]
Auto merge of #68802 - eddyb:debuginfo-there-can-only-be-one-arg, r=nagisa

rustc_codegen_ssa: don't treat inlined variables as debuginfo arguments.

Fixes #67586 by limiting `ArgumentVariable` special-casing to `VarDebugInfo` entries that are in `OUTERMOST_SOURCE_SCOPE`, i.e. the function's own argument scope.
That excludes `VarDebugInfo` from inlined callees, which can also point to the caller's argument locals.

This is a snippet from the optimized MIR (including inlining) of the testcase:
```rust
fn  foo(_1: usize) -> usize {
    debug bar => _1;                     // in scope 0 at ./example.rs:2:12: 2:15
    let mut _0: usize;                   // return place in scope 0 at ./example.rs:2:27: 2:32
    scope 1 {
        debug x => _1;                   // in scope 1 at /rustc/9ed29b6ff6aa2e048b09c27af8f62ee3040bdb37/src/libcore/convert/mod.rs:106:26: 106:27
    }
```
`scope 1` is from inlining the `identity` call, and `debug x => _1;` comes from the body of `core::convert::identity`, so they are now ignored for the purposes of determining the `ArgumentVariable` debuginfo associated to `_1`.

4 years agoReduce Vec allocations in normalization by passing &mut Vec
Markus Westerlind [Wed, 8 Jan 2020 21:06:25 +0000 (22:06 +0100)]
Reduce Vec allocations in normalization by passing &mut Vec

4 years agoMark several functions and methods in core::cmp as #[must_use]
Michael Bradshaw [Sat, 8 Feb 2020 06:13:36 +0000 (22:13 -0800)]
Mark several functions and methods in core::cmp as #[must_use]

4 years agoAuto merge of #68452 - msizanoen1:riscv-abi, r=nagisa,eddyb
bors [Sat, 8 Feb 2020 18:10:48 +0000 (18:10 +0000)]
Auto merge of #68452 - msizanoen1:riscv-abi, r=nagisa,eddyb

Implement proper C ABI lowering for RISC-V

This is necessary for full RISC-V psABI compliance when passing argument across C FFI boundary.

cc @lenary

4 years agorustc_codegen_ssa: remove unnecessary source_locations_enabled.
Eduard-Mihai Burtescu [Sat, 8 Feb 2020 16:27:49 +0000 (18:27 +0200)]
rustc_codegen_ssa: remove unnecessary source_locations_enabled.

4 years agorustc_codegen_llvm: remove InternalDebugLocation and simplify dbg_var_addr.
Eduard-Mihai Burtescu [Sat, 8 Feb 2020 16:07:44 +0000 (18:07 +0200)]
rustc_codegen_llvm: remove InternalDebugLocation and simplify dbg_var_addr.

4 years agorustc_codegen_llvm: remove unnecessary special-casing of root scopes' children.
Eduard-Mihai Burtescu [Sat, 8 Feb 2020 15:58:00 +0000 (17:58 +0200)]
rustc_codegen_llvm: remove unnecessary special-casing of root scopes' children.

4 years agoClean up E0277 and E0282 explanations
Guillaume Gomez [Sat, 8 Feb 2020 14:47:29 +0000 (15:47 +0100)]
Clean up E0277 and E0282 explanations

4 years agoAdd missing import
Jonas Schievink [Sat, 8 Feb 2020 13:44:32 +0000 (14:44 +0100)]
Add missing import

4 years agoMake `provided_trait_methods` use `impl Iterator`
Jonas Schievink [Fri, 7 Feb 2020 20:33:23 +0000 (21:33 +0100)]
Make `provided_trait_methods` use `impl Iterator`

4 years agoAdd a fast path to inherent impl overlap check
Jonas Schievink [Thu, 6 Feb 2020 23:52:35 +0000 (00:52 +0100)]
Add a fast path to inherent impl overlap check

Quickly skip impls that do not define any items with the same name

4 years agoUse `associated_items` query in impl overlap check
Jonas Schievink [Thu, 6 Feb 2020 22:50:08 +0000 (23:50 +0100)]
Use `associated_items` query in impl overlap check

This reduces the number of `associated_item` queries done here.

4 years agoMake `associated_items` query return a slice
Jonas Schievink [Thu, 6 Feb 2020 22:21:44 +0000 (23:21 +0100)]
Make `associated_items` query return a slice

4 years agoAuto merge of #68443 - eddyb:abi-compat-enum, r=nagisa
bors [Sat, 8 Feb 2020 13:02:21 +0000 (13:02 +0000)]
Auto merge of #68443 - eddyb:abi-compat-enum, r=nagisa

rustc_target: treat enum variants like union members, in call ABIs.

Fixes #68190, by handling non-C-like `enum`s as-if they were an `union` of `struct`s, in call ABIs.
Tests were provided by @sw17ch, from theirs and @bitwalker's original examples.

cc @nagisa @rkruppe

4 years agotest: use `all: $(call NATIVE_STATICLIB,test)` to build a C lib.
Eduard-Mihai Burtescu [Sat, 8 Feb 2020 11:40:50 +0000 (13:40 +0200)]
test: use `all: $(call NATIVE_STATICLIB,test)` to build a C lib.

4 years agotest: address comments and pacify the merciless tidy.
Eduard-Mihai Burtescu [Sat, 8 Feb 2020 04:50:41 +0000 (06:50 +0200)]
test: address comments and pacify the merciless tidy.

4 years agorustc_target: treat enum variants like union members, in call ABIs.
Eduard-Mihai Burtescu [Wed, 22 Jan 2020 00:52:54 +0000 (02:52 +0200)]
rustc_target: treat enum variants like union members, in call ABIs.

4 years agorustc_target: switch homogeneous_aggregate to returning Result.
Eduard-Mihai Burtescu [Wed, 22 Jan 2020 00:52:14 +0000 (02:52 +0200)]
rustc_target: switch homogeneous_aggregate to returning Result.

4 years agoAdd non-C-like enumeration tests on Rust->C calls to the abi-sysv64-arg-passing test.
John VanEnk [Wed, 22 Jan 2020 21:07:03 +0000 (13:07 -0800)]
Add non-C-like enumeration tests on Rust->C calls to the abi-sysv64-arg-passing test.

4 years agoTwo test cases where Rust calls C using enums by value
John VanEnk [Wed, 22 Jan 2020 06:26:13 +0000 (22:26 -0800)]
Two test cases where Rust calls C using enums by value

One calls into C functions passing non-c-like enumerations by
value. The other calls into C expecting non-C-like enumerations as
returns.

These test cases are based on the tests provided by @bitwalker on
issue #68190. The original tests were provided at:
https://github.com/bitwalker/rust_non_c_like_enums_issue/tree/2688d5c672bd4e289085fcdf1c6110e99e7e8ab1

4 years agoAdd similar examples that work to each test.
John VanEnk [Sat, 11 Jan 2020 01:59:18 +0000 (17:59 -0800)]
Add similar examples that work to each test.

4 years agoAdd a test that demonstrates an incorrect return value when calling into rust with...
John VanEnk [Sat, 11 Jan 2020 01:42:30 +0000 (17:42 -0800)]
Add a test that demonstrates an incorrect return value when calling into rust with non-c-like-enums.

4 years agoAdd a test that demonstrates a segfault when calling into rust with non-c-like-enum.
John VanEnk [Sat, 11 Jan 2020 01:16:04 +0000 (17:16 -0800)]
Add a test that demonstrates a segfault when calling into rust with non-c-like-enum.

4 years agoAuto merge of #68358 - matthewjasper:spec-fix, r=nikomatsakis
bors [Sat, 8 Feb 2020 03:46:56 +0000 (03:46 +0000)]
Auto merge of #68358 - matthewjasper:spec-fix, r=nikomatsakis

Remove some unsound specializations

This removes the unsound and exploitable specializations in the standard library

* The `PartialEq` and `Hash` implementations for  `RangeInclusive` are changed to avoid specialization.
* The `PartialOrd` specialization for slices now specializes on a limited set of concrete types.
* Added some tests for the soundness problems.

4 years agoAuto merge of #65232 - nikomatsakis:lazy-norm-anon-const-push-2, r=matthewjasper
bors [Fri, 7 Feb 2020 23:08:52 +0000 (23:08 +0000)]
Auto merge of #65232 - nikomatsakis:lazy-norm-anon-const-push-2, r=matthewjasper

replace the leak check with universes, take 2

This PR is an attempt to revive the "universe-based region check", which is an important step towards lazy normalization. Unlike before, we also modify the definition of `'empty` so that it is indexed by a universe. This sidesteps some of the surprising effects we saw before -- at the core, we no longer think that `exists<'a> { forall<'b> { 'b: 'a } }` is solveable. The new region lattice looks like this:

```
static ----------+-----...------+       (greatest)
|                |              |
early-bound and  |              |
free regions     |              |
|                |              |
scope regions    |              |
|                |              |
empty(root)   placeholder(U1)   |
|            /                  |
|           /         placeholder(Un)
empty(U1) --         /
|                   /
...                /
|                 /
empty(Un) --------                      (smallest)
```
This PR has three effects:

* It changes a fair number of error messages, I think for the better.
* It fixes a number of bugs. The old algorithm was too conservative and caused us to reject legal subtypings.
* It also causes two regressions (things that used to compile, but now do not).
    * `coherence-subtyping.rs` gets an additional error. This is expected.
    * `issue-57639.rs` regresses as before, for the reasons covered in #57639.

Both of the regressions stem from the same underlying property: without the leak check, the instantaneous "subtype" check is not able to tell whether higher-ranked subtyping will succeed or not. In both cases, we might be able to fix the problem by doing a 'leak-check like change' at some later point (e.g., as part of coherence).

This is a draft PR because:

* I didn't finish ripping out the leak-check completely.
* We might want to consider a crater run before landing this.
* We might want some kind of design meeting to cover the overall strategy.
* I just remembered I never finished 100% integrating this into the canonicalization code.
* I should also review what happens in NLL region checking -- it probably still has a notion of bottom (empty set).

r? @matthewjasper

4 years agoAuto merge of #68933 - Dylan-DPC:rollup-akz13kj, r=Dylan-DPC
bors [Fri, 7 Feb 2020 17:47:11 +0000 (17:47 +0000)]
Auto merge of #68933 - Dylan-DPC:rollup-akz13kj, r=Dylan-DPC

Rollup of 7 pull requests

Successful merges:

 - #68164 (Selectively disable sanitizer instrumentation)
 - #68413 (Add GitHub issue templates)
 - #68889 (Move the `hir().krate()` method to a query and remove the `Krate` dep node)
 - #68909 (Respect --nocapture in panic=abort test mode)
 - #68910 (Add myself to .mailmap)
 - #68919 (Remove HashStable impl for ast::Lifetime)
 - #68928 (clean up E0276 explanation)

Failed merges:

r? @ghost

4 years agoRollup merge of #68928 - GuillaumeGomez:cleanup-e0276, r=Dylan-DPC
Dylan DPC [Fri, 7 Feb 2020 16:00:27 +0000 (17:00 +0100)]
Rollup merge of #68928 - GuillaumeGomez:cleanup-e0276, r=Dylan-DPC

clean up E0276 explanation

r? @Dylan-DPC

4 years agoRollup merge of #68919 - Zoxc:ast-lifetime, r=nikomatsakis
Dylan DPC [Fri, 7 Feb 2020 16:00:25 +0000 (17:00 +0100)]
Rollup merge of #68919 - Zoxc:ast-lifetime, r=nikomatsakis

Remove HashStable impl for ast::Lifetime

4 years agoRollup merge of #68910 - hanna-kruppe:master, r=Mark-Simulacrum
Dylan DPC [Fri, 7 Feb 2020 16:00:23 +0000 (17:00 +0100)]
Rollup merge of #68910 - hanna-kruppe:master, r=Mark-Simulacrum

Add myself to .mailmap

4 years agoRollup merge of #68909 - tmandry:panic-abort-nocapture, r=alexcrichton
Dylan DPC [Fri, 7 Feb 2020 16:00:21 +0000 (17:00 +0100)]
Rollup merge of #68909 - tmandry:panic-abort-nocapture, r=alexcrichton

Respect --nocapture in panic=abort test mode

r? @alexcrichton

4 years agoRollup merge of #68889 - Zoxc:hir-krate, r=eddyb
Dylan DPC [Fri, 7 Feb 2020 16:00:19 +0000 (17:00 +0100)]
Rollup merge of #68889 - Zoxc:hir-krate, r=eddyb

Move the `hir().krate()` method to a query and remove the `Krate` dep node

r? @eddyb cc @michaelwoerister

4 years agoRollup merge of #68413 - XAMPPRocky:master, r=Mark-Simulacrum
Dylan DPC [Fri, 7 Feb 2020 16:00:18 +0000 (17:00 +0100)]
Rollup merge of #68413 - XAMPPRocky:master, r=Mark-Simulacrum

Add GitHub issue templates

This PR adds GitHub's issue templates to the repository. Adding templates for two of the most common issues we create on the repository. We could add more specific templates (e.g. ICEs) depending on the response to initial templates. I've included a screenshot of what it looks like, and people can also try out the UI and specific templates, by going to [`XAMPPRocky/rust`](https://github.com/XAMPPRocky/rust/issues/new/choose).

<img width="1115" alt="Screenshot 2020-01-21 at 13 57 46" src="https://user-images.githubusercontent.com/4464295/72807027-c51baa00-3c56-11ea-8a4c-98238489b345.png">

4 years agoRollup merge of #68164 - tmiasko:no-sanitize, r=nikomatsakis
Dylan DPC [Fri, 7 Feb 2020 16:00:16 +0000 (17:00 +0100)]
Rollup merge of #68164 - tmiasko:no-sanitize, r=nikomatsakis

Selectively disable sanitizer instrumentation

Add `no_sanitize` attribute that allows to opt out from sanitizer
instrumentation in an annotated function.

4 years agoadd hir printing
Mikhail Babenko [Fri, 7 Feb 2020 15:27:12 +0000 (18:27 +0300)]
add hir printing

4 years agoadd regression test
Mikhail Babenko [Fri, 7 Feb 2020 02:17:38 +0000 (05:17 +0300)]
add regression test

4 years agoprint generic bounds on associated types
Mikhail Babenko [Fri, 7 Feb 2020 01:03:54 +0000 (04:03 +0300)]
print generic bounds on associated types

4 years agoAuto merge of #68930 - RalfJung:miri, r=RalfJung
bors [Fri, 7 Feb 2020 14:41:17 +0000 (14:41 +0000)]
Auto merge of #68930 - RalfJung:miri, r=RalfJung

update miri

Cc @oli-obk r? @ghost

Fixes https://github.com/rust-lang/rust/issues/68878

4 years agoupdate miri
Ralf Jung [Fri, 7 Feb 2020 14:04:44 +0000 (15:04 +0100)]
update miri

4 years agoclean up E0276 explanation
Guillaume Gomez [Fri, 7 Feb 2020 12:23:33 +0000 (13:23 +0100)]
clean up E0276 explanation

4 years agoRemove HashStable impl for ast::Lifetime
John Kåre Alsaker [Fri, 7 Feb 2020 07:07:06 +0000 (08:07 +0100)]
Remove HashStable impl for ast::Lifetime

4 years agoAuto merge of #68499 - ssomers:btree_search_tidying, r=Mark-Simulacrum
bors [Fri, 7 Feb 2020 06:24:55 +0000 (06:24 +0000)]
Auto merge of #68499 - ssomers:btree_search_tidying, r=Mark-Simulacrum

BtreeMap range_search spruced up

#39457 created a lower level entry point for `range_search` to operate on, but it's really not hard to move it up a level of abstraction, making it somewhat shorter and reusing existing unsafe code (`new_edge` is unsafe although it is currently not tagged as such).

Benchmark added. Comparison says there's no real difference:
```
>cargo benchcmp old3.txt new3.txt --threshold 5
 name                                           old3.txt ns/iter  new3.txt ns/iter  diff ns/iter   diff %  speedup
 btree::map::find_seq_100                       19                21                           2   10.53%   x 0.90
 btree::map::range_excluded_unbounded           3,117             2,838                     -279   -8.95%   x 1.10
 btree::map::range_included_unbounded           1,768             1,871                      103    5.83%   x 0.94
 btree::set::intersection_10k_neg_vs_10k_pos    35                37                           2    5.71%   x 0.95
 btree::set::intersection_staggered_100_vs_10k  2,488             2,314                     -174   -6.99%   x 1.08
 btree::set::is_subset_10k_vs_100               3                 2                           -1  -33.33%   x 1.50
```

r? @Mark-Simulacrum

4 years agoDon't use the word 'unwrap' to describe core unwrapping functions
Brian Anderson [Fri, 7 Feb 2020 05:59:43 +0000 (13:59 +0800)]
Don't use the word 'unwrap' to describe core unwrapping functions

It's tautological, and Rust-specific Jargon.

This changes various Option/Result methods to consistently describe unwrapping
behavior using the words "return", "contain", "consume".

It also renames the closure argument of `Return::unwrap_or_else` to `default` to
be consistent with `Option`.

4 years agoLift range_search up one level of abstraction
Stein Somers [Thu, 23 Jan 2020 06:48:09 +0000 (07:48 +0100)]
Lift range_search up one level of abstraction

4 years agoAuto merge of #68907 - Dylan-DPC:rollup-osm5e8o, r=Dylan-DPC
bors [Fri, 7 Feb 2020 00:06:35 +0000 (00:06 +0000)]
Auto merge of #68907 - Dylan-DPC:rollup-osm5e8o, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #67359 (Rename -Zexternal-macro-backtrace to -Zmacro-backtrace and clean up implementation.)
 - #68524 (Generator Resume Arguments)
 - #68791 (implement proper linkchecker hardening)
 - #68886 (Mark fn map_or() as eagerly evaluated.)
 - #68888 (error code examples: replace some more ignore with compile_fail)
 - #68894 (Update E0565 examples)

Failed merges:

r? @ghost

4 years agoCreate benchmarks for BTreeMap::range
Stein Somers [Thu, 23 Jan 2020 20:58:55 +0000 (21:58 +0100)]
Create benchmarks for BTreeMap::range

4 years agoAdd myself to .mailmap
Hanna Kruppe [Thu, 6 Feb 2020 22:45:20 +0000 (23:45 +0100)]
Add myself to .mailmap

4 years agoRespect --nocapture in panic=abort test mode
Tyler Mandry [Thu, 6 Feb 2020 22:43:53 +0000 (14:43 -0800)]
Respect --nocapture in panic=abort test mode

4 years agoRollup merge of #68894 - JohnTitor:update-e0565, r=Dylan-DPC
Dylan DPC [Thu, 6 Feb 2020 21:38:39 +0000 (22:38 +0100)]
Rollup merge of #68894 - JohnTitor:update-e0565, r=Dylan-DPC

Update E0565 examples

Fixes #68892

r? @GuillaumeGomez

4 years agoRollup merge of #68888 - tspiteri:ignore-to-compile_fail, r=petrochenkov
Dylan DPC [Thu, 6 Feb 2020 21:38:37 +0000 (22:38 +0100)]
Rollup merge of #68888 - tspiteri:ignore-to-compile_fail, r=petrochenkov

error code examples: replace some more ignore with compile_fail

Now that #68664 has been merged and `compile_fail` attempts a full build rather than `--emit=metadata`, these errors should be caught by `compile_fail` and do not need to be ignored.

4 years agoRollup merge of #68886 - tom-a-wagner:master, r=Mark-Simulacrum
Dylan DPC [Thu, 6 Feb 2020 21:38:36 +0000 (22:38 +0100)]
Rollup merge of #68886 - tom-a-wagner:master, r=Mark-Simulacrum

Mark fn map_or() as eagerly evaluated.

In the docs for option.rs and result.rs, it is noted for all *_or()
functions that they are eagerly evaluated, except for the map_or()
function.
This commit adds this missing documentation to the two files.

Closes #68866