summary refs log tree commit diff
path: root/src/test/ui/consts/const-eval
AgeCommit message (Collapse)AuthorLines
2020-02-23Correct stderr output for failing testsMark Rousskov-10/+12
2020-02-22Resolve long compile times when evaluating always valid constantsWesley Wiser-0/+76
This extends the existing logic which skips validating every integer or floating point number type to also skip validating empty structs because they are also trivially valid. Fixes #67539
2020-01-13Use the correct type for static qualifsMatthew Jasper-0/+14
2019-12-15Auto merge of #67216 - ecstatic-morse:const-loop, r=oli-obkbors-9/+26
Enable `loop` and `while` in constants behind a feature flag This PR is an initial implementation of #52000. It adds a `const_loop` feature gate, which allows `while` and `loop` expressions through both HIR and MIR const-checkers if enabled. `for` expressions remain forbidden by the HIR const-checker, since they desugar to a call to `IntoIterator::into_iter`, which will be rejected anyways. `while` loops also require [`#![feature(const_if_match)]`](https://github.com/rust-lang/rust/pull/66507), since they have a conditional built into them. The diagnostics from the HIR const checker will suggest this to the user. r? @oli-obk cc @rust-lang/wg-const-eval
2019-12-14Auto merge of #67224 - nikomatsakis:revert-stabilization-of-never-type, ↵bors-8/+11
r=centril Revert stabilization of never type Fixes https://github.com/rust-lang/rust/issues/66757 I decided to keep the separate `never-type-fallback` feature gate, but tried to otherwise revert https://github.com/rust-lang/rust/pull/65355. Seemed pretty clean. ( cc @Centril, author of #65355, you may want to check this over briefly )
2019-12-14add `#![feature(never_type)]` to tests as neededNiko Matsakis-8/+11
2019-12-13Bless unrelated tests with new help messageDylan MacKenzie-9/+26
2019-12-13Require stable/unstable annotations for the constness of all stable ↵Oliver Scherer-2/+2
functions with a `const` modifier
2019-12-13Reuse the `staged_api` feature for `rustc_const_unstable`Oliver Scherer-2/+2
2019-12-11Rollup merge of #67164 - matthewjasper:never-remove-const, r=oli-obkMazdak Farrokhzad-0/+114
Ensure that panicking in constants eventually errors based on #67134 closes #66975 r? @oli-obk
2019-12-09Ensure that unevaluated constants of type `!` are present in the MIRMatthew Jasper-0/+114
2019-12-07Auto merge of #65881 - anp:implicit-caller-location, r=eddyb,oli-obkbors-23/+0
Implement #[track_caller] attribute. (RFC 2091 4/N) Implements the `#[track_caller]` attribute in both const and codegen contexts. The const implementation walks up the stack to find the nearest untracked callsite. The codegen implementation adds an implicit argument to tracked function calls, and populates it with either a call to the previously-landed intrinsic or if the caller has `#[track_caller]` with a copy of the location passed to the current function. Also includes a little cleanup and a few comments in the other caller location areas. [Depends on: 65664](https://github.com/rust-lang/rust/pull/65664) [RFC 2091 text](https://github.com/rust-lang/rfcs/blob/master/text/2091-inline-semantic.md) [Tracking issue](https://github.com/rust-lang/rust/issues/47809) [Tracking doc](https://paper.dropbox.com/doc/track_rfc_2091_impl-notes--Anf1NwnIb0xcRv31YLIadyj0Ag-rwCdRc2fi2yvRZ7syGZ9q#:uid=863513134494965680023183&h2=TODO-actually-pass-location-to)
2019-12-07Auto merge of #66927 - RalfJung:engines-dont-panic, r=oli-obkbors-44/+16
Miri core engine: use throw_ub instead of throw_panic See https://github.com/rust-lang/rust/issues/66902 for context: panicking is not really an "interpreter error", but just part of a normal Rust execution. This is a first step towards removing the `InterpError::Panic` variant: the core Miri engine does not use it any more. ConstProp and ConstEval still use it, though. This will be addressed in future PRs. From what I can tell, all the error messages this removes are actually duplicates. r? @oli-obk @wesleywiser
2019-12-06Rollup merge of #66606 - christianpoveda:mut-refs-in-const-fn, r=oli-obkMazdak Farrokhzad-3/+6
Add feature gate for mut refs in const fn r? @oli-obk
2019-12-05Rename test filename to match others.Adam Perry-41/+0
2019-12-05Implement #[track_caller] in const.Adam Perry-9/+27
2019-12-03Check intrinsics for callability in const fnsMahmut Bulut-0/+19
2019-12-02Suggest feature for const_mut_refs errorsChristian Poveda-3/+6
2019-12-02Move and rewrite tests to use &mut in constantsChristian Poveda-19/+0
2019-12-02Add tests for mutable borrows in const fnsChristian Poveda-0/+19
2019-12-01Miri core engine: use throw_ub instead of throw_panicRalf Jung-44/+16
2019-11-21Reorganize, bless and add tests for const control flowDylan MacKenzie-4/+10
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-18Surround types with backticks in type errorsEsteban Küber-5/+5
2019-11-18Remove E0308 note when primary label has all infoEsteban Küber-4/+0
2019-11-18Specific labels when referring to "expected" and "found" typesEsteban Küber-2/+2
2019-11-15Add explanation of test for validation mismatchDylan MacKenzie-7/+15
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 less verbose error messagesDylan MacKenzie-72/+16
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-7/+31
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-11/+59
2019-11-12check-consts remove cannot mutate statics in initializer of another static errorSantiago Pastorino-3/+5
2019-11-10Make error and warning annotations mandatory in UI testsTomasz Miąsko-22/+6
This change makes error and warning annotations mandatory in UI tests. The only exception are tests that use error patterns to match compiler output and don't have any annotations.
2019-11-06--blessRalf Jung-2/+2
2019-10-27Implementation of const caller_location.Adam Perry-0/+23
2019-10-20Remove `borrowck_graphviz_postflow` from testDylan MacKenzie-6/+3
2019-10-19Auto merge of #64890 - wesleywiser:const_prop_rvalue, r=oli-obkbors-0/+28
[const-prop] Handle remaining MIR Rvalue cases r? @oli-obk
2019-10-18Don't ICE when evaluating writes to uninhabited enum variantsWesley Wiser-0/+28
2019-10-16Add regression test for #65394Dylan MacKenzie-0/+24
2019-10-04[const-prop] Fix ICE when trying to eval polymorphic promoted MIRWesley Wiser-11/+22
2019-10-02Rollup merge of #64991 - wesleywiser:fix_too_eager_const_prop, r=oli-obkMazdak Farrokhzad-0/+23
[const-prop] Correctly handle locals that can't be propagated `const_prop()` now handles writing the Rvalue into the Place in the stack frame for us. So if we're not supposed to propagate that value, we need to clear it. r? @oli-obk Fixes #64970
2019-10-02[const-prop] Correctly handle locals that can't be propagatedWesley Wiser-0/+23
`const_prop()` now handles writing the Rvalue into the Place in the stack frame for us. So if we're not supported to propagate that value, we need to clear it.
2019-10-01Add test cases for #64945Dylan MacKenzie-0/+61
This also tests that `&&[]` no longer causes an ICE in this PR (although the test fails the borrow checker). This could be more complete.
2019-09-30Rollup merge of #64377 - GuillaumeGomez:E0493, r=estebankTyler Mandry-0/+1
Add long error explanation for E0493 Part of #61137.
2019-09-30update testsGuillaume Gomez-0/+1
2019-09-29Auto merge of #64470 - ecstatic-morse:split-promotion-and-validation, ↵bors-188/+21
r=eddyb,oli-obk Implement dataflow-based const validation This PR adds a separate, dataflow-enabled pass that checks the bodies of `const`s, `static`s and `const fn`s for [const safety](https://github.com/rust-rfcs/const-eval/blob/master/const.md). This is based on my work in #63860, which tried to integrate into the existing pass in [`qualify_consts.rs`](https://github.com/rust-lang/rust/blob/master/src/librustc_mir/transform/qualify_consts.rs). However, the resulting pass was even more unwieldy than the original. Unlike its predecessor, this PR is designed to be combined with #63812 to replace the existing pass completely. The new checker lives in [`librustc_mir/transform/check_consts`](https://github.com/ecstatic-morse/rust/tree/split-promotion-and-validation/src/librustc_mir/transform/check_consts). [`qualifs.rs`](https://github.com/ecstatic-morse/rust/blob/split-promotion-and-validation/src/librustc_mir/transform/check_consts/qualifs.rs) contains small modifications to the existing `Qualif` trait and its implementors, but is mostly unchanged except for the removal of `IsNotPromotable` and `IsNotImplicitlyPromotable`, which are only necessary for promotion. [`resolver.rs`](https://github.com/ecstatic-morse/rust/blob/split-promotion-and-validation/src/librustc_mir/transform/check_consts/resolver.rs) contains the dataflow analysis used to propagate qualifs between locals. Finally, [`validation.rs`](https://github.com/ecstatic-morse/rust/blob/split-promotion-and-validation/src/librustc_mir/transform/check_consts/validation.rs) contains a refactored version of the existing [`Visitor`](https://github.com/rust-lang/rust/blob/ca3766e2e58f462a20922e42c821a37eaf0e13db/src/librustc_mir/transform/qualify_consts.rs#L1024) in `qualfy_consts.rs`. All errors have been associated with a `struct` to make [comparison with the existing pass](https://github.com/ecstatic-morse/rust/blob/1c19f2d540ca0a964900449d79a5d5181b43146d/src/librustc_mir/transform/qualify_consts.rs#L1006) simple. The existing validation logic in [`qualify_consts`](https://github.com/rust-lang/rust/blob/master/src/librustc_mir/transform/qualify_consts.rs) has been modified to allow it to run in parallel with the new validator. If [`use_new_validator`](https://github.com/rust-lang/rust/pull/64470/files#diff-c2552a106550d05b69d5e07612f0f812R950) is not set, the old validation will be responsible for actually generating the errors, but those errors can be compared with the ones from the new validator.
2019-09-28Fix tests broken by more consistent miri unleashed warningsDylan MacKenzie-188/+21
2019-09-27[const-prop] Replace `eval_place()` with use of `InterpCx`Wesley Wiser-2/+11
2019-09-25Rollup merge of #64738 - gnzlbg:miri_norm_abi, r=oli-obkMazdak Farrokhzad-0/+53
Add const-eval support for SIMD types, insert, and extract This adds initial support for constant-evaluation of Abi::Vector types. r? @oli-obk
2019-09-25Remove fail testsgnzlbg-201/+0
2019-09-25Clean testsgnzlbg-11/+31