about summary refs log tree commit diff
path: root/src/test/ui/consts
AgeCommit message (Collapse)AuthorLines
2022-01-29Rollup merge of #92274 - woppopo:const_deallocate, r=oli-obkMatthias Krüger-3/+186
Add `intrinsics::const_deallocate` Tracking issue: #79597 Related: #91884 This allows deallocation of a memory allocated by `intrinsics::const_allocate`. At the moment, this can be only used to reduce memory usage, but in the future this may be useful to detect memory leaks (If an allocated memory remains after evaluation, raise an error...?).
2022-01-29Document about some behaviors of `const_(de)allocate` and add some tests.woppopo-0/+33
2022-01-28Replace span suggestion with multipartRob Pilling-1/+1
2022-01-28Suggest 1-tuple parentheses, without existing parensRob Pilling-0/+4
2022-01-26`const_deallocate`: Don't deallocate memory allocated in an another const. ↵woppopo-4/+27
Does nothing at runtime. `const_allocate`: Returns a null pointer at runtime.
2022-01-25#91939: integer to char cast error, make more targetedGeorge Bateman-0/+6
2022-01-26Improve selection errors for `~const` trait boundsDeadbeef-9/+17
2022-01-23Add `intrinsics::const_deallocate`woppopo-0/+127
2022-01-21Override rustc version in ui and mir-opt tests to get stable hashesThe 8472-2/+2
Building a dozen separate regexps for each test in compiletest consumes significant amounts of CPU cycles. Using `RUSTC_FORCE_INCR_COMP_ARTIFACT_HEADER` stabilizes hashes calcuated for the individual tests so no test-dependent normalization is needed. Hashes for the standard library still change so some normalizations are still needed.
2022-01-18Rollup merge of #92997 - woppopo:test92114, r=Mark-SimulacrumMatthias Krüger-3/+23
Add `~const` bound test for negative impls Resolves #92114 which has been fixed in #92892.
2022-01-17Auto merge of #92816 - tmiasko:rm-llvm-asm, r=Amanieubors-29/+4
Remove deprecated LLVM-style inline assembly The `llvm_asm!` was deprecated back in #87590 1.56.0, with intention to remove it once `asm!` was stabilized, which already happened in #91728 1.59.0. Now it is time to remove `llvm_asm!` to avoid continued maintenance cost. Closes #70173. Closes #92794. Closes #87612. Closes #82065. cc `@rust-lang/wg-inline-asm` r? `@Amanieu`
2022-01-17Add `~const` bound test for negative implswoppopo-3/+23
2022-01-14Do not fail evaluation in const blocksMichael Goulet-0/+38
2022-01-12Remove ui tests for LLVM-style inline assemblyTomasz Miąsko-29/+4
2022-01-11Deduplicate lines in long const-eval stack traceMichael Goulet-0/+42
2021-12-31Extend check for UnsafeCell in consts to cover unionsTomasz Miąsko-0/+92
A validity companion to changes from #90373.
2021-12-24Auto merge of #91342 - RalfJung:fn-abi, r=eddyb,oli-obkbors-2/+2
CTFE eval_fn_call: use FnAbi to determine argument skipping and compatibility This makes use of the `FnAbi` type in CTFE/Miri, which `@eddyb` has been saying for years is what we should do.^^ `FnAbi` is used to - determine which arguments to skip (rather than the previous heuristic of skipping ZST arguments with the Rust ABI) - impose further restrictions on whether caller and callee are consistent in how a given argument is passed I was hoping it would also simplify the code, but that is not the case -- the previous type compatibility checks are still required (AFAIK), only the ZST skipping is gone and that took barely any code. We also need some hacks because `FnAbi` assumes a certain way of implementing `caller_location` (by passing extra arguments), but Miri can just read the caller location from the call stack so it doesn't need those arguments. (The fact that every backend has to separately implement support for these arguments seems suboptimal -- looks like this might have been better implemented on the MIR level.) To avoid having to implement those unnecessary arguments in Miri, we just compute *whether* the argument is present on the caller/callee side, but don't actually pass that argument around. I have no idea if this looks the way `@eddyb` thinks it should look... but it makes Miri's test suite pass. ;) One of rustc's tests fails unfortunately (`ui/const-generics/issues/issue-67739.rs`), some const generic code that is evaluated too early -- I think that should raise `TooGeneric` but instead it ICEs. My assumption is this is some FnAbi code that has not been properly tested on polymorphic code, but it might also be me calling that FnAbi code the wrong way. r? `@oli-obk` `@eddyb` Fixes https://github.com/rust-lang/rust/issues/56166 Miri PR at https://github.com/rust-lang/miri/pull/1928
2021-12-21Use panic() instead of panic!() in some places in core.Mara Bos-10/+10
2021-12-20compare calling convention instead of call ABIRalf Jung-2/+2
2021-12-19Rollup merge of #91791 - terrarier2111:fix-float-ice, r=nagisaMatthias Krüger-0/+29
Fix an ICE when lowering a float with missing exponent magnitude This fixes: https://github.com/rust-lang/rust/issues/91434
2021-12-19Fix an ICE when lowering a float with missing exponent magnitudethreadexception-0/+29
Co-authored-by: Simonas Kazlauskas <github@kazlauskas.me>
2021-12-18Rollup merge of #91910 - tmiasko:miri-extern-type, r=RalfJungMatthias Krüger-0/+58
miri: lift restriction on extern types being the only field in a struct Fixes #91827. r? ````@RalfJung````
2021-12-16Auto merge of #89836 - pierwill:fix-85142-crate-hash, r=wesleywiserbors-2/+2
Include rustc version in `rustc_span::StableCrateId` `rustc_span::def_id::StableCrateId` is a hash of various data about a crate during compilation. This PR includes the version of `rustc` in the input when computing this hash. From a cursory reading of [RFC 2603](https://rust-lang.github.io/rfcs/2603-rust-symbol-name-mangling-v0.html), this appears to be acceptable within that design. In order to pass the `mir-opt` and `ui` test suites, this adds new [normalization for hashes and symbol names in `compiletest`](https://github.com/rust-lang/rust/pull/89836/files#diff-03a0567fa80ca04ed5a55f9ac5c711b4f84659be2d0ac4a984196d581c04f76b). These are enabled by default, but we might prefer it to be configurable. In the UI tests, I had to truncate a significant amount of error annotations in v0 symbols (and maybe some legacy) in order to get the normalization to work correctly. (See https://github.com/rust-lang/rust/issues/90116.) Closes #85142.
2021-12-15miri: lift restriction on extern types being the only field in a structTomasz Miąsko-0/+58
2021-12-14Auto merge of #91728 - Amanieu:stable_asm, r=joshtriplettbors-6/+8
Stabilize asm! and global_asm! Tracking issue: #72016 It's been almost 2 years since the original [RFC](https://github.com/rust-lang/rfcs/pull/2850) was posted and we're finally ready to stabilize this feature! The main changes in this PR are: - Removing `asm!` and `global_asm!` from the prelude as per the decision in #87228. - Stabilizing the `asm` and `global_asm` features. - Removing the unstable book pages for `asm` and `global_asm`. The contents are moved to the [reference](https://github.com/rust-lang/reference/pull/1105) and [rust by example](https://github.com/rust-lang/rust-by-example/pull/1483). - All links to these pages have been removed to satisfy the link checker. In a later PR these will be replaced with links to the reference or rust by example. - Removing the automatic suggestion for using `llvm_asm!` instead of `asm!` if you're still using the old syntax, since it doesn't work anymore with `asm!` no longer being in the prelude. This only affects code that predates the old LLVM-style `asm!` being renamed to `llvm_asm!`. - Updating `stdarch` and `compiler-builtins`. - Updating all the tests. r? `@joshtriplett`
2021-12-13Include rustc version in `rustc_span::StableCrateId`pierwill-2/+2
Normalize symbol hashes in compiletest. Remove DefId sorting
2021-12-12Stabilize asm! and global_asm!Amanieu d'Antras-6/+8
They are also removed from the prelude as per the decision in https://github.com/rust-lang/rust/issues/87228. stdarch and compiler-builtins are updated to work with the new, stable asm! and global_asm! macros.
2021-12-12Revert "Auto merge of #89450 - usbalbin:const_try_revert, r=oli-obk"Deadbeef-9/+23
This reverts commit a8387aef8c378a771686878062e544af4d5e2245, reversing changes made to 6e1211081239be62a5d0bb3bbcb29a9f14621c81.
2021-12-11Tweak assoc type obligation spansEsteban Kuber-3/+6
* Point at RHS of associated type in obligation span * Point at `impl` assoc type on projection error * Reduce verbosity of recursive obligations * Point at source of binding lifetime obligation * Tweak "required bound" note * Tweak "expected... found opaque (return) type" labels * Point at set type in impl assoc type WF errors
2021-12-08Rollup merge of #91551 - b-naber:const-eval-normalization-ice, r=oli-obkMatthias Krüger-1/+1
Allow for failure of subst_normalize_erasing_regions in const_eval Fixes https://github.com/rust-lang/rust/issues/72845 Using associated types that cannot be normalized previously resulted in an ICE. We now allow for normalization failure and return a "TooGeneric" error in that case. r? ```@RalfJung``` maybe?
2021-12-08Rollup merge of #91272 - FabianWolff:issue-90870-const-fn-eq, r=wesleywiserMatthias Krüger-0/+104
Print a suggestion when comparing references to primitive types in `const fn` Fixes #90870.
2021-12-05add test and bless existing onesb-naber-1/+1
2021-12-02Rollup merge of #91410 - ecstatic-morse:const-precise-live-drops-take-2, ↵Matthias Krüger-0/+26
r=oli-obk Move `#![feature(const_precise_live_drops)]` checks earlier in the pipeline Should mitigate the issues found during MCP on #73255. Once this is done, we should clean up the queries a bit, since I think `mir_drops_elaborated_and_const_checked` can be merged back into `mir_promoted`. Fixes #90770. cc ``@rust-lang/wg-const-eval`` r? ``@nikomatsakis`` (since they reviewed #71824)
2021-12-01Add regression test for #90770Dylan MacKenzie-0/+26
2021-11-30Rollup merge of #91323 - RalfJung:assert-type, r=oli-obkYuki Okushi-28/+61
CTFE: support assert_zero_valid and assert_uninit_valid This ensures the implementation of all three type-based assert_ intrinsics remains consistent in Miri. `assert_inhabited` recently got stabilized in https://github.com/rust-lang/rust/pull/90896 (meaning stable `const fn` can call it), so do the same with these other intrinsics. Cc ```@rust-lang/wg-const-eval```
2021-11-29CTFE: support assert_zero_valid and assert_uninit_validRalf Jung-28/+61
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-26Print a suggestion when comparing references to primitive types in constant ↵Fabian Wolff-0/+104
functions
2021-11-26Perform Sync check on static items in wf-check instead of during const checksOli Scherer-14/+14
2021-11-25Rollup merge of #91185 - camelid:rm-force-overflow-checks, r=wesleywiserMatthias Krüger-1/+1
Remove `-Z force-overflow-checks` It was replaced several years ago by the stable option `-C overflow-checks`. The goal was to delete the `-Z` flag once users had migrated [1]. Now that it's been several years, it makes sense to delete the old flag. See also the discussion on Zulip [2]. [1]: https://github.com/rust-lang/rust/issues/33134#issuecomment-280484097 [2]: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/overflow.20checks/near/262497224 r? ```@wesleywiser``` cc ```@RalfJung```
2021-11-25Rollup merge of #91111 - cjgillot:hir-no-lower-attrs, r=michaelwoeristerMatthias Krüger-19/+1
Do not visit attributes in `ItemLowerer`. By default, AST visitors visit expressions that appear in key-value attributes. Those expressions should not be lowered to HIR, as they do not correspond to actually compiled code. Since an attribute cannot produce meaningful HIR, just skip them altogether. Fixes https://github.com/rust-lang/rust/issues/81886 Fixes https://github.com/rust-lang/rust/issues/90873 r? `@michaelwoerister`
2021-11-25Do not visit attributes in `LateResolutionVisitor`.Camille GILLOT-19/+1
2021-11-24Remove `-Z force-overflow-checks`Noah Lev-1/+1
It was replaced several years ago by the stable option `-C overflow-checks`. The goal was to delete the `-Z` flag once users had migrated [1]. Now that it's been several years, it makes sense to delete the old flag. See also the discussion on Zulip [2]. [1]: https://github.com/rust-lang/rust/issues/33134#issuecomment-280484097 [2]: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/overflow.20checks/near/262497224
2021-11-22`#![feature(inline_const)]` is no longer incompleteGary Guo-2/+1
2021-11-20Rollup merge of #90930 - Nilstrieb:fix-non-const-value-ice, r=estebankMatthias Krüger-0/+101
Fix `non-constant value` ICE (#90878) This also fixes the same suggestion, which was kind of broken, because it just searched for the last occurence of `const` to replace with a `let`. This works great in some cases, but when there is no const and a leading space to the file, it doesn't work and panic with overflow because it thought that it had found a const. I also changed the suggestion to only trigger if the `const` and the non-constant value are on the same line, because if they aren't, the suggestion is very likely to be wrong. Also don't trigger the suggestion if the found `const` is on line 0, because that triggers the ICE. Asking Esteban to review since he was the last one to change the relevant code. r? ``@estebank`` Fixes #90878
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-17Add a test with a leading newline for ICE #90878Nilstrieb-0/+17
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)