about summary refs log tree commit diff
path: root/tests/ui/consts
AgeCommit message (Collapse)AuthorLines
2024-02-11Rollup merge of #120883 - RalfJung:extern-static-err, r=oli-obkMatthias Krüger-2/+43
interpret: rename ReadExternStatic → ExternStatic This error shows up for reads and writes, so `ReadExternStatic` is misleading.
2024-02-10rebless after rebaseRalf Jung-2/+28
2024-02-10detect consts that reference extern staticsRalf Jung-47/+76
2024-02-10validation: descend from consts into staticsRalf Jung-112/+249
2024-02-10unstably allow constants to refer to statics and read from immutable staticsRalf Jung-318/+311
2024-02-10interpret: rename ReadExternStatic → ExternStaticRalf Jung-2/+43
2024-02-10Rollup merge of #117614 - RalfJung:static-mut-refs, r=davidtwco,oli-obkMatthias Krüger-38/+30
static mut: allow mutable reference to arbitrary types, not just slices and arrays For historical reasons, we allow this: ```rust static mut ARRAY: &'static mut [isize] = &mut [1]; ``` However, we do not allow this: ```rust static mut INT: &'static mut isize = &mut 1; ``` I think that's terribly inconsistent. I don't care much for `static mut`, but we have to keep it around for backwards compatibility and so we have to keep supporting it properly in the compiler. In recent refactors of how we deal with mutability of data in `static` and `const`, I almost made a fatal mistake since I tested `static mut INT: &'static mut isize = &mut 1` and concluded that we don't allow such `'static` mutable references even inside `static mut`. After all, nobody would expect this to be allowed only for arrays and slices, right?!?? So for the sake of our own sanity, and of whoever else reverse engineers these rules in the future to understand what the Rust compiler accepts or does not accept, I propose that we accept this for all types, not just arrays and slices.
2024-02-08Continue to borrowck even if there were previous errorsOli Scherer-16/+351
2024-02-08Taint borrowck results without running any borrowck if the MIR body was ↵Oli Scherer-90/+20
already tainted
2024-02-07Update testsr0cky-3/+13
2024-02-07Auto merge of #120722 - matthiaskrgr:rollup-9o32280, r=matthiaskrgrbors-139/+148
Rollup of 9 pull requests Successful merges: - #119939 (Improve 'generic param from outer item' error for `Self` and inside `static`/`const` items) - #120331 (pattern_analysis: use a plain `Vec` in `DeconstructedPat`) - #120396 (Account for unbounded type param receiver in suggestions) - #120423 (update indirect structural match lints to match RFC and to show up for dependencies) - #120435 (Suggest name value cfg when only value is used for check-cfg) - #120502 (Remove `ffi_returns_twice` feature) - #120507 (Account for non-overlapping unmet trait bounds in suggestion) - #120513 (Normalize type outlives obligations in NLL for new solver) - #120707 (Don't expect early-bound region to be local when reporting errors in RPITIT well-formedness) r? `@ghost` `@rustbot` modify labels: rollup
2024-02-05revert stabilization of const_intrinsic_copyRalf Jung-1/+1
2024-02-05merge the accepted-structural-match tests into oneRalf Jung-34/+14
2024-02-05update the tracking issue for structural match violationsRalf Jung-15/+32
and bless a test I missed
2024-02-05show indirect_structural_match and pointer_structural_match in future compat ↵Ralf Jung-0/+107
reports
2024-02-05get rid of nontrivial_structural_match lint and custom_eq const qualifRalf Jung-99/+4
2024-02-05Rollup merge of #120384 - wackbyte:array-equality-generics, r=Mark-SimulacrumMatthias Krüger-6/+6
Use `<T, U>` for array/slice equality `impl`s Makes the trait implementation documentation for arrays and slices appear more consistent. [Example](https://doc.rust-lang.org/1.75.0/std/primitive.array.html): mixed `A`, `B`, and `U`. ![List of PartialEq implementations for arrays](https://github.com/wackbyte/rust/assets/29505620/823c010e-ee57-4de1-885b-a1cd6dcaf85f) This change makes them all `U`.
2024-02-04Auto merge of #120649 - matthiaskrgr:rollup-ek80j61, r=matthiaskrgrbors-2/+1
Rollup of 8 pull requests Successful merges: - #119759 (Add FileCheck annotations to dataflow-const-prop tests) - #120323 (On E0277 be clearer about implicit `Sized` bounds on type params and assoc types) - #120473 (Only suggest removal of `as_*` and `to_` conversion methods on E0308) - #120540 (add test for try-block-in-match-arm) - #120547 (`#![feature(inline_const_pat)]` is no longer incomplete) - #120552 (Correctly check `never_type` feature gating) - #120555 (put pnkfelix (me) back on the review queue.) - #120556 (Improve the diagnostics for unused generic parameters) r? `@ghost` `@rustbot` modify labels: rollup
2024-02-04Auto merge of #120624 - matthiaskrgr:rollup-3gvcl20, r=matthiaskrgrbors-2/+10
Rollup of 8 pull requests Successful merges: - #120484 (Avoid ICE when is_val_statically_known is not of a supported type) - #120516 (pattern_analysis: cleanup manual impls) - #120517 (never patterns: It is correct to lower `!` to `_`.) - #120523 (Improve `io::Read::read_buf_exact` error case) - #120528 (Store SHOULD_CAPTURE as AtomicU8) - #120529 (Update data layouts in custom target tests for LLVM 18) - #120531 (Remove a bunch of `has_errors` checks that have no meaningful or the wrong effect) - #120533 (Correct paths for hexagon-unknown-none-elf platform doc) r? `@ghost` `@rustbot` modify labels: rollup
2024-02-03Rollup merge of #120531 - oli-obk:track_errors7, r=estebankMatthias Krüger-2/+10
Remove a bunch of `has_errors` checks that have no meaningful or the wrong effect r? `@nnethercote`
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-02-01`#![feature(inline_const_pat)]` is no longer incompleteMatthew Jasper-2/+1
2024-01-31Remove a has_errors check that only hides errors after unrelated items have ↵Oli Scherer-2/+10
errored.
2024-01-31Rollup merge of #120490 - nnethercote:Diagnostic-hashing, r=estebankNadrieril-1/+0
Don't hash lints differently to non-lints. `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. r? `@estebank`
2024-01-30Provide more context on derived obligation error primary labelEsteban Küber-8/+8
Expand the primary span of E0277 when the immediate unmet bound is not what the user wrote: ``` error[E0277]: the trait bound `i32: Bar` is not satisfied --> f100.rs:6:6 | 6 | <i32 as Foo>::foo(); | ^^^ the trait `Bar` is not implemented for `i32`, which is required by `i32: Foo` | help: this trait has no implementations, consider adding one --> f100.rs:2:1 | 2 | trait Bar {} | ^^^^^^^^^ note: required for `i32` to implement `Foo` --> f100.rs:3:14 | 3 | impl<T: Bar> Foo for T {} | --- ^^^ ^ | | | unsatisfied trait bound introduced here ``` Fix #40120.
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-30Rollup merge of #120293 - estebank:issue-102629, r=nnethercoteGuillaume Gomez-1/+1
Deduplicate more sized errors on call exprs Change the implicit `Sized` `Obligation` `Span` for call expressions to include the whole expression. This aids the existing deduplication machinery to reduce the number of errors caused by a single unsized expression.
2024-01-28static mut: allow reference to arbitrary types, not just slices and arraysRalf Jung-38/+30
2024-01-26Use `<T, U>` for array/slice equality `impl`swackbyte-6/+6
Makes the trait implementation documentation for arrays and slices appear more consistent.
2024-01-26interpret: project_downcast: do not ICE for uninhabited variantsRalf Jung-0/+10
2024-01-26Auto merge of #116167 - RalfJung:structural-eq, r=lcnrbors-133/+74
remove StructuralEq trait The documentation given for the trait is outdated: *all* function pointers implement `PartialEq` and `Eq` these days. So the `StructuralEq` trait doesn't really seem to have any reason to exist any more. One side-effect of this PR is that we allow matching on some consts that do not implement `Eq`. However, we already allowed matching on floats and consts containing floats, so this is not new, it is just allowed in more cases now. IMO it makes no sense at all to allow float matching but also sometimes require an `Eq` instance. If we want to require `Eq` we should adjust https://github.com/rust-lang/rust/pull/115893 to check for `Eq`, and rule out float matching for good. Fixes https://github.com/rust-lang/rust/issues/115881
2024-01-25Auto merge of #119911 - NCGThompson:is-statically-known, r=oli-obkbors-0/+15
Replacement of #114390: Add new intrinsic `is_var_statically_known` and optimize pow for powers of two This adds a new intrinsic `is_val_statically_known` that lowers to [``@llvm.is.constant.*`](https://llvm.org/docs/LangRef.html#llvm-is-constant-intrinsic).` It also applies the intrinsic in the int_pow methods to recognize and optimize the idiom `2isize.pow(x)`. See #114390 for more discussion. While I have extended the scope of the power of two optimization from #114390, I haven't added any new uses for the intrinsic. That can be done in later pull requests. Note: When testing or using the library, be sure to use `--stage 1` or higher. Otherwise, the intrinsic will be a noop and the doctests will be skipped. If you are trying out edits, you may be interested in [`--keep-stage 0`](https://rustc-dev-guide.rust-lang.org/building/suggested.html#faster-builds-with---keep-stage). Fixes #47234 Resolves #114390 `@Centri3`
2024-01-25Auto merge of #119627 - oli-obk:const_prop_lint_n̵o̵n̵sense, r=cjgillotbors-3/+12
Remove all ConstPropNonsense We track all locals and projections on them ourselves within the const propagator and only use the InterpCx to actually do some low level operations or read from constants (via `OpTy` we get for said constants). This helps moving the const prop lint out from the normal pipeline and running it just based on borrowck information. This in turn allows us to make progress on https://github.com/rust-lang/rust/pull/108730#issuecomment-1875557745 there are various follow up cleanups that can be done after this PR (e.g. not matching on Rvalue twice and doing binop checks twice), but lets try landing this one first. r? `@RalfJung`
2024-01-24remove StructuralEq traitRalf Jung-133/+74
2024-01-24Deduplicate more sized errors on call exprsEsteban Küber-1/+1
Change the implicit `Sized` `Obligation` `Span` for call expressions to include the whole expression. This aids the existing deduplication machinery to reduce the number of errors caused by a single unsized expression.
2024-01-24Remove extra # from urlest31-4/+4
2024-01-23Rollup merge of #119805 - chenyukang:yukang-fix-119530, r=davidtwcoLeón Orell Valerian Liehr-0/+8
Suggest array::from_fn for array initialization Fixes #119530
2024-01-23Stop using `eval_rvalue_into_place` in const propOli Scherer-3/+12
2024-01-22raw pointers are not referencesRalf Jung-12/+12
2024-01-22const-eval interner: from-scratch rewrite using mutability information from ↵Ralf Jung-196/+733
provenance rather than types
2024-01-21Suggest arry::from_fn for array initializationyukang-0/+8
2024-01-20Auto merge of #119821 - oli-obk:reveal_all_const_evals, r=lcnrbors-38/+18
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-19Add new intrinsic `is_constant` and optimize `pow`Catherine Flores-0/+15
Fix overflow check Make MIRI choose the path randomly and rename the intrinsic Add back test Add miri test and make it operate on `ptr` Define `llvm.is.constant` for primitives Update MIRI comment and fix test in stage2 Add const eval test Clarify that both branches must have the same side effects guaranteed non guarantee use immediate type instead Co-Authored-By: Ralf Jung <post@ralfj.de>
2024-01-19Always use RevealAll for const eval queriesOli Scherer-38/+18
2024-01-18Remove no-longer-needed `allow(dead_code)` from the testsJake Goulding-1/+1
`repr(transparent)` now silences the lint.
2024-01-16Skip dead code checks on items that failed typeckOli Scherer-4/+12
2024-01-13Bless testsGeorge-lewis-0/+62
Update tests
2024-01-11Rollup merge of #119852 - RalfJung:const-err4, r=compiler-errorsMatthias Krüger-11/+1
give const-err4 a more descriptive name Also, doesn't look like this still needs to be per-bitwidth r? ``@oli-obk``
2024-01-11give const-err4 a more descriptive nameRalf Jung-11/+1