Commit graph

911 commits

Author SHA1 Message Date
Oli Scherer
29f4aa753f Fixes -Zpolymorphize for src/test/ui/const-generics/auxiliary/crayte.rs 2021-03-04 15:45:31 +00:00
Oli Scherer
63af264d62 Spread tracing instrumentation into the polymorphization logic 2021-03-04 15:45:31 +00:00
bors
6f7673d077 Auto merge of #81114 - bugadani:generator, r=estebank
Box generator-related Body fields

Might save some memory on functions that aren't generators.
2021-03-04 00:23:42 +00:00
Yuki Okushi
ae5e024194
Rollup merge of #82376 - tmiasko:inline-options, r=oli-obk
Add option to enable MIR inlining independently of mir-opt-level

Add `-Zinline-mir` option that enables MIR inlining independently of the
current MIR opt level. The primary use-case is enabling MIR inlining on the
default MIR opt level.

Turn inlining thresholds into optional values to make it possible to configure
different defaults depending on the current mir-opt-level (although thresholds
are yet to be used in such a manner).
2021-03-02 21:23:14 +09:00
Guillaume Gomez
865cf0c3b6
Rollup merge of #80734 - abonander:ab/issue-66693, r=oli-obk
check that first arg to `panic!()` in const is `&str`

closes #66693

~~TODO: regression test~~

cc `@RalfJung` for error message wording
2021-03-02 00:50:04 +01:00
Austin Bonander
5a33f531cd check that first arg to panic!() in const is &str 2021-03-01 08:32:15 -08:00
Dániel Buga
b97eb23cd0 Box generator-related Body fields 2021-03-01 08:32:49 +01:00
Tomasz Miąsko
8b184ff1b8 Remove storage markers if they won't be used during code generation
The storage markers constitute a substantial portion of all MIR
statements. At the same time, for builds without any optimizations,
the storage markers have no further use during and after MIR
optimization phase.

If storage markers are not necessary for code generation, remove them.
2021-02-28 20:10:44 +01:00
Dylan DPC
7847f690fd
Rollup merge of #82607 - bjorn3:frame_loc_getter, r=RalfJung
Add a getter for Frame.loc

This is necessary for Priroda.

For context see https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/Frame.3A.3Aloc.20no.20longer.20public/near/228070266 and oli-obk/priroda#27.

cc `@DJMcNab`

r? `@RalfJung`
2021-02-27 21:56:25 +01:00
Dylan DPC
13ea3fab5f
Rollup merge of #82498 - tmiasko:partitioning-debug, r=matthewjasper
Use log level to control partitioning debug output
2021-02-27 21:56:18 +01:00
bjorn3
632a89529a Add a getter for Frame.loc
This is necessary for Priroda.
2021-02-27 21:01:02 +01:00
Tomasz Miąsko
500aeccc5b Use optional values for inlining thresholds
Turn inlining threshold into optional values to make it possible to
configure different defaults depending on the current mir-opt-level.
2021-02-27 10:19:19 +01:00
Tomasz Miąsko
f895f1c35a Add option enabling MIR inlining independently of mir-opt-level 2021-02-27 10:18:06 +01:00
Dylan DPC
2942cf5a1f
Rollup merge of #82482 - tmiasko:small-cycles, r=varkor
Use small hash set in `mir_inliner_callees`

Use small hash set in `mir_inliner_callees` to avoid temporary
allocation when possible and quadratic behaviour for large number of
callees.
2021-02-27 02:34:32 +01:00
Dylan DPC
5c7b383e59
Rollup merge of #82442 - Aaron1011:fix/closure-mut-crash, r=matthewjasper
Skip emitting closure diagnostic when closure_kind_origins has no entry

Fixes #82438

This map is not guarnateed to have an entry for a closure.
2021-02-27 02:34:30 +01:00
bors
3da2dd3eae Auto merge of #82559 - tmiasko:inlined, r=petrochenkov
Miscellaneous inlining improvements

Inline a few small and hot functions.
2021-02-26 21:58:58 +00:00
Guillaume Gomez
ee4129f70c
Rollup merge of #82491 - tmiasko:i, r=lcnr
Consider inexpensive inlining criteria first

Refactor inlining decisions so that inexpensive criteria are considered first:

1. Based on code generation attributes.
2. Based on MIR availability (examines call graph).
3. Based on MIR body.
2021-02-26 15:52:32 +01:00
Guillaume Gomez
039b1b62ac
Rollup merge of #82456 - klensy:or-else, r=estebank
Replaced some unwrap_or and map_or with lazy variants

