about summary refs log tree commit diff
path: root/tests/ui/structs
AgeCommit message (Collapse)AuthorLines
2025-09-13Rollup merge of #145896 - Oneirical:uncountable-integer-10, r=jieyouxuJacob Pratt-0/+25
Rehome 30 `tests/ui/issues/` tests to other subdirectories under `tests/ui/` [#3 of Batch #2] Part of rust-lang/rust#133895 Methodology: 1. Refer to the previously written `tests/ui/SUMMARY.md` 2. Find an appropriate category for the test, using the original issue thread and the test contents. 3. Add the issue URL at the bottom (not at the top, as that would mess up stderr line numbers) 4. Rename the tests to make their purpose clearer Inspired by the methodology that `@Kivooeo` was using. r? `@jieyouxu`
2025-09-12Add test batch 3Oneirical-0/+25
2025-08-29Rollup merge of #145676 - Oneirical:uncountable-integer-9, r=jieyouxuMatthias Krüger-0/+25
Rehome 30 `tests/ui/issues/` tests to other subdirectories under `tests/ui/` [#2 of Batch #2] Part of rust-lang/rust#133895 Methodology: 1. Refer to the previously written `tests/ui/SUMMARY.md` 2. Find an appropriate category for the test, using the original issue thread and the test contents. 3. Add the issue URL at the bottom (not at the top, as that would mess up stderr line numbers) 4. Rename the tests to make their purpose clearer Inspired by the methodology that `@Kivooeo` was using. r? `@jieyouxu`
2025-08-27Add test batch 2Oneirical-0/+25
2025-08-27Add test batch 1Oneirical-0/+47
2025-08-17Rehome tests/ui/issues/ tests [5/?]Oneirical-0/+22
2025-08-14Do not ICE on private type in field of unresolved structEsteban Küber-0/+30
2025-08-10Auto merge of #135846 - estebank:non-exhaustive-dfv-ctor-2, r=BoxyUwUbors-0/+144
Detect struct construction with private field in field with default When trying to construct a struct that has a public field of a private type, suggest using `..` if that field has a default value. ``` error[E0603]: struct `Priv1` is private --> $DIR/non-exhaustive-ctor-2.rs:19:39 | LL | let _ = S { field: (), field1: m::Priv1 {} }; | ------ ^^^^^ private struct | | | while setting this field | note: the struct `Priv1` is defined here --> $DIR/non-exhaustive-ctor-2.rs:14:4 | LL | struct Priv1 {} | ^^^^^^^^^^^^ help: the type `Priv1` of field `field1` is private, but you can construct the default value defined for it in `S` using `..` in the struct initializer expression | LL | let _ = S { field: (), .. }; | ~~ ```
2025-08-10Rollup merge of #144553 - Oneirical:uncountable-integer-4, r=jieyouxuJacob Pratt-0/+41
Rehome 32 `tests/ui/issues/` tests to other subdirectories under `tests/ui/` rust-lang/rust#143902 divided into smaller, easier to review chunks. Part of rust-lang/rust#133895 Methodology: 1. Refer to the previously written `tests/ui/SUMMARY.md` 2. Find an appropriate category for the test, using the original issue thread and the test contents. 3. Add the issue URL at the bottom (not at the top, as that would mess up stderr line numbers) 4. Rename the tests to make their purpose clearer Inspired by the methodology that `@Kivooeo` was using. r? `@jieyouxu`
2025-08-10Detect struct construction with private field in field with defaultEsteban Küber-0/+144
When trying to construct a struct that has a public field of a private type, suggest using `..` if that field has a default value. ``` error[E0603]: struct `Priv1` is private --> $DIR/non-exhaustive-ctor.rs:25:39 | LL | let _ = S { field: (), field1: m::Priv1 {} }; | ------ ^^^^^ private struct | | | while setting this field | note: the struct `Priv1` is defined here --> $DIR/non-exhaustive-ctor.rs:14:4 | LL | struct Priv1 {} | ^^^^^^^^^^^^ help: the field `field1` you're trying to set has a default value, you can use `..` to use it | LL | let _ = S { field: (), .. }; | ~~ ```
2025-08-10Rehome tests/ui/issues/ tests [4/?]Oneirical-0/+41
2025-08-07Do not provide field typo suggestions for tuples and tuple structsEsteban Küber-5/+1
2025-08-06Rollup merge of #144552 - Oneirical:uncountable-integer-3, r=jieyouxuJakub Beránek-0/+36
Rehome 33 `tests/ui/issues/` tests to other subdirectories under `tests/ui/` rust-lang/rust#143902 divided into smaller, easier to review chunks. Part of rust-lang/rust#133895 Methodology: 1. Refer to the previously written `tests/ui/SUMMARY.md` 2. Find an appropriate category for the test, using the original issue thread and the test contents. 3. Add the issue URL at the bottom (not at the top, as that would mess up stderr line numbers) 4. Rename the tests to make their purpose clearer Inspired by the methodology that ``@Kivooeo`` was using. r? ``@jieyouxu``
2025-08-04Rehome tests/ui/issues/ tests [3/?]Oneirical-0/+36
2025-07-28Rollup merge of #144151 - Kivooeo:issue1, r=jieyouxuMatthias Krüger-0/+21
`tests/ui/issues/`: The Issues Strike Back [1/N] I believe I’ve finally brought [my program](https://github.com/Kivooeo/test-manager) to life -- it now handles multiple test moves in one go: plain moves first, then a gentle touch on each file depends on given options. The process should be much smoother now. Of course, I won’t rush through everything in a few days -- that would be unkind to `@Oneirical.` I’ll pace myself. And also I can't have more than one such PR because `issues.txt` will conflict with previous parts after merging them which is not fun as well. This PR is just that: first commit - moves; second - regression comments and the occasional .stderr reblesses, also issue.txt and tidy changes. Nothing special, but progress nonetheless. This is for the purpose of preserving test file history during restructuring Part of https://github.com/rust-lang/rust/issues/133895. r? `@jieyouxu`
2025-07-25commentsKivooeo-0/+2
2025-07-25move 28 testsKivooeo-0/+19
2025-07-24Rehome tests/ui/issues/ tests [1/?]Oneirical-0/+28
2025-07-17Add test for `default_field_values` and `const_default`Esteban Küber-0/+37
Add a test showing `#![feature(default_field_values)]` using `#[const_trait] trait Default` (`#![feature(const_default)]` + `#![feature(const_trait_impl)]`).
2025-06-30cleaned up some testsKivooeo-11/+13
2025-06-29moved & deleted some testsKivooeo-0/+23
2025-06-17Reject union default field valuesJieyou Xu-3/+15
2025-06-16Add union with default field values case testJieyou Xu-8/+14
In particular, there should be no additional errors (default field values for `union` fields are currently erroneously accepted).
2025-06-07const-eval error: always say in which item the error occurredRalf Jung-1/+1
also adjust the wording a little so that we don't say "the error occurred here" for two different spans
2025-06-02Clarify why we are talking about a failed const eval at a random placeOli Scherer-4/+4
2025-06-02Use the informative error as the main const eval error messageOli Scherer-11/+11
2025-05-06Preserve generic args in suggestions for ambiguous associated itemsLeón Orell Valerian Liehr-3/+21
Most notably, this preserves the `(..)` of ambiguous RTN paths.
2025-04-30compiletest: Make diagnostic kind mandatory on line annotationsVadim Petrochenkov-39/+43
2025-04-08UI tests: add missing diagnostic kinds where possibleVadim Petrochenkov-3/+3
2025-04-08Rollup merge of #139024 - compiler-errors:tweak-default-value-err, r=lcnrStuart Cook-12/+19
Make error message for missing fields with `..` and without `..` more consistent When `..` is not present, we say "missing field `bar` in initializer", but when it is present we say "missing mandatory field `bar`". I don't see why the primary error message should change, b/c the root cause is the same. Let's harmonize these error messages and instead use a label to explain that `..` is required b/c it's not defaulted. r? estebank
2025-04-07Make error message for missing fields with .. and without .. more consistentMichael Goulet-12/+19
2025-03-27Improve suggest construct with literal syntax instead of callingxizheyin-2/+15
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-03-27Add ui test for struct construction by calling syntaxxizheyin-0/+70
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-03-14Do not suggest using `-Zmacro-backtrace` for builtin macrosEsteban Küber-3/+0
For macros that are implemented on the compiler, we do *not* mention the `-Zmacro-backtrace` flag. This includes `derive`s and standard macros.
2025-03-06Rollup merge of #137565 - compiler-errors:macro-ex, r=estebankMichael Goulet-0/+33
Try to point of macro expansion from resolver and method errors if it involves macro var In the case that a macro caller passes an identifier into a macro generating a path or method expression, point out that identifier in the context of the *macro* so it's a bit more clear how the macro is involved in causing the error. r? ``````````@estebank`````````` or reassign
2025-03-04Rollup merge of #137913 - compiler-errors:struct-field-default-generic, ↵Jubilee-18/+107
r=BoxyUwU Allow struct field default values to reference struct's generics Right now, the default field value feature (https://github.com/rust-lang/rust/issues/132162) lowers anon consts whose types may reference ADT params that the const doesn't inherit. This PR fixes this, so that these defaults can reference ADTs' generics, and sets the `generics_of` parenting up correctly. There doesn't seem to be a good reason not to support this, since the anon const has a well-defined type from the field, and the anon const doesn't interact with the type system like generic parameter defaults do. r? `````@boxyuwu````` or reassign I could also make this into an error if this seems problematic (https://github.com/rust-lang/rust/compare/master...compiler-errors:rust:default-field-value-implicit-param?expand=1)...... but I'd rather make this work and register an open question on the tracking issue about validating that this is well-vetted. Fixes #137896
2025-03-04Allow struct field default values to reference struct's genericsMichael Goulet-18/+107
2025-03-04Also note struct access, and fix macro expansion from foreign cratesMichael Goulet-0/+33
2025-03-03Do not recover missing lifetime with random in-scope lifetimeMichael Goulet-12/+3
2025-02-28Shorten span of panic failures in const contextEsteban Küber-1/+1
Previously, we included a redundant prefix on the panic message and a postfix of the location of the panic. The prefix didn't carry any additional information beyond "something failed", and the location of the panic is redundant with the diagnostic's span, which gets printed out even if its code is not shown. ``` error[E0080]: evaluation of constant value failed --> $DIR/assert-type-intrinsics.rs:11:9 | LL | MaybeUninit::<!>::uninit().assume_init(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: aborted execution: attempted to instantiate uninhabited type `!` ``` ``` error[E0080]: evaluation of `Fail::<i32>::C` failed --> $DIR/collect-in-dead-closure.rs:9:19 | LL | const C: () = panic!(); | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) ``` ``` error[E0080]: evaluation of constant value failed --> $DIR/uninhabited.rs:41:9 | LL | assert!(false); | ^^^^^^^^^^^^^^ evaluation panicked: assertion failed: false | = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info) ``` --- When the primary span for a const error is the same as the first frame in the const error report, skip it. ``` error[E0080]: evaluation of constant value failed --> $DIR/issue-88434-removal-index-should-be-less.rs:3:24 | LL | const _CONST: &[u8] = &f(&[], |_| {}); | ^^^^^^^^^^^^^^ evaluation panicked: explicit panic | note: inside `f::<{closure@$DIR/issue-88434-removal-index-should-be-less.rs:3:31: 3:34}>` --> $DIR/issue-88434-removal-index-should-be-less.rs:10:5 | LL | panic!() | ^^^^^^^^ the failure occurred here = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) ``` instead of ``` error[E0080]: evaluation of constant value failed --> $DIR/issue-88434-removal-index-should-be-less.rs:10:5 | LL | panic!() | ^^^^^^^^ explicit panic | note: inside `f::<{closure@$DIR/issue-88434-removal-index-should-be-less.rs:3:31: 3:34}>` --> $DIR/issue-88434-removal-index-should-be-less.rs:10:5 | LL | panic!() | ^^^^^^^^ note: inside `_CONST` --> $DIR/issue-88434-removal-index-should-be-less.rs:3:24 | LL | const _CONST: &[u8] = &f(&[], |_| {}); | ^^^^^^^^^^^^^^ = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) ``` --- Revert order of constant evaluation errors Point at the code the user wrote first and std functions last. ``` error[E0080]: evaluation of constant value failed --> $DIR/const-errs-dont-conflict-103369.rs:5:25 | LL | impl ConstGenericTrait<{my_fn(1)}> for () {} | ^^^^^^^^ evaluation panicked: Some error occurred | note: called from `my_fn` --> $DIR/const-errs-dont-conflict-103369.rs:10:5 | LL | panic!("Some error occurred"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) ``` instead of ``` error[E0080]: evaluation of constant value failed --> $DIR/const-errs-dont-conflict-103369.rs:10:5 | LL | panic!("Some error occurred"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Some error occurred | note: called from `<() as ConstGenericTrait<{my_fn(1)}>>::{constant#0}` --> $DIR/const-errs-dont-conflict-103369.rs:5:25 | LL | impl ConstGenericTrait<{my_fn(1)}> for () {} | ^^^^^^^^ = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) ```
2025-02-21More sophisticated span trimmingMichael Goulet-6/+4
2025-02-18Rollup merge of #135711 - estebank:issue-135649, r=davidtwcoMatthias Krüger-0/+29
Do not ICE on default_field_value const with lifetimes `#![feature(default_field_values)]` uses a `const` body that should be treated as inline `const`s, but is actually being detected otherwise. This is similar to the situation in #78174, so we take the same solution: we check if the const actually comes from a field, and if it does, we use that logic to get the appropriate lifetimes and not ICE during borrowck. Fix #135649.
2025-02-14Trim suggestion parts to the subset that is purely additiveMichael Goulet-19/+19
2025-02-14Consider add-prefix replacements tooMichael Goulet-54/+36
2025-02-14Use underline suggestions for purely 'additive' replacementsMichael Goulet-3/+2
2025-02-10Show diff suggestion format on verbose replacementEsteban Küber-66/+99
``` error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> $DIR/attempted-access-non-fatal.rs:7:15 | LL | let _ = 2.l; | ^ | help: if intended to be a floating point literal, consider adding a `0` after the period and a `f64` suffix | LL - let _ = 2.l; LL + let _ = 2.0f64; | ```
2025-01-27Add `TooGeneric` variant to `LayoutError` and emit `Unknown` oneFedericoBruzzone-1/+1
- `check-pass` test for a MRE of #135020 - fail test for #135138 - switch to `TooGeneric` for checking CMSE fn signatures - switch to `TooGeneric` for compute `SizeSkeleton` (for transmute) - fix broken tests
2025-01-23tests: use `needs-subprocess` instead of `ignore-{wasm32,emscripten,sgx}`许杰友 Jieyou Xu (Joe)-1/+1
2025-01-21Detect missing fields with default values and suggest `..`Esteban Küber-0/+167
When a struct definition has default field values, and the use struct ctor has missing field, if all those missing fields have defaults suggest `..`: ``` error[E0063]: missing fields `field1` and `field2` in initializer of `S` --> $DIR/non-exhaustive-ctor.rs:16:13 | LL | let _ = S { field: () }; | ^ missing `field1` and `field2` | help: all remaining fields have defaults, use `..` | LL | let _ = S { field: (), .. }; | ++++ ```
2025-01-20Rollup merge of #135700 - estebank:priv-field-dfv, r=wesleywiser许杰友 Jieyou Xu (Joe)-0/+103
Emit single privacy error for struct literal with multiple private fields and add test for `default_field_values` privacy Add test ensuring that struct with default field values is not constructable if the fields are not accessible. Collect all unreachable fields in a single struct literal struct and emit a single error, instead of one error per private field. ``` error[E0451]: fields `beta` and `gamma` of struct `Alpha` are private --> $DIR/visibility.rs:18:13 | LL | let _x = Alpha { | ----- in this type LL | beta: 0, | ^^^^^^^ private field LL | .. | ^^ field `gamma` is private ```