about summary refs log tree commit diff
path: root/src/test/ui/consts/const-eval
AgeCommit message (Collapse)AuthorLines
2021-12-05add test and bless existing onesb-naber-1/+1
2021-11-28Rollup merge of #90131 - camsteffen:fmt-args-span-fix, r=cjgillotMatthias Krüger-0/+3
Fix a format_args span to be expansion I found this while exploring solutions for rust-lang/rust-clippy#7843. r? `@m-ou-se`
2021-11-20Rollup merge of #90999 - RalfJung:miri_simd, r=oli-obkMatthias Krüger-6/+16
fix CTFE/Miri simd_insert/extract on array-style repr(simd) types The changed test would previously fail since `place_index` would just return the only field of `f32x4`, i.e., the array -- rather than *indexing into* the array which is what we have to do. The new helper methods will also be needed for https://github.com/rust-lang/miri/issues/1912. r? ``````@oli-obk``````
2021-11-18CTFE SIMD: also test 1-element arrayRalf Jung-1/+10
2021-11-18fix CTFE/Miri simd_insert/extract on array-style repr(simd) typesRalf Jung-6/+7
2021-11-17Rollup merge of #90687 - jhpratt:const_panic, r=oli-obkMatthias Krüger-0/+46
Permit const panics in stable const contexts in stdlib Without this change, it is not possible to use `panic!` and similar (including `assert!`) in stable const contexts inside of stdlib. See #89542 for a real-world case that currently fails for this reason. This does _not_ affect any user code. For example, this snippet currently fails to compile: ```rust #[stable(feature = "foo", since = "1.0.0")] #[rustc_const_stable(feature = "foo", since = "1.0.0")] const fn foo() { assert!(false); assert!(false, "foo"); } ``` With the addition of `#[rustc_const_unstable]` to `core::panicking::panic`, the error no longer occurs. This snippet has been added verbatim in this PR as a UI test. To avoid needing to add `#![feature(core_panic)]` to libcore, the two instances of direct calls to `core::panicking::panic` have been switched to use the `panic!` macro. I am requesting prioritization because this is holding up other stabilizations such as #89542 (which is otherwise ready to merge and succeeds with this change)
2021-11-08Permit const assertions in stdlibJacob Pratt-0/+46
2021-11-06Stabilize `const_raw_ptr_deref` for `*const T`Jacob Pratt-66/+21
This stabilizes dereferencing immutable raw pointers in const contexts. It does not stabilize `*mut T` dereferencing. This is placed behind the `const_raw_mut_ptr_deref` feature gate.
2021-10-29Fix a format_args span to be expansionCameron Steffen-0/+3
2021-10-18add test for issue 84957cameron-0/+28
2021-10-04Rollup merge of #89508 - jhpratt:stabilize-const_panic, r=joshtriplettJubilee-108/+59
Stabilize `const_panic` Closes #51999 FCP completed in #89006 ```@rustbot``` label +A-const-eval +A-const-fn +T-lang cc ```@oli-obk``` for review (not `r?`'ing as not on lang team)
2021-10-04Stabilize `const_panic`Jacob Pratt-108/+59
2021-10-03Practice diagnostic message conventionHirochika Matsumoto-3/+3
2021-09-15Allow `panic!("{}", computed_str)` in const fn.Gary Guo-37/+83
2021-09-01Fix drop handling for `if let` expressionsMatthew Jasper-2/+2
MIR lowering for `if let` expressions is now more complicated now that `if let` exists in HIR. This PR adds a scope for the variables bound in an `if let` expression and then uses an approach similar to how we handle loops to ensure that we reliably drop the correct variables.
2021-08-27Fix more testsDeadbeef-1/+1
2021-08-27Introduce `~const`Deadbeef-11/+2
- [x] Removed `?const` and change uses of `?const` - [x] Added `~const` to the AST. It is gated behind const_trait_impl. - [x] Validate `~const` in ast_validation. - [ ] Add enum `BoundConstness` to the HIR. (With variants `NotConst` and `ConstIfConst` allowing future extensions) - [ ] Adjust trait selection and pre-existing code to use `BoundConstness`. - [ ] Optional steps (*for this PR, obviously*) - [ ] Fix #88155 - [ ] Do something with constness bounds in chalk
2021-08-19Revert "Revert "Auto merge of #83417 - erikdesjardins:enableremovezsts, ↵Erik Desjardins-8/+1
r=oli-obk"" This reverts commit 8e11199a153218c13a419df37a9bb675181cccb7.
2021-08-15Revert "Auto merge of #83417 - erikdesjardins:enableremovezsts, r=oli-obk"Erik Desjardins-1/+8
This reverts commit 8007b506ac5da629f223b755f5a5391edd5f6d01, reversing changes made to e55c13e1099b78b1a485202fabc9c1b10b1f1d15.
2021-08-14Auto merge of #83417 - erikdesjardins:enableremovezsts, r=oli-obkbors-8/+1
Run RemoveZsts pass at mir-opt-level=1 per https://github.com/rust-lang/rust/pull/83177#issuecomment-803942217 This pass removes assignments to ZST places. Perf (from https://github.com/rust-lang/rust/pull/83177#issuecomment-803442557): https://perf.rust-lang.org/compare.html?start=41b315a470d583f6446599984ff9ad3bd61012b2&end=bd5d1b96f0c64c9938feea831789e1b5bb2cd4a2 r? `@oli-obk`
2021-08-13Fix testsDeadbeef-2/+4
2021-08-07Run RemoveZsts at mir-opt-level=1Erik Desjardins-8/+1
Effectively reverts commit 6960bc9696b05b15d8d89ece2fef14e6e62a43fc.
2021-08-03rustc: Fill out remaining parts of C-unwind ABIAlex Crichton-7/+6
This commit intends to fill out some of the remaining pieces of the C-unwind ABI. This has a number of other changes with it though to move this design space forward a bit. Notably contained within here is: * On `panic=unwind`, the `extern "C"` ABI is now considered as "may unwind". This fixes a longstanding soundness issue where if you `panic!()` in an `extern "C"` function defined in Rust that's actually UB because the LLVM representation for the function has the `nounwind` attribute, but then you unwind. * Whether or not a function unwinds now mainly considers the ABI of the function instead of first checking the panic strategy. This fixes a miscompile of `extern "C-unwind"` with `panic=abort` because that ABI can still unwind. * The aborting stub for non-unwinding ABIs with `panic=unwind` has been reimplemented. Previously this was done as a small tweak during MIR generation, but this has been moved to a separate and dedicated MIR pass. This new pass will, for appropriate functions and function calls, insert a `cleanup` landing pad for any function call that may unwind within a function that is itself not allowed to unwind. Note that this subtly changes some behavior from before where previously on an unwind which was caught-to-abort it would run active destructors in the function, and now it simply immediately aborts the process. * The `#[unwind]` attribute has been removed and all users in tests and such are now using `C-unwind` and `#![feature(c_unwind)]`. I think this is largely the last piece of the RFC to implement. Unfortunately I believe this is still not stabilizable as-is because activating the feature gate changes the behavior of the existing `extern "C"` ABI in a way that has no replacement. My thinking for how to enable this is that we add support for the `C-unwind` ABI on stable Rust first, and then after it hits stable we change the behavior of the `C` ABI. That way anyone straddling stable/beta/nightly can switch to `C-unwind` safely.
2021-07-31add a testRalf Jung-0/+35
2021-07-28Add test for const panic in Rust 2021.Mara Bos-0/+94
2021-07-27Update testsJacob Pratt-52/+21
2021-07-15tweak pointer out-of-bounds error messageRalf Jung-4/+4
2021-07-14more precise message for the ptr access check on derefRalf Jung-2/+2
2021-07-14adjust testsRalf Jung-82/+72
2021-07-10remove duplicate testRalf Jung-15/+0
2021-07-10remove const_raw_ptr_to_usize_cast featureRalf Jung-34/+17
2021-07-09Use #[track_caller] in const panic diagnostics.Mara Bos-0/+38
It was already used for the message. This also uses it for the spans used for the error and backtrace.
2021-07-06Add s to non_fmt_panicRyan Levick-1/+1
2021-06-28Bless the test suite.Charles Lew-2/+2
2021-06-18bless youRalf Jung-160/+61
2021-06-17Rollup merge of #86340 - Smittyvb:ctfe-hard-error-message, r=RalfJungYuki Okushi-79/+48
Use better error message for hard errors in CTFE I noticed this while working on #86255: currently the same message is used for hard errors and soft errors in CTFE. This changes the error messages to make hard errors use a message that indicates the reality of the situation correctly, since usage of the constant is never allowed when there was a hard error evaluating it. This doesn't affect the behaviour of these error messages, only the content. This changes the error logic to check if the error should be hard or soft where it is generated, instead of where it is emitted, to allow this distinction in error messages.
2021-06-15Use better error message for hard errors in CTFESmitty-79/+48
Currently the same message is used for hard errors and soft errors. This makes hard errors use a message that indicates the reality of the situation correctly, since usage of the constant is never allowed when there was a hard error evaluating it.
2021-06-13update tests involving CTFE validationRémy Rakic-79/+79
2021-06-13Test invalid vtable size/alignment const UB errorsRémy Rakic-27/+129
2021-06-09detect incorrect vtable alignment during const eval instead of ICE-ingRémy Rakic-0/+48
also add tests for these 2 kinds of errors for size and alignment, as the existing size check wasn't apparently tested
2021-05-30Emit a hard error when a panic occurs during const-evalAaron Hill-119/+52
Previous, a panic during const evaluation would go through the `const_err` lint. This PR ensures that such a panic always causes compilation to fail.
2021-05-28const eval errors: display the current item instance if there are generics ↵Rémy Rakic-2/+2
involved
2021-05-27don't trim paths in collector PME messageRémy Rakic-2/+2
2021-05-25add test for issue 85155 and similarRémy Rakic-0/+56
This test reproduces post-monomorphization errors one can encounter when using incorrect immediate arguments to some of the stdarch intrinsics using const generics.
2021-05-15get rid of a bunch of unnecessary NOTE in const testsRalf Jung-5/+2
2021-05-13Auto merge of #85110 - RalfJung:no-rustc_args_required_const, r=oli-obkbors-17/+0
Remove rustc_args_required_const attribute Now that stdarch no longer needs it (thanks `@Amanieu!),` we can kill the `rustc_args_required_const` attribute. This means that lifetime extension of references to temporaries is the only remaining job that promotion is performing. :-) r? `@oli-obk` Fixes https://github.com/rust-lang/rust/issues/69493
2021-05-12Show macro name in 'this error originates in macro' messageAaron Hill-19/+19
When there are multiple macros in use, it can be difficult to tell which one was responsible for producing an error.
2021-05-12entirely remove rustc_args_required_const attributeRalf Jung-17/+0
2021-05-09more erroneous-const testsRalf Jung-3/+63
2021-05-09ensure failing promoteds in const/static bodies are handled correctlyRalf Jung-16/+38