about summary refs log tree commit diff
path: root/src/test/ui/consts
AgeCommit message (Collapse)AuthorLines
2020-05-05Rollup merge of #71902 - mibac138:const-feature-diag, r=varkorDylan DPC-0/+12
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/+12
2020-05-04Auto merge of #71751 - oli-obk:const_ice, r=RalfJungbors-0/+32
Move recursion check for zsts back to read site instead of access check site Reverts https://github.com/rust-lang/rust/pull/71140#discussion_r413709446 Fix #71612 Fix #71709 r? @RalfJung
2020-05-03Auto merge of #71631 - RalfJung:miri-unleash-the-gates, r=oli-obkbors-222/+330
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-03remove unneeded flags; exlain why we still have const_if_matchRalf Jung-27/+56
2020-05-03warn about each skipped feature gateRalf Jung-317/+315
2020-05-02Test associated const default qualifs cross-crateDylan MacKenzie-3/+41
This also tests for the ICE in #71734
2020-05-02fix miri-unleash delayed sanity checkingRalf Jung-9/+7
2020-05-02make sure the miri-unleash-flag is not used to circumvent feature gatesRalf Jung-17/+10
2020-05-01Name test appropriately and link to the issues it regress-checks forOliver Scherer-0/+5
2020-05-01Move recursion check for zsts back to read site instead of access check site.Oliver Scherer-0/+27
2020-05-01rename InvalidIntPtrUsageRalf Jung-4/+4
2020-05-01bless youRalf Jung-2/+2
2020-04-30Rollup merge of #71688 - ecstatic-morse:const-downcast, r=oli-obkTyler Mandry-10/+2
Allow `Downcast` projections unconditionally in const-checking `ProjectionElem::Downcast` sounds scary, but it's really just the projection we use to access a particular enum variant. They usually appear in the lowering of a `match` statement, so they have been associated with control flow in const-checking, but they don't do any control flow by themselves. We already have a HIR pass that looks for `if` and `match` (even ones that have 1 or fewer reachable branches). That pass is double-checked by a MIR pass that looks for `SwitchInt`s and `FakeRead`s for match scrutinees. In my opinion, there's no need to look for `Downcast` as well. r? @oli-obk
2020-04-30Rollup merge of #71590 - RalfJung:mir-dump-pointers, r=oli-obkTyler Mandry-37/+38
MIR dump: print pointers consistently with Miri output This makes MIR allocation dump pointer printing consistent with Miri output: both use hexadecimal offsets with a `0x` prefix. To save some space, MIR dump replaces the `alloc` prefix by `a` when necessary. I also made AllocId/Pointer printing more consistent in their Debug/Display handling, and adjusted Display printing for Scalar a bit to avoid using decimal printing when we do not know the sign with which to interpret the value (IMO using decimal then is misleading).
2020-04-30Rollup merge of #71597 - CohenArthur:refactor-unique-empty, r=shepmasterDylan DPC-2/+2
Rename Unique::empty() -> Unique::dangling() A `FIXME` comment in `src/libcore/ptr/unique.rs` suggested refactoring `Unique::empty()` to `Unique::dangling()` which this PR does.
2020-04-30deduplicate warningsRalf Jung-221/+225
2020-04-30remove no longer needed feature flagsRalf Jung-42/+128
2020-04-30Rollup merge of #71655 - RalfJung:const-pattern-soundness, r=oli-obkDylan DPC-14/+221
Miri: better document and fix dynamic const pattern soundness checks https://github.com/rust-lang/const-eval/issues/42 got me thinking about soundness for consts being used in patterns, and I found a hole in our existing dynamic checks: a const referring to a mutable static *in a different crate* was not caught. This PR fixes that. It also adds some comments that explain which invariants are crucial for soundness of const-patterns. Curiously, trying to weaponize this soundness hole failed: pattern matching compilation ICEd when encountering the cross-crate static, saying "expected allocation ID alloc0 to point to memory". I don't know why that would happen, statics *should* be entirely normal memory for pattern matching to access. r? @oli-obk Cc @rust-lang/wg-const-eval
2020-04-30rename-unique: Rename Unique::empty() to Unique::dangling()cohenarthur-2/+2
rename-unique: Change calls and doc in raw_vec.rs rename-unique: Change empty() -> dangling() in const-ptr-unique-rpass.rs
2020-04-29Bless testsDylan MacKenzie-10/+2
2020-04-29Auto merge of #67343 - ecstatic-morse:qualif-structural-match, r=pnkfelixbors-0/+655
Const qualification for `StructuralEq` Furthers #62411. Resolves #62614. The goal of this PR is to implement the logic in #67088 on the MIR instead of the HIR. It uses the `Qualif` trait to track `StructuralPartialEq`/`StructuralEq` in the final value of a `const`. Then, if we encounter a constant during HAIR lowering whose value may not be structurally matchable, we emit the `indirect_structural_match` lint. This PR contains all the tests present in #67088 and emits the proper warnings for the corner cases. This PR does not handle #65466, which would require that we be [more aggressive](https://github.com/rust-lang/rust/blob/42abbd8878d3b67238f3611b0587c704ba94f39c/src/librustc_mir_build/hair/pattern/const_to_pat.rs#L126-L130) when checking matched types for `PartialEq`. I think that should be done separately. Because this works on MIR and uses dataflow, this PR should accept more cases than #67088. Notably, the qualifs in the final value of a const are encoded cross-crate, so matching on a constant whose value is defined in another crate to be `Option::<TyWithCustomEqImpl>::None` should work. Additionally, if a `const` has branching/looping, we will only emit the warning if any possible control flow path could result in a type with a custom `PartialEq` impl ending up as the final value of a `const`. I'm not sure how #67088 handled this. AFAIK, it's not settled that these are the semantics we actually want: it's just how the `Qualif` framework happens to work. If the cross-crate part is undesirable, it would be quite easy to change the result of `mir_const_qualif().custom_eq` to `true` before encoding it in the crate metadata. This way, other crates would have to assume that all publicly exported constants may not be safe for matching. r? @pnkfelix cc @eddyb
2020-04-29some more test casesRalf Jung-14/+109
2020-04-29also test reference into static fieldRalf Jung-15/+40
2020-04-28TYPE -> TYPE_ASCRIPTIONGDylan MacKenzie-8/+8
2020-04-28Use path to refer to constants in cross-crate pattern testsDylan MacKenzie-10/+9
2020-04-28Add cross-crate const in pattern testsDylan MacKenzie-0/+55
2020-04-28Add branchy `const` in pattern testsDylan MacKenzie-0/+129
2020-04-28FIXME: ignore test that ICEsDylan MacKenzie-0/+4
2020-04-28Add tests from #67088 and the issues mentioned in its descriptionDylan MacKenzie-0/+468
2020-04-28add test for const-ref-to-cross-crate-mutable-staticRalf Jung-14/+101
2020-04-28Rollup merge of #71488 - spastorino:normalize-ty-to-fix-broken-mir, r=eddybDylan DPC-0/+1
normalize field projection ty to fix broken MIR issue Fixes #71344 r? @eddyb
2020-04-27keep 'pointer' terminology aroundRalf Jung-14/+14
2020-04-27make recursive-zst test unleashedRalf Jung-3/+27
2020-04-26organize Debug/Display impls a bit more; avoid sign-ignorant decimal displayRalf Jung-37/+38
2020-04-26Rollup merge of #71140 - oli-obk:static_cycle, r=RalfJungDylan DPC-2/+27
[breaking change] Disallow statics initializing themselves fixes #71078 Self-initialization is unsound because it breaks privacy assumptions that unsafe code can make. In ```rust pub mod foo { #[derive(Debug, Copy, Clone)] pub struct Foo { x: (), } } pub static FOO: foo::Foo = FOO; ``` unsafe could could expect that ony functions inside the `foo` module were able to create a value of type `Foo`.
2020-04-24adjust testsRalf Jung-4/+2
2020-04-23normalize field projection ty to fix broken MIR issueSantiago Pastorino-0/+1
2020-04-23explain what we are testing in mutable_constRalf Jung-9/+18
2020-04-23miri-unleash tests: ensure they fire even with 'allow(const_err)'Ralf Jung-174/+140
2020-04-23Rollup merge of #71005 - jonas-schievink:no-place-like-return, r=oli-obkDylan DPC-2/+2
Reading from the return place is fine Const eval thinks that reading from local `_0` is UB, but it isn't. `_0` is just a normal local like any other, and codegen handles it that way too. The only special thing is that the `Return` terminator will read from it. I've hit these errors while working on an NRVO pass that can merge other locals with `_0` in https://github.com/rust-lang/rust/pull/71003. r? @oli-obk
2020-04-23Disallow statics initializing themselvesOliver Scherer-2/+27
2020-04-22Rollup merge of #71336 - ecstatic-morse:check-consts-asm, r=oli-obkDylan DPC-1/+28
Exhaustively match on `{Statement,Terminator}Kind` during const checking This adds a pre-monomorphization error for inline assembly in a const context as well. r? @oli-obk
2020-04-22Rollup merge of #70970 - eddyb:trait-vs-impl-mismatch, r=oli-obkDylan DPC-0/+26
Detect mistyped associated consts in `Instance::resolve`. *Based on #71049 to prevent redundant/misleading downstream errors.* Fixes #70942 by refusing to resolve an associated `const` if it doesn't have the same type in the `impl` that it does in the `trait` (which we assume had errored, and `delay_span_bug` guards against bugs).
2020-04-21Assign correct span to new illegal opsDylan MacKenzie-11/+12
2020-04-20Treat RETURN_PLACE as a normal LocalJonas Schievink-2/+2
Copy its value to the `return_place` upon leaving a call frame
2020-04-19Bless new miri_unleashed testDylan MacKenzie-2/+13
2020-04-19Check for `llvm_asm` in a const contextDylan MacKenzie-0/+15
2020-04-19Rollup merge of #71324 - petrochenkov:passcheck2, r=RalfJungDylan DPC-2/+2
Fix some tests failing in `--pass check` mode r? @RalfJung
2020-04-19Rollup merge of #71317 - RalfJung:unleash-inline-asm, r=ecstatic-morseDylan DPC-0/+25
miri-unleash test for llvm_asm r? @oli-obk @ecstatic-morse