summary refs log tree commit diff
path: root/src/test/ui/consts/const-eval
AgeCommit message (Collapse)AuthorLines
2020-07-11Rollup merge of #72920 - oli-obk:const_transmute, r=RalfJungManish Goregaokar-59/+63
Stabilize `transmute` in constants and statics but not const fn cc #53605 (leaving issue open so we can add `transmute` to `const fn` later) Previous attempt: #64011 r? @RalfJung cc @rust-lang/wg-const-eval
2020-07-11Stabilize `transmute` in constants and statics but not const fnOliver Scherer-59/+63
2020-07-10Rollup merge of #73989 - RalfJung:ub-enum-test, r=oli-obkManish Goregaokar-8/+9
adjust ub-enum test to be endianess-independent @cuviper noted that our test fails on "other" endianess systems (I never know which is which^^), so let's fix that.
2020-07-05const validation: add test for uninit boolRalf Jung-2/+13
2020-07-05catch errors more locally around read_discriminantRalf Jung-3/+3
2020-07-03adjust ub-enum test to be endianess-independentRalf Jung-8/+9
2020-06-28Update testsDylan MacKenzie-87/+10
2020-06-28Update testsDylan MacKenzie-31/+2
2020-06-26Show the values and computation that would overflow a const evaluation or ↵Oliver Scherer-50/+50
propagation
2020-06-23Rollup merge of #73515 - christianpoveda:livedrop-diagnostics, r=oli-obkManish Goregaokar-4/+47
Add second message for LiveDrop errors This is an attempt to fix https://github.com/rust-lang/rust/issues/72907 by adding a second message to the `LiveDrop` diagnostics. Changing from this ``` error[E0493]: destructors cannot be evaluated at compile-time --> src/lib.rs:7:9 | 7 | let mut always_returned = None; | ^^^^^^^^^^^^^^^^^^^ constants cannot evaluate destructors error: aborting due to previous error ``` to this ``` error[E0493]: destructors cannot be evaluated at compile-time --> foo.rs:6:9 | 6 | let mut always_returned = None; | ^^^^^^^^^^^^^^^^^^^ constants cannot evaluate destructors ... 10 | always_returned = never_returned; | --------------- value is dropped here error: aborting due to previous error ``` r? @RalfJung @ecstatic-morse
2020-06-23Rollup merge of #73398 - oli-obk:const_raw_ptr_cmp, r=varkor,RalfJung,nagisaManish Goregaokar-49/+53
A way forward for pointer equality in const eval r? @varkor on the first commit and @RalfJung on the second commit cc #53020
2020-06-20update testsChristian Poveda-4/+47
2020-06-20Satisfy tidyOliver Scherer-2/+2
2020-06-20Refer just to the issue in the raw ptr cmp diagnostic instead of explaining ↵Oliver Scherer-8/+4
everything in the diagnostic
2020-06-19add new error codeChristian Poveda-3/+3
2020-06-19update diagnostics for &mut in constantsChristian Poveda-8/+5
2020-06-19Add fuzzy pointer comparison intrinsicsOliver Scherer-4/+6
2020-06-19Remove the const_raw_ptr_comparison feature gate.Oliver Scherer-49/+55
We can never supply a meaningful implementation of this. Instead, the follow up commits will create two intrinsics that approximate comparisons: * `ptr_maybe_eq` * `ptr_maybe_ne` The fact that `ptr_maybe_eq(a, b)` is not necessarily the same value as `!ptr_maybe_ne(a, b)` is a symptom of this entire problem.
2020-06-19Rollup merge of #72497 - RalfJung:tag-term, r=oli-obkRalf Jung-3/+3
tag/niche terminology cleanup The term "discriminant" was used in two ways throughout the compiler: * every enum variant has a corresponding discriminant, that can be given explicitly with `Variant = N`. * that discriminant is then encoded in memory to store which variant is active -- but this encoded form of the discriminant was also often called "discriminant", even though it is conceptually quite different (e.g., it can be smaller in size, or even use niche-filling). After discussion with @eddyb, this renames the second term to "tag". The way the tag is encoded can be either `TagEncoding::Direct` (formerly `DiscriminantKind::Tag`) or `TagEncoding::Niche` (formerly `DiscrimianntKind::Niche`). This finally resolves some long-standing confusion I had about the handling of variant indices and discriminants, which surfaced in https://github.com/rust-lang/rust/pull/72419. (There is also a `DiscriminantKind` type in libcore, it remains unaffected. I think this corresponds to the discriminant, not the tag, so that seems all right.) r? @eddyb
2020-06-18Rollup merge of #73361 - estebank:non-primitive-cast, r=davidtwcoManish Goregaokar-1/+1
Tweak "non-primitive cast" error - Suggest borrowing expression if it would allow cast to work. - Suggest using `<Type>::from(<expr>)` when appropriate. - Minor tweak to `;` typo suggestion. Partily address #47136.
2020-06-15Tweak "non-primitive cast" errorEsteban Küber-1/+1
- Suggest borrowing expression if it would allow cast to work. - Suggest using `<Type>::from(<expr>)` when appropriate. - Minor tweak to `;` typo suggestion. Partily address #47136.
2020-06-15Rollup merge of #72879 - RalfJung:miri-tctx-at, r=oli-obkRalf Jung-2/+2
Miri: avoid tracking current location three times Miri tracks the current instruction to execute in the call stack, but it also additionally has two `TyCtxtAt` that carry a `Span` that also tracks the current instruction. That is quite silly, so this PR uses `TyCtxt` instead, and then uses a method for computing the current span when a `TyCtxtAt` is needed. Having less redundant (semi-)global state seems like a good improvement to me. :D To keep the ConstProp errors the same, I had to add the option to `error_to_const_error` to overwrite the span. Also for some reason this changes cycle errors a bit -- not sure if we are now better or worse as giving those queries the right span. (It is unfortunately quite easy to accidentally use `DUMMY_SP` by calling the query on a `TyCtxt` instead of a `TyCtxtAt`.) r? @oli-obk @eddyb
2020-06-12fix const_prop spans and re-bless testsRalf Jung-2/+2
2020-06-10Migrate to numeric associated constsLzu Tao-3/+3
2020-05-30miri errors: rename InvalidDiscriminant -> InvalidTagRalf Jung-3/+3
2020-05-30miri validation: clarify valid values of 'char'Ralf Jung-1/+1
2020-05-17Don't unleash NRVO const-eval testDylan MacKenzie-0/+26
2020-05-14Rollup merge of #71741 - RalfJung:pointer-print, r=oli-obkRalf Jung-14/+14
Pointer printing: do not print 0 offset r? @eddyb Cc @oli-obk
2020-05-12Pointer printing: do not print 0 offsetRalf Jung-14/+14
2020-05-12strings do not have to be valid UTF-8 any moreRalf Jung-8/+8
2020-05-07use hex for pointers in Miri error messages; refine vtable error messageRalf Jung-3/+3
2020-05-06more precise vtable errorsRalf Jung-9/+9
2020-05-06convert remaining try_validation to new macroRalf Jung-5/+35
2020-05-06add test for insufficiently aligned vtableRalf Jung-6/+16
2020-05-05Rollup merge of #71902 - mibac138:const-feature-diag, r=varkorDylan DPC-0/+4
Suggest to add missing feature when using gated const features Fixes #71797
2020-05-04Suggest to add missing feature when using gated const featuresmibac138-0/+4
2020-05-03Auto merge of #71631 - RalfJung:miri-unleash-the-gates, r=oli-obkbors-16/+19
Miri: unleash all feature gates IMO it is silly to unleash features that do not even have a feature gate yet, but not unleash features that do. The only thing this achieves is making unleashed mode annoying to use as we have to figure out the feature flags to enable (and not always do the error messages say what that flag is). Given that the point of `-Z unleash-the-miri-inside-of-you` is to debug the Miri internals, I see no good reason for this extra hurdle. I cannot imagine a situation where we'd use that flag, realize the program also requires some feature gate, and then be like "oh I guess if this feature is unstable I will do something else". Instead, we'll always just add that flag to the code as well, so requiring the flag achieves nothing. r? @oli-obk @ecstatic-morse Fixes https://github.com/rust-lang/rust/issues/71630
2020-05-03warn about each skipped feature gateRalf Jung-38/+32
2020-05-01rename InvalidIntPtrUsageRalf Jung-3/+3
2020-05-01bless youRalf Jung-1/+1
2020-04-30deduplicate warningsRalf Jung-25/+34
2020-04-27keep 'pointer' terminology aroundRalf Jung-14/+14
2020-04-26organize Debug/Display impls a bit more; avoid sign-ignorant decimal displayRalf Jung-37/+38
2020-04-24adjust testsRalf Jung-4/+2
2020-04-20Treat RETURN_PLACE as a normal LocalJonas Schievink-1/+1
Copy its value to the `return_place` upon leaving a call frame
2020-04-19Fix some tests failing in `--pass check` modeVadim Petrochenkov-1/+1
2020-04-17Auto merge of #71049 - eddyb:const-err, r=oli-obkbors-50/+6
Add `ConstKind::Error` and convert `ErrorHandled::Reported` to it. By replicating the `ty::Error` approach to encoding "an error has occurred", all of the mechanisms that skip redundant/downstream errors are engaged and help out (see the reduction in test output). This PR also adds `ErrorHandled::Linted` for the lint case because using `ErrorHandled::Reported` *without* having emitted an error that is *guaranteed* to stop compilation, is incorrect now. r? @oli-obk cc @rust-lang/wg-const-eval @varkor @yodaldevoid
2020-04-16ty: convert `ErrorHandled::Reported` to `ConstKind::Error`.Eduard-Mihai Burtescu-50/+6
2020-04-16test fast path offset reportingRalf Jung-2/+112
2020-04-16switch back to 'bytes'Ralf Jung-1/+1