about summary refs log tree commit diff
path: root/tests/ui/consts/const-eval
AgeCommit message (Collapse)AuthorLines
2024-07-27improve dangling/oob errors and make them more uniformRalf Jung-10/+10
2024-07-26Rollup merge of #124941 - Skgland:stabilize-const-int-from-str, r=dtolnayTrevor Gross-4/+2
Stabilize const `{integer}::from_str_radix` i.e. `const_int_from_str` This PR stabilizes the feature `const_int_from_str`. - ACP Issue: rust-lang/libs-team#74 - Implementation PR: rust-lang/rust#99322 - Part of Tracking Issue: rust-lang/rust#59133 API Change Diff: ```diff impl {integer} { - pub fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>; + pub const fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>; } impl ParseIntError { - pub fn kind(&self) -> &IntErrorKind; + pub const fn kind(&self) -> &IntErrorKind; } ``` This makes it easier to parse integers at compile-time, e.g. the example from the Tracking Issue: ```rust env!("SOMETHING").parse::<usize>().unwrap() ``` could now be achived with ```rust match usize::from_str_radix(env!("SOMETHING"), 10) { Ok(val) => val, Err(err) => panic!("Invalid value for SOMETHING environment variable."), } ``` rather than having to depend on a library that implements or manually implement the parsing at compile-time. --- Checklist based on [Libs Stabilization Guide - When there's const involved](https://std-dev-guide.rust-lang.org/development/stabilization.html#when-theres-const-involved) I am treating this as a [partial stabilization](https://std-dev-guide.rust-lang.org/development/stabilization.html#partial-stabilizations) as it shares a tracking issue (and is rather small), so directly opening the partial stabilization PR for the subset (feature `const_int_from_str`) being stabilized. - [x] ping Constant Evaluation WG - [x] no unsafe involved - [x] no `#[allow_internal_unstable]` - [ ] usage of `intrinsic::const_eval_select` rust-lang/rust#124625 in `from_str_radix_assert` to change the error message between compile-time and run-time - [ ] [rust-labg/libs-api FCP](https://github.com/rust-lang/rust/pull/124941#issuecomment-2207021921)
2024-07-19Rollup merge of #127856 - RalfJung:interpret-cast-sanity, r=oli-obkMatthias Krüger-182/+113
interpret: add sanity check in dyn upcast to double-check what codegen does For dyn receiver calls, we already have two codepaths: look up the function to call by indexing into the vtable, or alternatively resolve the DefId given the dynamic type of the receiver. With debug assertions enabled, the interpreter does both and compares the results. (Without debug assertions we always use the vtable as it is simpler.) This PR does the same for dyn trait upcasts. However, for casts *not* using the vtable is the easier thing to do, so now the vtable path is the debug-assertion-only path. In particular, there are cases where the vtable does not contain a pointer for upcasts but instead reuses the old pointer: when the supertrait vtable is a prefix of the larger vtable. We don't want to expose this optimization and detect UB if people do a transmute assuming this optimization, so we cannot in general use the vtable indexing path. r? ``@oli-obk``
2024-07-18interpret: add sanity check in dyn upcast to double-check what codegen doesRalf Jung-182/+113
2024-07-12Make parse error suggestions verbose and fix spansEsteban Küber-6/+21
Go over all structured parser suggestions and make them verbose style. When suggesting to add or remove delimiters, turn them into multiple suggestion parts.
2024-07-11Always use a colon in `//@ normalize-*:` headersZalathar-27/+27
2024-07-04stabilize `const_int_from_str`Skgland-4/+2
2024-06-22don't ICE when encountering an extern type field during validationRalf Jung-1/+25
2024-06-19Remove c_unwind from tests and fix testsGary Guo-1/+1
2024-06-12Spell out other trait diagnosticAlex Macleod-8/+8
2024-06-11add const eval bool-to-int cast testRalf Jung-0/+31
2024-05-24Move the checks for Arguments constructors to inline constBen Kimock-4/+4
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-27Add missing tests for an ICEGurinder Singh-0/+76
2024-04-24Fix tests and blessGary Guo-2/+0
2024-04-23promotion: do not promote const-fn calls in const when that may fail without ↵Ralf Jung-184/+0
the entire const failing
2024-04-22Stabilize generic `NonZero`.Markus Reiter-3/+2
2024-04-17Validate before reporting interning errors.Oli Scherer-6/+16
validation produces much higher quality errors and already handles most of the cases
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-09tests: bless ui and rustdoc-ui tests for ICE messages许杰友 Jieyou Xu (Joe)-0/+2
2024-03-30Make {integer}::from_str_radix constantGeorge Bateman-0/+41
2024-03-27Use `TraitRef::to_string` sorting in favor of `TraitRef::ord`, as the latter ↵Oli Scherer-4/+4
compares `DefId`s which we need to avoid
2024-03-17Auto merge of #121885 - reitermarkus:generic-nonzero-inner, ↵bors-6/+6
r=oli-obk,wesleywiser Move generic `NonZero` `rustc_layout_scalar_valid_range_start` attribute to inner type. Tracking issue: https://github.com/rust-lang/rust/issues/120257 r? `@dtolnay`
2024-03-14preserve span when evaluating mir::ConstOperandRalf Jung-0/+88
2024-03-14Rollup merge of #122440 - RalfJung:required-consts, r=oli-obkMatthias Krüger-101/+0
const-eval: organize and extend tests for required-consts This includes some tests that are known-broken and hence disabled (due to https://github.com/rust-lang/rust/issues/107503). r? `````@oli-obk`````
2024-03-13const-eval: organize and extend tests for required-constsRalf Jung-101/+0
2024-03-13Added `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).
2024-03-10Move generic `NonZero` `rustc_layout_scalar_valid_range_start` attribute to ↵Markus Reiter-6/+6
inner type.
2024-03-08Fix crash in late internal checkingyukang-3/+33
2024-02-29add const test for ptr::metadataRalf Jung-33/+36
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-25Use generic `NonZero` in tests.Markus Reiter-135/+135
2024-02-25fix use of platform_intrinsics in testsRalf Jung-2/+2
2024-02-19Always evaluate free constants and statics, even if previous errors occurredOli Scherer-52/+23
2024-02-17Enable `ConstPropLint` for promotedsGurinder Singh-3/+28
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)-123/+123
2024-02-16remove stderr-per-bitwidth from some testsRalf Jung-62/+8
2024-02-05revert stabilization of const_intrinsic_copyRalf Jung-1/+1
2024-02-03Rollup merge of #120616 - fmease:fix-ice-const-eval-fail-undef-field-access, ↵Matthias Krüger-0/+22
r=compiler-errors Fix ICE on field access on a tainted type after const-eval failure Fixes #120615. r? oli-obk or compiler
2024-02-03Check for presence of field in typeck results before visiting itLeón Orell Valerian Liehr-0/+22
Co-authored-by: Michael Goulet <michael@errs.io>
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