Commit graph

6 commits

Author SHA1 Message Date
Dylan MacKenzie
fcf4bee7d3 Fix tests for RFC 2203 in a const
The previous test was incorrect. `const fn`s are *always* promotable
when inside a `const`, so it should pass. The error was caused by a bug
in `promote_consts`. I've added a failing test outside a `const`
alongside the existing one, which is now run-pass.
2019-11-22 11:01:31 -08:00
David Wood
4b1bc2ded9
tests: Add tests that use const fns. 2019-07-07 20:23:31 +01:00
David Wood
a655438988
tests: Update and add tests for RFC 2203. 2019-07-07 20:23:28 +01:00
David Wood
813c994a75
rustc_mir: Re-use report_selection_error.
This commit replaces the new error that was being emitted in NLL type
check with a call to `report_selection_error` so that the same trait
error as before this PR is emitted.
2019-07-07 19:51:31 +01:00
David Wood
3cca4ceed8
syntax: Add feature gate.
This commit adds a `const_in_array_repeat_expressions` feature gate and
only create `Candidate::Repeat` if it is enabled.
2019-07-07 19:51:29 +01:00
David Wood
485a80255b
rustc/rustc_mir: Implement RFC 2203.
This commit implements RFC 2203, allowing constants in array repeat
expressions.

Firstly, the check that the array repeat expression implements `Copy` is
removed and re-implemented in `rustc_mir::borrow_check::nll::type_check`
by emitting an error when the MIR contains a `Operand::Move` and the
type does not implement `Copy`.

Next, the `qualify_consts` pass is modified to construct a
`Candidate::Repeat` when it would be correct to promote a array repeat
expression.

Finally, the `promote_consts` pass is modified to promote the candidates
previously identified.
2019-07-07 19:51:09 +01:00