about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2020-09-24Auto merge of #76918 - ishitatsuyuki:match-fastpath, r=oli-obkbors-22/+165
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-24Auto merge of #77006 - oli-obk:🐌_const_queries, r=Mark-Simulacrumbors-5/+3
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-24Always cache const eval queriesOliver Scherer-8/+2
2020-09-24Auto merge of #76820 - jyn514:query-comments, r=davidtwcobors-34/+43
Preserve doc-comments when generating queries Closes https://github.com/rust-lang/rust/issues/76812
2020-09-24Auto merge of #77049 - lcnr:const-eval-function-signature, r=oli-obkbors-75/+122
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-24Auto merge of #77028 - andjo403:mini, r=matthewjasperbors-48/+46
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-24visit impl self ty + traitBastian Kauschke-0/+12
2020-09-24assign the correct `DefId` in `nominal_obligations`Bastian Kauschke-4/+16
2020-09-24walk hir to get const evaluatable predicatesBastian Kauschke-59/+84
2020-09-24fmt, use IndexSet directly instead of UniquePredicatesBastian Kauschke-35/+20
2020-09-24const_evaluatable_checked: collect predicates from fn_sigBastian Kauschke-5/+18
2020-09-24Auto merge of #76748 - tmiasko:no-op-jumps, r=matthewjasperbors-9/+10
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-23Auto merge of #77102 - Dylan-DPC:rollup-2jfrg3u, r=Dylan-DPCbors-99/+168
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-23Auto merge of #76673 - simonvandel:remove-unneeded-drops, r=oli-obkbors-0/+61
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-23Rollup merge of #77047 - RalfJung:miri-dealloc, r=oli-obkDylan DPC-4/+8
Miri: more informative deallocation error messages Make sure we show the affected AllocId. r? @oli-obk
2020-09-23Rollup merge of #76994 - yuk1ty:fix-small-typo, r=estebankDylan DPC-8/+8
fix small typo in docs and comments Fixed `the the` to `the`, as far as I found.
2020-09-23Rollup merge of #76965 - fusion-engineering-forks:fix-atomic-from-mut, r=AmanieuDylan DPC-4/+23
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-23Rollup merge of #76939 - lcnr:const-evaluatable-cont, r=oli-obkDylan DPC-82/+128
emit errors during AbstractConst building There changes are currently still untested, so I don't expect this to pass CI :laughing: 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-23Rollup merge of #76898 - Aaron1011:fix/item-def-span, r=oli-obkDylan DPC-1/+1
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-23Auto merge of #76659 - simonvandel:76432, r=oli-obkbors-21/+22
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-23Move MiniSet to data_structuresAndreas Jonson-48/+46
remove the need for T to be copy from MiniSet as was done for MiniMap
2020-09-23Auto merge of #76850 - ecstatic-morse:const-checking-refactor, r=oli-obkbors-97/+568
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-22Auto merge of #76928 - lcnr:opaque-types-cache, r=tmandrybors-68/+82
cache types during normalization partially fixes #75992 reduces the following test from 14 to 3 seconds locally. cc `@Mark-Simulacrum` would it make sense to add that test to `perf`? ```rust #![recursion_limit="2048"] #![type_length_limit="112457564"] pub async fn h0(v: &String, x: &u64) { println!("{} {}", v, x) } pub async fn h1(v: &String, x: &u64) { h0(v, x).await } pub async fn h2(v: &String, x: &u64) { h1(v, x).await } pub async fn h3(v: &String, x: &u64) { h2(v, x).await } pub async fn h4(v: &String, x: &u64) { h3(v, x).await } pub async fn h5(v: &String, x: &u64) { h4(v, x).await } pub async fn h6(v: &String, x: &u64) { h5(v, x).await } pub async fn h7(v: &String, x: &u64) { h6(v, x).await } pub async fn h8(v: &String, x: &u64) { h7(v, x).await } pub async fn h9(v: &String, x: &u64) { h8(v, x).await } pub async fn h10(v: &String, x: &u64) { h9(v, x).await } pub async fn h11(v: &String, x: &u64) { h10(v, x).await } pub async fn h12(v: &String, x: &u64) { h11(v, x).await } pub async fn h13(v: &String, x: &u64) { h12(v, x).await } pub async fn h14(v: &String, x: &u64) { h13(v, x).await } pub async fn h15(v: &String, x: &u64) { h14(v, x).await } pub async fn h16(v: &String, x: &u64) { h15(v, x).await } pub async fn h17(v: &String, x: &u64) { h16(v, x).await } pub async fn h18(v: &String, x: &u64) { h17(v, x).await } pub async fn h19(v: &String, x: &u64) { h18(v, x).await } macro_rules! async_recursive { (29, $inner:expr) => { async { async_recursive!(28, $inner) }.await }; (28, $inner:expr) => { async { async_recursive!(27, $inner) }.await }; (27, $inner:expr) => { async { async_recursive!(26, $inner) }.await }; (26, $inner:expr) => { async { async_recursive!(25, $inner) }.await }; (25, $inner:expr) => { async { async_recursive!(24, $inner) }.await }; (24, $inner:expr) => { async { async_recursive!(23, $inner) }.await }; (23, $inner:expr) => { async { async_recursive!(22, $inner) }.await }; (22, $inner:expr) => { async { async_recursive!(21, $inner) }.await }; (21, $inner:expr) => { async { async_recursive!(20, $inner) }.await }; (20, $inner:expr) => { async { async_recursive!(19, $inner) }.await }; (19, $inner:expr) => { async { async_recursive!(18, $inner) }.await }; (18, $inner:expr) => { async { async_recursive!(17, $inner) }.await }; (17, $inner:expr) => { async { async_recursive!(16, $inner) }.await }; (16, $inner:expr) => { async { async_recursive!(15, $inner) }.await }; (15, $inner:expr) => { async { async_recursive!(14, $inner) }.await }; (14, $inner:expr) => { async { async_recursive!(13, $inner) }.await }; (13, $inner:expr) => { async { async_recursive!(12, $inner) }.await }; (12, $inner:expr) => { async { async_recursive!(11, $inner) }.await }; (11, $inner:expr) => { async { async_recursive!(10, $inner) }.await }; (10, $inner:expr) => { async { async_recursive!(9, $inner) }.await }; (9, $inner:expr) => { async { async_recursive!(8, $inner) }.await }; (8, $inner:expr) => { async { async_recursive!(7, $inner) }.await }; (7, $inner:expr) => { async { async_recursive!(6, $inner) }.await }; (6, $inner:expr) => { async { async_recursive!(5, $inner) }.await }; (5, $inner:expr) => { async { async_recursive!(4, $inner) }.await }; (4, $inner:expr) => { async { async_recursive!(3, $inner) }.await }; (3, $inner:expr) => { async { async_recursive!(2, $inner) }.await }; (2, $inner:expr) => { async { async_recursive!(1, $inner) }.await }; (1, $inner:expr) => { async { async_recursive!(0, $inner) }.await }; (0, $inner:expr) => { async { h19(&String::from("owo"), &0).await; $inner }.await }; } async fn f() { async_recursive!(14, println!("hello")); } fn main() { let _ = f(); } ``` r? `@eddyb` requires a perf run.
2020-09-22cleanup cfg after optimizationSimon Vandel Sillesen-0/+9
2020-09-22The optimization should also apply for DropAndReplaceSimon Vandel Sillesen-1/+2
2020-09-22Get LocalDefId from source instead of passing inSimon Vandel Sillesen-11/+3
2020-09-22Suggestion from reviewSimon Vandel Sillesen-1/+1
Co-authored-by: Andreas Jonson <andjo403@users.noreply.github.com>
2020-09-22MIR pass to remove unneeded drops on types not needing dropSimon Vandel Sillesen-0/+59
This is heavily dependent on MIR inlining running to actually see the drop statement
2020-09-22Use correct feature gate for unsizing castsDylan MacKenzie-5/+1
2020-09-22Add `#![feature(const_fn_transmute)]` to `rustc_ast`Dylan MacKenzie-0/+1
2020-09-22Replace missing commentDylan MacKenzie-0/+2
2020-09-22Use the same name everywhere for `is_const_stable_const_fn`Dylan MacKenzie-2/+4
2020-09-22Update const-checker to replicate `qualify_min_const_fn`Dylan MacKenzie-73/+268
2020-09-22Add structured errors for `qualify_min_const_fn` checksDylan MacKenzie-3/+220
2020-09-22Allow errors to abort const checking when emittedDylan MacKenzie-4/+22
This is a hack for parity with `qualify_min_const_fn`, which only emitted a single error.
2020-09-22Return `true` if `check_const` emits an errorDylan MacKenzie-7/+11
2020-09-22Add const-stability helpersDylan MacKenzie-10/+45
2020-09-22Useful derives on `ops::Status`Dylan MacKenzie-0/+1
2020-09-22Auto merge of #76906 - Nicholas-Baron:shorten_typeck_check, r=oli-obkbors-4972/+5090
Split rustc_typeck::check into separate files Contributing to #60302.
2020-09-22Miri: more informative deallocation error messagesRalf Jung-4/+8
2020-09-22Add debug assertions against slow path reference resultsIshi Tatsuyuki-10/+37
2020-09-21Rollup merge of #77032 - lcnr:visit-all-the-item-likes, r=davidtwcoecstatic-morse-0/+13
lint missing docs for extern items fixes #76991
2020-09-21Rollup merge of #77022 - Juici:master, r=lcnrecstatic-morse-82/+55
Reduce boilerplate for BytePos and CharPos Reduces boilerplate code for BytePos and CharPos by using a macro to implement shared traits.
2020-09-21Rollup merge of #76914 - lcnr:path-no-more, r=ecstatic-morseecstatic-morse-8/+30
extend `Ty` and `TyCtxt` lints to self types blocked on #76891 r? @ecstatic-morse cc @Aaron1011
2020-09-21Rollup merge of #76888 - matthiaskrgr:clippy_single_match_2, r=Dylan-DPCecstatic-morse-58/+28
use if let instead of single match arm expressions use if let instead of single match arm expressions to compact code and reduce nesting (clippy::single_match)
2020-09-21Rollup merge of #76807 - ecstatic-morse:const-checking-staged-api, r=oli-obkecstatic-morse-65/+109
Use const-checking to forbid use of unstable features in const-stable functions First step towards #76618. Currently this code isn't ever hit because `qualify_min_const_fn` runs first and catches pretty much everything. One exception is `const_precise_live_drops`, which does not use the newly added code since it runs as part of a separate pass. Also contains some unrelated refactoring, which is split into separate commits. r? @oli-obk
2020-09-21Rollup merge of #76581 - lcnr:bound-too-generic, r=eddybecstatic-morse-6/+4
do not ICE on bound variables, return `TooGeneric` instead fixes #73260, fixes #74634, fixes #76595 r? @nikomatsakis
2020-09-21Rollup merge of #76489 - GuillaumeGomez:add-explanation-e0756, r=jyn514ecstatic-morse-1/+30
Add explanation for E0756 r? @pickfire
2020-09-21Rollup merge of #76131 - Aaron1011:fix/pretty-print-zip, r=lcnrecstatic-morse-8/+5
Don't use `zip` to compare iterators during pretty-print hack If the right-hand iterator has exactly one more element than the left-hand iterator, then both iterators will be fully consumed, but the extra element will never be compared. Split out from https://github.com/rust-lang/rust/pull/76130
2020-09-22Auto merge of #76913 - vandenheuvel:performance_debug, r=lcnrbors-3/+6
Fixing the performance regression of #76244 Issue https://github.com/rust-lang/rust/issues/74865 suggested that removing the `def_id` field from `ParamEnv` would improve performance. PR https://github.com/rust-lang/rust/pull/76244 implemented this change. Generally, [results](https://perf.rust-lang.org/compare.html?start=80fc9b0ecb29050d45b17c64af004200afd3cfc2&end=5ef250dd2ad618ee339f165e9b711a1b4746887d) were as expected: an instruction count decrease of about a percent. The instruction count for the unicode crates increased by about 3%, which `@nnethercote` speculated to be caused by a quirk of inlining or codegen. As the results were generally positive, and for chalk integration, this was also a step in the right direction, the PR was r+'d regardless. However, [wall-time performance results](https://perf.rust-lang.org/compare.html?start=a055c5a1bd95e029e9b31891db63b6dc8258b472&end=7402a394471a6738a40fea7d4f1891666e5a80c5&stat=task-clock) show a much larger performance degradation: 25%, as [mentioned](https://github.com/rust-lang/rust/pull/76244#issuecomment-694459840) by `@Mark-Simulacrum.` This PR, for now, reverts #76244 and attempts to find out, which change caused the regression.