summary refs log tree commit diff
path: root/src/test/ui/consts
AgeCommit message (Collapse)AuthorLines
2020-10-01Regression test for case in #77361Dylan MacKenzie-0/+16
2020-10-01Auto merge of #77354 - ecstatic-morse:const-checking-moar-errors, r=oli-obkbors-132/+289
Overhaul const-checking diagnostics The primary purpose of this PR was to remove `NonConstOp::STOPS_CONST_CHECKING`, which causes any additional errors found by the const-checker to be silenced. I used this flag to preserve diagnostic parity with `qualify_min_const_fn.rs`, which has since been removed. However, simply removing the flag caused a deluge of errors in some cases, since an error would be emitted any time a local or temporary had a wrong type. To remedy this, I added an alternative system (`DiagnosticImportance`) to silence additional error messages that were likely to distract the user from the underlying issue. When an error of the highest importance occurs, all less important errors are silenced. When no error of the highest importance occurs, all less important errors are emitted after checking is complete. Following the suggestions from the important error is usually enough to fix the less important errors, so this should lead to better UX most of the time. There's also some unrelated diagnostics improvements in this PR isolated in their own commits. Splitting them out would be possible, but a bit of a pain. This isn't as tidy as some of my other PRs, but it should *only* affect diagnostics, never whether or not something passes const-checking. Note that there are a few trivial exceptions to this, like banning `Yield` in all const-contexts, not just `const fn`. As always, meant to be reviewed commit-by-commit. r? `@oli-obk`
2020-09-30Remove E0019, use E0015 for inline assembly in a constDylan MacKenzie-3/+3
2020-09-29Bless testsDylan MacKenzie-15/+55
2020-09-29Bless outputDylan MacKenzie-15/+95
2020-09-29Bless testsDylan MacKenzie-78/+38
2020-09-29Bless mut testsDylan MacKenzie-105/+173
2020-09-29Fix "unstable in stable" errorDylan MacKenzie-3/+12
The "otherwise" note is printed before the suggestion currently.
2020-09-29Liveness analysis for everybodyTomasz Miąsko-2/+3
Perform liveness analysis for every body instead of limiting it to fns.
2020-09-29Auto merge of #76754 - varkor:diagnostic-cleanup-ii, r=ecstatic-morsebors-97/+97
Clean up diagnostics for arithmetic operation errors Plus a small tweak to a range pattern error message.
2020-09-27Remove feature gate test for `rustc_allow_const_fn_ptr`Dylan MacKenzie-47/+0
2020-09-27Mark `min_const_fn_fn_ptr` test as gate testDylan MacKenzie-2/+4
2020-09-27Bless testsDylan MacKenzie-40/+85
2020-09-27Update tests with new feature gateDylan MacKenzie-23/+29
2020-09-26Make invalid integer operation messages consistentvarkor-97/+97
2020-09-26Rollup merge of #77122 - ecstatic-morse:const-fn-arithmetic, r=RalfJung,oli-obkRalf Jung-75/+107
Add `#![feature(const_fn_floating_point_arithmetic)]` cc #76618 This is a template for splitting up `const_fn` into granular feature gates. I think this will make it easier, both for us and for users, to track stabilization of each individual feature. We don't *have* to do this, however. We could also keep stabilizing things out from under `const_fn`. cc @rust-lang/wg-const-eval r? @oli-obk
2020-09-26Auto merge of #70743 - oli-obk:eager_const_to_pat_conversion, r=eddybbors-172/+32
Fully destructure constants into patterns r? `@varkor` as discussed in https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/constants.20in.20patterns/near/192789924 we should probably crater it once reviewed
2020-09-25Move from {{closure}}#0 syntax to {closure#0} for (def) path componentsmarmeladema-7/+7
2020-09-25Use proper issue for `const_fn_floating_point_arithmetic`Dylan MacKenzie-6/+6
2020-09-25Move const fn floating point test out of `min_const_fn`Dylan MacKenzie-62/+94
2020-09-25Bless testsDylan MacKenzie-24/+24
2020-09-25Rollup merge of #77136 - ecstatic-morse:issue-77134, r=oli-obkJonas Schievink-38/+38
Suggest `const_mut_refs`, not `const_fn` for mutable references in `const fn` Resolves #77134. Prior to #76850, most uses of `&mut` in `const fn` ~~required~~ involved two feature gates, `const_mut_refs` and `const_fn`. The first allowed all mutable borrows of locals. The second allowed only locals, arguments and return values whose types contained `&mut`. I switched the second check to the `const_mut_refs` gate. However, I forgot update the error message with the new suggestion. Alternatively, we could revert to having two different feature gates for this. OP's code never borrows anything mutably, so it didn't need `const_mut_refs` in the past, only `const_fn`. I'd prefer to keep everything under a single gate, however. r? @oli-obk
2020-09-24Use correct type in diagnostics againOliver Scherer-5/+5
2020-09-23Bless testsDylan MacKenzie-38/+38
2020-09-24Auto merge of #77083 - KodrAus:revert/const-type-id, r=RalfJungbors-4/+7
revert const_type_id stabilization This reverts #72488, which is currently on beta and scheduled to stabilize in `1.47.0`, based on https://github.com/rust-lang/rust/pull/75923#issuecomment-696676511 It turns out we might not be quite ready to stabilize `TypeId` in const contexts before having a chance to rework its internals. Since `TypeId` is a bit of an oddity we want to be careful about how those internals are currently being relied on while making changes. That will be easier to do without having to also consider compile-time contexts. r? `@eddyb`
2020-09-23Make sure we keep emitting a hard errorOliver Scherer-13/+1
2020-09-23Make sure we report a future incompat error in all casesOliver Scherer-3/+3
2020-09-23Make sure we don't hide errors just because a lint has been emittedOliver Scherer-15/+8
2020-09-23Deduplicate errors in const to pat conversionOliver Scherer-113/+15
2020-09-23Rollup merge of #76898 - Aaron1011:fix/item-def-span, r=oli-obkDylan DPC-13/+7
Record `tcx.def_span` instead of `item.span` in crate metadata This was missed in PR #75465. As a result, a few places have been using the full body span of functions, instead of just the header span.
2020-09-23revert const_type_id stabilizationAshley Mannix-4/+7
This reverts commit e3856616ee2a894c7811a7017d98fafa7ba84dd8.
2020-09-22Bless testsDylan MacKenzie-122/+142
2020-09-21Rollup merge of #76807 - ecstatic-morse:const-checking-staged-api, r=oli-obkecstatic-morse-6/+63
Use const-checking to forbid use of unstable features in const-stable functions First step towards #76618. Currently this code isn't ever hit because `qualify_min_const_fn` runs first and catches pretty much everything. One exception is `const_precise_live_drops`, which does not use the newly added code since it runs as part of a separate pass. Also contains some unrelated refactoring, which is split into separate commits. r? @oli-obk
2020-09-21Record `tcx.def_span` instead of `item.span` in crate metadataAaron Hill-13/+7
This was missed in PR #75465. As a result, a few places have been using the full body span of functions, instead of just the header span.
2020-09-20Move const tests for `Option` to `library\core`Christiaan Dirkx-12/+0
Part of #76268
2020-09-20Stabilize some Option methods as constCDirkx-2/+0
Stabilize the following methods of `Option` as const: - `is_some` - `is_none` - `as_ref` Possible because of stabilization of #49146 (Allow if and match in constants).
2020-09-20Use precise errors during const to pat conversion instead of a catch-all on ↵Oliver Scherer-48/+47
the main constant
2020-09-20Implement destructuring for all aggregates and for referencesOliver Scherer-24/+2
2020-09-20Auto merge of #74949 - oli-obk:validate_const_eval_raw, r=RalfJungbors-66/+45
Validate constants during `const_eval_raw` This PR implements the groundwork for https://github.com/rust-lang/rust/issues/72396 * constants are now validated during `const_eval_raw` * to prevent cycle errors, we do not validate references to statics anymore beyond the fact that they are not dangling * the `const_eval` query ICEs if used on `static` items * as a side effect promoteds are now evaluated to `ConstValue::Scalar` again (since they are just a reference to the actual promoted allocation in most cases).
2020-09-19cleanup promotion const_kind checksRalf Jung-14/+54
in particular allow a few more promotions for consistency when they were already allowed in other contexts
2020-09-19Rollup merge of #76434 - RalfJung:black-box, r=Mark-SimulacrumRalf Jung-18/+13
do not inline black_box when building for Miri We cannot do the assembly trick in Miri, but let's at least make sure MIR inlining does not circumvent the black_box. Also use black_box instead of local optimization barriers in a few const tests.
2020-09-19Reflect the "do not call this query directly" mentality in its nameOliver Scherer-2/+2
2020-09-19Address review commentsOliver Scherer-16/+16
2020-09-19Fix rebase fallout and make the test work with debug infoOliver Scherer-3/+3
2020-09-19We can make const eval sound, it's just super expensiveOliver Scherer-7/+3
2020-09-19Clarify a statement in UB testOliver Scherer-1/+3
2020-09-19Stop using the `const_eval` query for initializers of staticsOliver Scherer-22/+14
As a side effect, we now represent most promoteds as `ConstValue::Scalar` again. This is useful because all implict promoteds are just references anyway and most explicit promoteds are numeric arguments to `asm!` or SIMD instructions.
2020-09-19Validate constants during `const_eval_raw`Oliver Scherer-28/+17
2020-09-16Test that `const_precise_live_drops` can't be depended upon stablyDylan MacKenzie-0/+57
2020-09-16Bless `miri-unleashed` testsDylan MacKenzie-6/+6
`const_mut_refs` doesn't actually work in a `const` or `static`