Commit graph

75 commits

Author SHA1 Message Date
Dylan MacKenzie fca642c1c3 Add pass for simple phase change 2021-12-02 17:31:38 -08:00
Dylan MacKenzie fd18b45e11 Update passes with new interface 2021-12-02 17:31:38 -08:00
Dylan MacKenzie c1a501b131 Implement a pass manager 2021-12-02 17:31:38 -08:00
Matthias Krüger 39641319ad
Rollup merge of #91410 - ecstatic-morse:const-precise-live-drops-take-2, r=oli-obk
Move `#![feature(const_precise_live_drops)]` checks earlier in the pipeline

Should mitigate the issues found during MCP on #73255.

Once this is done, we should clean up the queries a bit, since I think `mir_drops_elaborated_and_const_checked` can be merged back into `mir_promoted`.

Fixes #90770.

cc ``@rust-lang/wg-const-eval``
r? ``@nikomatsakis`` (since they reviewed #71824)
2021-12-02 22:16:13 +01:00
Dylan MacKenzie 58c996c3a7 Move post-elaboration const-checking earlier in the pipeline
Instead we run `RemoveFalseEdges` and `RemoveUninitDrops` at the
appropriate time. The extra `SimplifyCfg` avoids visiting unreachable
blocks during `RemoveUninitDrops`.
2021-11-30 17:25:30 -08:00
Dylan MacKenzie ce2959da97 Add rationale for RemoveUnneededDrops
...since its name is very close to `RemoveUninitDrops`.
2021-11-30 17:25:30 -08:00
Dylan MacKenzie 4f7605b6fd Add RemoveUninitDrops MIR pass 2021-11-30 17:25:30 -08:00
Dylan MacKenzie bb27b05104 Separate RemoveFalseEdges from SimplifyBranches
Otherwise dataflow state will propagate along false edges and cause
things to be marked as maybe init unnecessarily. These should be
separate, since `SimplifyBranches` also makes `if true {} else {}` into
a `goto`, which means we wouldn't lint anything in the `else` block.
2021-11-30 17:14:48 -08:00
Matthias Krüger dc78cd4c61
Rollup merge of #91294 - cjgillot:process-elem, r=jackh726
Visit type in process_projection_elem.

Instead of reimplementing it for each visitor.
2021-11-30 23:43:31 +01:00
Dylan MacKenzie 188d670125 Don't re-export MirPass 2021-11-29 12:58:15 -08:00
Camille GILLOT 29b30a9bd2 Visit type in process_projection_elem. 2021-11-27 17:39:27 +01:00
bstrie ce1143e94d impl Copy/Clone for arrays in std, not in compiler 2021-11-08 13:11:58 -05:00
Matthias Krüger ec471de865
Rollup merge of #90649 - cjgillot:reveal-all-2, r=lcnr
Run reveal_all on MIR when inlining is activated.

Fix logic error in https://github.com/rust-lang/rust/pull/85254 which prevented the pass from running when needed.
Fixes https://github.com/rust-lang/rust/issues/78442
r? ``@lcnr``
2021-11-06 23:12:06 +01:00
Matthias Krüger 0a5640b55f use matches!() macro in more places 2021-11-06 16:13:14 +01:00
Camille GILLOT a3776d99cc Run reveal_all on MIR more often. 2021-11-06 15:56:29 +01:00
Mark Rousskov 3215eeb99f
Revert "Add rustc lint, warning when iterating over hashmaps" 2021-10-28 11:01:42 -04:00
bors 235d9853d8 Auto merge of #90042 - pietroalbini:1.56-master, r=Mark-Simulacrum
Bump bootstrap compiler to 1.57

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

r? `@Mark-Simulacrum`
2021-10-25 11:31:47 +00:00
bors 00d5e42e77 Auto merge of #90235 - matthiaskrgr:rollup-7pqtevk, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #89558 (Add rustc lint, warning when iterating over hashmaps)
 - #90100 (Skip documentation for tier 2 targets on dist-x86_64-apple-darwin)
 - #90155 (Fix alignment of method headings for scannability)
 - #90162 (Mark `{array, slice}::{from_ref, from_mut}` as const fn)
 - #90221 (Fix ICE when forgetting to `Box` a parameter to a `Self::func` call)
 - #90234 (Temporarily turn overflow checks off for rustc-rayon-core)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-24 14:12:10 +00:00
Matthias Krüger 87822b27ee
Rollup merge of #89558 - lcnr:query-stable-lint, r=estebank
Add rustc lint, warning when iterating over hashmaps

r? rust-lang/wg-incr-comp
2021-10-24 15:48:42 +02:00
bors ed08a67566 Auto merge of #85254 - cjgillot:reveal-mir, r=lcnr
Normalize MIR with RevealAll before optimizations.

Fixes #78442
2021-10-24 11:04:54 +00:00
Pietro Albini b63ab8005a update cfg(bootstrap) 2021-10-23 21:55:57 -04:00
bors 01198792a6 Auto merge of #89893 - camsteffen:redundant-dump-enabled, r=matthewjasper
Remove redundant dump_enabled check
2021-10-22 17:32:20 +00:00
Yuki Okushi afdd0c3ade
Rollup merge of #90071 - cjgillot:no-blocks, r=oli-obk
Remove hir::map::blocks and use FnKind instead

The principal tool is `FnLikeNode`, which is not often used and can be easily implemented using `rustc_hir::intravisit::FnKind`.
2021-10-21 14:11:08 +09:00
Camille GILLOT 6e98688e68 Replace FnLikeNode by FnKind. 2021-10-19 23:31:51 +02:00
bors 1af55d19c7 Auto merge of #89933 - est31:let_else, r=michaelwoerister
Adopt let_else across the compiler

This performs a substitution of code following the pattern:

```
let <id> = if let <pat> = ... { identity } else { ... : ! };
```

To simplify it to:

```
let <pat> = ... { identity } else { ... : ! };
```

By adopting the `let_else` feature (cc #87335).

The PR also updates the syn crate because the currently used version of the crate doesn't support `let_else` syntax yet.

Note: Generally I'm the person who *removes* usages of unstable features from the compiler, not adds more usages of them, but in this instance I think it hopefully helps the feature get stabilized sooner and in a better state. I have written a [comment](https://github.com/rust-lang/rust/issues/87335#issuecomment-944846205) on the tracking issue about my experience and what I feel could be improved before stabilization of `let_else`.
2021-10-19 14:41:39 +00:00
bors bd41e09da3 Auto merge of #89124 - cjgillot:owner-info, r=michaelwoerister
Index and hash HIR as part of lowering

Part of https://github.com/rust-lang/rust/pull/88186
~Based on https://github.com/rust-lang/rust/pull/88880 (see merge commit).~

Once HIR is lowered, it is later indexed by the `index_hir` query and hashed for `crate_hash`. This PR moves those post-processing steps to lowering itself. As a side objective, the HIR crate data structure is refactored as an `IndexVec<LocalDefId, Option<OwnerInfo<'hir>>>` where `OwnerInfo` stores all the relevant information for an HIR owner.

r? `@michaelwoerister`
cc `@petrochenkov`
2021-10-18 19:53:05 +00:00
Camille GILLOT a7ccf22b48 Fix remove_unneeded_drops pass. 2021-10-17 14:57:57 +02:00
Camille GILLOT 2fa9b11804 Normalize MIR with RevealAll before optimizations. 2021-10-17 14:57:57 +02:00
est31 1418df5888 Adopt let_else across the compiler
This performs a substitution of code following the pattern:

let <id> = if let <pat> = ... { identity } else { ... : ! };

To simplify it to:

let <pat> = ... { identity } else { ... : ! };

By adopting the let_else feature.
2021-10-16 07:18:05 +02:00
lcnr 00e5abe9b6 allow potential_query_instability everywhere 2021-10-15 10:58:18 +02:00
Cameron Steffen 7166df4b59 Inline on_mir_pass and add inline to dump_mir 2021-10-14 15:26:59 -05:00
Camille GILLOT 394f7198ca Allow to hash HIR for coverage. 2021-10-14 22:24:43 +02:00
Cameron Steffen cf1d702411 Remove redundant dump_enabled check 2021-10-14 15:10:13 -05:00
Matthias Krüger e6f77a1787 clippy::complexity fixes 2021-10-08 20:07:44 +02:00
Alexander a31518fbf4 opt-level >= 4 2021-10-06 20:37:24 +02:00
Alexander d61f95fead fix import 2021-10-06 17:45:54 +02:00
Alexander 94e1413f60 reset and cleanup 2021-10-06 17:31:35 +02:00
bors 55111d656f Auto merge of #89266 - cjgillot:session-ich, r=michaelwoerister
Move ICH to rustc_query_system

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

The StableHashingContext does not need to be in rustc_middle.

This PR moves it to rustc_query_system. This will avoid a dependency between rustc_ast_lowering and rustc_middle in https://github.com/rust-lang/rust/pull/89124.
2021-10-05 09:45:11 +00:00
Jubilee 9866b090f4
Rollup merge of #89508 - jhpratt:stabilize-const_panic, r=joshtriplett
Stabilize `const_panic`

Closes #51999

FCP completed in #89006

```@rustbot``` label +A-const-eval +A-const-fn +T-lang

cc ```@oli-obk``` for review (not `r?`'ing as not on lang team)
2021-10-04 13:58:17 -07:00
bors a4797664ba Auto merge of #89489 - FabianWolff:issue-89485, r=oli-obk
Fix unsound optimization with explicit variant discriminants

Fixes #89485.
2021-10-04 10:09:04 +00:00
Jacob Pratt bce8621983
Stabilize const_panic 2021-10-04 02:33:33 -04:00
Fabian Wolff dd9b4763a4 Disable SimplifyBranchSame optimization for now 2021-10-03 22:58:24 +02:00
Fabian Wolff 20489eaca2 Update comments 2021-10-03 21:06:49 +02:00
Camille GILLOT 02025d86ac Remove re-export. 2021-10-03 16:08:54 +02:00
Fabian Wolff 529c35331b Fix unsound optimization with explicit variant discriminants 2021-10-03 16:04:38 +02:00
Cameron Steffen eec856bfbc Make diangostic item names consistent 2021-10-02 19:38:19 -05:00
bors c02371c442 Auto merge of #88880 - cjgillot:no-krate, r=oli-obk
Rework HIR API to make invocations of the hir_crate query harder.

`hir_crate` forces the recomputation of queries that depend on it.

This PR aims at avoiding useless invocations of `hir_crate` by making dependent code go through `tcx.hir()`.
2021-10-01 20:06:34 +00:00
Manish Goregaokar 534946cba1
Rollup merge of #89415 - wesleywiser:inliner_caller_callsite_message, r=michaelwoerister
Correct caller/callsite confusion in inliner message

`callee_body` is the MIR `Body` for the `callsite.callee` so this message basically says `"Inline {bar span} into bar"` when it should say `"Inline bar into foo"`.

Extracted out of #82280
2021-10-01 09:18:20 -07:00
Wesley Wiser 3565e8a088 Correct caller/callsite confusion in inliner message 2021-09-30 21:39:02 -04:00
Camille GILLOT abc57f63ad Move body_owners to tcx.hir(). 2021-09-29 23:16:48 +02:00