Replaced some `unwrap_or` and `map_or` with `unwrap_or_else` and `map_or_else`.
2021-02-26 15:52:31 +01:00
Guillaume Gomez
0db8349fff
Rollup merge of #81940 - jhpratt:stabilize-str_split_once, r=m-ou-se
Stabilize str_split_once

Closes #74773
2021-02-26 15:52:29 +01:00
bors
d95d304861 Auto merge of #78429 - casey:doctest-attribute-splitting, r=jyn514
[librustdoc] Only split lang string on `,`, ` `, and `\t`

Split markdown lang strings into tokens on `,`.

The previous behavior was to split lang strings into tokens on any
character that wasn't a `_`, `_`, or alphanumeric.

This is a potentially breaking change, so please scrutinize! See discussion in #78344.

I noticed some test cases that made me wonder if there might have been some reason for the original behavior:

```
t("{.no_run .example}", false, true, Ignore::None, true, false, false, false, v(), None);
t("{.sh .should_panic}", true, false, Ignore::None, false, false, false, false, v(), None);
t("{.example .rust}", false, false, Ignore::None, true, false, false, false, v(), None);
t("{.test_harness .rust}", false, false, Ignore::None, true, true, false, false, v(), None);
```

It seemed pretty peculiar to specifically test lang strings in braces, with all the tokens prefixed by `.`.

