about summary refs log tree commit diff
path: root/src/test/ui/consts
AgeCommit message (Collapse)AuthorLines
2021-01-17validation test: turn some const_err back into validation failuresRalf Jung-81/+59
2021-01-17Add regression testoli-0/+44
2021-01-16Move some tests to more reasonable directories - 2Caio-0/+495
Address comments Update limits
2021-01-13Update code to account for extern ABI requirementMark Rousskov-20/+20
2021-01-13Update tests for extern block lintingMark Rousskov-3/+3
2021-01-13Stabilize remaining integer methods as `const fn`Jacob Pratt-5/+0
This includes the following functions: - i*::checked_div - i*::checked_div_euclid - i*::checked_rem - i*::checked_rem_euclid - i*::div_euclid - i*::overflowing_div - i*::overflowing_div_euclid - i*::overflowing_rem - i*::overflowing_rem_euclid - i*::rem_euclid - i*::wrapping_div - i*::wrapping_div_euclid - i*::wrapping_rem - i*::wrapping_rem_euclid - u*::checked_div - u*::checked_div_euclid - u*::checked_rem - u*::checked_rem_euclid - u*::div_euclid - u*::overflowing_div - u*::overflowing_div_euclid - u*::overflowing_rem - u*::overflowing_rem_euclid - u*::rem_euclid - u*::wrapping_div - u*::wrapping_div_euclid - u*::wrapping_rem - u*::wrapping_rem_euclid
2021-01-12Auto merge of #78407 - oli-obk:ub_checkable_ctfe, r=RalfJung,pnkfelixbors-42/+69
Make CTFE able to check for UB... ... by not doing any optimizations on the `const fn` MIR used in CTFE. This means we duplicate all `const fn`'s MIR now, once for CTFE, once for runtime. This PR is for checking the perf effect, so we have some data when talking about https://github.com/rust-lang/const-eval/blob/master/rfcs/0000-const-ub.md To do this, we now have two queries for obtaining mir: `optimized_mir` and `mir_for_ctfe`. It is now illegal to invoke `optimized_mir` to obtain the MIR of a const/static item's initializer, an array length, an inline const expression or an enum discriminant initializer. For `const fn`, both `optimized_mir` and `mir_for_ctfe` work, the former returning the MIR that LLVM should use if the function is called at runtime. Similarly it is illegal to invoke `mir_for_ctfe` on regular functions. This is all checked via appropriate assertions and I don't think it is easy to get wrong, as there should be no `mir_for_ctfe` calls outside the const evaluator or metadata encoding. Almost all rustc devs should keep using `optimized_mir` (or `instance_mir` for that matter).
2021-01-04Do not run const prop on the `mir_for_ctfe` of `const fn`oli-1/+1
2021-01-04Update stderr files after rebaseoli-5/+0
2021-01-04Keep an unoptimized duplicate of `const fn` aroundoli-41/+73
This allows CTFE to reliably detect UB, as otherwise optimizations may hide UB.
2021-01-04make sure that promoteds which fail to evaluate in dead const code behave ↵Ralf Jung-2/+13
correctly
2021-01-03Refactor the non-transient cell borrow error diagnosticoli-9/+9
2021-01-03Update now-more-precise operation with a preciser messageoli-6/+6
2021-01-01Reinstate the error-code error over the feature gate erroroli-9/+3
2021-01-01Enhance some commentsoli-9/+14
2021-01-01Fix cell checks in const fnoli-0/+2
2021-01-01Allow references to interior mutable data behind a feature gateoli-23/+64
2020-12-30Rollup merge of #80491 - RalfJung:dangling-of-val, r=oli-obkMara Bos-0/+7
Miri: make size/align_of_val work for dangling raw ptrs This is needed for https://github.com/rust-lang/rust/issues/80365#issuecomment-752128105. r? `@oli-obk`
2020-12-30CTFE: test size/align_of_val_raw on dangling pointersRalf Jung-0/+7
2020-12-29Remove `compile-fail` test suiteVadim Petrochenkov-0/+142
2020-12-21Auto merge of #79270 - RalfJung:array-repeat-consts, r=oli-obkbors-0/+27
Acknowledge that `[CONST; N]` is stable When `const_in_array_repeat_expressions` (RFC 2203) got unstably implemented as part of https://github.com/rust-lang/rust/pull/61749, accidentally, the special case of repeating a *constant* got stabilized immediately. That is why the following code works on stable: ```rust const EMPTY: Vec<i32> = Vec::new(); pub const fn bar() -> [Vec<i32>; 2] { [EMPTY; 2] } fn main() { let x = bar(); } ``` In contrast, if we had written `[expr; 2]` for some expression that is not *literally* a constant but could be evaluated at compile-time (e.g. `(EMPTY,).0`), this would have failed. We could take back this stabilization as it was clearly accidental. However, I propose we instead just officially accept this and stabilize a small subset of RFC 2203, while leaving the more complex case of general expressions that could be evaluated at compile-time unstable. Making that case work well is pretty much blocked on inline `const` expressions (to avoid relying too much on [implicit promotion](https://github.com/rust-lang/const-eval/blob/master/promotion.md)), so it could take a bit until it comes to full fruition. `[CONST; N]` is an uncontroversial subset of this feature that has no semantic ambiguities, does not rely on promotion, and basically provides the full expressive power of RFC 2203 but without the convenience (people have to define constants to repeat them, possibly using associated consts if generics are involved). Well, I said "no semantic ambiguities", that is only almost true... the one point I am not sure about is `[CONST; 0]`. There are two possible behaviors here: either this is equivalent to `let x = CONST; [x; 0]`, or it is a NOP (if we argue that the constant is never actually instantiated). The difference between the two is that if `CONST` has a destructor, it should run in the former case (but currently doesn't, due to https://github.com/rust-lang/rust/issues/74836); but should not run if it is considered a NOP. For regular `[x; 0]` there seems to be consensus on running drop (there isn't really an alternative); any opinions for the `CONST` special case? Should this instantiate the const only to immediately run its destructors? That seems somewhat silly to me. After all, the `let`-expansion does *not* work in general, for `N > 1`. Cc `@rust-lang/lang` `@rust-lang/wg-const-eval` Cc https://github.com/rust-lang/rust/issues/49147
2020-12-20make sure [CONST; N] drops N timesRalf Jung-2/+16
2020-12-20add test that repeating non-Copy constants worksRalf Jung-0/+13
2020-12-19also const-check FakeReadRalf Jung-0/+5
2020-12-10re-bless testsRalf Jung-0/+34
2020-12-09remove a hack that seems to only benefit a few very special casesRalf Jung-3/+31
2020-12-09make sure we do not promote things with interior mutabilityRalf Jung-7/+22
2020-12-03Auto merge of #79594 - vn-ki:const-eval-intrinsic, r=oli-obkbors-112/+235
add const_allocate intrinsic r? `@oli-obk` fixes #75390
2020-12-02rename MemoryKind::Heap to ConstHeap; bless testVishnunarayan K I-7/+14
2020-12-02add comment and bless some testsVishnunarayan K I-110/+93
2020-12-01review comment and one more testVishnunarayan K I-11/+23
2020-12-01review commentsVishnunarayan K I-1/+43
2020-12-01Rollup merge of #79444 - sasurau4:test/move-const-ip, r=matkladMara Bos-13/+0
Move const ip in ui test to unit test Helps with #76268 r? ``@matklad``
2020-12-01Rollup merge of #79227 - sasurau4:test/move-cell-test-to-lib-core, r=jyn514Mara Bos-13/+0
Remove const_fn_feature_flags test ## Overview Helps with #76268 I found `const_fn_feature_flags` is targeting feature-gate and remove it. r? ``@matklad``
2020-12-01add const_allocate intrisicVishnunarayan K I-0/+79
2020-11-30Make ui test that are run-pass and do not test the compiler itself library testsChristiaan Dirkx-70/+0
2020-11-29Update tests to remove old numeric constantsbstrie-86/+68
Part of #68490. Care has been taken to leave the old consts where appropriate, for testing backcompat regressions, module shadowing, etc. The intrinsics docs were accidentally referring to some methods on f64 as std::f64, which I changed due to being contrary with how we normally disambiguate the shadow module from the primitive. In one other place I changed std::u8 to std::ops since it was just testing path handling in macros. For places which have legitimate uses of the old consts, deprecated attributes have been optimistically inserted. Although currently unnecessary, they exist to emphasize to any future deprecation effort the necessity of these specific symbols and prevent them from being accidentally removed.
2020-11-26Move const ip in ui test to unit testDaiki Ihara-13/+0
2020-11-26remove const-fn-feature-flags testDaiki Ihara-13/+0
2020-11-25Resolve inference variables before trying to remove overloaded indexingAaron Hill-0/+11
Fixes #79152 This code was already set up to handle indexing an array. However, it appears that we never end up with an inference variable for the slice case, so the missing call to `resolve_vars_if_possible` had no effect until now.
2020-11-23Rollup merge of #76829 - tspiteri:const-int-pow, r=oli-obkJonas Schievink-1/+0
stabilize const_int_pow This also requires stabilizing constctlz for const ctlz_nonzero.
2020-11-23Auto merge of #76226 - CDirkx:const-ipaddr, r=dtolnaybors-0/+13
Stabilize `IpAddr::is_ipv4` and `is_ipv6` as const Insta-stabilize the methods `is_ipv4` and `is_ipv6` of `std::net::IpAddr` as const, in the same way as [PR#76198](https://github.com/rust-lang/rust/pull/76198). Possible because of the recent stabilization of const control flow. Part of #76225 and #76205.
2020-11-23stabilize const_int_powTrevor Spiteri-1/+0
Also stabilize constctlz for const ctlz_nonzero. The public methods stabilized const by this commit are: * `{i*,u*}::checked_pow` * `{i*,u*}::saturating_pow` * `{i*,u*}::wrapping_pow` * `{i*,u*}::overflowing_pow` * `{i*,u*}::pow` * `u*::next_power_of_two` * `u*::checked_next_power_of_two` * `u*::wrapping_next_power_of_two` (the method itself is still unstable)
2020-11-23Stabilize `IpAddr::is_ipv4` and `is_ipv6` as constChristiaan Dirkx-0/+13
Insta-stabilize the methods `is_ipv4` and `is_ipv6` of `IpAddr`. Possible because of the recent stabilization of const control flow. Also adds a test for these methods in a const context.
2020-11-21Fix comments of toogeneris testNgo Iok Ui-5/+3
2020-11-20Exhaustively match in variant count instrinsicNgo Iok Ui-0/+54
2020-11-14Auto merge of #79049 - tmiasko:lower-intrinsics, r=jonas-schievinkbors-5/+0
Lower intrinsics calls: forget, size_of, unreachable, wrapping_* This allows constant propagation to evaluate `size_of` and `wrapping_*`, and unreachable propagation to propagate a call to `unreachable`. The lowering is performed as a MIR optimization, rather than during MIR building to preserve the special status of intrinsics with respect to unsafety checks and promotion. Currently enabled by default to determine the performance impact (no significant impact expected). In practice only useful when combined with inlining since intrinsics are rarely used directly (with exception of `unreachable` and `discriminant_value` used by built-in derive macros). Closes #32716.
2020-11-14Lower intrinsics calls: forget, size_of, unreachable, wrapping_*Tomasz Miąsko-5/+0
This allows constant propagation to evaluate `size_of` and `wrapping_*`, and unreachable propagation to propagate a call to `unreachable`. The lowering is performed as a MIR optimization, rather than during MIR building to preserve the special status of intrinsics with respect to unsafety checks and promotion.
2020-11-12fix tests and formattingVishnunarayan K I-40/+8
2020-11-12add error_occured field to ConstQualifs, fix #76064Vishnunarayan K I-0/+16