about summary refs log tree commit diff
path: root/src/test/ui/consts
AgeCommit message (Collapse)AuthorLines
2020-07-11Rollup merge of #72920 - oli-obk:const_transmute, r=RalfJungManish Goregaokar-72/+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-72/+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-10Rollup merge of #73887 - DutchGhost:master, r=oli-obkManish Goregaokar-2/+0
stabilize const mem::forget Stabilizes const `mem::forget` as implemented in https://github.com/rust-lang/rust/pull/69617 and tracked in https://github.com/rust-lang/rust/issues/69616. Closes https://github.com/rust-lang/rust/issues/69616
2020-07-10Rollup merge of #73862 - oli-obk:const_array_to_slice, r=RalfJungManish Goregaokar-29/+22
Stabilize casts and coercions to `&[T]` in const fn Part of #64992 There was never a reason to not stabilize this, we just accidentally prevented them when we implemented the `min_const_fn` feature that gave us `const fn` on stable. This PR stabilizes these casts (which are already stable in `const` outside `const fn`), while keeping all other unsizing casts (so `T` -> `dyn Trait`) unstable within const fn. These casts have no forward compatibility concerns with any future features for const eval and users were able to use them under the `const_fn` feature gate already since at least the miri merger, possibly longer. r? @rust-lang/lang
2020-07-05Remove the usage of the LengthAtMost32 traitRoman Proskuryakov-7/+16
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-07-01Add feature const_optionBenoît du Garreau-0/+14
2020-06-30Bless failing testsLeSeulArtichaut-97/+99
2020-06-30stabilize const mem::forgetDodo-2/+0
2020-06-30Stabilize casts and coercions to `&[T]` in const fnOliver Scherer-29/+22
2020-06-29stabilize const_ascii_ctype_on_intrinsicsTrevor Spiteri-2/+0
2020-06-29stabilize const_int_signTrevor Spiteri-2/+0
2020-06-29stabilize const_saturating_int_methodsTrevor Spiteri-2/+0
2020-06-29stabilize const_nonzero_int_methodsTrevor Spiteri-2/+0
2020-06-28Update testsDylan MacKenzie-314/+40
2020-06-28Update testsDylan MacKenzie-1022/+178
2020-06-26Show the values and computation that would overflow a const evaluation or ↵Oliver Scherer-95/+95
propagation
2020-06-24Fix testsNathan Corbyn-0/+1
2020-06-24Implement intrinsicNathan Corbyn-0/+46
2020-06-23Rollup merge of #73515 - christianpoveda:livedrop-diagnostics, r=oli-obkManish Goregaokar-8/+77
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-50/+71
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-22Revert "Rollup merge of #72389 - Aaron1011:feature/move-fn-self-msg, ↵Aaron Hill-5/+4
r=nikomatsakis" This reverts commit 372cb9b69c76a042d0b9d4b48ff6084f64c84a2c, reversing changes made to 5c61a8dc34c3e2fc6d7f02cb288c350f0233f944.
2020-06-20update testsChristian Poveda-8/+77
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-19Rollup merge of #72934 - christianpoveda:mut-borrows-in-consts, r=oli-obkManish Goregaokar-57/+90
forbid mutable references in all constant contexts except for const-fns PR to address #71212 cc: @ecstatic-morse
2020-06-19Rollup merge of #71420 - RalfJung:specialization-incomplete, r=matthewjasperManish Goregaokar-1/+12
Specialization is unsound As discussed in https://github.com/rust-lang/rust/issues/31844#issuecomment-617013949, it might be a good idea to warn users of specialization that the feature they are using is unsound. I also expanded the "incomplete feature" warning to link the user to the tracking issue.
2020-06-19add new error codeChristian Poveda-27/+29
2020-06-19update diagnostics for &mut in constantsChristian Poveda-96/+54
2020-06-19update testsChristian Poveda-17/+90
2020-06-19Add fuzzy pointer comparison intrinsicsOliver Scherer-4/+23
2020-06-19Remove the const_raw_ptr_comparison feature gate.Oliver Scherer-50/+56
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-19Auto merge of #73486 - Manishearth:rollup-11iyqpc, r=Manishearthbors-1/+1
Rollup of 17 pull requests Successful merges: - #70551 (Make all uses of ty::Error delay a span bug) - #71338 (Expand "recursive opaque type" diagnostic) - #71976 (Improve diagnostics for `let x += 1`) - #72279 (add raw_ref macros) - #72628 (Add tests for 'impl Default for [T; N]') - #72804 (Further tweak lifetime errors involving `dyn Trait` and `impl Trait` in return position) - #72814 (remove visit_terminator_kind from MIR visitor) - #72836 (Complete the std::time documentation to warn about the inconsistencies between OS) - #72968 (Only highlight doc search results via mouseover if mouse has moved) - #73034 (Export `#[inline]` fns with extern indicators) - #73315 (Clean up some weird command strings) - #73320 (Make new type param suggestion more targetted) - #73361 (Tweak "non-primitive cast" error) - #73425 (Mention functions pointers in the documentation) - #73428 (Fix typo in librustc_ast docs) - #73447 (Improve document for `Result::as_deref(_mut)` methods) - #73476 (Added tooltip for should_panic code examples) Failed merges: r? @ghost
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-17Add regression test for #73431Dylan MacKenzie-0/+29
2020-06-16warn against 'specialization' featureRalf Jung-1/+12
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-15Auto merge of #73369 - RalfJung:rollup-hl8g9zf, r=RalfJungbors-24/+27
Rollup of 10 pull requests Successful merges: - #72707 (Use min_specialization in the remaining rustc crates) - #72740 (On recursive ADT, provide indirection structured suggestion) - #72879 (Miri: avoid tracking current location three times) - #72938 (Stabilize Option::zip) - #73086 (Rename "cyclone" to "apple-a7" per changes in upstream LLVM) - #73104 (Example about explicit mutex dropping) - #73139 (Add methods to go from a nul-terminated Vec<u8> to a CString) - #73296 (Remove vestigial CI job msvc-aux.) - #73304 (Revert heterogeneous SocketAddr PartialEq impls) - #73331 (extend network support for HermitCore) Failed merges: r? @ghost
2020-06-15Rollup merge of #72879 - RalfJung:miri-tctx-at, r=oli-obkRalf Jung-24/+27
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-15Rollup merge of #72389 - Aaron1011:feature/move-fn-self-msg, r=nikomatsakisRalf Jung-4/+5
Explain move errors that occur due to method calls involving `self` When calling a method that takes `self` (e.g. `vec.into_iter()`), the method receiver is moved out of. If the method receiver is used again, a move error will be emitted:: ```rust fn main() { let a = vec![true]; a.into_iter(); a; } ``` emits ``` error[E0382]: use of moved value: `a` --> src/main.rs:4:5 | 2 | let a = vec![true]; | - move occurs because `a` has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait 3 | a.into_iter(); | - value moved here 4 | a; | ^ value used here after move ``` However, the error message doesn't make it clear that the move is caused by the call to `into_iter`. This PR adds additional messages to move errors when the move is caused by using a value as the receiver of a `self` method:: ``` error[E0382]: use of moved value: `a` --> vec.rs:4:5 | 2 | let a = vec![true]; | - move occurs because `a` has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait 3 | a.into_iter(); | ------------- value moved due to this method call 4 | a; | ^ value used here after move | note: this function takes `self`, which moves the receiver --> /home/aaron/repos/rust/src/libcore/iter/traits/collect.rs:239:5 | 239 | fn into_iter(self) -> Self::IntoIter; ``` TODO: - [x] Add special handling for `FnOnce/FnMut/Fn` - we probably don't want to point at the unstable trait methods - [x] Consider adding additional context for operations (e.g. `Shr::shr`) when the call was generated using the operator syntax (e.g. `a >> b`) - [x] Consider pointing to the method parent (impl or trait block) in addition to the method itself.
2020-06-15Rollup merge of #71824 - ecstatic-morse:const-check-post-drop-elab, r=oli-obkRalf Jung-9/+49
Check for live drops in constants after drop elaboration Resolves #66753. This PR splits the MIR "optimization" pass series in two and introduces a query–`mir_drops_elaborated_and_const_checked`–that holds the result of the `post_borrowck_cleanup` analyses and checks for live drops. This query is invoked in `rustc_interface` for all items requiring const-checking, which means we now do `post_borrowck_cleanup` for items even if they are unused in the crate. As a result, we are now more precise about when drops are live. This is because drop elaboration can e.g. eliminate drops of a local when all its fields are moved from. This does not mean we are doing value-based analysis on move paths, however; Storing a `Some(CustomDropImpl)` into a field of a local will still set the qualifs for that entire local. r? @oli-obk
2020-06-13Add tests for `const_precise_live_drops`Dylan MacKenzie-9/+49
2020-06-13avoid computing precise span for const_eval queryRalf Jung-2/+2
2020-06-13Prefer the associated consts for pattern matching errorLzu Tao-18/+18
2020-06-12Rollup merge of #72906 - lzutao:migrate-numeric-assoc-consts, r=dtolnayDylan DPC-53/+53
Migrate to numeric associated consts The deprecation PR is #72885 cc #68490 cc rust-lang/rfcs#2700
2020-06-12fix const_prop spans and re-bless testsRalf Jung-22/+25