Commit graph

594 commits

Author SHA1 Message Date
Jonas Schievink
1b8c939a8d
Rollup merge of #76973 - lzutao:unstably-const-assume, r=oli-obk
Unstably allow assume intrinsic in const contexts

Not sure much about this usage because there are concerns
about [blocking  optimization][1] and [slowing down LLVM][2] when using `assme` intrinsic
in inline functions.
But since Oli suggested in https://github.com/rust-lang/rust/issues/76960#issuecomment-695772221,
here we are.

[1]: https://github.com/rust-lang/rust/pull/54995#issuecomment-429302709
[2]: https://github.com/rust-lang/rust/issues/49572#issuecomment-589615423
2020-09-25 19:42:29 +02:00
bors
5b9e886403 Auto merge of #73453 - erikdesjardins:tuplayout, r=eddyb
Ignore ZST offsets when deciding whether to use Scalar/ScalarPair layout

This is important because Scalar/ScalarPair layout previously would not be used if any ZST had nonzero offset.
For example, before this change, only `((), u128)` would be laid out like `u128`, not `(u128, ())`.

Fixes #63244
2020-09-25 14:42:20 +00:00
bors
b984ef6797 Auto merge of #77152 - vandenheuvel:update_chalk_further, r=jackh726
Update chalk to 0.28.0
2020-09-25 12:22:05 +00:00
bors
521d8d8a22 Auto merge of #77041 - lcnr:const-eval-perf, r=ecstatic-morse
perf: move cold path of `process_obligations` into a separate function

cc #76575

This probably won't matter too much in the long run once #69218 is merged so we may not want to merge this.

r? `@ecstatic-morse`
2020-09-25 10:14:47 +00:00
bors
9d74efe32e Auto merge of #76844 - simonvandel:fix-76803, r=wesleywiser
Fix #76803 miscompilation

Fixes #76803
Seems like it was an oversight that the discriminant value being set was not compared to the target value from the SwitchInt, as a comment says this is a requirement for the optimization to be sound.

r? `@wesleywiser` since you are probably familiar with the optimization and made #76837 to workaround the bug
2020-09-25 04:17:03 +00:00
bors
5bfeee5fe0 Auto merge of #77172 - jonas-schievink:rollup-a041rou, r=jonas-schievink
Rollup of 15 pull requests

Successful merges:

 - #75438 (Use adaptive SVG favicon for rustdoc like other rust sites)
 - #76304 (Make delegation methods of `std::net::IpAddr` unstably const)
 - #76724 (Allow a unique name to be assigned to dataflow graphviz output)
 - #76978 (Documented From impls in std/sync/mpsc/mod.rs)
 - #77044 (Liballoc bench vec use mem take not replace)
 - #77050 (Typo fix: "satsify" -> "satisfy")
 - #77074 (add array::from_ref)
 - #77078 (Don't use an if guard to check equality with a constant)
 - #77079 (Use `Self` in docs when possible)
 - #77081 (Merge two almost identical match arms)
 - #77121 (Updated html_root_url for compiler crates)
 - #77136 (Suggest `const_mut_refs`, not `const_fn` for mutable references in `const fn`)
 - #77160 (Suggest `const_fn_transmute`, not `const_fn`)
 - #77164 (Remove workaround for deref issue that no longer exists.)
 - #77165 (Followup to #76673)

Failed merges:

r? `@ghost`
2020-09-25 01:56:06 +00:00
Jonas Schievink
8515efb193
Rollup merge of #77165 - simonvandel:do-not-fire-on-drop-and-replace, r=oli-obk
Followup to #76673

Resolves https://github.com/rust-lang/rust/pull/76673#discussion_r494426303
r? @tmiasko
2020-09-25 02:29:52 +02:00
Jonas Schievink
b8d158b0f8
Rollup merge of #77160 - ecstatic-morse:const-fn-transmute-suggestion, r=oli-obk
Suggest `const_fn_transmute`, not `const_fn`

More fallout from #76850 in the vein of #77134. The fix is the same. I looked through the structured errors file and didn't see any more of this kind of diagnostics bug.

