about summary refs log tree commit diff
path: root/src/test/ui/consts
AgeCommit message (Collapse)AuthorLines
2019-12-02Add dual tests for const_mut_refsChristian Poveda-9/+39
2019-12-02Update miri unleashed testsChristian Poveda-9/+37
2019-12-02Suggest feature for const_mut_refs errorsChristian Poveda-16/+34
2019-12-02Update miri_unleashed testsChristian Poveda-53/+6
2019-12-02Extend test for const_mut_refs featureChristian Poveda-3/+22
2019-12-02Allow mutable derefs with feature gateChristian Poveda-1/+3
2019-12-02Move and rewrite tests to use &mut in constantsChristian Poveda-16/+16
2019-12-02Rename feature gateChristian Poveda-1/+1
2019-12-02Add tests for mutable borrows in const fnsChristian Poveda-0/+34
2019-12-02Rollup merge of #66654 - ecstatic-morse:check-consts-ref, r=eddyb,matthewjasperRalf Jung-9/+23
Handle const-checks for `&mut` outside of `HasMutInterior` Addresses [this comment](https://github.com/rust-lang/rust/pull/64470#discussion_r328200508). Const-checking relied on `HasMutInterior` to forbid `&mut` in a const context. This was strange because all we needed to do was look for an `Rvalue::Ref` with a certain `BorrowKind`, whereas the `Qualif` traits are specifically meant to get the qualifs for a *value*. This PR removes that logic from `HasMutInterior` and moves it into `check_consts::Validator`. As a result, we can now properly handle qualifications for `static`s, which had to be ignored previously since you can e.g. borrow a static `Cell` from another `static`. We also remove the `derived_from_illegal_borrow` logic, since it is no longer necessary; we give good errors for subsequent reborrows/borrows of illegal borrows.
2019-12-01Miri core engine: use throw_ub instead of throw_panicRalf Jung-69/+20
2019-11-28Auto merge of #66642 - ecstatic-morse:promotion-in-const, r=eddybbors-29/+44
Create promoted MIR fragments for `const` and `static`s Resolves #65732. The previous strategy of removing `Drop` and `StorageDead` for promoted locals only worked for rvalue lifetime extension and only if no `loop`s were present. This PR applies the approach currently used for `fn` and `const fn`s to `const` and `statics`. This may have some performance impacts. r? @eddyb
2019-11-28Auto merge of #66294 - davidhewitt:const_fn_memoization, r=oli-obkbors-69/+36
Add memoization for const function evaluations When a const function is being evaluated, as long as all its arguments are zero-sized-types (or it has no arguments) then we can trivially memoize the evaluation result using the existing query mechanism. With thanks to @oli-obk for mentoring me through this at RustFest Barcelona. r? @oli-obk
2019-11-27Also test shared borrows of `Cell` for good errorsDylan MacKenzie-3/+20
2019-11-27Rollup merge of #66800 - jyn514:combine-const-match-tests, r=Dylan-DPCTyler Mandry-22/+11
Combine similar tests for const match See https://github.com/rust-lang/rust/pull/66788#issuecomment-558799307 for context.
2019-11-27Update test with improved diagnosticsDylan MacKenzie-10/+7
Now, `derived_from_illegal_borrow` is also applied to reborrows, so we don't show the user a useless error message.
2019-11-27Add memoization for const function evaluationsDavid Hewitt-69/+36
When a const function is being evaluated, as long as all its arguments are zero-sized-types (or it has no arguments) then we can trivially memoize the evaluation result using the existing query mechanism.
2019-11-27Auto merge of #66677 - wesleywiser:fix_const_prop_alloc_id_ice, r=oli-obkbors-0/+24
[const prop] Fix "alloc id without corresponding allocation" ICE r? @oli-obk
2019-11-27Combine similar tests for const matchJoshua Nelson-22/+11
See https://github.com/rust-lang/rust/pull/66788#issuecomment-558799307 for context.
2019-11-26Rollup merge of #66788 - ecstatic-morse:const-fn-unreachable, r=CentrilTyler Mandry-0/+21
Allow `Unreachable` terminators through `min_const_fn` checks Resolves #66756. This allows `Unreachable` terminators through the `min_const_fn` checks if `#![feature(const_if_match)]` is enabled. We could probably just allow them with no feature flag, but it seems okay to be conservative here. r? @oli-obk
2019-11-26Remove test for #66758Dylan MacKenzie-6/+0
2019-11-26Add regression test for #66756Dylan MacKenzie-0/+27
2019-11-26Test multiple variantsJoshua Nelson-0/+2
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2019-11-25Add wildcard test for const_if_matchJoshua Nelson-0/+19
Closes https://github.com/rust-lang/rust/issues/66758
2019-11-23[const prop] Fix "alloc id without corresponding allocation" ICEWesley Wiser-0/+24
Fixes #66345
2019-11-23Auto merge of #66507 - ecstatic-morse:const-if-match, r=oli-obkbors-354/+1171
Enable `if` and `match` in constants behind a feature flag This PR is an initial implementation of #49146. It introduces a `const_if_match` feature flag and does the following if it is enabled: - Allows `Downcast` projections, `SwitchInt` terminators and `FakeRead`s for matched places through the MIR const-checker. - Allows `if` and `match` expressions through the HIR const-checker. - Stops converting `&&` to `&` and `||` to `|` in `const` and `static` items. As a result, the following operations are now allowed in a const context behind the feature flag: - `if` and `match` - short circuiting logic operators (`&&` and `||`) - the `assert` and `debug_assert` macros (if the `const_panic` feature flag is also enabled) However, the following operations remain forbidden: - `while`, `loop` and `for` (see #52000) - the `?` operator (calls `From::from` on its error variant) - the `assert_eq` and `assert_ne` macros, along with their `debug` variants (calls `fmt::Debug`) This PR is possible now that we use dataflow for const qualification (see #64470 and #66385). r? @oli-obk cc @rust-lang/wg-const-eval @eddyb
2019-11-22Fix tests for RFC 2203 in a `const`Dylan MacKenzie-29/+44
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-22Rollup merge of #66587 - matthewjasper:handle-static-as-const, r=oli-obkMazdak Farrokhzad-9/+9
Handle statics in MIR as const pointers This is the first PR towards the goal of removing `PlaceBase::Static`. In this PR: * Statics are lowered to dereferencing a const pointer. * The temporaries holding such pointers are tracked in MIR, for the most part this is only used for diagnostics. There are two exceptions: * The borrow checker has some checks for thread-locals that directly use this data. * Const checking will suppress "cannot dereference raw pointer" diagnostics for pointers to `static mut`/`extern static`. This is to maintain the current behaviour (12 tests fail otherwise). The following are left to future PRs (I think that @spastorino will be working on the first 3): * Applying the same treatments to promoted statics. * Removing `PlaceBase::Static`. * Replacing `PlaceBase` with `Local`. * Moving the ever growing collection of metadata that we have for diagnostics in MIR passes somewhere more appropriate. r? @oli-obk
2019-11-21Reorganize, bless and add tests for const control flowDylan MacKenzie-354/+1171
This creates a new test directory, `ui/consts/control-flow` to hold tests related to control flow in a const context. It also blesses all existing tests with the new error messages, and adds new tests for the `const_if_match` feature.
2019-11-21Bless remaining test outputMatthew Jasper-5/+5
2019-11-21Readjust const qualification to detect statics againSantiago Pastorino-4/+4
2019-11-21Auto merge of #66389 - estebank:type-err-labels, r=petrochenkovbors-83/+49
Specific labels when referring to "expected" and "found" types
2019-11-21Remove `#![feature(never_type)]` from tests.Mazdak Farrokhzad-1/+1
Also remove `never_type` the feature-gate test.
2019-11-18Surround types with backticks in type errorsEsteban Küber-47/+47
2019-11-18Remove E0308 note when primary label has all infoEsteban Küber-34/+0
2019-11-18Specific labels when referring to "expected" and "found" typesEsteban Küber-8/+8
2019-11-18Update ui testsGuillaume Gomez-0/+1
2019-11-17Auto merge of #66385 - ecstatic-morse:check-only-pass2, r=eddybbors-60/+20
Make dataflow-based const qualification the canonical one For over a month, dataflow-based const qualification has been running in parallel with `qualify_consts` to check the bodies of `const` and `static`s. This PR removes the old qualification pass completely in favor of the dataflow-based one. **edit:** This PR also stops checking `QUALIF_ERROR_BIT` during promotion. This check appears to no longer serve a purpose now that the CTFE engine is more robust. As a side-effect, this resolves #66167. r? @eddyb
2019-11-16Only run tests on x86_64Wesley Wiser-1/+3
2019-11-15Respond to review feedbackWesley Wiser-0/+4
2019-11-15[ConstProp] Avoid OOM crashes by not evaluating large PlacesWesley Wiser-0/+5
Fixes #66397
2019-11-15Fix spurious CI filures due to OOMWesley Wiser-0/+9
Fixes #66342
2019-11-15Add explanation of test for validation mismatchDylan MacKenzie-7/+15
2019-11-15Silence miri unleashed warnings in testDylan MacKenzie-53/+5
2019-11-15Rollup merge of #66306 - spastorino:remove-error-handled-by-miri, r=oli-obkYuki Okushi-3/+5
Remove cannot mutate statics in initializer of another static error r? @oli-obk This is just a refactoring. As the removed code itself said, it only a heuristic catching a few cases early instead of leaving it all to const eval. It's easy to work around the static check and then run into the miri-engine check.
2019-11-13Bless miri unleashed test now that errors are mandatoryDylan MacKenzie-7/+13
2019-11-13Bless less verbose error messagesDylan MacKenzie-111/+59
The MIR const-checker errors for if/match/loop are now delay span bugs, so nothing will be emitted unless the HIR checker misses something.
2019-11-13Bless back-compat breakagesDylan MacKenzie-10/+45
This PR BREAKS CODE THAT WAS ACCEPTED ON STABLE. It's arguably a bug that this was accepted in the first place, but here we are. See #62272 for more info.
2019-11-13Bless const tests with improved diagnosticsDylan MacKenzie-165/+288
2019-11-13Extend const-loop and const-if to handle more casesDylan MacKenzie-21/+71
This makes sure that our HIR visitor is visiting as many const-items as possible.