Commit Graph

107145 Commits

Author SHA1 Message Date
Jonas Schievink
a323ff2c86 Implement RFC 2532 – Associated Type Defaults 2020-02-21 19:41:21 +01:00
bors
187f3d73ab Auto merge of #69342 - flip1995:clippyup, r=Dylan-DPC
Update Clippy from 2855b21 to 8fbb23f

```
Fix ICE in `missing_errors_doc`
Update License
Migrate Clippy to GitHub Actions
redundant_clone: Migrate to new dataflow framework
Move unneeded_field_pattern to pedantic group
Rustup to rust-lang/rust#69325
Rustup to rust-lang/rust#69072
```

Fixes #69338

r? @Manishearth
2020-02-21 13:33:23 +00:00
bors
212aa3ea28 Auto merge of #69330 - Centril:literally-melting-ice, r=eddyb
`lit_to_const`: gracefully bubble up type errors.

Fixes https://github.com/rust-lang/rust/issues/69310 which was injected by https://github.com/rust-lang/rust/pull/68118.

r? @pnkfelix @varkor @eddyb
cc @skinny121
2020-02-21 10:04:22 +00:00
flip1995
df11447ca8
Update Clippy 2020-02-21 10:32:57 +01:00
bors
01a8b5f26e Auto merge of #69290 - wesleywiser:speed_up_ctfe_stress_4, r=RalfJung
Check `RUSTC_CTFE_BACKTRACE` much less by generating fewer errors

Before this change, `get_size_and_align()`  calls `get_fn_alloc()` *a
lot* in CTFE heavy code. This previously returned an `Error` which would
check if `RUSTC_CTFE_BACKTRACE` was set on construction. Doing this
turned out to be a performance hotspot as @nnethercote discovered in
#68792.

This is an alternate take on that PR which resolves the performance
issue by generating *many* fewer errors. Previously, `ctfe-stress-4`
would generate over 5,000,000 errors each of which would check for the
presence of the environment variable. With these changes, that number is
reduced to 30.

r? @RalfJung
2020-02-21 06:43:40 +00:00
bors
2851e59a52 Auto merge of #69281 - nnethercote:inline-some-encoding-decoding-methods, r=Centril
Inline some encoding and decoding methods.

This is a small performance win.

r? @Centril
2020-02-21 03:14:55 +00:00
bors
d3ebd592d0 Auto merge of #69072 - ecstatic-morse:associated-items, r=petrochenkov
O(log n) lookup of associated items by name

Resolves #68957, in which compile time is quadratic in the number of associated items. This PR makes name lookup use binary search instead of a linear scan to improve its asymptotic performance. As a result, the pathological case from that issue now runs in 8 seconds on my local machine, as opposed to many minutes on the current stable.

Currently, method resolution must do a linear scan through all associated items of a type to find one with a certain name. This PR changes the result of the `associated_items` query to a data structure that preserves the definition order of associated items (which is used, e.g., for the layout of trait object vtables) while adding an index of those items sorted by (unhygienic) name. When doing name lookup, we first find all items with the same `Symbol` using binary search, then run hygienic comparison to find the one we are looking for. Ideally, this would be implemented using an insertion-order preserving, hash-based multi-map, but one is not readily available.

Someone who is more familiar with identifier hygiene could probably make this better by auditing the uses of the `AssociatedItems` interface. My goal was to preserve the current behavior exactly, even if it seemed strange (I left at least one FIXME to this effect). For example, some places use comparison with `ident.modern()` and some places use `tcx.hygienic_eq` which requires the `DefId` of the containing `impl`. I don't know whether those approaches are equivalent or which one should be preferred.
2020-02-20 22:44:01 +00:00
Mazdak Farrokhzad
748dd455ad lit_to_const: gracefully bubble up type errors. 2020-02-20 23:43:16 +01:00
bors
2c462a2f77 Auto merge of #69325 - Centril:rollup-vce2ko2, r=Centril
Rollup of 5 pull requests

Successful merges:

 - #68877 (On mismatched argument count point at arguments)
 - #69185 (Unify and improve const-prop lints)
 - #69305 (Tweak binding lifetime suggestion text)
 - #69311 (Clean up E0321 and E0322)
 - #69317 (Fix broken link to the rustc guide)

Failed merges:

r? @ghost
2020-02-20 19:19:54 +00:00
Mazdak Farrokhzad
c1165ce786
Rollup merge of #69317 - LeSeulArtichaut:patch-1, r=Dylan-DPC
Fix broken link to the rustc guide
2020-02-20 20:18:55 +01:00
Mazdak Farrokhzad
362f6501f0
Rollup merge of #69311 - GuillaumeGomez:clean-up-e0321-e0322, r=Dylan-DPC
Clean up E0321 and E0322

