about summary refs log tree commit diff
path: root/tests/ui/consts
AgeCommit message (Collapse)AuthorLines
2024-06-14Add more testsMichael Goulet-0/+245
2024-06-14Resolve elided lifetimes in assoc const to static if no other lifetimes are ↵Michael Goulet-0/+12
in scope
2024-06-14Rollup merge of #126426 - RalfJung:dangling-zst-ice, r=oli-obkMatthias Krüger-3/+38
const validation: fix ICE on dangling ZST reference Fixes https://github.com/rust-lang/rust/issues/126393 I'm not super happy with this fix but I can't think of a better one. r? `@oli-obk`
2024-06-14const validation: fix ICE on dangling ZST referenceRalf Jung-3/+38
2024-06-13Tweak output of import suggestionsEsteban Küber-4/+8
When both `std::` and `core::` items are available, only suggest the `std::` ones. We ensure that in `no_std` crates we suggest `core::` items. Ensure that the list of items suggested to be imported are always in the order of local crate items, `std`/`core` items and finally foreign crate items. Tweak wording of import suggestion: if there are multiple items but they are all of the same kind, we use the kind name and not the generic "items". Fix #83564.
2024-06-12Spell out other trait diagnosticAlex Macleod-16/+16
2024-06-12Require any function with a tait in its signature to actually constrain a ↵Oli Scherer-0/+244
hidden type
2024-06-11add const eval bool-to-int cast testRalf Jung-0/+31
2024-06-05Bless tests and handle tests/crashesBoxy-18/+11
2024-06-03Auto merge of #125778 - estebank:issue-67100, r=compiler-errorsbors-8/+8
Use parenthetical notation for `Fn` traits Always use the `Fn(T) -> R` format when printing closure traits instead of `Fn<(T,), Output = R>`. Address #67100: ``` error[E0277]: expected a `Fn()` closure, found `F` --> file.rs:6:13 | 6 | call_fn(f) | ------- ^ expected an `Fn()` closure, found `F` | | | required by a bound introduced by this call | = note: wrap the `F` in a closure with no arguments: `|| { /* code */ }` note: required by a bound in `call_fn` --> file.rs:1:15 | 1 | fn call_fn<F: Fn() -> ()>(f: &F) { | ^^^^^^^^^^ required by this bound in `call_fn` help: consider further restricting this bound | 5 | fn call_any<F: std::any::Any + Fn()>(f: &F) { | ++++++ ```
2024-05-29Use parenthetical notation for `Fn` traitsEsteban Küber-8/+8
Always use the `Fn(T) -> R` format when printing closure traits instead of `Fn<(T,), Output = R>`. Fix #67100: ``` error[E0277]: expected a `Fn()` closure, found `F` --> file.rs:6:13 | 6 | call_fn(f) | ------- ^ expected an `Fn()` closure, found `F` | | | required by a bound introduced by this call | = note: wrap the `F` in a closure with no arguments: `|| { /* code */ }` note: required by a bound in `call_fn` --> file.rs:1:15 | 1 | fn call_fn<F: Fn() -> ()>(f: &F) { | ^^^^^^^^^^ required by this bound in `call_fn` help: consider further restricting this bound | 5 | fn call_any<F: std::any::Any + Fn()>(f: &F) { | ++++++ ```
2024-05-29Partially implement `ConstArgHasType`Boxy-51/+0
2024-05-26Auto merge of #124661 - RalfJung:only-structural-consts-in-patterns, r=pnkfelixbors-202/+32
Turn remaining non-structural-const-in-pattern lints into hard errors This completes the implementation of https://github.com/rust-lang/rust/issues/120362 by turning our remaining future-compat lints into hard errors: indirect_structural_match and pointer_structural_match. They have been future-compat lints for a while (indirect_structural_match for many years, pointer_structural_match since Rust 1.75 (released Dec 28, 2023)), and have shown up in dependency breakage reports since Rust 1.78 (just released on May 2, 2024). I don't expect a lot of code will still depend on them, but we will of course do a crater run. A lot of cleanup is now possible in const_to_pat, but that is deferred to a later PR. Fixes https://github.com/rust-lang/rust/issues/70861
2024-05-26Auto merge of #125518 - saethlin:check-arguments-new-in-const, r=joboetbors-4/+4
Move the checks for Arguments constructors to inline const Thanks `@Skgland` for pointing out this opportunity: https://github.com/rust-lang/rust/pull/117804#discussion_r1612964362
2024-05-24Move the checks for Arguments constructors to inline constBen Kimock-4/+4
2024-05-23Allow const eval failures if the cause is a type layout issueOli Scherer-14/+26
2024-05-23Add regression testsOli Scherer-0/+42
2024-05-23Auto merge of #125359 - RalfJung:interpret-overflowing-ops, r=oli-obkbors-3/+3
interpret: make overflowing binops just normal binops Follow-up to https://github.com/rust-lang/rust/pull/125173 (Cc `@scottmcm)`
2024-05-21interpret: make overflowing binops just normal binopsRalf Jung-3/+3
2024-05-13offset, offset_from: allow zero-byte offset on arbitrary pointersRalf Jung-63/+36
2024-05-09interpret/miri: better errors on failing offset_fromRalf Jung-7/+7
2024-05-03turn pointer_structural_match into a hard errorRalf Jung-140/+11
2024-05-03remove IndirectStructuralMatch lint, emit the usual hard error insteadRalf Jung-62/+21
2024-05-02Stabilize exclusive_rangeRoss Smyth-1/+1
2024-05-01Add inline comments why we're forcing the target cpuJosh Stone-1/+2
2024-05-01Use an explicit x86-64 cpu in tests that are sensitive to itJosh Stone-1/+1
There are a few tests that depend on some target features **not** being enabled by default, and usually they are correct with the default x86-64 target CPU. However, in downstream builds we have modified the default to fit our distros -- `x86-64-v2` in RHEL 9 and `x86-64-v3` in RHEL 10 -- and the latter especially trips tests that expect not to have AVX. These cases are few enough that we can just set them back explicitly.
2024-04-27Rollup merge of #124425 - saethlin:ceci-nest-pas-une-ice, r=compiler-errorsMatthias Krüger-0/+52
Do not ICE on invalid consts when walking mono-reachable blocks The `bug!` here was written under the logic of "this condition is impossible, right?" except that of course, if the compiler is given code that results in an compile error, then the situation is possible. So now we just direct errors into the already-existing path for when we can't do a mono-time optimization.
2024-04-27Add missing tests for an ICEGurinder Singh-0/+76
2024-04-26Do not ICE on invalid consts when walking mono-reachable blocksBen Kimock-0/+52
2024-04-24Fix tests and blessGary Guo-6/+2
2024-04-23properly fill a promoted's required_constsRalf Jung-1/+89
then we can also make all_required_consts_are_checked a constant instead of a function
2024-04-23promotion: do not promote const-fn calls in const when that may fail without ↵Ralf Jung-219/+60
the entire const failing
2024-04-22Rollup merge of #124230 - reitermarkus:generic-nonzero-stable, r=dtolnayGuillaume Gomez-4/+2
Stabilize generic `NonZero`. Tracking issue: https://github.com/rust-lang/rust/issues/120257 r? `@dtolnay`
2024-04-22Stabilize generic `NonZero`.Markus Reiter-4/+2
2024-04-22Rollup merge of #124240 - matthiaskrgr:tests_sunday, r=compiler-errorsMatthias Krüger-0/+62
add a couple tests for fixed ICEs. Fixes https://github.com/rust-lang/rust/issues/121413 Fixes https://github.com/rust-lang/rust/issues/121463 Fixes https://github.com/rust-lang/rust/issues/114463
2024-04-21add test for #121413Matthias Krüger-0/+62
Fixes #121413
2024-04-21Move some testsCaio-0/+33
2024-04-18Auto merge of #122684 - oli-obk:delay_interning_errors_to_after_validaiton, ↵bors-460/+241
r=RalfJung Delay interning errors to after validation fixes https://github.com/rust-lang/rust/issues/122398 fixes #122548 This improves diagnostics since validation errors are usually more helpful compared with interning errors that just make broad statements about the entire constant r? `@RalfJung`
2024-04-17Auto merge of #123936 - Mark-Simulacrum:zst-no-alloc, r=oli-obkbors-8/+13
Codegen ZSTs without an allocation This makes sure that &[] is equivalent to unsafe code (from_raw_parts(dangling, 0)). No new stable guarantee is intended about whether or not we do this, this is just an optimization. This regressed in #67000 (no comments I can see about that regression in the PR, though it did change the test modified here). We had previously performed this optimization since #63635.
2024-04-17Validate before reporting interning errors.Oli Scherer-490/+201
validation produces much higher quality errors and already handles most of the cases
2024-04-17Validate nested static itemsOli Scherer-61/+131
2024-04-16Codegen ZSTs without an allocationMark Rousskov-8/+13
This makes sure that &[] is just as efficient as indirecting through unsafe code (from_raw_parts). No new stable guarantee is intended about whether or not we do this, this is just an optimization. Co-authored-by: Ralf Jung <post@ralfj.de>
2024-04-17Rollup merge of #124000 - compiler-errors:sugg-tweaks, r=wesleywiserGuillaume Gomez-2/+2
Use `/* value */` as a placeholder The expression `value` isn't a valid suggestion; let's use `/* value */` as a placeholder (which is also invalid) since it more clearly signals to the user that they need to fill it in with something meaningful. This parallels the suggestions we have in a couple other places, like arguments. We could also print the type name instead of `/* value */`, especially if it's suggestable, but I don't care strongly about that.
2024-04-16Fail candidate assembly for erroneous typesGurinder Singh-0/+39
Trait predicates for types which have errors may still evaluate to OK leading to downstream ICEs. Now we return a selection error for such types in candidate assembly and thereby prevent such issues
2024-04-15Use /* value */ as a placeholderMichael Goulet-2/+2
2024-04-15Fix pretty hir for anon consts in diagnosticsMichael Goulet-1/+1
2024-04-14Fix value suggestion for array in generic contextMichael Goulet-0/+26
2024-04-12Stabilize (const_)slice_ptr_len and (const_)slice_ptr_is_empty_nonnullEduardo Sánchez Muñoz-1/+0
2024-04-11Rollup merge of #123704 - estebank:diag-changes, r=compiler-errorsMatthias Krüger-2/+2
Tweak value suggestions in `borrowck` and `hir_analysis` Unify the output of `suggest_assign_value` and `ty_kind_suggestion`. Ideally we'd make these a single function, but doing so would likely require modify the crate dependency tree.
2024-04-10Handle more cases of value suggestionsEsteban Küber-2/+2