summary refs log tree commit diff
path: root/tests/ui/consts/const-eval
AgeCommit message (Collapse)AuthorLines
2024-03-14Added `deny(const_eval_mutable_ptr_in_final_value)` attribute to all tests ↵Felix S. Klock II-1/+26
that were expecting the hard error for it. I attempted to do this in a manner that preserved the line numbers to reduce the review effort on the resulting diff, but we still have to deal with the ramifications of how a future-incompat lint behaves compared to a hard-error (in terms of its impact on the diagnostic output). (cherry picked from commit 1c3424bfc1354db47fd3901cb1b76c22fbe33392)
2024-01-31Don't hash lints differently to non-lints.Nicholas Nethercote-1/+0
`Diagnostic::keys`, which is used for hashing and equating diagnostics, has a surprising behaviour: it ignores children, but only for lints. This was added in #88493 to fix some duplicated diagnostics, but it doesn't seem necessary any more. This commit removes the special case and only four tests have changed output, with additional errors. And those additional errors aren't exact duplicates, they're just similar. For example, in src/tools/clippy/tests/ui/same_name_method.rs we currently have this error: ``` error: method's name is the same as an existing method in a trait --> $DIR/same_name_method.rs:75:13 | LL | fn foo() {} | ^^^^^^^^^^^ | note: existing `foo` defined here --> $DIR/same_name_method.rs:79:9 | LL | impl T1 for S {} | ^^^^^^^^^^^^^^^^ ``` and with this change we also get this error: ``` error: method's name is the same as an existing method in a trait --> $DIR/same_name_method.rs:75:13 | LL | fn foo() {} | ^^^^^^^^^^^ | note: existing `foo` defined here --> $DIR/same_name_method.rs:81:9 | LL | impl T2 for S {} | ^^^^^^^^^^^^^^^^ ``` I think printing this second argument is reasonable, possibly even preferable to hiding it. And the other cases are similar.
2024-01-22const-eval interner: from-scratch rewrite using mutability information from ↵Ralf Jung-35/+7
provenance rather than types
2024-01-20Auto merge of #119821 - oli-obk:reveal_all_const_evals, r=lcnrbors-3/+2
Always use RevealAll for const eval queries implements what is described in https://github.com/rust-lang/rust/pull/116803#discussion_r1364089471 Using `UserFacing` for const eval does not make sense anymore, unless we significantly change things like avoiding revealing opaque types. New tests are copied from https://github.com/rust-lang/rust/pull/101478
2024-01-19Always use RevealAll for const eval queriesOli Scherer-3/+2
2024-01-16Skip dead code checks on items that failed typeckOli Scherer-4/+12
2024-01-13Bless testsGeorge-lewis-0/+3
Update tests
2024-01-11Use the right level with `-Ztreat-err-as-bug`.Nicholas Nethercote-1/+1
Errors in `DiagCtxtInner::emit_diagnostic` are never set to `Level::Bug`, because the condition never succeeds, because `self.treat_err_as_bug()` is called *before* the error counts are incremented. This commit switches to `self.treat_next_err_as_bug()`, fixing the problem. This changes the error message output to actually say "internal compiler error".
2024-01-06remove an unnecessary stderr-per-bitwidthRalf Jung-139/+5
2023-12-24Replace legacy ConstProp by GVN.Camille GILLOT-6/+0
2023-12-12also test projecting to some sized fields at non-zero offset in structs with ↵Ralf Jung-2/+7
an extern type tail
2023-12-12make it more clear what comments refer to; avoid dangling unaligned referencesRalf Jung-5/+11
Co-authored-by: Waffle Maybe <waffle.lapkin@gmail.com>
2023-12-12reject projecting to fields whose offset we cannot computeRalf Jung-59/+41
2023-12-07also print 'immutable' flagRalf Jung-48/+48
2023-12-07compile-time evaluation: emit a lint when a write through an immutable ↵Ralf Jung-0/+85
pointer occurs
2023-12-02Auto merge of #118077 - calebzulawski:sync-portable-simd-2023-11-19, ↵bors-2/+2
r=workingjubilee Portable SIMD subtree update Syncs nightly to the latest changes from rust-lang/portable-simd r? `@rust-lang/libs`
2023-11-30generic_const_exprs: suggest to add the feature, not use itRalf Jung-1/+1
2023-11-27make const tests independent of std debug assertionsRalf Jung-163/+112
2023-11-26Update std::simd usage and test outputsCaleb Zulawski-2/+2
2023-11-25Fix testsGary Guo-110/+111
2023-11-24Manual find replace updatesNilstrieb-5/+5
2023-11-24Show number in error message even for one errorNilstrieb-54/+54
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-10-31Do not ICE on constant evaluation failure in GVN.Camille GILLOT-3/+26
2023-10-28Auto merge of #116240 - dtolnay:constdiscriminant, r=thomccbors-1/+1
Const stabilize mem::discriminant Tracking issue: #69821. This PR is a rebase of https://github.com/rust-lang/rust/pull/103893 to resolve conflicts in library/core/src/lib.rs (against #102470 and #110393).
2023-10-25Stabilize `[const_]pointer_byte_offsets`Maybe Waffle-7/+5
2023-10-16Stop trying to preserve pretty-printing.Camille GILLOT-44/+44
2023-10-16Rebless.Camille GILLOT-9/+9
2023-10-16Normalize alloc-id in tests.Camille GILLOT-63/+63
2023-10-15more precise error for 'based on misaligned pointer' caseRalf Jung-7/+7
2023-10-15place evaluation: require the original pointer to be aligned if an access ↵Ralf Jung-2/+19
happens
2023-10-15don't UB on dangling ptr deref, instead check inbounds on projectionsRalf Jung-86/+105
2023-10-14Rollup merge of #116576 - eduardosm:const-eval-wasm-target-features, r=RalfJungGuillaume Gomez-0/+14
const-eval: allow calling functions with targat features disabled at compile time in WASM This is not unsafe on WASM, see https://github.com/rust-lang/rust/pull/84988 r? `@RalfJung` Fixes https://github.com/rust-lang/rust/issues/116516
2023-10-14const-eval: allow calling functions with targat features disabled at compile ↵Eduardo Sánchez Muñoz-0/+14
time in WASM This is not unsafe on WASM, see https://github.com/rust-lang/rust/pull/84988
2023-10-14Auto merge of #116015 - EvanMerlock:master, r=oli-obkbors-0/+53
const_eval: allow function pointer signatures containing &mut T in const contexts potentially fixes #114994 We utilize a `TypeVisitor` here in order to more easily handle control flow. - In the event the typekind the Visitor sees is a function pointer, we skip over it - However, otherwise we do one of two things: - If we find a mutable reference, check it, then continue visiting types - If we find any other type, continue visiting types This means we will check if the function pointer _itself_ is mutable, but not if any of the types _within_ are.
2023-10-14Auto merge of #115524 - RalfJung:misalign, r=wesleywiserbors-0/+72
const-eval: make misalignment a hard error It's been a future-incompat error (showing up in cargo's reports) since https://github.com/rust-lang/rust/pull/104616, Rust 1.68, released in March. That should be long enough. The question for the lang team is simply -- should we move ahead with this, making const-eval alignment failures a hard error? (It turns out some of them accidentally already were hard errors since #104616. But not all so this is still a breaking change. Crater found no regression.)
2023-10-10Rollup merge of #116444 - RalfJung:broken-unused-const, r=oli-obkGuillaume Gomez-0/+31
add test for const-eval error in dead code during monomorphization
2023-10-08add test for const-eval error in dead code during monomorphizationRalf Jung-0/+31
2023-10-06Rollup merge of #116329 - RalfJung:swap-comments, r=scottmcmGuillaume Gomez-1/+2
update some comments around swap() Based on ``@eddyb's`` comment [here](https://github.com/rust-lang/unsafe-code-guidelines/issues/461#issuecomment-1742156410). And then I noticed the wrong capitalization for Miri and fixed it in some other places as well.
2023-10-05Add a note to duplicate diagnosticsAlex Macleod-5/+9
2023-10-02MIRI -> MiriRalf Jung-1/+2
2023-09-28Const stabilize mem::discriminantDavid Tolnay-1/+1
2023-09-26add misalignment const-eval testRalf Jung-0/+72
and some other raw pointer shenanigans while we are at it
2023-09-22test(const_eval): add test cases for #114994Evan Merlock-0/+53
- add new testcase for TypeVisitor on const-eval mutable ref check
2023-09-14don't point at const usage site for resolution-time errorsRalf Jung-23/+23
also share the code that emits the actual error
2023-09-05Auto merge of #115531 - RalfJung:read_via_copy, r=scottmcmbors-4/+26
read_via_copy: don't prematurely optimize away the read Always do the read to ensure consistent UB error messages in const-eval/Miri. r? `@scottmcm`
2023-09-04read_via_copy: don't prematurely optimize away the readRalf Jung-4/+26
2023-09-04Auto merge of #115513 - Urgau:normalize-msg-after-translate, r=petrochenkovbors-0/+16
Don't forget to normalize the translated message This PR adds a missing call to `normalize_whitespace` after translating an label. Fixes https://github.com/rust-lang/rust/issues/115498
2023-09-03Don't forget to normalize the translated messageUrgau-0/+16
2023-08-24Fix ub-int-array test for big-endian platformsUlrich Weigand-42/+10
As of commit 7767cbb3b0b332fd0a46e347ea7f68f20109d768, the tests/ui/consts/const-eval/ub-int-array.rs test is failing on big-endian platforms (in particular s390x), as the stderr output contains a hex dump that depends on endianness. Since this point intentionally verifies the hex dump to check the uninitialized byte markers, I think we should not simply standardize away the hex dump as is done with some of the other tests in this directory. However, most of the test is already endian-independent. The only exception is one line of hex dump, which can also be made endian-independent by choosing appropriate constants in the source code. Since the 32bit and 64bit stderr outputs were already (and remain) identical, I've merged them and removed the stderr-per-bitwidth marker. Fixes (again) https://github.com/rust-lang/rust/issues/105383.
2023-08-02const validation: point at where we found a pointer but expected an integerRalf Jung-131/+165