about summary refs log tree commit diff
path: root/src/test/ui/consts
AgeCommit message (Collapse)AuthorLines
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
2020-04-19Fix commentRalf Jung-3/+2
2020-04-19Fix some tests failing in `--pass check` modeVadim Petrochenkov-2/+2
2020-04-19miri-unleash test for llvm_asmRalf Jung-0/+26
2020-04-18Detect mistyped associated consts in `Instance::resolve`.Eduard-Mihai Burtescu-0/+26
2020-04-18miri-unleashed: test that we detect heap allocationsRalf Jung-0/+29
2020-04-17Auto merge of #71049 - eddyb:const-err, r=oli-obkbors-148/+25
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-17Rollup merge of #71206 - RalfJung:dont-try, r=oli-obkDylan DPC-1/+1
Miri error messages: avoid try terminology r? @oli-obk
2020-04-16bikeshedRalf Jung-1/+1
2020-04-16ty: convert `ErrorHandled::Reported` to `ConstKind::Error`.Eduard-Mihai Burtescu-148/+25
2020-04-16Miri error messages: avoid try terminologyRalf Jung-1/+1
2020-04-16test fast path offset reportingRalf Jung-2/+112
2020-04-16switch back to 'bytes'Ralf Jung-1/+1
2020-04-15reword Miri validity errors: undefined -> uninitializedRalf Jung-3/+3
2020-04-14typeck: always expose repeat count `AnonConst`s' parent in `generics_of`.Eduard-Mihai Burtescu-45/+8
2020-04-14borrow_check/type_check: normalize `Aggregate` and `Call` operands.Eduard-Mihai Burtescu-0/+15
2020-04-14typeck: workaround WF hole in `to_const`.Eduard-Mihai Burtescu-5/+30