summary refs log tree commit diff
path: root/src/test/ui/consts
AgeCommit message (Collapse)AuthorLines
2019-12-14Show const_err lint in addition to the hard errorOliver Scherer-2/+16
2019-12-14Ensure that we get a hard error on generic ZST constants if their body ↵Oliver Scherer-0/+27
causes an error during evaluation
2019-12-06[ConstProp] Avoid OOM crashes by not evaluating large PlacesWesley Wiser-0/+20
Fix spurious CI filures due to OOM Fixes #66397
2019-11-02Auto merge of #63810 - oli-obk:const_offset_from, r=RalfJung,nikicbors-0/+145
Make <*const/mut T>::offset_from `const fn` This reenables offset_of cc @mjbshaw after https://github.com/rust-lang/rust/pull/63075 broke it
2019-11-02adjust for missing spans on x86 test runnerRalf Jung-8/+7
2019-10-28Auto merge of #65188 - matthewjasper:stabilize-const-constructor, r=Centrilbors-98/+40
Stabilize `const_constructor` # Stabilization proposal I propose that we stabilize `#![feature(const_constructor)]`. Tracking issue: https://github.com/rust-lang/rust/issues/61456 Version target: 1.40 (2019-11-05 => beta, 2019-12-19 => stable). ## What is stabilized ### User guide Tuple struct and tuple variant constructors are now considered to be constant functions. As such a call expression where the callee has a tuple struct or variant constructor "function item" type can be called: ```rust const fn make_options() { // These already work because they are special cased: Some(0); (Option::Some)(1); // These also work now: let f = Option::Some; f(2); {Option::Some}(3); <Option<_>>::Some(5); } ``` ### Motivation Consistency with other `const fn`. Consistency between syntactic path forms. This should also ensure that constructors implement `const Fn` traits and can be coerced to `const fn` function pointers, if they are introduced. ## Tests * [ui/consts/const_constructor/const-construct-call.rs](https://github.com/rust-lang/rust/blob/0d75ab2293a106eb674ac01860910cfc1580837e/src/test/ui/consts/const_constructor/const-construct-call.rs) - Tests various syntactic forms, use in both `const fn` and `const` items, and constructors in both the current and extern crates. * [ui/consts/const_constructor/const_constructor_qpath.rs](https://github.com/rust-lang/rust/blob/1850dfcdabf8258a1f023f26c2c59e96b869dd95/src/test/ui/consts/const_constructor/const_constructor_qpath.rs) - Tests that type qualified paths to enum variants are also considered to be `const fn`.(#64247) r? @oli-obk Closes #61456 Closes #64247
2019-10-27Stabilize `const_constructor`Matthew Jasper-98/+40
2019-10-27Implementation of const caller_location.Adam Perry-0/+23
2019-10-24Increase spacing for suggestions in diagnosticsEsteban Küber-0/+1
Make the spacing between the code snippet and verbose structured suggestions consistent with note and help messages.
2019-10-21Rollup merge of #65092 - tspiteri:const-is-pow2, r=oli-obkMazdak Farrokhzad-0/+11
make is_power_of_two a const function This makes `is_power_of_two` a const function by using `&` instead of short-circuiting `&&`; Rust supports bitwise `&` for `bool` and short-circuiting is not required in the existing expression. I don't think this needs a const-hack label as I don't find the changed code less readable, if anything I prefer that it is clearer that short circuiting is not used. @oli-obk
2019-10-21Rollup merge of #65629 - ecstatic-morse:remove-graphviz, r=Mark-SimulacrumMazdak Farrokhzad-6/+3
Remove `borrowck_graphviz_postflow` from test Resolves #65071 (again). Sorry. I've added a commit hook to prevent this from happening in the future. r? @petrochenkov
2019-10-20Remove `borrowck_graphviz_postflow` from testDylan MacKenzie-6/+3
2019-10-20Rollup merge of #65593 - RalfJung:non-const-fn, r=oli-obkMazdak Farrokhzad-0/+42
add test for calling non-const fn The good news is that there is an error. But I expected to see [this error](https://github.com/rust-lang/rust/blob/9578272d681c8691ca2ff3f5c4230b491bc1c694/src/librustc_mir/const_eval.rs#L346) surface. @oli-obk any idea why that message is not shown anywhere? r? @oli-obk
2019-10-19Rollup merge of #65192 - estebank:restrict-bound, r=matthewjasperMazdak Farrokhzad-2/+6
Use structured suggestion for restricting bounds When a trait bound is not met and restricting a type parameter would make the restriction hold, use a structured suggestion pointing at an appropriate place (type param in param list or `where` clause). Account for opaque parameters where instead of suggesting extending the `where` clause, we suggest appending the new restriction: `fn foo(impl Trait + UnmetTrait)`. Fix #64565, fix #41817, fix #24354, cc #26026, cc #37808, cc #24159, fix #37138, fix #24354, cc #20671.
2019-10-19show the proper diagnosticsRalf Jung-2/+17
2019-10-19add test for calling non-const fnRalf Jung-0/+27
2019-10-19Update ui outputOliver Scherer-6/+6
2019-10-19Auto merge of #64890 - wesleywiser:const_prop_rvalue, r=oli-obkbors-3/+52
[const-prop] Handle remaining MIR Rvalue cases r? @oli-obk
2019-10-19Rollup merge of #65485 - ecstatic-morse:const-validation-mismatch-ugliness, ↵Mazdak Farrokhzad-0/+24
r=eddyb Suppress ICE when validators disagree on `LiveDrop`s in presence of `&mut` Resolves #65394. This hack disables the validator mismatch ICE in cases where a `MutBorrow` error has been emitted by both validators, but they don't agree on the number of `LiveDrop` errors. The new validator is more conservative about whether a value is moved from in the presence of mutable borrows. For example, the new validator will emit a `LiveDrop` error on the following code. ```rust const _: Vec<i32> = { let mut x = Vec::new(); let px = &mut x as *mut _; let y = x; unsafe { ptr::write(px, Vec::new()); } y }; ``` This code is not UB AFAIK (it passes MIRI at least). The current validator does not emit a `LiveDrop` error for `x` upon exit from the initializer. `x` is not actually dropped, so I think this is correct? A proper fix for this would require a new `MaybeInitializedLocals` dataflow analysis or maybe a relaxation of the existing `IndirectlyMutableLocals` one. r? @RalfJung
2019-10-18Don't ICE when evaluating writes to uninhabited enum variantsWesley Wiser-0/+28
2019-10-18Ignore a test on musl because its ui output differsOliver Scherer-0/+3
2019-10-18Adjust const eval code to reflect `offset_from` docsOliver Scherer-30/+9
2019-10-18[const-prop] Handle MIR Rvalue::AggregatesWesley Wiser-2/+16
2019-10-18[const-prop] Handle MIR Rvalue::RepeatWesley Wiser-1/+8
2019-10-16Add regression test for #65394Dylan MacKenzie-0/+24
2019-10-16Upgrade Emscripten targets to use upstream LLVM backendThomas Lively-1/+0
- Compatible with Emscripten 1.38.46-upstream or later upstream. - Refactors the Emscripten target spec to share code with other wasm targets. - Replaces the old incorrect wasm32 C call ABI with the correct one, preserving the old one as wasm32_bindgen_compat for wasm-bindgen compatibility. - Updates the varargs ABI used by Emscripten and deletes the old one. - Removes the obsolete wasm32-experimental-emscripten target. - Uses EMCC_CFLAGS on CI to avoid the timeout problems with #63649.
2019-10-15Rollup merge of #65389 - ecstatic-morse:zero-sized-array-no-drop, r=eddybTyler Mandry-0/+23
Return `false` from `needs_drop` for all zero-sized arrays. Resolves #65348. This changes the result of the `needs_drop` query from `true` to `false` for types such as `[Box<i32>; 0]`. I believe this change to be sound because a zero-sized array can never actually hold a value. This is an elegant way of resolving #65348 and #64945, but obviously it has much broader implications.
2019-10-15Handle more cases involving `impl` and `trait`Esteban Küber-2/+6
2019-10-14Auto merge of #64987 - oli-obk:code_reuse_prevents_bugs, r=eddybbors-0/+20
Compute the layout of uninhabited structs fixes #64506 r? @eddyb
2019-10-13Add regression test for #65348Dylan MacKenzie-0/+23
2019-10-13Rollup merge of #65320 - memoryruins:const_err, r=oli-obkMazdak Farrokhzad-0/+38
Report `CONST_ERR` lint in external macros fixes #65300 fixes #61058 r? @oli-obk
2019-10-11Add regression test for CONST_ERR lints in extern macrosmemoryruins-0/+38
2019-10-11Make <*const/mut T>::offset_from `const fn`Oliver Scherer-0/+164
2019-10-09Suggest `if let` on `let` refutable bindingEsteban Küber-0/+42
2019-10-09Move test next to likeminded onesOliver Scherer-0/+20
2019-10-07Auto merge of #64906 - Aaron1011:feature/extern-const-fn, r=Centrilbors-0/+229
Add support for `const unsafe? extern fn` This works just as you might expect - an `const extern fn` is a `const fn` that is callable from foreign code. Currently, panicking is not allowed in `const`s. When https://github.com/rust-lang/rfcs/pull/2345 (https://github.com/rust-lang/rust/issues/51999) is stabilized, then panicking in an `const extern fn` will produce a compile-time error when invoked at compile time, and an abort when invoked at runtime. Since this is extending the language (we're allowing the `const` keyword in a new context), I believe that this will need an FCP. However, it's a very minor change, so I didn't think that filing an RFC was necessary. This will allow libc (and other FFI crates) to make many functions `const`, without having to give up on making them `extern` as well. Tracking issue: https://github.com/rust-lang/rust/issues/64926.
2019-10-05Rollup merge of #65151 - tmandry:revert-emscripten-upgrade, r=tmandryTyler Mandry-0/+1
Revert #63649 - "Upgrade Emscripten targets to use upstream LLVM backend" This change caused the runtime of the linux-asmjs builder to nearly double from 2+ hours to about 4 hours, which happens to be the bors timeout. (It made it in barely under 4 hours when it was merged.) This is causing timeouts on all new changes. This reverts commit 7870050796e5904a0fc85ecbe6fa6dde1cfe0c91, reversing changes made to 2e7244807a7878f6eca3eb7d97ae9b413aa49014.
2019-10-05Rollup merge of #65066 - ↵Tyler Mandry-11/+22
wesleywiser:fix_const_prop_ice_on_polymorphic_promoted_mir, r=oli-obk [const-prop] Fix ICE when trying to eval polymorphic promoted MIR Fixes #64908 r? @oli-obk cc @nikomatsakis @pnkfelix
2019-10-05Revert "Auto merge of #63649 - tlively:emscripten-upstream-upgrade, ↵Tyler Mandry-0/+1
r=alexcrichton" This reverts commit 7870050796e5904a0fc85ecbe6fa6dde1cfe0c91, reversing changes made to 2e7244807a7878f6eca3eb7d97ae9b413aa49014.
2019-10-04Auto merge of #63649 - tlively:emscripten-upstream-upgrade, r=alexcrichtonbors-1/+0
Upgrade Emscripten targets to use upstream LLVM backend - Refactors the Emscripten target spec to share code with other wasm targets. - Replaces the incorrect wasm32 C call ABI with the old asmjs version, which is correct for both wasm32 and JS. - Updates the varargs ABI used by Emscripten and deletes the old one. - Removes the obsolete wasm32-experimental-emscripten target. - Temporarily makes Emscripten targets use panic=abort by default because supporting unwinding will require an LLVM patch.
2019-10-04[const-prop] Fix ICE when trying to eval polymorphic promoted MIRWesley Wiser-11/+22
2019-10-04make is_power_of_two a const functionTrevor Spiteri-0/+11
2019-10-04Upgrade Emscripten targets to use upstream LLVM backendThomas Lively-1/+0
- Refactors the Emscripten target spec to share code with other wasm targets. - Replaces the incorrect wasm32 C call ABI with the old asmjs version, which is correct for both wasm32 and JS. - Updates the varargs ABI used by Emscripten and deletes the old one. - Removes the obsolete wasm32-experimental-emscripten target. - Temporarily makes Emscripten targets use panic=abort by default because supporting unwinding will require an LLVM patch.
2019-10-04Rollup merge of #64749 - matthewjasper:liveness-opt, r=nikomatsakisMazdak Farrokhzad-29/+0
Fix most remaining Polonius test differences This fixes most of the Polonius test differences and also avoids overflow in issue-38591.rs. r? @nikomatsakis
2019-10-02Calculate liveness for the same locals with and without -ZpoloniusMatthew Jasper-29/+0
This fixes some test differences and also avoids overflow in issue-38591.rs.
2019-10-02Rollup merge of #64991 - wesleywiser:fix_too_eager_const_prop, r=oli-obkMazdak Farrokhzad-0/+23
[const-prop] Correctly handle locals that can't be propagated `const_prop()` now handles writing the Rvalue into the Place in the stack frame for us. So if we're not supposed to propagate that value, we need to clear it. r? @oli-obk Fixes #64970
2019-10-02[const-prop] Correctly handle locals that can't be propagatedWesley Wiser-0/+23
`const_prop()` now handles writing the Rvalue into the Place in the stack frame for us. So if we're not supported to propagate that value, we need to clear it.
2019-10-02Add support for 'extern const fn'Aaron Hill-0/+229
This works just as you might expect - an 'extern const fn' is a 'const fn' that is callable from foreign code. Currently, panicking is not allowed in consts. When RFC 2345 is stabilized, then panicking in an 'extern const fn' will produce a compile-time error when invoked at compile time, and an abort when invoked at runtime. Since this is extending the language (we're allowing the `const` keyword in a new context), I believe that this will need an FCP. However, it's a very minor change, so I didn't think that filing an RFC was necessary. This will allow libc (and other FFI crates) to make many functions `const`, without having to give up on making them `extern` as well.
2019-10-01Add test cases for #64945Dylan MacKenzie-0/+61
This also tests that `&&[]` no longer causes an ICE in this PR (although the test fails the borrow checker). This could be more complete.
2019-09-30Rollup merge of #64921 - JohnTitor:add-test-enum, r=varkorTyler Mandry-0/+25
Add test for issue-64662 Closes #64662 r? @varkor