I did some digging, and it looks like the test cases were added way back in [this commit from 2014](https://github.com/rust-lang/rust/commit/3fef7a74ca9a) by `@skade.`

It looks like they were added just to make sure that the splitting was permissive, and aren't testing that those strings in particular are accepted.

Closes https://github.com/rust-lang/rust/issues/78344.
2021-02-26 00:17:22 +00:00
Tomasz Miąsko
481e1fd3a8 Miscellaneous inlining improvements
Inline a few small and hot functions.
2021-02-26 00:00:00 +00:00
bors
89d32eb1ea Auto merge of #82338 - RalfJung:interp-error-allocs, r=oli-obk
all InterpError allocate now, so adjust alloc-error-check

Cc https://github.com/rust-lang/rust/pull/82116#discussion_r578310770
r? `@oli-obk`
2021-02-25 08:27:09 +00:00
klensy
08b1e8004b fix review 2021-02-25 04:21:12 +03:00
bors
1fdadbf13a Auto merge of #82159 - BoxyUwU:uwu, r=varkor
Use correct param_env in conservative_is_privately_uninhabited

cc `@lcnr`
r? `@varkor` since this is your FIXME that was removed ^^
2021-02-24 21:54:52 +00:00
bors
6b56603e35 Auto merge of #80475 - simonvandel:fix-77355, r=oli-obk
New mir-opt pass to simplify gotos with const values (reopening #77486)

Reopening PR #77486

Fixes #77355

This pass optimizes the following sequence
```rust
bb2: {
    _2 = const true;
    goto -> bb3;
}

bb3: {
    switchInt(_2) -> [false: bb4, otherwise: bb5];
}
```
into
```rust
bb2: {
    _2 = const true;
    goto -> bb5;
}
```
2021-02-24 07:23:54 +00:00
Tomasz Miąsko
55626eda08 Use log level to control partitioning debug output 2021-02-24 00:00:00 +00:00
Tomasz Miąsko
ef731b31db Use small hash set in mir_inliner_callees
Use small hash set in `mir_inliner_callees` to avoid temporary
allocation when possible and quadratic behaviour for large number of
callees.
2021-02-24 00:00:00 +00:00
Tomasz Miąsko
6d5c0c1bcb Consider inexpensive inlining criteria first
Refactor inlining decisions so that inexpensive criteria are considered first:

1. Based on code generation attributes.
2. Based on MIR availability (examines call graph).
3. Based on MIR body.
2021-02-24 00:00:00 +00:00
klensy
c75c4a579b replaced some map_or with map_or_else 2021-02-24 02:43:35 +03:00
Ellen
42cbfd6346 yeet 2021-02-23 23:35:59 +00:00
Dylan DPC
aa1405fff7
Rollup merge of #82362 - osa1:issue81918, r=oli-obk
Fix mir-cfg dumps

Fixes #81918
Fixes #82326 (duplicate)
Fixes #82325

---

r? ``@oli-obk``
2021-02-23 16:10:29 +01:00
Dylan DPC
18d1284433
Rollup merge of #81629 - 1000teslas:issue-81365-fix, r=Aaron1011
Point out implicit deref coercions in borrow

Fixes #81365

`@Aaron1011` I'm not sure why my code shows the note even in an implicit `Deref` call. See the output for `issue-81365-8.rs`.
2021-02-23 16:10:20 +01:00
Aaron Hill
46db4bab0b
Skip emitting closure diagnostic when closure_kind_origins has no entry
Fixes #82438

This map is not guarnateed to have an entry for a closure.
2021-02-23 09:46:20 -05:00
Dylan DPC
cc07061190
Rollup merge of #82091 - henryboisdequin:use-place-ref-more, r=RalfJung
use PlaceRef abstractions more consistently

Addresses this [comment](https://github.com/rust-lang/rust/pull/80865/files#r558978715)
Associated issue: #80647

r? ```@RalfJung```
2021-02-23 02:51:50 +01:00
Simon Vandel Sillesen
a6dccfeb23 New mir-opt pass to simplify gotos with const values
Fixes #77355
2021-02-22 21:03:57 +01:00
Ömer Sinan Ağacan
2145a8770c Fix mir-cfg dumps
Fixes #81918
Fixes #82326 (duplicate)
Fixes #82325
2021-02-22 17:36:30 +03:00
bors
15598a83db Auto merge of #77551 - simonvandel:extend-simplify-branch-same, r=oli-obk
MIR-OPT: Pass to deduplicate blocks

This pass finds basic blocks that are completely equal,
and replaces all uses with just one of them.

```bash
$ RUSTC_LOG=rustc_mir::transform::deduplicate_blocks ./x.py build --stage 2 | grep "SUCCESS: Replacing: " > log
...
$ cat log | wc -l
23875
```
2021-02-22 12:14:23 +00:00
1000teslas
1847a6c0c1 Extract deref coercion explanation into method 2021-02-22 19:08:44 +11:00
Simon Vandel Sillesen
2d1e0adfe9 New pass to deduplicate blocks 2021-02-21 21:51:54 +01:00
Simon Vandel Sillesen
1e865709a6 Make MatchBranchSimplification clean up after itself 2021-02-21 21:22:04 +01:00
Simon Vandel Sillesen
ccecc4f6bf Drive-by formatting of comment 2021-02-21 21:22:04 +01:00
Matthias Krüger
da9a588d4f remove redundant wrapping of return types of allow_internal_unstable() and rustc_allow_const_fn_unstable() 2021-02-21 18:11:27 +01:00
Matthias Krüger
a9b90c02a2 rustc_mir: remove redundant wrapping of return type in numeric_intrinsic() 2021-02-21 13:44:16 +01:00
Guillaume Gomez
2d39300e2f
Rollup merge of #82176 - RalfJung:mir-fn-ptr-pretty, r=oli-obk
fix MIR fn-ptr pretty-printing

An uninitialized function pointer would get printed as `{{uninit  fn()}` (notice the unbalanced parentheses), and a dangling fn ptr would ICE. This fixes both of that.

However, I have no idea how to add tests for this.

Also, I don't understand this MIR pretty-printing code. Somehow the print function `pretty_print_const_scalar` actually *returns* a transformed form of the const (but there is no doc comment explaining what is being returned); some match arms do `p!` while others do `self =`, and there's a wild mixture of `p!` and `write!`... all very mysterious and confusing.^^

r? ``@oli-obk``
2021-02-20 20:37:00 +01:00
Ralf Jung
d496bfc161 all InterpError allocate now, so adjust alloc-error-check 2021-02-20 19:01:25 +01:00
Henry Boisdequin
a9c6188889 make super_projection take a PlaceRef 2021-02-20 16:56:08 +05:30
bors
e7c23ab933 Auto merge of #82124 - tmiasko:op-ty-ref, r=oli-obk
Pass large interpreter types by reference, not value

r? `@ghost`
2021-02-20 10:20:42 +00:00
1000teslas
99f4573264 Add deref definition location
Update conflict_errors.rs

Add deref definition location
2021-02-19 18:43:57 +11:00
Eduard-Mihai Burtescu
6165d1cc72 Print -Ztime-passes (and misc stats/logs) on stderr, not stdout. 2021-02-18 14:13:38 +02:00
Yuki Okushi
ce6367f479
Rollup merge of #82240 - matthiaskrgr:qmark, r=Dylan-DPC
remove useless ?s (clippy::needless_question_marks)

Example code:
```rust
fn opts() -> Option<String> {
    let s: Option<String> = Some(String::new());
    Some(s?) // this can just be "s"
}
```
2021-02-18 15:57:33 +09:00