about summary refs log tree commit diff
path: root/tests/ui/deriving
AgeCommit message (Collapse)AuthorLines
2025-08-19Avoid using `()` in `derive(From)` output.Nicholas Nethercote-42/+2
Using an error type instead of `()` avoids the duplicated errors on `struct SUnsizedField` in `deriving-from-wrong-target.rs`. It also improves the expanded output from this: ``` struct S2(u32, u32); impl ::core::convert::From<()> for S2 { #[inline] fn from(value: ()) -> S2 { (/*ERROR*/) } } ``` to this: ``` struct S2(u32, u32); impl ::core::convert::From<(/*ERROR*/)> for S2 { #[inline] fn from(value: (/*ERROR*/)) -> S2 { (/*ERROR*/) } } ``` The new code also only matchs on `item.kind` once.
2025-08-18Remove the `From` derive macro from preludeJakub Beránek-13/+30
To avoid backwards compatibility problems.
2025-08-15Implement `#[derive(From)]`Jakub Beránek-1/+369
2025-07-28expand: Micro-optimize prelude injectionVadim Petrochenkov-8/+8
Use `splice` to avoid shifting the other items twice. Put `extern crate std;` first so it's already resolved when we resolve `::std::prelude::rust_20XX`.
2025-06-03Rollup merge of #141724 - Sol-Ell:issue-141141-fix, r=nnethercoteMatthias Krüger-0/+195
fix(#141141): When expanding `PartialEq`, check equality of scalar types first. Fixes rust-lang/rust#141141. Now, `cs_eq` function of `partial_eq.rs` compares [scalar types](https://doc.rust-lang.org/rust-by-example/primitives.html#scalar-types) first. - Add `is_scalar` field to `FieldInfo`. - Add `is_scalar` method to `TyKind`. - Pass `FieldInfo` via `CsFold::Combine` and refactor code relying on it. - Implement `TryFrom<&str>` and `TryFrom<Symbol>` for FloatTy. - Implement `TryFrom<&str>` and `TryFrom<Symbol>` for IntTy. - Implement `TryFrom<&str>` and `TryFrom<Symbol>` for UintTy.
2025-06-02Separately check equality of the scalar types and compound types in the ↵Ell-0/+195
order of declaration.
2025-05-27Refactor the two-phase check for impls and impl itemsMu001999-1/+2
2025-04-18Remove let_chains feature gate from even more testsest31-1/+1
2025-04-16Explicitly annotate edition for `unpretty=expanded` and `unpretty=hir` testsLukas Wirth-0/+6
These emit prelude imports which means they are always edition dependent
2025-03-14Do not suggest using `-Zmacro-backtrace` for builtin macrosEsteban Küber-20/+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-02-24tests: use minicore moreDavid Wood-3/+4
minicore makes it much easier to add new language items to all of the existing `no_core` tests.
2025-02-24Deduplicate CoerceUnsized and DispatchFromDyn impl errorsMichael Goulet-46/+6
2025-02-24Simplify trait error message for CoercePointee validationMichael Goulet-3/+114
2025-02-09move repr(transparent) checks to coherenceDing Xiang Fei-9/+7
2025-02-09rename the trait to validity and place a feature gate afrontDing Xiang Fei-9/+6
2025-02-09introduce CoercePointeeWellformed for coherence checks at typeck stageDing Xiang Fei-26/+93
2025-01-24Skip suggestions in `derive`d codeEsteban Küber-0/+22
Do not suggest ``` help: use parentheses to call these | 5 | (callback: Rc<dyn Fn()>)(), | + +++ ``` Skip all "call function for this binop" suggestions when in a derive context. Fix #135989.
2024-12-04make CoercePointee errors translatableDing Xiang Fei-7/+7
2024-11-27Update tests to use new proc-macro headerEric Huss-8/+4
2024-11-26tests: remove `//@ pretty-expanded` usages许杰友 Jieyou Xu (Joe)-13/+0
Done with ```bash sd '//@ pretty-expanded.*\n' '' tests/ui/**/*.rs ``` and ``` sd '//@pretty-expanded.*\n' '' tests/ui/**/*.rs ```
2024-10-29Remove detail from label/note that is already available in other noteEsteban Küber-1/+1
Remove the "which is required by `{root_obligation}`" post-script in "the trait `X` is not implemented for `Y`" explanation in E0277. This information is already conveyed in the notes explaining requirements, making it redundant while making the text (particularly in labels) harder to read. ``` error[E0277]: the trait bound `NotCopy: Copy` is not satisfied --> $DIR/wf-static-type.rs:10:13 | LL | static FOO: IsCopy<Option<NotCopy>> = IsCopy { t: None }; | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `NotCopy` | = note: required for `Option<NotCopy>` to implement `Copy` note: required by a bound in `IsCopy` --> $DIR/wf-static-type.rs:7:17 | LL | struct IsCopy<T:Copy> { t: T } | ^^^^ required by this bound in `IsCopy` ``` vs the prior ``` error[E0277]: the trait bound `NotCopy: Copy` is not satisfied --> $DIR/wf-static-type.rs:10:13 | LL | static FOO: IsCopy<Option<NotCopy>> = IsCopy { t: None }; | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `NotCopy`, which is required by `Option<NotCopy>: Copy` | = note: required for `Option<NotCopy>` to implement `Copy` note: required by a bound in `IsCopy` --> $DIR/wf-static-type.rs:7:17 | LL | struct IsCopy<T:Copy> { t: T } | ^^^^ required by this bound in `IsCopy` ```
2024-10-24s/SmartPointer/CoerceReferent/gDing Xiang Fei-183/+199
move derive_smart_pointer into removed set
2024-10-06Check that `#[pointee]` is applied only to generic argumentsBrezak-1/+58
2024-08-29derive(SmartPointer): assume pointee from the single generic and better ↵Ding Xiang Fei-16/+61
error messages
2024-08-13derive(SmartPointer): register helper attributesDing Xiang Fei-0/+163
2024-08-05Rollup merge of #127907 - RalfJung:byte_slice_in_packed_struct_with_derive, ↵Matthias Krüger-93/+0
r=nnethercote built-in derive: remove BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE hack and lint Fixes https://github.com/rust-lang/rust/issues/107457 by turning the lint into a hard error. The lint has been shown in future breakage reports since Rust 1.69 (released in April 2023). Let's see (via crater) if enough time has passed since https://github.com/rust-lang/rust/pull/104429, and https://github.com/unicode-org/icu4x/pull/2834 has propagated far enough to let us make this a hard error. Cc ``@nnethercote`` ``@Manishearth``
2024-08-01reject pointee without ?SizedDing Xiang Fei-10/+46
2024-07-30derive(SmartPointer): rewrite bounds in where and generic boundsDing Xiang Fei-0/+144
2024-07-27built-in derive: remove BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE hack and lintRalf Jung-93/+0
2024-07-06Mark format! with must_use hintlukas-1/+1
2024-07-04reject SmartPointer constructions not serving the purposeDing Xiang Fei-0/+121
2024-06-25Rollup merge of #126302 - mu001999-contrib:ignore/default, r=michaelwoeristerMatthias Krüger-1/+1
Detect unused structs which derived Default <!-- If this PR is related to an unstable feature or an otherwise tracked effort, please link to the relevant tracking issue here. If you don't know of a related tracking issue or there are none, feel free to ignore this. This PR will get automatically assigned to a reviewer. In case you would like a specific user to review your work, you can assign it to them by using r​? <reviewer name> --> Fixes #98871
2024-06-25Detect unused structs which derived Defaultmu001999-1/+1
2024-06-24SmartPointer derive-macroXiangfei Ding-0/+55
Co-authored-by: Wedson Almeida Filho <walmeida@microsoft.com>
2024-04-23Do not add leading asterisk in the `PartialEq`Daniel Sedlak-8/+46
Adding leading asterisk can cause compilation failure for the _types_ that don't implement the `Copy`.
2024-04-14builtin-derive: tag → discriminantRalf Jung-47/+47
2024-03-27Use `TraitRef::to_string` sorting in favor of `TraitRef::ord`, as the latter ↵Oli Scherer-5/+5
compares `DefId`s which we need to avoid
2024-03-03Move testsCaio-0/+17
2024-02-16[AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives许杰友 Jieyou Xu (Joe)-71/+71
2024-02-07Update testsr0cky-1/+1
2024-01-30Provide more context on derived obligation error primary labelEsteban Küber-1/+1
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-24remove StructuralEq traitRalf Jung-28/+0
2024-01-02Adjust compiler tests for unused_tuple_struct_fields -> dead_codeJake Goulding-3/+3
2023-11-24Show number in error message even for one errorNilstrieb-1/+1
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-21improve help for multiple `#[default]` variantsLukas Markeffsky-38/+103
2023-11-09Emit #[inline] on derive(Debug)Ben Kimock-0/+15
2023-09-08Rework no_coverage to coverage(off)Andy Caldwell-14/+14
2023-07-16Generate safe stable code for derives on empty enumsDavid Tolnay-9/+5
Generate `match *self {}` instead of `unsafe { core::intrinsics::unreachable() }`. This is: 1. safe 2. stable for the benefit of everyone looking at these derived impls through `cargo expand`. Both expansions compile to the same code at all optimization levels (including `0`).
2023-06-27Don't sort strings right after we just sorted by typesMichael Goulet-5/+5
2023-05-26Inline derived `hash` function.Nicholas Nethercote-0/+15
Because most of the other derived functions are inlined: `clone`, `default`, `eq`, `partial_cmp`, `cmp`. The exception is `fmt`, but it tends to not be on hot paths as much.