r? @Dylan-DPC
2020-02-20 20:18:53 +01:00
Mazdak Farrokhzad
1facbb8578
Rollup merge of #69305 - estebank:consider-lt, r=Dylan-DPC
Tweak binding lifetime suggestion text

We already have a structured suggestion, but the wording made it seem like that wasn't the case.

Fix #65286. r? @varkor
2020-02-20 20:18:52 +01:00
Mazdak Farrokhzad
d237e0fc6c
Rollup merge of #69185 - RalfJung:const-prop-lints, r=oli-obk
Unify and improve const-prop lints

Add a single helper method for all lints emitted by const-prop, and make that lint different from the CTFE `const_err` lint. Also consistently check overflow on *arithmetic*, not on the assertion, to make behavior the same for debug and release builds.

See [this summary comment](https://github.com/rust-lang/rust/pull/69185#issuecomment-587924754) for details and the latest status.

In terms of lint formatting, I went for what seems to be the better style: have a general message above the code, and then a specific message at the span:
```
error: this arithmetic operation will overflow
  --> $DIR/const-err2.rs:21:18
   |
LL |     let a_i128 = -std::i128::MIN;
   |                  ^^^^^^^^^^^^^^^ attempt to negate with overflow
```
We could also just have the specific message above and no text at the span if that is preferred.

I also converted some of the existing tests to use compiletest revisions, so that the same test can check a bunch of different compile flags.

Fixes https://github.com/rust-lang/rust/issues/69020.
Helps with https://github.com/rust-lang/rust/issues/69021: debug/release are now consistent, but the assoc-const test in that issue still fails (there is a FIXME in the PR for this). The reason seems to be that const-prop notices the assoc const in `T::N << 42` and does not even bother calling `const_prop` on that operation.
Has no effect on https://github.com/rust-lang/rust/issues/61821; the duplication there has entirely different reasons.
2020-02-20 20:18:50 +01:00
Mazdak Farrokhzad
b680a5e7c2
Rollup merge of #68877 - estebank:point-at-params, r=petrochenkov
On mismatched argument count point at arguments
2020-02-20 20:18:48 +01:00
LeSeulArtichaut
8e793ed649 Fix broken link to the rustc guide 2020-02-20 17:34:10 +01:00
bors
bfb96048b5 Auto merge of #69145 - matthewjasper:mir-typeck-static-ty, r=nikomatsakis
Fix MIR typeck soundness holes

* Check types of static items
* Always check lifetime bounds of `Copy` impls

r? @nikomatsakis
closes #69114
2020-02-20 15:52:57 +00:00
Guillaume Gomez
90ebf93bdf Greatly improve E0322 explanation 2020-02-20 14:26:56 +01:00
Guillaume Gomez
a6b5f875c1 clean up E0321 explanation 2020-02-20 14:26:43 +01:00
bors
93711d063b Auto merge of #69309 - Dylan-DPC:rollup-gjdqx7l, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #68705 (Add LinkedList::remove())
 - #68945 (Stabilize Once::is_completed)
 - #68978 (Make integer exponentiation methods unstably const)
 - #69266 (Fix race condition when allocating source files in SourceMap)
 - #69287 (Clean up E0317 explanation)

Failed merges:

r? @ghost
2020-02-20 12:06:12 +00:00
Dylan DPC
941ce1a557
Rollup merge of #69287 - GuillaumeGomez:clean-e0317, r=Dylan-DPC
Clean up E0317 explanation

r? @Dylan-DPC
2020-02-20 10:49:14 +01:00
Dylan DPC
5d285dcb22
Rollup merge of #69266 - Zoxc:fix-source-map-race, r=wesleywiser
Fix race condition when allocating source files in SourceMap

This makes allocating address space in the source map an atomic operation. `rustc` does not currently do this in parallel, so this bug can't trigger, but parsing files in parallel could trigger it, and that is something we want to do.

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

r? @wesleywiser
2020-02-20 10:49:13 +01:00
Dylan DPC
d96951f554
Rollup merge of #68978 - ecstatic-morse:const-int-pow, r=oli-obk
Make integer exponentiation methods unstably const

cc #53718

This makes the following inherent methods on integer primitives into unstable `const fn`:
- `pow`
- `checked_pow`
- `wrapping_pow`
- `overflowing_pow`
- `saturating_pow`
- `next_power_of_two`
- `checked_next_power_of_two`
- `wrapping_next_power_of_two`

Only two changes were made to the implementation of these methods. First, I had to switch from the `?` operator, which is not yet implemented in a const context, to a `try_opt` macro. Second, `next_power_of_two` was using `ops::Add::add` (see the first commit) to "get overflow checks", so I switched to `#[rustc_inherit_overflow_checks]`. I'm not quite sure why the attribute wasn't used in the first place.
2020-02-20 10:49:12 +01:00
Dylan DPC
588f00841b
Rollup merge of #68945 - mjbshaw:once_is_completed, r=LukasKalbertodt
Stabilize Once::is_completed

Closes #54890

This function has been around for some time. I haven't seen anyone raise any objections to it. I've personally found it useful myself. It would be nice to finally stabilize it and
2020-02-20 10:49:10 +01:00
Dylan DPC
f7ce5ff19c
Rollup merge of #68705 - BijanT:ll_remove, r=Mark-Simulacrum
Add LinkedList::remove()

LinkedList::remove() removes the element at the specified index and returns it.

I added this because I think having a remove function would be useful to have, and similar functions are in other containers, like Vec and HashMap.

I'm not sure if adding a feature like this requires an RFC or not, so I'm sorry if this PR is premature.
2020-02-20 10:49:08 +01:00
bors
6af388b250 Auto merge of #68847 - ecstatic-morse:const-impl, r=oli-obk
Allow trait methods to be called on concrete types in a const context

This partially implements [RFC 2632](https://github.com/rust-lang/rfcs/pull/2632) by const-checking methods inside an `impl const` block and allowing those methods to be called on concrete types. Calling trait methods on type parameters in a const context is not yet allowed. Implementing this will require much more work. Since we are only concerned with methods on concrete types, we are able to take advantage of the machinery in `Instance::resolve`, which is doing most of the work.

This also propagates `#[rustc_const_unstable]` from parent items to child items, making that attribute behave like `#[stable]` and `#[unstable]` do. This allows trait methods to be marked as unstably const.

cc #67792 #57563
cc @rust-lang/wg-const-eval
r? @oli-obk
2020-02-20 08:41:17 +00:00
bors
de362d88ea Auto merge of #67925 - petertodd:2020-fromstr-infallible, r=LukasKalbertodt
Change FromStr for String to use Infallible directly

Fixes the confusing documentation on `ParseError` by making it irrelevant.

It might be fine to mark it as depreciated right now too - I can't imagine much code uses `ParseError` directly.
2020-02-20 05:18:18 +00:00
Esteban Küber
c816430f99 Tweak binding lifetime suggestion text
We already have a structured suggestion, but the wording made it seem
like that wasn't the case.
Fix #65286. r? @varkor
2020-02-19 18:04:03 -08:00
bors
183e893aaa Auto merge of #69256 - nnethercote:misc-inlining, r=Centril
Miscellaneous inlining improvements

These commits inline some hot functions that aren't currently inlined, for some speed wins.

r? @Centril
2020-02-20 02:00:31 +00:00
Wesley Wiser
9f3bc82fe4 Check RUSTC_CTFE_BACKTRACE much less by generating fewer errors
Before this change, `get_size_and_align()`  calls `get_fn_alloc()` *a
lot* in CTFE heavy code. This previously returned an `Error` which would
check if `RUSTC_CTFE_BACKTRACE` was set on construction. Doing this
turned out to be a performance hotspot as @nnethercote discovered in
#68792.

This is an alternate take on that PR which resolves the performance
issue by generating *many* fewer errors. Previously, `ctfe-stress-4`
would generate over 5,000,000 errors each of which would check for the
presence of the environment variable. With these changes, that number is
reduced to 30.
2020-02-19 18:28:37 -05:00
bors
d5638142b3 Auto merge of #68988 - Zoxc:query-caches, r=eddyb
Add an abstraction for custom query caches

r? @eddyb
2020-02-19 22:29:07 +00:00
Peter Todd
883e69db95
Change FromStr for String to use Infallible directly
Fixes the confusing documentation on `ParseError` by making it
irrelevant.
2020-02-19 16:37:58 -05:00
Dylan MacKenzie
a0212ba40f Construct AssociatedItems from an iterator instead of a Vec 2020-02-19 12:55:59 -08:00
Ralf Jung
88d14bfbc9 fix 32bit-only test 2020-02-19 20:12:01 +01:00
bors
7760cd0fbb Auto merge of #69293 - Dylan-DPC:rollup-imcbvgo, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #68863 (ci: switch macOS builders to 10.15)
 - #69142 (Add shared script for linkchecking books.)
 - #69248 (Don't eliminate frame pointers on thumb targets)
 - #69280 (Remove special case for `simd_shuffle` arg promotion)
 - #69284 (Reword OpenOptions::{create, create_new} doc.)

Failed merges:

r? @ghost
2020-02-19 19:10:58 +00:00
Dylan MacKenzie
186cbfad89 Replace FIXME with explanation 2020-02-19 10:51:40 -08:00
Dylan MacKenzie
7f3ec5e50b Make lookup of associated item by name O(log n) 2020-02-19 10:51:40 -08:00
Dylan MacKenzie
3bb7da2e4f Replace rustc_typeck::Namespace with rustc_hir::def::Namespace 2020-02-19 10:51:40 -08:00
Dylan MacKenzie
ea3c9d27cf Implement an insertion-order preserving, efficient multi-map 2020-02-19 10:51:40 -08:00
Dylan MacKenzie
19801b12c9 Update tests 2020-02-19 09:39:29 -08:00
Dylan DPC
a97f354767
Rollup merge of #69284 - jumbatm:openoptions-create-doc, r=Dylan-DPC
Reword OpenOptions::{create, create_new} doc.

Closes #69254.

Currently, the doc comment for `fs::OpenOptions::create` doesn't mention its behaviour when opening an existing file, and `fs::OpenOptions::create_new`'s doc comment is worded in a way that doesn't make it clear that it actually _fails_ if the file already exists, not overwrite the existing file with a new one.

This PR addresses addresses this by rewording the doc comments to be more explicit.

r? @GuillaumeGomez
2020-02-19 18:12:13 +01:00
Dylan DPC
61d3b6dedb
Rollup merge of #69280 - ecstatic-morse:promote-shuffle-no-special-case, r=petrochenkov
Remove special case for `simd_shuffle` arg promotion

After rust-lang/stdarch#825, these intrinsics are now defined with `#[rustc_args_required_const(2)]`, so the special-case is no longer necessary.
2020-02-19 18:12:11 +01:00
Dylan DPC
c6ad1e2c2a
Rollup merge of #69248 - jonas-schievink:thumb-fp, r=japaric
Don't eliminate frame pointers on thumb targets

This should hopefully fix issues https://github.com/rust-lang/rust/issues/69231 and https://github.com/rust-embedded/cortex-m-rt/issues/139.

~~I couldn't test this locally as the rustc I produced does not create binaries (no idea why).~~ Resolved.
2020-02-19 18:12:10 +01:00
Dylan DPC
1761b39fb0
Rollup merge of #69142 - ehuss:linkcheck-script, r=alexcrichton
Add shared script for linkchecking books.

This adds a script that can be used on each book's CI to ensure they don't break local links.

I've been running something similar on the reference CI.  The intent here is to add this to all the external books' CI scripts. This will help avoid dealing with broken links when updating submodules on rust-lang/rust.
2020-02-19 18:12:09 +01:00
Dylan DPC
2f914bf327
Rollup merge of #68863 - pietroalbini:azure-macos-10.15, r=Mark-Simulacrum
ci: switch macOS builders to 10.15

Azure Pipelines is deprecating the macOS 10.13 image we're currently running, [and they plan to remove them](https://devblogs.microsoft.com/devops/removing-older-images-in-azure-pipelines-hosted-pools/) on March 23, 2020. This PR switches our macOS builders to macOS 10.15.

r? @Mark-Simulacrum
2020-02-19 18:12:07 +01:00
Bijan Tabatabai
c797ce7877 Add LinkedList::remove()
LinkedList::remove() removes the element at the specified index and returns it.

Signed-off-by: Bijan Tabatabai <bijan311@yahoo.com>
2020-02-19 10:29:12 -06:00
bors
7d6b8c414e Auto merge of #69198 - ollie27:rustbuild_rustdoc-js, r=Mark-Simulacrum
Fix running rustdoc-js test suite individually

Without `Compiletest.path` set running `x.py test src/test/rustdoc-js` would run the `rustdoc-js` test suite with everything filtered out.

As this was the only place setting `Compiletest.path` to `None` this removes the `Option` wrapper as well.
2020-02-19 15:55:57 +00:00
Guillaume Gomez
1b342f70df Clean up E0317 explanation 2020-02-19 16:09:28 +01:00
John Kåre Alsaker
d924a251f1 Use a constructor function per dep node instead of an enum and a single function 2020-02-19 16:03:22 +01:00
John Kåre Alsaker
b248767a07 Remove support for dep node structs 2020-02-19 16:03:22 +01:00
John Kåre Alsaker
a8522256c5 Tune inlining 2020-02-19 16:03:21 +01:00