about summary refs log tree commit diff
path: root/tests/ui/consts
AgeCommit message (Collapse)AuthorLines
2023-12-14update use of feature flagslcnr-1/+1
2023-12-13Auto merge of #118534 - RalfJung:extern-type-size-of-val, r=WaffleLapkinbors-59/+52
codegen: panic when trying to compute size/align of extern type The alignment is also computed when accessing a field of extern type at non-zero offset, so we also panic in that case. Previously `size_of_val` worked because the code path there assumed that "thin pointer" means "sized". But that's not true any more with extern types. The returned size and align are just blatantly wrong, so it seems better to panic than returning wrong results. We use a non-unwinding panic since code probably does not expect size_of_val to panic.
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-12Improve an error involving attribute values.Nicholas Nethercote-2/+2
Attribute values must be literals. The error you get when that doesn't hold is pretty bad, e.g.: ``` unexpected expression: 1 + 1 ``` You also get the same error if the attribute value is a literal, but an invalid literal, e.g.: ``` unexpected expression: "foo"suffix ``` This commit does two things. - Changes the error message to "attribute value must be a literal", which gives a better idea of what the problem is and how to fix it. It also no longer prints the invalid expression, because the carets below highlight it anyway. - Separates the "not a literal" case from the "invalid literal" case. Which means invalid literals now get the specific error at the literal level, rather than at the attribute level.
2023-12-11Auto merge of #118661 - fee1-dead-contrib:restore-const-partialEq, ↵bors-7/+1
r=compiler-errors Restore `const PartialEq` And thus fixes a number of tests. There is a bug that still needs to be fixed, so WIP for now. r? `@compiler-errors`
2023-12-10fix testsDeadbeef-7/+1
2023-12-10remove redundant importssurechen-2/+0
detects redundant imports that can be eliminated. for #117772 : In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR.
2023-12-08Auto merge of #118689 - compiler-errors:const-drop, r=fee1-deadbors-12/+1
Fix const drop checking Fixes confirmation of `~const Destruct` and const drops. r? fee1-dead
2023-12-07also print 'immutable' flagRalf Jung-61/+61
2023-12-07compile-time evaluation: emit a lint when a write through an immutable ↵Ralf Jung-15/+94
pointer occurs
2023-12-07Fix const drop checkingMichael Goulet-12/+1
2023-12-02Auto merge of #118077 - calebzulawski:sync-portable-simd-2023-11-19, ↵bors-19/+19
r=workingjubilee Portable SIMD subtree update Syncs nightly to the latest changes from rust-lang/portable-simd r? `@rust-lang/libs`
2023-12-02Auto merge of #118470 - nnethercote:cleanup-error-handlers, r=compiler-errorsbors-1/+1
Cleanup error handlers Mostly by making function naming more consistent. More to do after this, but this is enough for one PR. r? compiler-errors
2023-12-02Rename `HandlerInner::delay_span_bug` as `HandlerInner::span_delayed_bug`.Nicholas Nethercote-1/+1
Because the corresponding `Level` is `DelayedBug` and `span_delayed_bug` follows the pattern used everywhere else: `span_err`, `span_warning`, etc.
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-232/+112
2023-11-26Update std::simd usage and test outputsCaleb Zulawski-19/+19
2023-11-25Fix testsGary Guo-114/+116
2023-11-24Manual find replace updatesNilstrieb-9/+9
2023-11-24Show number in error message even for one errorNilstrieb-169/+169
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-19Rollup merge of #117832 - RalfJung:interpret-shift, r=cjgillotMichael Goulet-20/+20
interpret: simplify handling of shifts by no longer trying to handle signed and unsigned shift amounts in the same branch While we're at it, also update comments in codegen and MIR building related to shifts, and fix the overflow error printed by Miri on negative shift amounts.
2023-11-19Auto merge of #117807 - RalfJung:raw-str-slice, r=davidtwcobors-2/+19
patterns: don't ice when encountering a raw str slice Fixes https://github.com/rust-lang/rust/issues/117806
2023-11-12interpret: simplify handling of shifts by no longer trying to handle signed ↵Ralf Jung-20/+20
and unsigned shift amounts in the same branch
2023-11-12patterns: don't ice when encountering a raw str sliceRalf Jung-2/+19
2023-11-12Reenable effects in libcoreDeadbeef-2/+22
2023-11-08Auto merge of #116930 - RalfJung:raw-ptr-match, r=davidtwcobors-25/+70
patterns: reject raw pointers that are not just integers Matching against `0 as *const i32` is fine, matching against `&42 as *const i32` is not. This extends the existing check against function pointers and wide pointers: we now uniformly reject all these pointer types during valtree construction, and then later lint because of that. See [here](https://github.com/rust-lang/rust/pull/116930#issuecomment-1784654073) for some more explanation and context. Also fixes https://github.com/rust-lang/rust/issues/116929. Cc `@oli-obk` `@lcnr`
2023-11-08Rollup merge of #113925 - clubby789:const-ctor-repeat, r=estebankMatthias Krüger-9/+55
Improve diagnostic for const ctors in array repeat expressions Fixes #113912
2023-11-05Auto merge of #116218 - tgross35:const-maybe-uninit-zeroed, r=dtolnaybors-7/+6
Stabilize `const_maybe_uninit_zeroed` and `const_mem_zeroed` Make `MaybeUninit::zeroed` and `mem::zeroed` const stable. Newly stable API: ```rust // core::mem pub const unsafe fn zeroed<T>() ->; impl<T> MaybeUninit<T> { pub const fn zeroed() -> MaybeUninit<T>; } ``` This relies on features based around `const_mut_refs`. Per `@RalfJung,` this should be OK since we do not leak any `&mut` to the user. For this to be possible, intrinsics `assert_zero_valid` and `assert_mem_uninitialized_valid` were made const stable. Tracking issue: #91850 Zulip discussion: https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/.60const_mut_refs.60.20dependents r? libs-api `@rustbot` label -T-libs +T-libs-api +A-const-eval cc `@RalfJung` `@oli-obk` `@rust-lang/wg-const-eval`
2023-11-04Stabilize `const_mem_zeroed`Trevor Gross-7/+6
Make `core::mem::zeroed` const stable. Newly stable API: // core::mem pub const unsafe fn zeroed<T>() -> T; This is stabilized with `const_maybe_uninit_zeroed` since it is a simple wrapper. In order to make this possible, intrinsics `assert_zero_valid` was made const stable under `const_assert_type2`. `assert_mem_uninitialized_valid` was also made const stable since it is under the same gate.
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-2/+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-28also lint against fn ptr and raw ptr nested inside the constRalf Jung-3/+23
2023-10-28patterns: reject raw pointers that are not just integersRalf Jung-9/+34
2023-10-27Auto merge of #103208 - cjgillot:match-fake-read, r=oli-obk,RalfJungbors-0/+10
Allow partially moved values in match This PR attempts to unify the behaviour between `let _ = PLACE`, `let _: TY = PLACE;` and `match PLACE { _ => {} }`. The logical conclusion is that the `match` version should not check for uninitialised places nor check that borrows are still live. The `match PLACE {}` case is handled by keeping a `FakeRead` in the unreachable fallback case to verify that `PLACE` has a legal value. Schematically, `match PLACE { arms }` in surface rust becomes in MIR: ```rust PlaceMention(PLACE) match PLACE { // Decision tree for the explicit arms arms, // An extra fallback arm _ => { FakeRead(ForMatchedPlace, PLACE); unreachable } } ``` `match *borrow { _ => {} }` continues to check that `*borrow` is live, but does not read the value. `match *borrow {}` both checks that `*borrow` is live, and fake-reads the value. Continuation of ~https://github.com/rust-lang/rust/pull/102256~ ~https://github.com/rust-lang/rust/pull/104844~ Fixes https://github.com/rust-lang/rust/issues/99180 https://github.com/rust-lang/rust/issues/53114
2023-10-27Auto merge of #116205 - WaffleLapkin:stabilize_pointer_byte_offsets, r=dtolnaybors-12/+9
Stabilize `[const_]pointer_byte_offsets` Closes #96283 Awaiting FCP completion: https://github.com/rust-lang/rust/issues/96283#issuecomment-1735835331 r? libs-api
2023-10-26Remove unused feature from a miri testMaybe Waffle-4/+3
2023-10-25Stabilize `[const_]pointer_byte_offsets`Maybe Waffle-9/+7
2023-10-25Work around the fact that `check_mod_type_wf` may spuriously return ↵Oli Scherer-4/+44
`ErrorGuaranteed`, even if that error is only emitted by `check_modwitem_types`
2023-10-25Auto merge of #116482 - matthewjasper:thir-unsafeck-inline-constants, r=b-naberbors-1/+10
Fix inline const pattern unsafety checking in THIR Fix THIR unsafety checking of inline constants. - Steal THIR in THIR unsafety checking (if enabled) instead of MIR lowering. - Represent inline constants in THIR patterns.
2023-10-24Use `PlaceMention` for match scrutinees.Camille GILLOT-0/+10
2023-10-23return unfixed len if pat has reported errorbohan-0/+33
2023-10-20Avoid a `track_errors` by bubbling up most errors from `check_well_formed`Oli Scherer-2/+12
2023-10-18Rollup merge of #116856 - oli-obk:no_effects, r=compiler-errorsAli MJ Al-Nasrawy-0/+30
Disable effects in libcore again r? `@fee1-dead` This was accidentally allowed by https://github.com/rust-lang/rust/pull/114776 without feature gates
2023-10-17Disable effects in libcore againOli Scherer-0/+30
2023-10-16Stop trying to preserve pretty-printing.Camille GILLOT-65/+65
2023-10-16Rebless.Camille GILLOT-11/+11
2023-10-16Normalize alloc-id in tests.Camille GILLOT-100/+100
2023-10-16Fix inline const pattern unsafety checking in THIRMatthew Jasper-1/+10
THIR unsafety checking was getting a cycle of function unsafety checking -> building THIR for the function -> evaluating pattern inline constants in the function -> building MIR for the inline constant -> checking unsafety of functions (so that THIR can be stolen) This is fixed by not stealing THIR when generating MIR but instead when unsafety checking. This leaves an issue with pattern inline constants not being unsafety checked because they are evaluated away when generating THIR. To fix that we now represent inline constants in THIR patterns and visit them in THIR unsafety checking.