summary refs log tree commit diff
path: root/src/test/ui/consts
AgeCommit message (Collapse)AuthorLines
2020-01-17expect `fn` after `const unsafe` / `const extern`Mazdak Farrokhzad-0/+41
(cherry picked from commit 915db7ae6430baef99f186ba40f08e105b7694fe)
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-102/+454
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-9/+12
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-14Revert "Remove `#![feature(never_type)]` from tests."Niko Matsakis-1/+1
This reverts commit 8f6197f39f7d468dfc5b2bd41dae4769992a2f83.
2019-12-14Auto merge of #67136 - oli-obk:const_stability, r=Centrilbors-23/+39
Require stable/unstable annotations for the constness of all stable fns with a const modifier r? @RalfJung @Centril Every `#[stable]` const fn now needs either a `#[rustc_const_unstable]` attribute or a `#[rustc_const_stable]` attribute. You can't silently stabilize the constness of a function anymore.
2019-12-13Auto merge of #65951 - estebank:type-inference-error, r=nikomatsakisbors-2/+2
Point at method call when type annotations are needed - Point at method call instead of whole expression when type annotations are needed. - Suggest use of turbofish on function and methods. Fix #49391, fix #46333, fix #48089. CC #58517, #63502, #63082. Fixes https://github.com/rust-lang/rust/issues/40015 r? @nikomatsakis
2019-12-13Ensure test actually uses dataflow, not simulationDylan MacKenzie-3/+7
2019-12-13Apply suggestions from reviewDylan MacKenzie-0/+2
2019-12-13Fix grammar in test descriptionecstatic-morse-1/+1
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2019-12-13Bless modified testsDylan MacKenzie-80/+298
2019-12-13Bless unrelated tests with new help messageDylan MacKenzie-13/+37
2019-12-13Add qualif smoke tests for const loopsDylan MacKenzie-0/+61
2019-12-13Extend control flow basics tests with loopsDylan MacKenzie-9/+52
2019-12-13Require stable/unstable annotations for the constness of all stable ↵Oliver Scherer-18/+34
functions with a `const` modifier
2019-12-13Reuse the `staged_api` feature for `rustc_const_unstable`Oliver Scherer-5/+5
2019-12-12Require `allow_internal_unstable` for stable min_const_fn using unstable ↵Oliver Scherer-27/+32
features
2019-12-11Add more context for type parametersEsteban Küber-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-11Rollup merge of #67134 - oli-obk:const_prop_zst, r=wesleywiserYuki Okushi-0/+41
Ensure that we get a hard error on generic ZST constants if their bod… …y causes an error during evaluation cc #67083 (does not fix because we still need the beta backport) r? @wesleywiser cc @RalfJung
2019-12-09Ensure that unevaluated constants of type `!` are present in the MIRMatthew Jasper-0/+114
2019-12-09Show const_err lint in addition to the hard errorOliver Scherer-2/+16
2019-12-08Ensure that we get a hard error on generic ZST constants if their body ↵Oliver Scherer-0/+27
causes an error during evaluation
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-69/+20
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-68/+152
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-05add regression test for issue 67053Remy Rakic-0/+51
2019-12-04Auto merge of #66275 - oli-obk:organize-intrinsics-promotion-checks, r=RalfJungbors-4/+23
Organize intrinsics promotion checks cc @vertexclique supersedes #61835 r? @RalfJung
2019-12-03Rollup merge of #66960 - wesleywiser:fix_66787_take2, r=oli-obk,RalfJungMazdak Farrokhzad-0/+39
[const-prop] Fix ICE calculating enum discriminant Fixes #66787 Different approach than #66857 r? @oli-obk cc @RalfJung @eddyb
2019-12-03[const-prop] Fix ICE calculating enum discriminantWesley Wiser-0/+39
Fixes #66787
2019-12-03Move all intrinsic whitelists into the constness check fileOliver Scherer-4/+4
2019-12-03Check intrinsics for callability in const fnsMahmut Bulut-0/+19
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.