Commit graph

682 commits

Author SHA1 Message Date
Vishnunarayan K I 86a7831f0b formatting 2020-11-10 00:21:25 +05:30
Dylan DPC ee1fedf392
Rollup merge of #78580 - tmiasko:inline-loop, r=oli-obk
inliner: Break inlining cycles

Keep track of all instances inlined so far. When examining a new call
sites from an inlined body, skip those where callee had been inlined
already to avoid potential inlining cycles.

Fixes #78573.
2020-11-09 19:06:53 +01:00
Dylan DPC 99f16e637b
Rollup merge of #76468 - SNCPlay42:lifetime-names, r=Mark-Simulacrum
Improve lifetime name annotations for closures & async functions

* Don't refer to async functions as "generators" in error output
* Where possible, emit annotations pointing exactly at the `&` in the return type of closures (when they have explicit return types) and async functions, like we do for arguments.
Addresses #74072, but I wouldn't call that *closed* until annotations are identical for async and non-async functions.
* Emit a better annotation when the lifetime doesn't appear in the full name type, which currently happens for opaque types like `impl Future`. Addresses #74497, but further improves could probably be made (why *doesn't* it appear in the type as `impl Future + '1`?)
This is included in the same PR because the changes to `give_name_if_anonymous_region_appears_in_output` would introduce ICE otherwise (it would return `None` in cases where it didn't previously, which then gets `unwrap`ped)
2020-11-09 19:06:39 +01:00
Vishnunarayan K I a4e94ec9b8 update gsgdt 2020-11-09 22:39:12 +05:30
Vishnunarayan K I 5b049e107b write to a String instead to reduce churn 2020-11-09 22:39:12 +05:30
Vishnunarayan K I ea1460773f make MIR graphviz generation use gsgdt
gsgdt [https://crates.io/crates/gsgdt] is a crate which provides an
interface for stringly typed graphs. It also provides generation of
graphviz dot format from said graph.
2020-11-09 22:39:06 +05:30
SNCPlay42 61b52a33b3 use RegionNameHighlight for async fn and closure returns 2020-11-09 16:14:40 +00:00
Dylan DPC b4589a86cc
Rollup merge of #78674 - tmiasko:inline-substs-for-mir-body, r=oli-obk
inliner: Use substs_for_mir_body

Changes from 68965 extended the kind of instances that are being
inlined. For some of those, the `instance_mir` returns a MIR body that
is already expressed in terms of the types found in substitution array,
and doesn't need further substitution.

Use `substs_for_mir_body` to take that into account.

Resolves #78529.
Resolves #78560.
2020-11-09 01:13:42 +01:00
Tomasz Miąsko ffa70d75c8 Support inlining diverging function calls
Additionally introduce storage markers for all temporaries created by
the inliner. The temporary introduced for destination rebrorrow, didn't
use them previously.
2020-11-09 00:00:00 +00:00
Tomasz Miąsko dc4d74d149 inliner: Break inlining cycles
When examining candidates for inlining, reject those that are determined
to be recursive either because of self-recursive calls or calls to any
instances already inlined.
2020-11-09 00:00:00 +00:00
Tomasz Miąsko b7f16c56d1 inliner: Make inline_call infallible
The inliner does not support inlining of divering calls. Reject them
early on and turn `inline_call` into an infallible operation.
2020-11-09 11:41:10 +01:00
Vadim Petrochenkov bf66988aa1 Collapse all uses of target.options.foo into target.foo
with an eye on merging `TargetOptions` into `Target`.

`TargetOptions` as a separate structure is mostly an implementation detail of `Target` construction, all its fields logically belong to `Target` and available from `Target` through `Deref` impls.
2020-11-08 17:29:13 +03:00
bors b1277d04db Auto merge of #78874 - m-ou-se:rollup-3jp1ijj, r=m-ou-se
Rollup of 19 pull requests

Successful merges:

 - #76097 (Stabilize hint::spin_loop)
 - #76227 (Stabilize `Poll::is_ready` and `is_pending` as const)
 - #78065 (make concurrency helper more pleasant to read)
 - #78570 (Remove FIXME comment in print_type_sizes ui test suite)
 - #78572 (Use SOCK_CLOEXEC and accept4() on more platforms.)
 - #78658 (Add a tool to run `x.py` from any subdirectory)
 - #78706 (Fix run-make tests running when LLVM is disabled)
 - #78728 (Constantify `UnsafeCell::into_inner` and related)
 - #78775 (Bump Rustfmt and RLS)
 - #78788 (Correct unsigned equivalent of isize to be usize)
 - #78811 (Make some std::io functions `const`)
 - #78828 (use single char patterns for split() (clippy::single_char_pattern))
 - #78841 (Small cleanup in `TypeFoldable` derive macro)
 - #78842 (Honor the rustfmt setting in config.toml)
 - #78843 (Less verbose debug logging from inlining integrator)
 - #78852 (Convert a bunch of intra-doc links)
 - #78860 (rustc_resolve: Use `#![feature(format_args_capture)]`)
 - #78861 (typo and formatting)
 - #78865 (Don't fire `CONST_ITEM_MUTATION` lint when borrowing a deref)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2020-11-08 13:49:17 +00:00
Mara Bos 91759b2de5
Rollup merge of #78865 - Aaron1011:fix/const-item-mut-reborrow, r=varkor
Don't fire `CONST_ITEM_MUTATION` lint when borrowing a deref

Fixes #78819

This extends the check for dereferences added in PR #77324
to cover mutable borrows, as well as direct writes. If we're operating
on a dereference of a `const` item, we shouldn't be firing the lint.
2020-11-08 13:36:33 +01:00
Mara Bos e5230fdf96
Rollup merge of #78843 - tmiasko:inline-trace, r=wesleywiser
Less verbose debug logging from inlining integrator

The inlining integrator produces relatively verbose and uninteresting
logs.  Move them from a debug log level to a trace level, so that they
can be easily isolated from others.
2020-11-08 13:36:26 +01:00
bors 87a0997ef9 Auto merge of #78410 - lcnr:revert75443, r=nikomatsakis
revert #75443, update mir validator

This PR reverts rust-lang#75443 to fix rust-lang#75992 and instead uses rust-lang#75419 to fix rust-lang#75313.

Adapts rust-lang#75419 to correctly deal with unevaluated constants as otherwise some `feature(const_evaluatable_checked)` tests would ICE.

Note that rust-lang#72793 was also fixed by rust-lang#75443, but as that issue only concerns `feature(type_alias_impl_trait)` I deleted that test case for now and would reopen that issue.

rust-lang#75443 may have also allowed some other code to now successfully compile which would make this revert a breaking change after 2 stable versions, but I hope that this is a purely theoretical concern.

See https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/generator.20upvars/near/214617274 for more reasoning about this.

r? `@nikomatsakis` `@eddyb` `@RalfJung`
2020-11-08 11:27:06 +00:00
Aaron Hill bd3f3fa32a
Use a semicolon instead of a dash in lint note 2020-11-07 20:39:35 -05:00
Aaron Hill e4e9bb4a24
Don't fire CONST_ITEM_MUTATION lint when borrowing a deref
Fixes #78819

This extends the check for dereferences added in PR #77324
to cover mutable borrows, as well as direct writes. If we're operating
on a dereference of a `const` item, we shouldn't be firing the lint.
2020-11-07 20:11:53 -05:00
Tomasz Miąsko 425675da42 Less verbose debug logging from inlining integrator
The inlining integrator produces relatively verbose and uninteresting
logs.  Move them from a debug log level to a trace level, so that they
can be easily isolated from others.
2020-11-07 19:56:08 +01:00
Joshua Nelson 622c48e4f1 Allow making RUSTC_BOOTSTRAP conditional on the crate name
The main change is that `UnstableOptions::from_environment` now requires
an (optional) crate name. If the crate name is unknown (`None`), then the new feature is not available and you still have to use `RUSTC_BOOTSTRAP=1`. In practice this means the feature is only available for `--crate-name`, not for `#![crate_name]`; I'm interested in supporting the second but I'm not sure how.

Other major changes:

- Added `Session::is_nightly_build()`, which uses the `crate_name` of
the session
- Added `nightly_options::match_is_nightly_build`, a convenience method
for looking up `--crate-name` from CLI arguments.
`Session::is_nightly_build()`should be preferred where possible, since
it will take into account `#![crate_name]` (I think).
- Added `unstable_features` to `rustdoc::RenderOptions`

  There is a user-facing change here: things like `RUSTC_BOOTSTRAP=0` no
  longer active nightly features. In practice this shouldn't be a big
  deal, since `RUSTC_BOOTSTRAP` is the opposite of stable and everyone
  uses `RUSTC_BOOTSTRAP=1` anyway.

- Add tests

  Check against `Cheat`, not whether nightly features are allowed.
  Nightly features are always allowed on the nightly channel.

- Only call `is_nightly_build()` once within a function

- Use booleans consistently for rustc_incremental

  Sessions can't be passed through threads, so `read_file` couldn't take a
  session. To be consistent, also take a boolean in `write_file_header`.
2020-11-07 13:45:11 -05:00
Matthias Krüger 020ed653a3 use single char patterns for split() (clippy::single_char_pattern) 2020-11-07 07:27:44 +01:00
Tomasz Miąsko 89c3582d59 Assert that a return place is not used for indexing during integration
The inliner integrates call destination place with callee return place
by remapping the local and adding extra projections as necessary.

If a call destination place contains any projections (which is already
possible) and a return place is used in an indexing projection (most
likely doesn't happen yet) the end result would be incorrect.

Add an assertion to ensure that potential issue won't go unnoticed in
the presence of more sophisticated copy propagation scheme.
2020-11-07 00:00:00 +00:00
Bastian Kauschke e06785b676 improve fixme 2020-11-06 22:37:16 +01:00
Yuki Okushi af50c796fa
Rollup merge of #78798 - ankushduacodes:fixing-typo, r=jonas-schievink
Fixing Spelling Typos

Fixing #78787
2020-11-07 01:02:30 +09:00
Yuki Okushi 0a89d7bd7e
Rollup merge of #78771 - tmiasko:inline-consts, r=oli-obk
inliner: Copy unevaluated constants only after successful inlining

Inliner copies the unevaluated constants from the callee body to the
caller at the point where decision to inline is yet to be made. The
constants will be unnecessary if inlining were to fail.

Organize the code moving items from callee to the caller together in one
place to avoid the issue.
2020-11-07 01:02:24 +09:00
bors 8532e742fc Auto merge of #78267 - richkadel:llvm-coverage-counters-2.0.3r1, r=tmandry
Working expression optimization, and some improvements to branch-level source coverage

This replaces PR #78040 after reorganizing the original commits (by request) into a more logical sequence of major changes.

Most of the work is in the MIR `transform/coverage/` directory (originally, `transform/instrument_coverage.rs`).

Note this PR includes some significant additional debugging capabilities, to help myself and any future developer working on coverage improvements or issues.

In particular, there's a new Graphviz (.dot file) output for the coverage graph (the `BasicCoverageBlock` control flow graph) that provides ways to get some very good insight into the relationships between the MIR, the coverage graph BCBs, coverage spans, and counters. (There are also some cool debugging options, available via environment variable, to alter how some data in the graph appears.)

And the code for this Graphviz view is actually generic... it can be used by any implementation of the Rust `Graph` traits.

Finally (for now), I also now output information from `llvm-cov` that shows the actual counters and spans it found in the coverage map, and their counts (from the `--debug` flag). I found this to be enormously helpful in debugging some coverage issues, so I kept it in the test results as well for additional context.

`@tmandry` `@wesleywiser`

r? `@tmandry`

Here's an example of the new coverage graph:

* Within each `BasicCoverageBlock` (BCB), you can see each `CoverageSpan` and its contributing statements (MIR `Statement`s and/or `Terminator`s)
* Each `CoverageSpan` has a `Counter` or and `Expression`, and `Expression`s show their Add/Subtract operation with nested operations. (This can be changed to show the Counter and Expression IDs instead, or in addition to, the BCB.)
* The terminators of all MIR `BasicBlock`s in the BCB, including one final `Terminator`
* If an "edge counter" is required (because we need to count an edge between blocks, in some cases) the edge's Counter or Expression is shown next to its label. (Not shown in the example below.) (FYI, Edge Counters are converted into a new MIR `BasicBlock` with `Goto`)

<img width="1116" alt="Screen Shot 2020-10-17 at 12 23 29 AM" src="https://user-images.githubusercontent.com/3827298/96331095-616cb480-100f-11eb-8212-60f2d433e2d8.png">

r? `@tmandry`
FYI: `@wesleywiser`
2020-11-06 06:59:44 +00:00
bors f92b931045 Auto merge of #77856 - GuillaumeGomez:automatic-links-lint, r=jyn514,ollie27
Add non_autolinks lint

Part of #77501.

r? `@jyn514`
2020-11-06 04:17:41 +00:00
ankushduacodes 0af959d3a2 Fixing Spelling Typos 2020-11-06 09:25:58 +05:30
Rich Kadel a7d956583c Responded to all feedback as of 2020-10-30 2020-11-05 18:24:18 -08:00
Rich Kadel 1973f84ebb Addressed all feedback to date 2020-11-05 18:24:17 -08:00
Rich Kadel 198ba3bd1c Injecting expressions in place of counters where helpful
Implementing the Graph traits for the BasicCoverageBlock
graph.

optimized replacement of counters with expressions plus new BCB graphviz

* Avoid adding coverage to unreachable blocks.
* Special case for Goto at the end of the body. Make it non-reportable.

Improved debugging and formatting options (from env)

Don't automatically add counters to BCBs without CoverageSpans. They may
still get counters but only if there are dependencies from
other BCBs that have spans, I think.

Make CodeRegions optional for Counters too. It is
possible to inject counters (`llvm.instrprof.increment` intrinsic calls
without corresponding code regions in the coverage map. An expression
can still uses these counter values.

Refactored instrument_coverage.rs -> instrument_coverage/mod.rs, and
then broke up the mod into multiple files.

Compiling with coverage, with the expression optimization, works on
the json5format crate and its dependencies.

Refactored debug features from mod.rs to debug.rs
2020-11-05 18:24:15 -08:00
Rich Kadel 3291d28e9a Adds coverage graphviz 2020-11-05 18:24:14 -08:00
Rich Kadel b5020648fe Implemented CoverageGraph of BasicCoverageBlocks 2020-11-05 18:24:13 -08:00
Rich Kadel c7ae4c2cb6 Splitting transform/instrument_coverage.rs into transform/coverage/... 2020-11-05 18:24:12 -08:00
Rich Kadel c7747cc772 Rust coverage before splitting instrument_coverage.rs 2020-11-05 18:24:12 -08:00
Tomasz Miąsko 8a8ee1a3ed inliner: Use substs_for_mir_body
Changes from 68965 extended the kind of instances that are being
inlined. For some of those, the `instance_mir` returns a MIR body that
is already expressed in terms of the types found in substitution array,
and doesn't need further substitution.

Use `substs_for_mir_body` to take that into account.
2020-11-06 00:00:00 +00:00
Guillaume Gomez 99200f760b Fix even more URLs 2020-11-05 20:11:29 +01:00
Mara Bos 5ffccc4dfa
Rollup merge of #78742 - vn-ki:fix-issue-78655, r=oli-obk
make intern_const_alloc_recursive return error

fix #78655

r? ``@oli-obk``
2020-11-05 10:29:59 +01:00
Mara Bos 8640360870
Rollup merge of #78733 - matthiaskrgr:cl11ppy, r=jyn514
fix a couple of clippy warnings:

filter_next
manual_strip
redundant_static_lifetimes
single_char_pattern
unnecessary_cast
unused_unit
op_ref
redundant_closure
useless_conversion
2020-11-05 10:29:53 +01:00
Tomasz Miąsko 6ca43aca1d inliner: Copy unevaluated constants only after successful inlining
Inliner copies the unevaluated constants from the callee body to the
caller at the point where decision to inline is yet to be made. The
constants will be unnecessary if inlining were to fail.

Organize the code moving items from callee to the caller together in one
place to avoid the issue.
2020-11-05 00:00:00 +00:00
Vishnunarayan K I bd7229daf0 make intern_const_alloc_recursive return error fix #78655 2020-11-04 23:22:14 +05:30
oli abacaf2aef u128 truncation and sign extension are not just interpreter related 2020-11-04 13:41:58 +00:00
Matthias Krüger bcd2f2df67 fix a couple of clippy warnings:
filter_next
manual_strip
redundant_static_lifetimes
single_char_pattern
unnecessary_cast
unused_unit
op_ref
redundant_closure
useless_conversion
2020-11-04 13:48:50 +01:00
oli 500af76831 Add helper for getting an int out of a Scalar 2020-11-04 10:13:59 +00:00
oli f03b18b99b Add is_null helper
This is cheaper than creating a null-`ScalarInt` and comparing
and then just throwing it away.
2020-11-04 10:13:22 +00:00
oli 8282d526e0 Replace Scalar::zst with a Scalar::ZST constant 2020-11-04 10:12:41 +00:00
oli df4d717d0b s/Scalar::Raw/Scalar::Int 2020-11-04 10:11:31 +00:00
Oliver Scherer ed7a4adeb3 32 bit platforms don't have 64 bit pointers 2020-11-04 09:58:59 +00:00
Oliver Scherer 362123dd75 Split the "raw integer bytes" part out of Scalar 2020-11-04 09:58:59 +00:00
bors 56293097f7 Auto merge of #78711 - m-ou-se:rollup-pxqnny7, r=m-ou-se
Rollup of 7 pull requests

Successful merges:

 - #77950 (Add support for SHA256 source file hashing)
 - #78624 (Sync rustc_codegen_cranelift)
 - #78626 (Improve errors about #[deprecated] attribute)
 - #78659 (Corrected suggestion for generic parameters in `function_item_references` lint)
 - #78687 (Suggest library/std when running all stage 0 tests)
 - #78699 (Show more error information in lldb_batchmode)
 - #78709 (Fix panic in bootstrap for non-workspace path dependencies.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2020-11-03 18:58:06 +00:00
Mara Bos f347dab47c
Rollup merge of #78659 - ayrtonm:fn-ref-lint-fix, r=oli-obk
Corrected suggestion for generic parameters in `function_item_references` lint

This commit handles functions with generic type parameters like you pointed out as well as const generics. Also this is probably a minor thing, but the type alias you used in the example doesn't show up so the suggestion right now would be `size_of::<[u8; 16]> as fn() ->`. This is because the lint checker works with MIR instead of HIR. I don't think we can get the alias at that point, but let me know if I'm wrong and there's a way to fix this. Also I put you as the reviewer, but I'm not sure if you want to review it or if it makes more sense to ask one of the original reviewers of this lint.
closes #78571
2020-11-03 19:32:38 +01:00
bors 5cdf5b882d Auto merge of #76931 - oli-obk:const_prop_inline_lint_madness, r=wesleywiser
Properly handle lint spans after MIR inlining

The first commit shows what happens when we apply mir inlining and then cause lints on the inlined MIR.
The second commit fixes that.

r? `@wesleywiser`
2020-11-03 16:32:34 +00:00
bors 0cd1516696 Auto merge of #78597 - RalfJung:raw-retag, r=oli-obk
Retagging: do not retag 'raw reborrows'

When doing `&raw const (*raw_ptr).field`, we do not want any retagging; the original provenance should be fully preserved.

Fixes https://github.com/rust-lang/miri/issues/1608
Test added by https://github.com/rust-lang/miri/pull/1614

Not sure whom to ask for review on this... `@oli-obk` can you have a look? Or maybe highfive makes a good choice.^^
2020-11-03 13:48:54 +00:00
Bastian Kauschke cc19df627e revert #75443 update mir validator 2020-11-02 23:57:03 +01:00
Ayrton ace02c40f0 Corrected suggestion for generic parameters in function_item_references lint
This lint was incorrectly suggesting casting a function to a pointer without
specifying generic type parameters or const generics. This would cause a
compiler error since the missing parameters couldn't be inferred. This commit
fixed the suggestion and added a few tests with generics.
2020-11-01 23:50:17 -04:00
Tomasz Miąsko c0cbf6368d inliner: Remove redundant loop
No functional changes intended.
2020-11-02 00:00:00 +00:00
bors 3e93027557 Auto merge of #78592 - fpoli:nll-facts-dir, r=matthewjasper
Add option to customize the nll-facts' folder location

This PR adds a `nll-facts-dir` option to specify the location of the directory in which NLL facts are dumped into. It works the same way `dump-mir-dir` controls the location used by the `dump-mir` option.
2020-11-02 04:39:05 +00:00
Tomasz Miąsko 3b7157dc1a Assert that locals have storage when used
The validator in visit_local asserts that local has a stroage when used,
but visit_local is never called so validation is ineffective.

Use super_statement and super_terminator to ensure that locals are visited.
2020-10-31 21:06:29 +01:00
Ralf Jung 289c0d8489 Retagging: do not retag 'raw reborrows' 2020-10-31 15:31:27 +01:00
Mara Bos 841f0e7f2c
Rollup merge of #78577 - tmiasko:validate-aliasing, r=jonas-schievink
validator: Extend aliasing check to a call terminator
2020-10-31 09:49:38 +01:00
bors 0d033dee3e Auto merge of #78182 - LeSeulArtichaut:ty-visitor-contolflow, r=lcnr,oli-obk
TypeVisitor: use `std::ops::ControlFlow` instead of `bool`

Implements MCP rust-lang/compiler-team#374.

Blocked on FCP in rust-lang/compiler-team#374.
r? `@lcnr` cc `@jonas-schievink`
2020-10-30 22:53:55 +00:00
Federico Poli 97a65b6f81 Add option to customize the nll-facts' folder location 2020-10-30 21:33:08 +01:00
LeSeulArtichaut 9433eb83fe Remove implicit Continue type 2020-10-30 12:27:47 +01:00
LeSeulArtichaut 24e1a7e656 Use ControlFlow::is{break,continue} 2020-10-30 12:27:46 +01:00
LeSeulArtichaut 61f8182cec TypeVisitor: use ControlFlow in rustc_{mir,privacy,traits,typeck} 2020-10-30 12:27:44 +01:00
Camelid f558d96253 Link to pass docs from NRVO module docs 2020-10-29 23:05:45 -07:00
Tomasz Miąsko b816e5dfb4 validator: Extend aliasing check to a call terminator 2020-10-30 00:00:00 +00:00
Yuki Okushi 30d1d8f5da
Rollup merge of #78494 - bugadani:typo2, r=jonas-schievink
Fix typos
2020-10-29 12:09:03 +09:00
Yuki Okushi 5e3cc6e913
Rollup merge of #78475 - RalfJung:validity-comment, r=oli-obk
fix a comment in validity check

A few things changed since that comment was written; update it to the current reality.

r? @oli-obk
2020-10-29 12:08:55 +09:00
Dániel Buga 0fabbf9713 Fix typos 2020-10-28 19:32:28 +01:00
Ralf Jung c90ef979de fix a comment in validity check 2020-10-28 10:39:21 +01:00
Dylan DPC 54ea0f9ccd
Rollup merge of #78351 - RalfJung:validity-unsafe-cell, r=oli-obk
Move "mutable thing in const" check from interning to validity

This moves the check for mutable things (such as `UnsafeCell` or `&mut`) in a`const` from interning to validity. That means we can give more targeted error messages (pointing out *where* the problem lies), and we can simplify interning a bit.

Also fix the interning mode used for promoteds in statics.

r? @oli-obk
2020-10-28 01:21:18 +01:00
Dylan DPC 346aeef496
Rollup merge of #78152 - spastorino:separate-unsized-locals, r=oli-obk
Separate unsized locals

Closes #71694

Takes over again #72029 and #74971

cc @RalfJung @oli-obk @pnkfelix @eddyb as they've participated in previous reviews of this PR.
2020-10-28 01:21:08 +01:00
Santiago Pastorino 00fd703eb7
Use unsized_feature_enabled helper function 2020-10-27 14:45:42 -03:00
Santiago Pastorino 9584b00b1d
is -> are both 2020-10-27 14:45:41 -03:00
Santiago Pastorino f0fe0a6eba
or -> and 2020-10-27 14:45:40 -03:00
Santiago Pastorino 708fc3b1a2
Add unsized_fn_params feature 2020-10-27 14:45:02 -03:00
bors 07e968b640 Auto merge of #76269 - ayrtonm:function-reference-lint, r=oli-obk
added a lint against function references

this lint suggests casting function references to `*const ()`
closes #75239
r? `@RalfJung`
2020-10-27 16:32:23 +00:00
Ayrton c791c64e84 Added suggestion to function_item_references lint and fixed warning message
Also updated tests accordingly and tweaked some wording in the lint declaration.
2020-10-27 11:04:04 -04:00
Ayrton 935fc3642a Added documentation for function_item_references lint
Added documentation for `function_item_references` lint to the rustc book and
fixed comments in the lint checker itself.
2020-10-27 11:04:04 -04:00
Ayrton d6fa7e15d6 Fixed compiler error in lint checker triggered by associated types
When a function argument bound by `Pointer` is an associated type, we only
perform substitutions using the parameters from the callsite but don't attempt
to normalize since it may not succeed. A simplified version of the scenario that
triggered this error was added as a test case. Also fixed `Pointer::fmt` which
was being double-counted when called outside of macros and added a test case for
this.
2020-10-27 11:04:04 -04:00
Ayrton 432ebd57ef Removed test for unhandled case in function_item_references lint
Removed test for the unhandled case of calls to `fn f<T>(x: &T)` where `x` is a
function reference and is formatted as a pointer in `f`. This compiles since
`&T` implements `Pointer`, but is unlikely to occur in practice. Also tweaked
the lint's wording and modified tests accordingly.
2020-10-27 11:04:04 -04:00
Ayrton 511fe048b4 Changed lint to check for std::fmt::Pointer and transmute
The lint checks arguments in calls to `transmute` or functions that have
`Pointer` as a trait bound and displays a warning if the argument is a function
reference. Also checks for `std::fmt::Pointer::fmt` to handle formatting macros
although it doesn't depend on the exact expansion of the macro or formatting
internals. `std::fmt::Pointer` and `std::fmt::Pointer::fmt` were also added as
diagnostic items and symbols.
2020-10-27 11:04:04 -04:00
Ayrton 3214de7359 modified lint to work with MIR
Working with MIR let's us exclude expressions like `&fn_name as &dyn Something`
and `(&fn_name)()`. Also added ABI, unsafety and whether a function is variadic
in the lint suggestion, included the `&` in the span of the lint and updated the
test.
2020-10-27 11:04:04 -04:00
Oliver Scherer c8a866ea17 Show the inline stack of MIR lints that only occur after inlining 2020-10-27 14:08:07 +00:00
Jonas Schievink 0be35cf9c7 Disable "optimization to avoid load of address" in InstCombine 2020-10-27 10:59:28 +01:00
bors a4d30a7b49 Auto merge of #77876 - tmiasko:simplify-locals, r=wesleywiser
Remove unused set-discriminant statements and assignments regardless of rvalue

* Represent use counts with u32
* Unify use count visitors
* Change RemoveStatements visitor into a function
* Remove unused set-discriminant statements
* Use exhaustive match to clarify what is being optimized
* Remove unused assignments regardless of rvalue kind
2020-10-26 23:22:39 +00:00
bors 0da6d42f29 Auto merge of #68965 - eddyb:mir-inline-scope, r=nagisa,oli-obk
rustc_mir: track inlined callees in SourceScopeData.

We now record which MIR scopes are the roots of *other* (inlined) functions's scope trees, which allows us to generate the correct debuginfo in codegen, similar to what LLVM inlining generates.
This PR makes the `ui` test `backtrace-debuginfo` pass, if the MIR inliner is turned on by default.

Also, `#[track_caller]` is now correct in the face of MIR inlining (cc `@anp).`

Fixes #76997.

r? `@rust-lang/wg-mir-opt`
2020-10-26 18:50:22 +00:00
Tomasz Miąsko 4c3e06a0ba simplify-locals: Remove unused assignments regardless of rvalue kind 2020-10-26 10:48:28 +01:00
Tomasz Miąsko 52d3782685 simplify-locals: Remove unused set-discriminant statements
Update affected ui & incremental tests to use a user declared variable
bindings instead of temporaries. The former are preserved because of
debuginfo, the latter are not.
2020-10-26 10:41:44 +01:00
Tomasz Miąsko e1e48ae29b simplify-locals: Change RemoveStatements visitor into a function
No functionl changes intended.
2020-10-26 10:33:45 +01:00
Tomasz Miąsko a6b64be8b5 simplify-locals: Unify use count visitors
The simplify locals implementation uses two different visitors to update
the locals use counts. The DeclMarker calculates the initial use counts.
The StatementDeclMarker updates the use counts as statements are being
removed from the block.

Replace them with a single visitor that can operate in either mode,
ensuring consistency of behaviour.

Additionally use exhaustive match to clarify what is being optimized.

No functional changes intended.
2020-10-26 10:33:39 +01:00
Tomasz Miąsko 11269536e2 simplify-locals: Represent use counts with u32 2020-10-26 10:33:31 +01:00
Ralf Jung 744dfd8847 explain why interning is not as trivial as it might seem 2020-10-26 08:56:54 +01:00
Ralf Jung 18fd58e9d1 interning cleanup: we no longer need to distinguish Const and ConstInner; we no longer need the ignore_interior_mut_in_const hack 2020-10-26 08:56:54 +01:00
Ralf Jung 9b501edf08 move &mut-in-const check from interning to validation 2020-10-26 08:56:54 +01:00
Ralf Jung 0e014be359 move UnsafeCell-in-const check from interning to validation 2020-10-26 08:56:54 +01:00
Ralf Jung d0a23e613d ensure we intern all promoteds as InternKind::Promoted 2020-10-26 08:56:54 +01:00
Dylan DPC 8646c2a15b
Rollup merge of #78247 - simonvandel:fix-78192, r=oli-obk
Fix #78192

Check which places are marked dead.

Fixes #78192
2020-10-26 03:09:08 +01:00
bors 4760b8fb88 Auto merge of #78179 - RalfJung:miri-comments, r=oli-obk
Miri engine: entirely skip interning of ZST, and improve some comments

r? `@oli-obk`
2020-10-25 20:15:44 +00:00
Yuki Okushi 72e02b015e
Rollup merge of #78208 - liketechnik:issue-69399, r=oli-obk
replace `#[allow_internal_unstable]` with `#[rustc_allow_const_fn_unstable]` for `const fn`s

`#[allow_internal_unstable]` is currently used to side-step feature gate and stability checks.
While it was originally only meant to be used only on macros, its use was expanded to `const fn`s.

This pr adds stricter checks for the usage of `#[allow_internal_unstable]` (only on macros) and introduces the `#[rustc_allow_const_fn_unstable]` attribute for usage on `const fn`s.

This pr does not change any of the functionality associated with the use of `#[allow_internal_unstable]` on macros or the usage of `#[rustc_allow_const_fn_unstable]` (instead of `#[allow_internal_unstable]`) on `const fn`s (see https://github.com/rust-lang/rust/issues/69399#issuecomment-712911540).

Note: The check for `#[rustc_allow_const_fn_unstable]` currently only validates that the attribute is used on a function, because I don't know how I would check if the function is a `const fn` at the place of the check. I therefore openend this as a 'draft pull request'.

Closes rust-lang/rust#69399

r? @oli-obk
2020-10-25 18:43:40 +09:00
Yuki Okushi dbdc61f9f9
Rollup merge of #78085 - wesleywiser:mir_validation_switch_int, r=oli-obk
MIR validation should check `SwitchInt` values are valid for the type

Fixes #75440
2020-10-25 18:43:38 +09:00
bors 36a74944cb Auto merge of #77526 - RalfJung:dont-promote-unions, r=lcnr
stop promoting union field accesses in 'const'

Turns out that promotion of union field accesses is the only difference between "promotion in `const`/`static` bodies" and "explicit promotion". So if we can remove this, we have finally achieved what I thought to already be the case -- that the bodies of `const`/`static` initializers behave the same as explicit promotion contexts.

The reason we do not want to promote union field accesses is that they can introduce UB, i.e., they can go wrong. We want to [minimize the ways promoteds can fail to evaluate](https://github.com/rust-lang/const-eval/issues/53). Also this change makes things more consistent overall, removing a special case that was added without much consideration (as far as I can tell).

Cc `@rust-lang/wg-const-eval`
2020-10-25 02:27:09 +00:00
Jonas Schievink 597b4c5bb4
Rollup merge of #78191 - tmiasko:temp-match-branch-simplification, r=oli-obk
Introduce a temporary for discriminant value in MatchBranchSimplification

The optimization introduces additional uses of the discriminant operand, but
does not ensure that it is still valid to evaluate it or that it still
evaluates to the same value.

Evaluate it once at original position, and store the result in a new temporary.

Follow up on #78151. The optimization remains disabled by default.

Closes #78239.
2020-10-24 22:39:55 +02:00
Jonas Schievink 0a06d7344b
Rollup merge of #78069 - fusion-engineering-forks:core-const-panic-str, r=RalfJung
Fix const core::panic!(non_literal_str).

Invocations of `core::panic!(x)` where `x` is not a string literal expand to `panic!("{}", x)`, which is not understood by the const panic logic right now. This adds `panic_str` as a lang item, and modifies the const eval implementation to hook into this item as well.

This fixes the issue mentioned here: https://github.com/rust-lang/rust/issues/51999#issuecomment-687604248

r? `@RalfJung`

`@rustbot` modify labels: +A-const-eval
2020-10-24 22:39:49 +02:00
Wesley Wiser dd683e5ab5 MIR validation should check SwitchInt values are valid for the type 2020-10-24 16:00:04 -04:00
Jonas Schievink 86c07a4955
Rollup merge of #78198 - tmiasko:assert, r=davidtwco
Simplify assert terminator only if condition evaluates to expected value
2020-10-24 14:12:03 +02:00
Florian Warzecha 13b481b247
rename allow_internal_unstable() to rustc_allow_const_fn_unstable() in rustc_mir
Followup rename from 05f4a9a42a,
which introduced `#[rustc_allow_const_fn_unstable]` for `const fn`s.
2020-10-23 17:14:57 +02:00
Simon Vandel Sillesen 57d01a9aee Check which places are dead
Fixes #78192
2020-10-22 22:23:56 +02:00
Mara Bos 4f7ffbf351 Fix const core::panic!(non_literal_str). 2020-10-22 18:41:35 +02:00
bors ef3e386393 Auto merge of #78212 - JohnTitor:rollup-j5r6xuy, r=JohnTitor
Rollup of 10 pull requests

Successful merges:

 - #77420 (Unify const-checking structured errors for `&mut` and `&raw mut`)
 - #77554 (Support signed integers and `char` in v0 mangling)
 - #77976 (Mark inout asm! operands as used in liveness pass)
 - #78009 (Haiku: explicitly set CMAKE_SYSTEM_NAME when cross-compiling)
 - #78084 (Greatly improve display for small mobile devices screens)
 - #78155 (Fix two small issues in compiler/rustc_lint/src/types.rs)
 - #78156 (Fixed build failure of `rustfmt`)
 - #78172 (Add test case for #77062)
 - #78188 (Add tracking issue number for pin_static_ref)
 - #78200 (Add `ControlFlow::is_{break,continue}` methods)

Failed merges:

r? `@ghost`
2020-10-22 01:35:05 +00:00
Yuki Okushi 6245b951d5
Rollup merge of #77420 - ecstatic-morse:const-checking-raw-mut-ref, r=davidtwco
Unify const-checking structured errors for `&mut` and `&raw mut`

Resolves #77414 as well as a FIXME.
2020-10-22 09:45:25 +09:00
Bastian Kauschke 17825c93ff review 2020-10-21 23:59:35 +02:00
Bastian Kauschke 8752a560b9 Lift: take self by value 2020-10-21 23:59:35 +02:00
Florian Warzecha 05f4a9a42a
switch allow_internal_unstable const fns to rustc_allow_const_fn_unstable 2020-10-21 20:54:20 +02:00
Ralf Jung fcaf2338da Miri engine interning: improve comments, and entirely skip ZST 2020-10-21 09:47:15 +02:00
Ralf Jung 2202653893 Miri engine validity check: simplify code with 'matches!'
and improve a comment a bit
2020-10-21 09:46:51 +02:00
Eduard-Mihai Burtescu aff4d3e659 rustc_mir: run the MIR inlining Integrator on the whole callee body at once. 2020-10-21 05:46:16 +03:00
Eduard-Mihai Burtescu 9b21c50335 rustc_mir: create the Integrator as soon as possible in MIR inlining. 2020-10-21 05:46:16 +03:00
Eduard-Mihai Burtescu 2bfb462b58 rustc_mir: don't throw away inlined locals' spans. 2020-10-21 04:43:56 +03:00
Eduard-Mihai Burtescu 387e31c9a7 rustc_mir: properly map scope parent chains into the caller when inlining. 2020-10-21 04:43:56 +03:00
Eduard-Mihai Burtescu 6451b39a25 rustc_mir: support MIR-inlining #[track_caller] functions. 2020-10-21 04:43:56 +03:00
Eduard-Mihai Burtescu 6bc5eafbce rustc_mir: track inlined callees in SourceScopeData. 2020-10-21 04:43:56 +03:00
Eduard-Mihai Burtescu 708fc0b692 rustc_mir: use Instance more in the inliner. 2020-10-21 04:43:55 +03:00
Eduard-Mihai Burtescu 8c942c1511 rustc_mir: rename location: SourceInfo to source_info. 2020-10-21 04:43:55 +03:00
Tomasz Miąsko a4dc92b483 Introduce a temporary for discriminant value in MatchBranchSimplification
The optimization introduces additional uses of the discriminant operand, but
does not ensure that it is still valid to evaluate it or that it still
evaluates to the same value.

Evaluate it once at original position, and store the result in a new temporary.
2020-10-21 00:00:00 +00:00
Tomasz Miąsko a9470d0522 Simplify assert terminator only if condition evaluates to expected value 2020-10-21 00:00:00 +00:00
Yuki Okushi 83f126bedf
Rollup merge of #78101 - RalfJung:foreign-static, r=oli-obk
fix static_ptr_ty for foreign statics

Cc https://github.com/rust-lang/rust/issues/74840

This does not fix that issue but fixes a problem in `static_ptr_ty` that we noticed while discussing that issue. I also added and updated a few comments. The one about `internal` locals being ignored does not seem to have been true [even in the commit that introduced it](https://github.com/rust-lang/rust/pull/44700/files#diff-ae2f3c7e2f9744f7ef43e96072b10e98d4e3fe74a3a399a3ad8a810fbe56c520R139).

r? @oli-obk
2020-10-21 13:59:43 +09:00
Tomasz Miąsko e200a4a0d2 Disable "optimization to avoid load of address" in InstCombine 2020-10-21 00:00:00 +00:00
Guillaume Gomez 3fea201b11
Rollup merge of #78061 - wesleywiser:opt_zst_const_interning, r=oli-obk
Optimize const value interning for ZST types

Interning can skip any inhabited ZST type in general.

Fixes #68010

r? @oli-obk
2020-10-20 21:46:32 +02:00
Tomasz Miąsko c2af254e3b Disable MatchBranchSimplification
This optimization can result in unsoundness, because it introduces
additional uses of a place holding the discriminant value without
ensuring that it is valid to do so.
2020-10-20 00:00:00 +00:00
Ralf Jung c1766c6372 fix static_ptr_ty for foreign statics, and more comments in check_unsafety 2020-10-19 09:47:18 +02:00
bors 4d247ad7d3 Auto merge of #77306 - lcnr:inline-ok, r=eddyb
normalize substs while inlining

fixes #68347 or more precisely, this fixes the same ICE in rust analyser as veloren is pinned to a specific nightly
and had an error with the current one.

I didn't look into creating an MVCE here as that seems fairly annoying, will spend a few minutes doing so rn. (failed)

r? `@eddyb` cc `@bjorn3`
2020-10-18 16:10:00 +00:00
bors 834821e3b6 Auto merge of #78066 - bugadani:wat, r=jonas-schievink
Clean up small, surprising bits of code

This PR clean up a small number of unrelated, small things I found while browsing the code base.
2020-10-18 13:50:31 +00:00
Dániel Buga f3a0f68453 Zip -> Enumerate 2020-10-18 11:01:08 +02:00
Wesley Wiser 1d07d696d2 Optimize const value interning for ZST types
Interning can skip any inhabited ZST type in general.
2020-10-17 16:07:00 -04:00
bors ffeeb20398 Auto merge of #77373 - jonas-schievink:rm-rf-copy-prop, r=oli-obk
Remove the old copy propagation pass

This pass was added a long time ago, and has not really seen much improvement since (apart from some great work in https://github.com/rust-lang/rust/pull/76569 that unfortunately ran into preexisting soundness issues). It is slow and unsound, and we now have a destination propagation pass that performs a related optimization and could be extended.

Closes https://github.com/rust-lang/rust/issues/36673
Closes https://github.com/rust-lang/rust/issues/73717
Closes https://github.com/rust-lang/rust/issues/76740
2020-10-17 16:57:21 +00:00
Dylan DPC 496e2feed6
Rollup merge of #76199 - Mark-Simulacrum:void-zero, r=nikomatsakis
Permit uninhabited enums to cast into ints

This essentially reverts part of #6204; it is unclear why that [commit](c0f587de34) was introduced, and I suspect no one remembers.

The changed code was only called from casting checks and appears to not affect any callers of that code (other than permitting this one case).

Fixes #75647.
2020-10-17 03:27:12 +02:00
Jonas Schievink dc3177775c Remove the old copy propagation pass 2020-10-17 02:25:31 +02:00
Yuki Okushi d334059696
Rollup merge of #77992 - nagisa:thaw-coverage-instrumentation, r=wesleywiser
instrument-coverage: try our best to not ICE

instrument-coverage was ICEing for me on some code, in particular code
that had devirtualized paths from standard library. Instrument coverage
probably has no bussiness dictating which paths are valid and which
aren't so just feed it everything and whatever and let tooling deal with
other stuff.

For example, with this commit we can generate coverage hitpoints for
these interesting paths:

* `/rustc/.../library/core/lib.rs` – non-devirtualized path for libcore
* `/home/.../src/library/core/lib.rs` – devirtualized version of above
* `<inline asm>`, `<anon>` and many similar synthetic paths

Even if those paths somehow get to the instrumentation pass, I'd much
rather get hits for these weird paths and hope some of them work (as
would be the case for devirtualized path to libcore), rather than have
compilation fail entirely.
2020-10-17 05:36:52 +09:00
Simonas Kazlauskas 8436cfe71d instrument-coverage: try our best to not ICE
instrument-coverage was ICEing for me on some code, in particular code
that had devirtualized paths from standard library. Instrument coverage
probably has no bussiness dictating which paths are valid and which
aren't so just feed it everything and whatever and let tooling deal with
other stuff.

For example, with this commit we can generate coverage hitpoints for
these interesting paths:

* `/rustc/.../library/core/lib.rs` – non-devirtualized path for libcore
* `/home/.../src/library/core/lib.rs` – devirtualized version of above
* `<inline asm>`, `<anon>` and many similar synthetic paths

Even if those paths somehow get to the instrumentation pass, I'd much
rather get hits for these weird paths and hope some of them work (as
would be the case for devirtualized path to libcore), rather than have
compilation fail entirely.
2020-10-16 21:46:41 +03:00
bors 9bd740a8f1 Auto merge of #77947 - tmiasko:promoted-scope, r=oli-obk
Create a single source scope for promoteds

A promoted inherits all scopes from the parent body.  At the same time,
almost all statements and terminators inside the promoted body so far
refer only to one of those scopes: the outermost one.

Instead of inheriting all scopes, inherit only a single scope
corresponding to the location of the promoted, making sure that there
are no references to other scopes.
2020-10-16 02:27:49 +00:00
est31 4fa5578774 Replace target.target with target and target.ptr_width with target.pointer_width
Preparation for a subsequent change that replaces
rustc_target::config::Config with its wrapped Target.

On its own, this commit breaks the build. I don't like making
build-breaking commits, but in this instance I believe that it
makes review easier, as the "real" changes of this PR can be
seen much more easily.

Result of running:

find compiler/ -type f -exec sed -i -e 's/target\.target\([)\.,; ]\)/target\1/g' {} \;
find compiler/ -type f -exec sed -i -e 's/target\.target$/target/g' {} \;
find compiler/ -type f -exec sed -i -e 's/target.ptr_width/target.pointer_width/g' {} \;
./x.py fmt
2020-10-15 12:02:24 +02:00
Yuki Okushi ccc86bbb40
Rollup merge of #77946 - tmiasko:validate-source-scope, r=jonas-schievink
Validate references to source scopes
2020-10-15 07:32:39 +09:00
Yuki Okushi df08fe7214
Rollup merge of #77936 - est31:remove_needless_alloc_slice, r=jonas-schievink
Remove needless alloc_slice

Don't invoke alloc_slice.

Arenas are temporary,
empty slices are eternal!
2020-10-15 07:32:37 +09:00
est31 301907497f Remove needless alloc_slice
Don't invoke alloc_slice.

Arenas are temporary,
empty slices are eternal!
2020-10-14 14:23:32 +02:00
est31 215cd36e1c Remove unused code from remaining compiler crates 2020-10-14 04:14:32 +02:00
Tomasz Miąsko db54752082 Create a single source scope for promoteds
A promoted inherits all scopes from the parent body.  At the same time,
almost all statements and terminators inside the promoted body so far
refer only to one of those scopes: the outermost one.

Instead of inheriting all scopes, inherit only a single scope
corresponding to the location of the promoted, making sure that there
are no references to other scopes.
2020-10-14 00:00:00 +00:00
Tomasz Miąsko 585e737ec1 Validate references to source scopes 2020-10-14 00:00:00 +00:00
Yuki Okushi 70f8e1a56f
Rollup merge of #77892 - est31:remove_redundant_absolute_paths, r=lcnr
Replace absolute paths with relative ones

Modern compilers allow reaching external crates
like std or core via relative paths in modules
outside of lib.rs and main.rs.
2020-10-14 06:02:36 +09:00
est31 a0fc455d30 Replace absolute paths with relative ones
Modern compilers allow reaching external crates
like std or core via relative paths in modules
outside of lib.rs and main.rs.
2020-10-13 14:16:45 +02:00
bors 2d6eccdb67 Auto merge of #77755 - bugadani:perf-calc-dtor, r=ecstatic-morse
Monomorphize `calculate_dtor` instead of using function pointers

Change `calculate_dtor` to avoid dynamic dispatching. This change allows the empty functions to be optimized away.

Based on the discussion in https://github.com/rust-lang/rust/pull/77754#discussion_r502498970, the performance impact of this change was measured.

Perf run results: https://perf.rust-lang.org/compare.html?start=7bc5839e99411aad9061a632b62075d1346cbb3b&end=ffec759ae9bbc4d6d2235ff40ade6723a85bc7cc
2020-10-13 10:19:30 +00:00
bors afb4514c09 Auto merge of #77796 - jonas-schievink:switchint-refactor, r=oli-obk
Refactor how SwitchInt stores jump targets

Closes https://github.com/rust-lang/rust/issues/65693
2020-10-13 00:57:03 +00:00
Yuki Okushi 233319fc65
Rollup merge of #77818 - bugadani:range, r=oli-obk
Mono collector: replace pair of ints with Range

I found the initial PR (#33171) that introduced this piece of code but I didn't find any information about why a tuple was preferred over a `Range<usize>`.

I'm hoping there are no technical reasons to not do this.
2020-10-13 04:08:02 +09:00
Yuki Okushi 687d7646de
Rollup merge of #77550 - lcnr:ty-dep-path-ct-cleanup, r=ecstatic-morse
add shims for WithOptConstParam query calls

r? @ecstatic-morse @eddyb
2020-10-13 04:07:50 +09:00
bors 8cc82ee340 Auto merge of #77793 - tmiasko:no-op-discriminant, r=ecstatic-morse
Recognize discriminant reads as no-ops in RemoveNoopLandingPads

The cleanup blocks often contain read of discriminants. Teach
RemoveNoopLandingPads to recognize them as no-ops to remove
additional no-op landing pads.
2020-10-11 16:33:47 +00:00
Jonas Schievink 9a47f74bfe Use SmallVec in SwitchTargets
This allows building common SwitchTargets (eg. for `if`s) without
allocation.
2020-10-11 01:14:12 +02:00
Dániel Buga 0a2a68edae Use range instead of tuple of ints 2020-10-10 22:33:22 +02:00
Jonas Schievink 432535da2b Refactor how SwitchInt stores jump targets 2020-10-10 17:46:11 +02:00
Dániel Buga 0d27b765a6 Take functions by value 2020-10-10 16:19:53 +02:00
Tomasz Miąsko ecd7862dfb Recognize discriminant reads as no-ops in RemoveNoopLandingPads
The cleanup blocks often contain read of discriminants. Teach
RemoveNoopLandingPads to recognize them as no-ops to remove
additional no-op landing pads.
2020-10-10 00:00:00 +00:00
Dániel Buga 217d6f9741 Revert calculate_dtor signature change 2020-10-09 17:18:57 +02:00
Dániel Buga 7993ddd89d Add find_map_relevant_impl 2020-10-09 16:22:49 +02:00
Lzu Tao ab226bda9a Suggest removing &mut from borrow of &mut
Fix a typo: minding -> binding
Add test for &mut &mut
2020-10-08 14:26:21 +00:00
bors 382848989f Auto merge of #77581 - ecstatic-morse:dataflow-dump-mir-graphviz, r=davidtwco
Use `pretty::create_dump_file` for dumping dataflow results

The old code wasn't incorporating promoteds into the path, meaning other `dot` files could get clobbered. Use the MIR dump infrastructure to generate paths so that this doesn't occur in the future.
2020-10-08 11:42:24 +00:00
bors e055f87cdf Auto merge of #77597 - simonvandel:uninhabited-hashset, r=jonas-schievink
perf: UninhabitedEnumBranching avoid n^2

Avoid n² complexity. This showed up in a profile for match-stress-enum that has 8192 variants

I have only profiled locally against `match-stress-enum`, so we should have it perf tested to make sure it does not regress other crates.
2020-10-07 23:44:57 +00:00
Simon Vandel Sillesen e231c47aa6 perf: UninhabitedEnumBranching void n^2
Avoid n² complexity. This showed up in a profile for match-stress-enum that has 8192 variants
2020-10-07 22:06:08 +02:00
bors 4437b4b150 Auto merge of #77464 - ecstatic-morse:const-fn-impl-trait, r=oli-obk
Give `impl Trait` in a `const fn` its own feature gate

...previously it was gated under `#![feature(const_fn)]`.

I think we actually want to do this in all const-contexts? If so, this should be `#![feature(const_impl_trait)]` instead. I don't think there's any way to make use of `impl Trait` within a `const` initializer.

cc #77463

r? `@oli-obk`
2020-10-07 19:59:52 +00:00
Bastian Kauschke f0487cee74 normalize substs during inlining 2020-10-07 10:04:08 +02:00
Dylan DPC 6b4dbb196c
Rollup merge of #77582 - ecstatic-morse:disable-early-otherwise-branch, r=wesleywiser
Move `EarlyOtherwiseBranch` to mir-opt-level 2

cc #75119

This didn't have an [effect in most cases](https://perf.rust-lang.org/compare.html?start=81e02708f1f4760244756548981277d5199baa9a&end=2e0edc0f28c5647141bedba02e7a222d3a5dc9c3&stat=instructions:u), and is not trivially sound. Let it bake at `mir-opt-level=2` for a while.

Also, this missed the cutoff for beta, so we'll have to backport this.
r? @wesleywiser
2020-10-07 00:16:08 +02:00
Dylan DPC 83c58d6fb6
Rollup merge of #77568 - lcnr:mir-inline-def-id, r=ecstatic-morse
inliner: use caller param_env

We used the callee param env instead of the caller param env by accident in #77430, this PR fixes that and caches it in the `Inliner` struct.

fixes #77564

r? @ecstatic-morse
2020-10-07 00:16:05 +02:00
Matthew Jasper 69fc6d8c5c Fix NLL compare mode tests 2020-10-06 11:19:33 +01:00
Yuki Okushi 2970af8e28
Rollup merge of #77559 - camelid:fix-rustdoc-warnings-invalid-rust-syntax, r=lcnr
Fix rustdoc warnings about invalid Rust syntax
2020-10-06 16:26:09 +09:00
Dylan MacKenzie 9beb6f81e4 Make impl Trait unstable in all contexts 2020-10-05 21:44:00 -07:00
Dylan MacKenzie c4ef5fdf8f Remove fn from feature name 2020-10-05 21:44:00 -07:00
Dylan MacKenzie e1d76818b2 Add #![feature(const_fn_impl)] 2020-10-05 19:56:50 -07:00
Camelid c8d25af698 Fixup 2020-10-05 15:07:27 -07:00
Dylan MacKenzie af4b13283f Move EarlyOtherwiseBranch to mir-opt-level 2
This didn't have an effect in most cases, and is not trivially sound.
Let it bake at `mir-opt-level=2` for a while.
2020-10-05 10:21:14 -07:00
Dylan MacKenzie 3b87398738 Print to stderr when a graphviz file can't be written
`warn` prints nothing by default
2020-10-05 10:14:40 -07:00
Dylan MacKenzie 29e5e6e766 Use MIR dump interface for dataflow 2020-10-05 10:14:40 -07:00
Rich Kadel 6f627663a7 Renamed tests to avoid exceeding Windows max path limit 2020-10-05 09:40:25 -07:00
Rich Kadel f5aebad28f Updates to experimental coverage counter injection
This is a combination of 18 commits.

Commit #2:

Additional examples and some small improvements.

Commit #3:

fixed mir-opt non-mir extensions and spanview title elements

Corrected a fairly recent assumption in runtest.rs that all MIR dump
files end in .mir. (It was appending .mir to the graphviz .dot and
spanview .html file names when generating blessed output files. That
also left outdated files in the baseline alongside the files with the
incorrect names, which I've now removed.)

Updated spanview HTML title elements to match their content, replacing a
hardcoded and incorrect name that was left in accidentally when
originally submitted.

Commit #4:

added more test examples

also improved Makefiles with support for non-zero exit status and to
force validation of tests unless a specific test overrides it with a
specific comment.

Commit #5:

Fixed rare issues after testing on real-world crate

Commit #6:

Addressed PR feedback, and removed temporary -Zexperimental-coverage

-Zinstrument-coverage once again supports the latest capabilities of
LLVM instrprof coverage instrumentation.

Also fixed a bug in spanview.

Commit #7:

Fix closure handling, add tests for closures and inner items

And cleaned up other tests for consistency, and to make it more clear
where spans start/end by breaking up lines.

Commit #8:

renamed "typical" test results "expected"

Now that the `llvm-cov show` tests are improved to normally expect
matching actuals, and to allow individual tests to override that
expectation.

Commit #9:

test coverage of inline generic struct function

Commit #10:

Addressed review feedback

* Removed unnecessary Unreachable filter.
* Replaced a match wildcard with remining variants.
* Added more comments to help clarify the role of successors() in the
CFG traversal

Commit #11:

refactoring based on feedback

* refactored `fn coverage_spans()`.
* changed the way I expand an empty coverage span to improve performance
* fixed a typo that I had accidently left in, in visit.rs

Commit #12:

Optimized use of SourceMap and SourceFile

Commit #13:

Fixed a regression, and synched with upstream

Some generated test file names changed due to some new change upstream.

Commit #14:

Stripping out crate disambiguators from demangled names

These can vary depending on the test platform.

Commit #15:

Ignore llvm-cov show diff on test with generics, expand IO error message

Tests with generics produce llvm-cov show results with demangled names
that can include an unstable "crate disambiguator" (hex value). The
value changes when run in the Rust CI Windows environment. I added a sed
filter to strip them out (in a prior commit), but sed also appears to
fail in the same environment. Until I can figure out a workaround, I'm
just going to ignore this specific test result. I added a FIXME to
follow up later, but it's not that critical.

I also saw an error with Windows GNU, but the IO error did not
specify a path for the directory or file that triggered the error. I
updated the error messages to provide more info for next, time but also
noticed some other tests with similar steps did not fail. Looks
spurious.

Commit #16:

Modify rust-demangler to strip disambiguators by default

Commit #17:

Remove std::process::exit from coverage tests

Due to Issue #77553, programs that call std::process::exit() do not
generate coverage results on Windows MSVC.

Commit #18:

fix: test file paths exceeding Windows max path len
2020-10-05 08:02:58 -07:00
SNCPlay42 5042dbdb2e add RegionNameHighlight::Occluded 2020-10-05 14:01:42 +01:00
SNCPlay42 34ff352989 don't refer to async as 'generators'
and give return of async fn a better span
2020-10-05 14:01:42 +01:00
bors d890e64dff Auto merge of #77549 - tmiasko:simplify-branch-same-fix, r=oli-obk
Fix miscompile in SimplifyBranchSame

Cherry-picked from #77486, but with a different test case that used to be compiled incorrectly on both master & beta branches.
2020-10-05 11:41:59 +00:00
bors 62bfcfd8a3 Auto merge of #77552 - ecstatic-morse:body-def-id, r=lcnr
Replace `(Body, DefId)` with `Body` where possible

Follow-up to #77430.

I `grep`-ed for parameter lists in which a `Body` appeared within a few lines of a `DefId`, so it's possible that I missed some cases, but this should be pretty complete. Most of these changes were mechanical, but there's a few places where I started calling things "caller" and "callee" when multiple `DefId`s were in-scope at once. Also, we should probably have a helper function on `Body` that returns a `LocalDefId`. I can do that in this PR or in a follow-up.
2020-10-05 09:26:32 +00:00
Bastian Kauschke daf48b82ab inliner: use caller param_env 2020-10-05 11:04:25 +02:00
Bastian Kauschke 8160bfa39c query_name_of_opt_const_arg -> query_name_opt_const_arg 2020-10-05 08:49:21 +02:00
bors efbaa41306 Auto merge of #77557 - Dylan-DPC:rollup-aib9ptp, r=Dylan-DPC
Rollup of 11 pull requests

Successful merges:

 - #75853 (Use more intra-doc-links in `core::fmt`)
 - #75928 (Remove trait_selection error message in specific case)
 - #76329 (Add check for doc alias attribute at crate level)
 - #77219 (core::global_allocator docs link to std::alloc::GlobalAlloc)
 - #77395 (BTreeMap: admit the existence of leaf edges in comments)
 - #77407 (Improve build-manifest to work with the improved promote-release)
 - #77426 (Include scope id in SocketAddrV6::Display)
 - #77439 (Fix missing diagnostic span for `impl Trait` with const generics, and add various tests for `min_const_generics` and `const_generics`)
 - #77471 (BTreeMap: refactoring around edges, missed spots)
 - #77512 (Allow `Abort` terminators in all const-contexts)
 - #77514 (Replace some once(x).chain(once(y)) with [x, y] IntoIter)

Failed merges:

r? `@ghost`
2020-10-05 02:49:51 +00:00
Camelid c877ff3664 Fix rustdoc warnings about invalid Rust syntax 2020-10-04 19:35:44 -07:00
bors ced813fec0 Auto merge of #77466 - Aaron1011:reland-drop-tree, r=matthewjasper
Re-land PR #71840 (Rework MIR drop tree lowering)

PR https://github.com/rust-lang/rust/pull/71840 was reverted in https://github.com/rust-lang/rust/pull/72989 to fix an LLVM error (https://github.com/rust-lang/rust/issues/72470). That LLVM error no longer occurs with the recent upgrade to LLVM 11 (https://github.com/rust-lang/rust/pull/73526), so let's try re-landing this PR.

I've cherry-picked the commits from the original PR (with the exception of the commit blessing test output), making as few modifications as possible. I addressed the rebase fallout in separate commits on top of those.

r? `@matthewjasper`
2020-10-05 00:35:58 +00:00
Dylan DPC 5fbb41108a
Rollup merge of #77512 - ecstatic-morse:const-checking-allow-abort, r=RalfJung
Allow `Abort` terminators in all const-contexts

We never unwind during const-eval, so we basically have these semantics already. Also I just figured out that these only appear along the cleanup path, which doesn't get const-checked. In other words, this doesn't actually change behavior: the `check-pass` test I added compiles just fine on nightly.

r? @RalfJung
cc @rust-lang/wg-const-eval
2020-10-05 02:29:40 +02:00
Dylan MacKenzie 04a94abcb9 Remove DefId from MirBorrowckCtxt 2020-10-04 17:23:55 -07:00
Dylan MacKenzie fff3b7596a nll: solve 2020-10-04 17:22:40 -07:00
Dylan MacKenzie 2e35cf973b Replace (Body, WithOptConstParam) with Body where possible 2020-10-04 16:59:51 -07:00
Dylan MacKenzie e72e43c730 Replace (Body, DefId) with Body where possible
A `Body` now contains its `MirSource`, which in turn contains the
`DefId` of the item associated with the `Body`.
2020-10-04 16:07:03 -07:00
Bastian Kauschke 536674fb69 cleanup WithOptConstParam queries 2020-10-04 23:22:08 +02:00
ecstatic-morse fe97990e23
Add comment to Abort match arm
Co-authored-by: Ralf Jung <post@ralfj.de>
2020-10-04 13:02:54 -07:00
Dylan MacKenzie 6f61e71648 Remember the MirSource for each Body 2020-10-04 11:01:38 -07:00
Dylan MacKenzie 938d8fd805 Move MirSource to rustc_middle 2020-10-04 11:01:13 -07:00
Dylan MacKenzie 25fdbaff44 Discuss cleanup blocks and span_bug on Abort 2020-10-04 10:41:08 -07:00
Ralf Jung d727f642b9 stop promoting union field accesses in 'const' 2020-10-04 15:25:26 +02:00
Aaron Hill 4c83eec008
Fix rebase fallout 2020-10-04 07:54:02 -04:00
Matthew Jasper 8902ce5d84
Address review comments 2020-10-04 07:54:02 -04:00
Matthew Jasper f810e600cd
Reduce the number of drop-flag assignments in unwind paths 2020-10-04 07:54:01 -04:00
Matthew Jasper fa3e2fcbe4
Defer creating drop trees in MIR lowering until leaving that scope 2020-10-04 07:54:01 -04:00
Yuki Okushi 6e25418474
Rollup merge of #75143 - oli-obk:tracing, r=RalfJung
Use `tracing` spans to trace the entire MIR interp stack

r? @RalfJung

While being very verbose, this allows really good tracking of what's going on. While I considered schemes like the previous indenter that we had (which we could get by using the `tracing-tree` crate), this will break down horribly with things like multithreaded rustc. Instead, we can now use `RUSTC_LOG` to restrict the things being traced. You could specify a filter in a way that only shows the logging of a specific frame.

![screenshot of command line output of the new formatting](https://user-images.githubusercontent.com/332036/89291343-aa40de00-d65a-11ea-9f6c-ea06c1806327.png)

If we lower the span's level to `debug`, then in `info` level logging we'd not see the frames, but in `debug` level we would see them. The filtering rules in `tracing` are super powerful, but  I'm not sure if we can specify a filter so we do see `debug` level events, but *not* the `frame` spans. The documentation at https://docs.rs/tracing-subscriber/0.2.10/tracing_subscriber/struct.EnvFilter.html makes me think that we can only turn on things, not turn off things at a more precise level.

cc @hawkw
2020-10-04 11:44:49 +09:00
Tomasz Miąsko 59c243331d Enable RenameReturnPlace MIR optimization on mir-opt-level >= 2
The destination propagation as currently implemented does not supersede
the NRVO, e.g., the destination propagation never applies if either
local has an address taken, while NRVO might.

Additionally, the issue with failing assertions had been already
resolved.

Continue running both optimizations at mir-opt-level >= 2.
2020-10-04 00:00:00 +00:00
Simon Vandel Sillesen 80d5017a6e Fix miscompile in SimplifyBranchSame 2020-10-04 00:00:00 +00:00
Dylan MacKenzie 98a2292919 Allow Abort terminators in a const-context
These appear along the cleanup path inside functions with
`#[unwind(aborts)]`. We don't const-check the cleanup path anyways,
since const-eval already has "abort-on-panic" semantics and there's
often drops that would otherwise be forbidden, so the check wasn't
really preventing anything anyways.
2020-10-03 14:38:01 -07:00
Jonas Schievink 6522868664
Rollup merge of #77251 - dtolnay:drop, r=Aaron1011
Bypass const_item_mutation if const's type has Drop impl

Follow-up to #75573. This PR disables the const_item_mutation lint in cases that the const has a Drop impl which observes the mutation.

```rust
struct Log { msg: &'static str }
const LOG: Log = Log { msg: "" };
impl Drop for Log {
    fn drop(&mut self) { println!("{}", self.msg); }
}

LOG.msg = "wow";  // prints "wow"
```

r? @Aaron1011
2020-10-03 00:31:12 +02:00
bors 8876ffc923 Auto merge of #77462 - jonas-schievink:rollup-m0rqdh5, r=jonas-schievink
Rollup of 12 pull requests

Successful merges:

 - #76101 (Update RELEASES.md for 1.47.0)
 - #76739 (resolve: prohibit anon const non-static lifetimes)
 - #76811 (Doc alias name restriction)
 - #77405 (Add tracking issue of iter_advance_by feature)
 - #77409 (Add example for iter chain struct)
 - #77415 (Better error message for `async` blocks in a const-context)
 - #77423 (Add `-Zprecise-enum-drop-elaboration`)
 - #77432 (Use posix_spawn on musl targets)
 - #77441 (Fix AVR stack corruption bug)
 - #77442 (Clean up on example doc fixes for ptr::copy)
 - #77444 (Fix span for incorrect pattern field and add label)
 - #77453 (Stop running macOS builds on Azure Pipelines)

Failed merges:

r? `@ghost`
2020-10-02 19:42:07 +00:00
Jonas Schievink 1e3c7e214a
Rollup merge of #77423 - ecstatic-morse:discriminant-switch-effect-config, r=pnkfelix
Add `-Zprecise-enum-drop-elaboration`

Its purpose is to assist in debugging #77382 and #74551. Passing `-Zprecise-enum-drop-elaboration=no` will turn off the added precision that seems to be causing issues on some platforms. This assumes that we can reproduce #77382 on the latest master. I should have done this earlier. Oh well.

cc @cuviper
r? @pnkfelix
2020-10-02 20:27:09 +02:00
Jonas Schievink cac5352e33
Rollup merge of #77415 - ecstatic-morse:const-checking-async-block, r=oli-obk
Better error message for `async` blocks in a const-context

Improves the error message for the case in #77361.

r? @oli-obk
2020-10-02 20:27:08 +02:00
Jonas Schievink acc150b2e9 validate: skip debuginfo 2020-10-02 16:50:29 +02:00
Jonas Schievink c1a431edc3 validate: storage must be allocated on local use 2020-10-02 16:11:47 +02:00
Wesley Wiser f9d7720be7 Disable the SimplifyArmIdentity mir-opt
The optimization still has some bugs that need to be worked out
such as #77359.

We can try re-enabling this again after the known issues are resolved.
2020-10-01 20:29:53 -04:00
David Tolnay 804d159c62
Fixme with link for re-enabling const mutation lint for Drop consts 2020-10-01 13:41:43 -07:00
Dylan MacKenzie 6691d11234 Add -Zprecise-enum-drop-elaboration
Its purpose is to assist in debugging #77382 and #74551.
2020-10-01 11:31:43 -07:00
Dylan MacKenzie 77e6c56ab6 Unify &mut and &raw mut const-checking errors 2020-10-01 11:04:33 -07:00
Dylan MacKenzie 50e0c0d97b Give better const-checking error for async blocks 2020-10-01 10:11:58 -07:00
bors 9cba260df0 Auto merge of #74839 - alarsyo:multiple_return_terminators, r=oli-obk
Implement multiple return terminator optimization

Closes #72022
2020-10-01 09:52:58 +00:00
Antoine Martin f54bfac074 Implement multiple return terminators optimization 2020-10-01 10:06:37 +02:00
bors fc42fb8e70 Auto merge of #77354 - ecstatic-morse:const-checking-moar-errors, r=oli-obk
Overhaul const-checking diagnostics

The primary purpose of this PR was to remove `NonConstOp::STOPS_CONST_CHECKING`, which causes any additional errors found by the const-checker to be silenced. I used this flag to preserve diagnostic parity with `qualify_min_const_fn.rs`, which has since been removed.

However, simply removing the flag caused a deluge of errors in some cases, since an error would be emitted any time a local or temporary had a wrong type. To remedy this, I added an alternative system (`DiagnosticImportance`) to silence additional error messages that were likely to distract the user from the underlying issue. When an error of the highest importance occurs, all less important errors are silenced. When no error of the highest importance occurs, all less important errors are emitted after checking is complete. Following the suggestions from the important error is usually enough to fix the less important errors, so this should lead to better UX most of the time.

There's also some unrelated diagnostics improvements in this PR isolated in their own commits. Splitting them out would be possible, but a bit of a pain. This isn't as tidy as some of my other PRs, but it should *only* affect diagnostics, never whether or not something passes const-checking. Note that there are a few trivial exceptions to this, like banning `Yield` in all const-contexts, not just `const fn`.

As always, meant to be reviewed commit-by-commit.

r? `@oli-obk`
2020-10-01 07:38:47 +00:00
Oliver Scherer 8f9472cc9e Only mention that a stack frame is being popped when starting to do so 2020-10-01 08:32:24 +02:00
David Tolnay 75c2fdf34a
Warn on method call mutating const, even if it has destructor 2020-09-30 22:19:45 -07:00
David Tolnay 41baa090ad
Skip dropck::check_drop_impl in is_const_item_without_destructor
adt_destructor by default also validates the Drop impl using
dropck::check_drop_impl, which contains an expect_local(). This
leads to ICE in check_const_item_mutation if the const's type is
not a local type.

    thread 'rustc' panicked at 'DefId::expect_local: `DefId(5:4805 ~ alloc[d7e9]::vec::{impl#50})` isn't local', compiler/rustc_span/src/def_id.rs:174:43
    stack backtrace:
       0: rust_begin_unwind
       1: rustc_span::def_id::DefId::expect_local::{{closure}}
       2: rustc_typeck::check::dropck::check_drop_impl
       3: rustc_middle::ty::util::<impl rustc_middle::ty::context::TyCtxt>::calculate_dtor::{{closure}}
       4: rustc_middle::ty::trait_def::<impl rustc_middle::ty::context::TyCtxt>::for_each_relevant_impl
       5: rustc_middle::ty::util::<impl rustc_middle::ty::context::TyCtxt>::calculate_dtor
       6: rustc_typeck::check::adt_destructor
       7: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::adt_destructor>::compute
       8: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
       9: rustc_query_system::query::plumbing::get_query_impl
      10: rustc_mir::transform::check_const_item_mutation::ConstMutationChecker::is_const_item_without_destructor
2020-09-30 21:58:13 -07:00
David Tolnay bb760b53bf
Simplify defid destructor check 2020-09-30 21:45:56 -07:00
David Tolnay 0dfe7b6434
Add justification of the destructor filter 2020-09-30 21:45:56 -07:00
David Tolnay 17db1cb5d5
Bypass const_item_mutation if const's type has Drop impl 2020-09-30 21:45:56 -07:00
Dylan DPC cc1513b860
Rollup merge of #77360 - oli-obk:zst_const_pat_regression, r=RalfJung
References to ZSTs may be at arbitrary aligned addresses

fixes #77320

r? @RalfJung
2020-10-01 02:13:48 +02:00
Dylan DPC 849e5636ea
Rollup merge of #77343 - varkor:rustc_args_required_const-validation, r=lcnr
Validate `rustc_args_required_const`

Fixes https://github.com/rust-lang/rust/issues/74608.
2020-10-01 02:13:44 +02:00
Dylan DPC 73258f87ea
Rollup merge of #77324 - Aaron1011:fix/const-item-mutation-ptr, r=petrochenkov
Don't fire `const_item_mutation` lint on writes through a pointer

Fixes #77321
2020-10-01 02:13:43 +02:00
Jonas Schievink 248d6bf1e2
Rollup merge of #77037 - matthiaskrgr:cl42ppy, r=Dylan-DPC
more tiny clippy cleanups

commits stand alone and can be reviewed one by one
2020-09-30 20:56:05 +02:00
Dylan MacKenzie 1301f43119 Remove E0019, use E0015 for inline assembly in a const 2020-09-30 11:29:25 -07:00
Dylan MacKenzie 0c26144b1a Better span for attribute suggestions
`def_span` has the same issues as `body.span`, so do it this way instead.
2020-09-30 11:29:16 -07:00
varkor 609786dbd8 Validate rustc_args_required_const 2020-09-30 11:59:44 +01:00
Oliver Scherer ce6c25da58 References to ZSTs may be at arbitrary aligned addresses 2020-09-30 10:40:49 +02:00
Dylan MacKenzie 1513904c1c Remove default build_error impl
Now all structured errors must have their own error code
2020-09-29 21:17:48 -07:00
Dylan MacKenzie 287993c961 Remove machinery for halting error output 2020-09-29 19:20:33 -07:00
Dylan MacKenzie e02ea835a7 Don't stop const-checking after erroneous trait bound 2020-09-29 19:20:33 -07:00
Dylan MacKenzie 37f37dc5ba Emit multiple function pointer errors from const-checker 2020-09-29 19:20:33 -07:00
Dylan MacKenzie b400871b9c Don't emit duplicate errors for the return place 2020-09-29 19:20:33 -07:00
Dylan MacKenzie 5b3145574e Priority levels 2020-09-29 19:20:33 -07:00
Dylan MacKenzie a23297f5c0 Bless mut tests 2020-09-29 19:20:33 -07:00
Dylan MacKenzie b518ccb4c3 Give MutDeref a real error message 2020-09-29 19:20:33 -07:00
Dylan MacKenzie de35c4293d Remove ops::non_const
This helper function was meant to reduce code duplication between
const-checking pre- and post-drop-elaboration. Most of the functionality
is only relevant for the pre-drop-elaboration pass.
2020-09-29 19:20:33 -07:00
Dylan MacKenzie ce50939952 Fix "unstable in stable" error
The "otherwise" note is printed before the suggestion currently.
2020-09-29 19:20:33 -07:00
Dylan MacKenzie 782a595d7c Return a DiagnosticBuilder from structured errors
This ensures that `emit_error` will actually cause compilation to fail.
2020-09-29 19:20:33 -07:00
Dylan MacKenzie 20e07e7b8e Forbid generator-specific MIR in all const-contexts 2020-09-29 19:20:33 -07:00