r? @oli-obk
2020-09-25 02:29:49 +02:00
Jonas Schievink
473ae229f0
Rollup merge of #77136 - ecstatic-morse:issue-77134, r=oli-obk
Suggest `const_mut_refs`, not `const_fn` for mutable references in `const fn`

Resolves #77134.

Prior to #76850, most uses of `&mut` in `const fn` ~~required~~ involved two feature gates, `const_mut_refs` and `const_fn`. The first allowed all mutable borrows of locals. The second allowed only locals, arguments and return values whose types contained `&mut`. I switched the second check to the `const_mut_refs` gate. However, I forgot update the error message with the new suggestion.

Alternatively, we could revert to having two different feature gates for this. OP's code never borrows anything mutably, so it didn't need `const_mut_refs` in the past, only `const_fn`. I'd prefer to keep everything under a single gate, however.

r? @oli-obk
2020-09-25 02:29:47 +02:00
Jonas Schievink
6f3da3d53f
Rollup merge of #77121 - duckymirror:html-root-url, r=jyn514
Updated html_root_url for compiler crates

Closes #77103

r? @jyn514
2020-09-25 02:29:45 +02:00
Jonas Schievink
b8ab6eb217
Rollup merge of #77081 - LingMan:patch-1, r=jonas-schievink
Merge two almost identical match arms
2020-09-25 02:29:44 +02:00
Jonas Schievink
28e0bc997e
Rollup merge of #77078 - LingMan:patch-2, r=jonas-schievink
Don't use an if guard to check equality with a constant

Match on it directly instead
2020-09-25 02:29:40 +02:00
Jonas Schievink
d766c239bd
Rollup merge of #76724 - ecstatic-morse:dataflow-pass-names, r=lcnr
Allow a unique name to be assigned to dataflow graphviz output

Previously, if the same analysis were invoked multiple times in a single compilation session, the graphviz output for later runs would overwrite that of previous runs. Allow callers to add a unique identifier to each run so this can be avoided.
2020-09-25 02:29:31 +02:00
bors
9b5c98f640 Auto merge of #77014 - tmiasko:arena, r=Mark-Simulacrum
DroplessArena: Allocate objects from the end of memory chunk

Allocating from the end of memory chunk simplifies the alignment code
and reduces the number of checked arithmetic operations.
2020-09-24 23:51:45 +00:00
Bastian Kauschke
06d2325a50 perf: split progress_obligations with inline(never) 2020-09-24 22:13:41 +02:00
Dylan MacKenzie
ebf024bba8 Suggest const_fn_transmute instead of const_fn 2020-09-24 12:07:41 -07:00
Simon Vandel Sillesen
7dec440340 Resolve https://github.com/rust-lang/rust/pull/76673#discussion_r494426303 2020-09-24 21:02:53 +02:00
Bram van den Heuvel
51c781f613 Upgrade chalk to 0.28.0 2020-09-24 20:54:33 +02:00
bors
e599b53e67 Auto merge of #76918 - ishitatsuyuki:match-fastpath, r=oli-obk
Add fast path for match checking

