about summary refs log tree commit diff
path: root/tests/ui/consts
AgeCommit message (Collapse)AuthorLines
2024-03-10Move generic `NonZero` `rustc_layout_scalar_valid_range_start` attribute to ↵Markus Reiter-6/+6
inner type.
2024-03-08Auto merge of #122190 - matthiaskrgr:rollup-9ol4y30, r=matthiaskrgrbors-3/+49
Rollup of 8 pull requests Successful merges: - #121025 (add known-bug tests for derive failure to detect packed repr) - #121194 (Refactor pre-getopts command line argument handling) - #121563 (Use `ControlFlow` in visitors.) - #122173 (Don't ICE in CTFE if raw/fn-ptr types differ) - #122175 (Bless tidy issues order) - #122179 (rustc: Fix typo) - #122181 (Fix crash in internal late lint checking) - #122183 (interpret: update comment about read_discriminant on uninhabited variants) Failed merges: - #122076 (Tweak the way we protect in-place function arguments in interpreters) - #122132 (Diagnostic renaming 3) r? `@ghost` `@rustbot` modify labels: rollup
2024-03-08Rollup merge of #122181 - chenyukang:yukang-fix-late-lint-crash, r=oli-obkMatthias Krüger-3/+33
Fix crash in internal late lint checking Fixes #122177
2024-03-08Fix crash in late internal checkingyukang-3/+33
2024-03-08Don't ICE in CTFE if raw/fn-ptr types differMichael Goulet-0/+16
2024-03-07Merge collect_mod_item_types query into check_well_formedOli Scherer-20/+8
2024-03-02add comment and test: we do not do value-based reasoning for promotion of unionsRalf Jung-25/+45
2024-02-29Rollup merge of #121806 - RalfJung:const-metadata, r=oli-obkMatthias Krüger-33/+36
add const test for ptr::metadata https://github.com/rust-lang/rust/pull/121199 uncovered this as a gap in our test suite. r? `@oli-obk`
2024-02-29add const test for ptr::metadataRalf Jung-33/+36
2024-02-29make mutable_references_err not bitwidth-dependentRalf Jung-361/+2
2024-02-29allow statics pointing to mutable staticsRalf Jung-37/+196
2024-02-26Auto merge of #121516 - RalfJung:platform-intrinsics-begone, r=oli-obkbors-2/+2
remove platform-intrinsics ABI; make SIMD intrinsics be regular intrinsics `@Amanieu` `@workingjubilee` I don't think there is any reason these need to be "special"? The [original RFC](https://rust-lang.github.io/rfcs/1199-simd-infrastructure.html) indicated eventually making them stable, but I think that is no longer the plan, so seems to me like we can clean this up a bit. Blocked on https://github.com/rust-lang/stdarch/pull/1538, https://github.com/rust-lang/rust/pull/121542.
2024-02-26Auto merge of #121461 - reitermarkus:generic-nonzero-tests, r=dtolnaybors-139/+140
Use generic `NonZero` in tests. Tracking issue: https://github.com/rust-lang/rust/issues/120257 r? `@dtolnay`
2024-02-25Auto merge of #120393 - Urgau:rfc3373-non-local-defs, r=WaffleLapkinbors-0/+1
Implement RFC 3373: Avoid non-local definitions in functions This PR implements [RFC 3373: Avoid non-local definitions in functions](https://github.com/rust-lang/rust/issues/120363).
2024-02-25Use generic `NonZero` in tests.Markus Reiter-139/+140
2024-02-25make non-PartialEq-typed consts as patterns a hard errorRalf Jung-24/+4
2024-02-25fix use of platform_intrinsics in testsRalf Jung-2/+2
2024-02-24promotion: don't promote int::MIN / -1Ralf Jung-11/+62
2024-02-20Stabilize `LazyCell` and `LazyLock` (`lazy_cell`)Peter Jaszkowiak-4/+4
2024-05-24Fail relating constants of different typesOli Scherer-0/+51
2024-02-19Always evaluate free constants and statics, even if previous errors occurredOli Scherer-209/+247
2024-02-18Improve wording of static_mut_refObei Sideg-96/+94
Rename `static_mut_ref` lint to `static_mut_refs`.
2024-02-17Allow newly added non_local_definitions lint in testsUrgau-0/+1
2024-02-17Rollup merge of #120932 - RalfJung:mut-ptr-to-static, r=oli-obkGuillaume Boisseau-4/+98
const_mut_refs: allow mutable pointers to statics Fixes https://github.com/rust-lang/rust/issues/118447 Writing this PR became a bit messy, see [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/Statics.20pointing.20to.20interior.20mutable.20statics) for some of my journey.^^ Turns out there was a long-standing bug in our qualif logic that led to us incorrectly classifying certain places as "no interior mut" when they actually had interior mut. Due to that the `const_refs_to_cell` feature gate was required far less often than it otherwise would, e.g. in [this code](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=9e0c042c451b3d11d64dd6263679a164). Fixing this however would be a massive breaking change all over libcore and likely the wider ecosystem. So I also changed the const-checking logic to just not require the feature gate for the affected cases. While doing so I discovered a bunch of logic that is not explained and that I could not explain. However I think stabilizing some const-eval feature will make most of that logic inconsequential so I just added some FIXMEs and left it at that. r? `@oli-obk`
2024-02-17const_mut_refs: allow mutable refs to staticsRalf Jung-4/+98
2024-02-17Enable `ConstPropLint` for promotedsGurinder Singh-188/+3386
This fixes the issue wherein the lint didn't fire for promoteds in the case of SHL/SHR operators in non-optimized builds and all arithmetic operators in optimized builds
2024-02-16[AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives许杰友 Jieyou Xu (Joe)-576/+576
2024-02-16Rollup merge of #121179 - RalfJung:zst-mutable-refs, r=oli-obkGuillaume Gomez-325/+151
allow mutable references in const values when they point to no memory Fixes https://github.com/rust-lang/rust/issues/120450 The second commit is just some drive-by test suite cleanup. r? `@oli-obk`
2024-02-16add test ensuring we detect a static actually having a mutable referenceRalf Jung-8/+29
2024-02-16Auto merge of #120500 - oli-obk:intrinsics2.0, r=WaffleLapkinbors-3/+2
Implement intrinsics with fallback bodies fixes #93145 (though we can port many more intrinsics) cc #63585 The way this works is that the backend logic for generating custom code for intrinsics has been made fallible. The only failure path is "this intrinsic is unknown". The `Instance` (that was `InstanceDef::Intrinsic`) then gets converted to `InstanceDef::Item`, which represents the fallback body. A regular function call to that body is then codegenned. This is currently implemented for * codegen_ssa (so llvm and gcc) * codegen_cranelift other backends will need to adjust, but they can just keep doing what they were doing if they prefer (though adding new intrinsics to the compiler will then require them to implement them, instead of getting the fallback body). cc `@scottmcm` `@WaffleLapkin` ### todo * [ ] miri support * [x] default intrinsic name to name of function instead of requiring it to be specified in attribute * [x] make sure that the bodies are always available (must be collected for metadata)
2024-02-16add back some more attempts at having &mut in the final value of a const/staticRalf Jung-7/+57
2024-02-16remove stderr-per-bitwidth from some testsRalf Jung-311/+53
2024-02-16allow mutable references in const values when they point to no memoryRalf Jung-22/+35
2024-02-15Do not allocate a second "background" alloc id for the main allocation of a ↵Oli Scherer-34/+51
static. Instead we re-use the static's alloc id within the interpreter for its initializer to refer to the `Allocation` that only exists within the interpreter.
2024-02-15Return ConstAllocation from eval_static_initializer query directlyOli Scherer-21/+6
2024-02-15Add new query just for static initializersOli Scherer-10/+25
2024-02-14Auto merge of #120847 - oli-obk:track_errors9, r=compiler-errorsbors-2/+17
Continue compilation after check_mod_type_wf errors The ICEs fixed here were probably reachable through const eval gymnastics before, but now they are easily reachable without that, too. The new errors are often bugfixes, where useful errors were missing, because they were reported after the early abort. In other cases sometimes they are just duplication of already emitted errors, which won't be user-visible due to deduplication. fixes https://github.com/rust-lang/rust/issues/120860
2024-02-14Rollup merge of #120893 - c410-f3r:testsssssss, r=petrochenkovGuillaume Gomez-0/+29
Move some tests r? `@petrochenkov`
2024-02-14Continue compilation after check_mod_type_wf errorsOli Scherer-2/+17
2024-02-13Move testsCaio-0/+29
2024-02-13Do not point at `#[allow(_)]` as the reason for compat lint triggeringEsteban Küber-5/+0
Fix #121009.
2024-02-13Rollup merge of #120973 - RalfJung:static_mut_ref, r=compiler-errorsMatthias Krüger-131/+23
allow static_mut_ref in some tests that specifically test mutable statics The lint just distracts from what these tests are about.
2024-02-12Rollup merge of #120970 - RalfJung:static-promoted-test, r=oli-obkMatthias Krüger-0/+33
add another test for promoteds-in-static https://github.com/rust-lang/rust/pull/119614 led to validation of promoteds recursing into statics. These statics can point to `static mut` and interior mutable `static` and do other things we don't allow in `const`, but promoteds are validated as `const`, so we get strange errors (saying "in `const`" when there is no const) and surprising validation failures. https://github.com/rust-lang/rust/pull/120960 fixes that; this here adds another test. r? ``@oli-obk`` Fixes https://github.com/rust-lang/rust/issues/120968
2024-02-12allow static_mut_ref in some tests that specifically test mutable staticsRalf Jung-131/+23
2024-02-12Support safe intrinsics with fallback bodiesOli Scherer-1/+1
Turn `is_val_statically_known` into such an intrinsic to demonstrate. It is perfectly safe to call after all.
2024-02-12Rollup merge of #120933 - RalfJung:const-check-misc, r=oli-obkMatthias Krüger-125/+1
check_consts: fix duplicate errors, make importance consistent This is stuff I noticed while working on https://github.com/rust-lang/rust/pull/120932, but it's orthogonal to that PR. r? ``@oli-obk``
2024-02-12add another test for promoteds-in-staticRalf Jung-0/+33
2024-02-12Implement intrinsics with fallback bodiesOli Scherer-2/+1
2024-02-12fix cycle error when a static and a promoted are mutually recursiveRalf Jung-0/+12
This also now allows promoteds everywhere to point to 'extern static', because why not? We still check that constants cannot transitively reach 'extern static' through references. (We allow it through raw pointers.)
2024-02-11check_consts: fix some duplicate errors by not calling check_static ↵Ralf Jung-125/+1
unnecessarily