about summary refs log tree commit diff
path: root/tests/ui/auto-traits
AgeCommit message (Collapse)AuthorLines
2025-08-22On E0277, point at type that doesn't implement boundEsteban Küber-7/+39
When encountering an unmet trait bound, point at local type that doesn't implement the trait: ``` error[E0277]: the trait bound `Bar<T>: Foo` is not satisfied --> $DIR/issue-64855.rs:9:19 | LL | pub struct Bar<T>(<Self as Foo>::Type) where Self: ; | ^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound | help: the trait `Foo` is not implemented for `Bar<T>` --> $DIR/issue-64855.rs:9:1 | LL | pub struct Bar<T>(<Self as Foo>::Type) where Self: ; | ^^^^^^^^^^^^^^^^^ ```
2025-08-19bless tests with new lint messagesKarol Zwolak-1/+1
2025-08-04Tweak auto trait errorsEsteban Küber-29/+99
Make suggestions to remove params and super traits tool-only, and make the suggestion span more accurate. ``` error[E0567]: auto traits cannot have generic parameters --> $DIR/auto-trait-validation.rs:6:19 | LL | auto trait Generic<T> {} | -------^^^ | | | auto trait cannot have generic parameters error[E0568]: auto traits cannot have super traits or lifetime bounds --> $DIR/auto-trait-validation.rs:8:20 | LL | auto trait Bound : Copy {} | ----- ^^^^ | | | auto traits cannot have super traits or lifetime bounds ``` ``` error[E0380]: auto traits cannot have associated items --> $DIR/issue-23080.rs:5:8 | LL | unsafe auto trait Trait { | ----- auto traits cannot have associated items LL | fn method(&self) { | ^^^^^^ ```
2025-07-11Rollup merge of #143302 - Kivooeo:tf27, r=tgross35Matthias Krüger-0/+37
`tests/ui`: A New Order [27/N] > [!NOTE] > > Intermediate commits are intended to help review, but will be squashed prior to merge. Some `tests/ui/` housekeeping, to trim down number of tests directly under `tests/ui/`. Part of rust-lang/rust#133895. r? ``@tgross35``
2025-07-10cleaned up some testsKivooeo-8/+9
2025-07-05cleaned up some testsKivooeo-12/+12
2025-07-01moved testsKivooeo-0/+36
2025-07-01moved testsKivooeo-0/+98
2025-04-17Rollup merge of #138632 - clubby789:stabilize-cfg-boolean-lit, ↵Matthias Krüger-1/+1
r=davidtwco,Urgau,traviscross Stabilize `cfg_boolean_literals` Closes #131204 `@rustbot` labels +T-lang +I-lang-nominated This will end up conflicting with the test in #138293 so whichever doesn't land first will need updating -- # Stabilization Report ## General design ### What is the RFC for this feature and what changes have occurred to the user-facing design since the RFC was finalized? [RFC 3695](https://github.com/rust-lang/rfcs/pull/3695), none. ### What behavior are we committing to that has been controversial? Summarize the major arguments pro/con. None ### Are there extensions to this feature that remain unstable? How do we know that we are not accidentally committing to those? None ## Has a call-for-testing period been conducted? If so, what feedback was received? Yes; only positive feedback was received. ## Implementation quality ### Summarize the major parts of the implementation and provide links into the code (or to PRs) Implemented in [#131034](https://github.com/rust-lang/rust/pull/131034). ### Summarize existing test coverage of this feature - [Basic usage, including `#[cfg()]`, `cfg!()` and `#[cfg_attr()]`](https://github.com/rust-lang/rust/blob/6d71251cf9e40326461f90f8ff9a7024706aea87/tests/ui/cfg/true-false.rs) - [`--cfg=true/false` on the command line being accessible via `r#true/r#false`](https://github.com/rust-lang/rust/blob/6d71251cf9e40326461f90f8ff9a7024706aea87/tests/ui/cfg/raw-true-false.rs) - [Interaction with the unstable `#[doc(cfg(..))]` feature](https://github.com/rust-lang/rust/tree/6d71251/tests/rustdoc-ui/cfg-boolean-literal.rs) - [Denying `--check-cfg=cfg(true/false)`](https://github.com/rust-lang/rust/tree/6d71251/tests/ui/check-cfg/invalid-arguments.rs) - Ensuring `--cfg false` on the command line doesn't change the meaning of `cfg(false)`: `tests/ui/cfg/cmdline-false.rs` - Ensuring both `cfg(true)` and `cfg(false)` on the same item result in it being disabled: `tests/ui/cfg/both-true-false.rs` ### What outstanding bugs in the issue tracker involve this feature? Are they stabilization-blocking? The above mentioned issue; it should not block as it interacts with another unstable feature. ### What FIXMEs are still in the code for that feature and why is it ok to leave them there? None ### Summarize contributors to the feature by name for recognition and assuredness that people involved in the feature agree with stabilization - `@clubby789` (RFC) - `@Urgau` (Implementation in rustc) ### Which tools need to be adjusted to support this feature. Has this work been done? `rustdoc`'s unstable`#[doc(cfg(..)]` has been updated to respect it. `cargo` has been updated with a forward compatibility lint to enable supporting it in cargo once stabilized. ## Type system and execution rules ### What updates are needed to the reference/specification? (link to PRs when they exist) A few lines to be added to the reference for configuration predicates, specified in the RFC.
2025-04-08UI tests: add missing diagnostic kinds where possibleVadim Petrochenkov-8/+8
2025-04-03Use `cfg(false)` in UI testsclubby789-1/+1
2025-03-07Delay bug for negative auto trait rather than ICEingMichael Goulet-0/+30
2025-02-13adjust derive_errorlcnr-13/+16
2025-01-06Normalize each signature input/output in typeck_with_fallback with its own spanMichael Goulet-9/+3
2024-12-07Mention type parameter in more cases and don't suggest ~const bound already ↵Esteban Küber-1/+1
there
2024-12-07reword trait bound suggestion message to include the boundsEsteban Küber-1/+1
2024-10-29Remove detail from label/note that is already available in other noteEsteban Küber-5/+5
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-15stabilize `-Znext-solver=coherence`lcnr-30/+0
2024-09-11Revert 'Stabilize -Znext-solver=coherence'Michael Goulet-0/+30
2024-09-05stabilize `-Znext-solver=coherence`lcnr-30/+0
2024-07-24Don't ICE when auto trait has assoc ty in old solverMichael Goulet-0/+97
2024-07-24Don't use global caches if opaques can be definedOli Scherer-0/+30
2024-06-12Harmonize use of leaf and root obligation in trait error reportingMichael Goulet-1/+1
2024-04-24Mention when type parameter could be `Clone`Esteban Küber-0/+7
``` error[E0382]: use of moved value: `t` --> $DIR/use_of_moved_value_copy_suggestions.rs:7:9 | LL | fn duplicate_t<T>(t: T) -> (T, T) { | - move occurs because `t` has type `T`, which does not implement the `Copy` trait ... LL | (t, t) | - ^ value used here after move | | | value moved here | help: if `T` implemented `Clone`, you could clone the value --> $DIR/use_of_moved_value_copy_suggestions.rs:4:16 | LL | fn duplicate_t<T>(t: T) -> (T, T) { | ^ consider constraining this type parameter with `Clone` ... LL | (t, t) | - you could clone this value help: consider restricting type parameter `T` | LL | fn duplicate_t<T: Copy>(t: T) -> (T, T) { | ++++++ ``` The `help` is new. On ADTs, we also extend the output with span labels: ``` error[E0507]: cannot move out of static item `FOO` --> $DIR/issue-17718-static-move.rs:6:14 | LL | let _a = FOO; | ^^^ move occurs because `FOO` has type `Foo`, which does not implement the `Copy` trait | note: if `Foo` implemented `Clone`, you could clone the value --> $DIR/issue-17718-static-move.rs:1:1 | LL | struct Foo; | ^^^^^^^^^^ consider implementing `Clone` for this type ... LL | let _a = FOO; | --- you could clone this value help: consider borrowing here | LL | let _a = &FOO; | + ```
2024-03-10Ignore tests w/ current/next revisions from compare-mode=next-solverMichael Goulet-2/+3
2024-03-03Use root obligation on E0277 for some casesEsteban Küber-3/+3
When encountering trait bound errors that satisfy some heuristics that tell us that the relevant trait for the user comes from the root obligation and not the current obligation, we use the root predicate for the main message. This allows to talk about "X doesn't implement Pattern<'_>" over the most specific case that just happened to fail, like "char doesn't implement Fn(&mut char)" in `tests/ui/traits/suggest-dereferences/root-obligation.rs` The heuristics are: - the type of the leaf predicate is (roughly) the same as the type from the root predicate, as a proxy for "we care about the root" - the leaf trait and the root trait are different, so as to avoid talking about `&mut T: Trait` and instead remain talking about `T: Trait` instead - the root trait is not `Unsize`, as to avoid talking about it in `tests/ui/coercion/coerce-issue-49593-box-never.rs`. ``` error[E0277]: the trait bound `&char: Pattern<'_>` is not satisfied --> $DIR/root-obligation.rs:6:38 | LL | .filter(|c| "aeiou".contains(c)) | -------- ^ the trait `Fn<(char,)>` is not implemented for `&char`, which is required by `&char: Pattern<'_>` | | | required by a bound introduced by this call | = note: required for `&char` to implement `FnOnce<(char,)>` = note: required for `&char` to implement `Pattern<'_>` note: required by a bound in `core::str::<impl str>::contains` --> $SRC_DIR/core/src/str/mod.rs:LL:COL help: consider dereferencing here | LL | .filter(|c| "aeiou".contains(*c)) | + ``` Fix #79359, fix #119983, fix #118779, cc #118415 (the suggestion needs to change).
2024-02-19Remove suspicious auto trait lintSantiago Pastorino-216/+8
2024-02-16[AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives许杰友 Jieyou Xu (Joe)-8/+8
2024-02-14Continue compilation after check_mod_type_wf errorsOli Scherer-1/+47
2024-02-08Continue to borrowck even if there were previous errorsOli Scherer-2/+18
2024-02-07Update testsr0cky-6/+24
2024-01-30Provide more context on derived obligation error primary labelEsteban Küber-4/+4
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-13Bless testsGeorge-lewis-0/+2
Update tests
2024-01-02Adjust compiler tests for unused_tuple_struct_fields -> dead_codeJake Goulding-1/+1
2023-12-14update use of feature flagslcnr-1/+1
2023-11-24Show number in error message even for one errorNilstrieb-12/+12
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-13Turn assert_eq into a delay_span_bugMu001999-0/+28
2023-11-06Extend builtin/auto trait args with error when they have >1 argumentMichael Goulet-0/+21
2023-10-03Gate against auto traits pre-expansionMichael Goulet-0/+21
2023-08-28Revert "Suggest using `Arc` on `!Send`/`!Sync` types"David Tolnay-1/+0
This reverts commit 9de1a472b68ed85f396b2e2cc79c3ef17584d6e1.
2023-08-09Suggest using `Arc` on `!Send`/`!Sync` typesEsteban Kuber-0/+1
2023-07-28clean up after 113312Oleksandr Babak-2/+4
2023-07-06update auto trait handlinglcnr-0/+53
2023-06-02Don't ICE in new solver when auto traits have associated typesMichael Goulet-1/+15
2023-03-06Bless the suspicious-negative-impls-lint.rsMu42-33/+3
2023-03-06Moves the negative impls into a separate test fileMu42-67/+115
2023-03-06emit the suspicious_auto_trait_impls for negative impls as wellMu42-12/+67
2023-02-26Rollup merge of #107941 - compiler-errors:str-has-u8-slice-for-auto, r=lcnrMatthias Krüger-0/+29
Treat `str` as containing `[u8]` for auto trait purposes Wanted to gauge ``@rust-lang/lang`` and ``@rust-lang/types`` teams' thoughts on treating `str` as "containing" a `[u8]` slice for auto-trait purposes. ``@dtolnay`` brought this up in https://github.com/rust-lang/rust/issues/13231#issuecomment-1399386472 as a blocker for future `str` type librarification, and I think it's both a valid concern and very easy to fix. I'm interested in actually doing that `str` type librarification (#107939), but this probably should be considered in the mean time regardless of that PR. r? types for the impl, though this definitely needs an FCP.
2023-02-25Special note for str in auto traitsMichael Goulet-1/+1
2023-02-25Treat `str` as containing `[u8]` for auto trait purposesMichael Goulet-0/+29