This adds a fast path that would reduce the complexity to linear on matches consisting of only variant patterns (i.e. enum matches). (Also see: #7462) Unfortunately, I was too lazy to add a similar fast path for constants (mostly for integer matches), ideally that could be added another day.

TBH, I'm not confident with the performance claims due to the fact that enums tends to be small and FxHashMap could add a lot of overhead.

r? `@Mark-Simulacrum`

needs perf
2020-09-24 17:22:56 +00:00
Bram van den Heuvel
5f67571e34 Update chalk to 0.27.0 2020-09-24 19:10:01 +02:00
Bram van den Heuvel
61b2a6f5e5 Update chalk to 0.26.0 2020-09-24 19:10:01 +02:00
Bram van den Heuvel
ed784023e5 Update chalk to 0.25.0 2020-09-24 19:10:01 +02:00
Bram van den Heuvel
cb660c6ab5 Update chalk to 0.24.0 2020-09-24 19:10:01 +02:00
Bram van den Heuvel
52eeff6fbe Update chalk to 0.23.0 2020-09-24 19:10:00 +02:00
Bram van den Heuvel
b832a97a51 Update chalk to 0.22.0 2020-09-24 19:10:00 +02:00
bors
87d262acb5 Auto merge of #77006 - oli-obk:🐌_const_queries, r=Mark-Simulacrum
Cache `eval_to_allocation_raw` on disk

https://github.com/rust-lang/rust/pull/74949#issuecomment-695833161 regressed the performance on these queries, this PR gets the perf back.
2020-09-24 15:12:17 +00:00
Oliver Scherer
40629ef827 Always cache const eval queries 2020-09-24 17:09:09 +02:00
bors
893fadd11a Auto merge of #76820 - jyn514:query-comments, r=davidtwco
Preserve doc-comments when generating queries

Closes https://github.com/rust-lang/rust/issues/76812
2020-09-24 13:01:46 +00:00
bors
3a4da87f58 Auto merge of #77049 - lcnr:const-eval-function-signature, r=oli-obk
const_evaluatable_checked: extend predicate collection

We now walk the hir instead of using `ty` so that we get better spans here, While I am still not completely sure if that's
what we want in the end, it does seem a lot closer to the final goal than the previous version.

We also look into type aliases (and use a `TypeVisitor` here), about which I am not completely sure, but we will see how well this works.

We also look into fn decls, so the following should work now.
```rust
fn test<T>() -> [u8; std::mem::size_of::<T>()] {
    [0; std::mem::size_of::<T>()]
}
```
Additionally, we visit the optional trait and self type of impls.

r? `@oli-obk`
2020-09-24 10:29:14 +00:00
bors
86b4172305 Auto merge of #77028 - andjo403:mini, r=matthewjasper
Move MiniSet to data_structures

remove the need for T to be copy from MiniSet as was done for MiniMap

MiniMap and MiniSet was added by https://github.com/rust-lang/rust/pull/72412

think that this can be used in https://github.com/rust-lang/rust/pull/68828
2020-09-24 08:14:30 +00:00
Bastian Kauschke
3f9015b22d visit impl self ty + trait 2020-09-24 09:04:26 +02:00
Bastian Kauschke
b8402d6a6e assign the correct DefId in nominal_obligations 2020-09-24 09:04:23 +02:00
Bastian Kauschke
f8d3f401df walk hir to get const evaluatable predicates 2020-09-24 09:03:50 +02:00
Bastian Kauschke
ac1d0d8b28 fmt, use IndexSet directly instead of UniquePredicates 2020-09-24 09:03:14 +02:00
Bastian Kauschke
e1f408e6c8 const_evaluatable_checked: collect predicates from fn_sig 2020-09-24 09:03:07 +02:00
bors
5562bb6d74 Auto merge of #76748 - tmiasko:no-op-jumps, r=matthewjasper
Fix underflow when calculating the number of no-op jumps folded

When removing unwinds to no-op blocks and folding jumps to no-op blocks,
remove the unwind target first. Otherwise we cannot determine if target
has been already folded or not.

Previous implementation incorrectly assumed that all resume targets had
been folded already, occasionally resulting in an underflow:

```
remove_noop_landing_pads: removed 18446744073709551613 jumps and 3 landing pads
```
2020-09-24 05:57:06 +00:00
Dylan MacKenzie
a320ef751b Suggest const_mut_refs for mutable references in const fn 2020-09-23 21:04:07 -07:00
bors
c35177582b Auto merge of #77102 - Dylan-DPC:rollup-2jfrg3u, r=Dylan-DPC
Rollup of 9 pull requests

Successful merges:

 - #76898 (Record `tcx.def_span` instead of `item.span` in crate metadata)
 - #76939 (emit errors during AbstractConst building)
 - #76965 (Add cfg(target_has_atomic_equal_alignment) and use it for Atomic::from_mut.)
 - #76993 (Changing the alloc() to accept &self instead of &mut self)
 - #76994 (fix small typo in docs and comments)
 - #77017 (Add missing examples on Vec iter types)
 - #77042 (Improve documentation for ToSocketAddrs)
 - #77047 (Miri: more informative deallocation error messages)
 - #77055 (Add #[track_caller] to more panicking Cell functions)

Failed merges:

r? `@ghost`
2020-09-23 22:34:44 +00:00
bors
8b4085359a Auto merge of #76673 - simonvandel:remove-unneeded-drops, r=oli-obk
MIR pass to remove unneeded drops on types not needing drop

This is heavily dependent on MIR inlining running to actually see the drop statement.

Do we want to special case replacing a call to std::mem::drop with a goto aswell?
2020-09-23 20:13:47 +00:00
Erik Hofmayer
764967a7e5 tidy 2020-09-23 22:08:30 +02:00
Erik Hofmayer
138a2e5eaa /nightly/nightly-rustc 2020-09-23 21:51:56 +02:00
Erik Hofmayer
dd66ea2d3d Updated html_root_url for compiler crates 2020-09-23 21:14:43 +02:00
Dylan DPC
f8dec3d054
Rollup merge of #77047 - RalfJung:miri-dealloc, r=oli-obk
Miri: more informative deallocation error messages

Make sure we show the affected AllocId.

r? @oli-obk
2020-09-23 14:54:13 +02:00
Dylan DPC
bcdbe79f0c
Rollup merge of #76994 - yuk1ty:fix-small-typo, r=estebank
fix small typo in docs and comments

Fixed `the the` to `the`, as far as I found.
2020-09-23 14:54:07 +02:00
Dylan DPC
eaaf5d7e38
Rollup merge of #76965 - fusion-engineering-forks:fix-atomic-from-mut, r=Amanieu
Add cfg(target_has_atomic_equal_alignment) and use it for Atomic::from_mut.

Fixes some platform-specific problems with #74532 by using the actual alignment of the types instead of hardcoding a few `target_arch`s.

r? @RalfJung
2020-09-23 14:54:04 +02:00
Dylan DPC
98e5ee7df0
Rollup merge of #76939 - lcnr:const-evaluatable-cont, r=oli-obk
emit errors during AbstractConst building

There changes are currently still untested, so I don't expect this to pass CI 😆

It seems to me like this is the direction we want to go in, though we didn't have too much of a discussion about this.

r? @oli-obk
2020-09-23 14:54:02 +02:00
Dylan DPC
a22eb31668
Rollup merge of #76898 - Aaron1011:fix/item-def-span, r=oli-obk
Record `tcx.def_span` instead of `item.span` in crate metadata

This was missed in PR #75465. As a result, a few places have been using
the full body span of functions, instead of just the header span.
2020-09-23 14:54:00 +02:00
bors
feca2c229e Auto merge of #76659 - simonvandel:76432, r=oli-obk
SimplifyComparisonIntegral: fix miscompilation

Fixes #76432
Only insert StorageDeads if we actually removed one.
Fixes an issue where we added StorageDead to a place with no StorageLive

r? `@oli-obk`
2020-09-23 08:23:00 +00:00
Andreas Jonson
6586c37bec Move MiniSet to data_structures
remove the need for T to be copy from MiniSet as was done for MiniMap
2020-09-23 08:09:16 +02:00
bors
f6d59207ad Auto merge of #76850 - ecstatic-morse:const-checking-refactor, r=oli-obk
Remove `qualify_min_const_fn`

~~Blocked on #76807 (the first six commits).~~

With this PR, all checks in `qualify_min_const_fn` are replicated in `check_consts`, and the former is no longer invoked. My goal was to have as few changes to test output as possible, since making sweeping changes to the code *while* doing big batches of diagnostics updates turned out to be a headache. To this end, there's a few `HACK`s in `check_consts` to achieve parity with `qualify_min_const_fn`.

The new system that replaces `is_min_const_fn` is referred to as "const-stability"  My end goal for the const-stability rules is this:
* Const-stability is only applicable to functions defined in `staged_api` crates.
* All functions not marked `rustc_const_unstable` are considered "const-stable".
    - NB. This is currently not implemented. `#[unstable]` functions are also const-unstable. This causes problems when searching for feature gates.
    - All "const-unstable" functions have an associated feature gate
* const-stable functions can only call other const-stable functions
     - `allow_internal_unstable` can be used to circumvent this.
* All const-stable functions are subject to some additional checks (the ones that were unique to `qualify_min_const_fn`)

The plan is to remove each `HACK` individually in subsequent PRs. That way, changes to error message output can be reviewed in isolation.
2020-09-23 05:40:35 +00:00