about summary refs log tree commit diff
path: root/tests/ui/on-unimplemented
AgeCommit message (Collapse)AuthorLines
2025-08-22On E0277, point at type that doesn't implement boundEsteban Küber-7/+36
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-06-22Implement DesugaringKind::FormatLiteralmejrs-4/+12
2025-06-09refactor `AttributeGate` and `rustc_attr!` to emit notes during feature ↵mejrs-5/+7
checking
2025-05-17do away with `_Self` and `TraitName` and check generic params for ↵mejrs-3/+25
rustc_on_unimplemented
2025-05-05Rollup merge of #140307 - mejrs:condition_parser, r=nnethercoteTrevor Gross-78/+171
Refactor rustc_on_unimplemented's filter parser Followup to https://github.com/rust-lang/rust/pull/139091; I plan on moving most of this code into `rustc_attr_parsing` at some point, but want to land this separately first. I have taken care to preserve the original behavior as much as I could: - All but one of the new error variants are replacements for the ones originally emitted by the cfg parsing machinery; so these errors are not "new". - the `InvalidFlag` variant is new, this PR turns this (from being ignored and silently doing nothing) into an error: ```rust #[rustc_on_unimplemented(on(something, message = "y"))] //~^ ERROR invalid boolean flag //~^^ NOTE expected one of `crate_local`, `direct` or `from_desugaring`, not `something` trait InvalidFlag {} ``` This does not occur anywhere except in this test. I couldn't find a way that I liked to keep allowing this or to do nothing, erroring was the cleanest solution. - There are a bunch of FIXME throughout this and the previous PR, I plan on addressing those in follow up prs.. Finally, this gets rid of the "longest" dependency in rustc: ![image](https://github.com/user-attachments/assets/3c3eb3a0-b7b3-40d9-aada-a752e28c8678)
2025-05-02Refactor rustc_on_unimplemented's filter parsermejrs-49/+109
2025-04-29Fix comment describing what the test doesmejrs-6/+3
2025-04-22Improve rustc_on_unimplemented ui testmejrs-53/+86
2025-04-14Remove rustc_on_unimplemented on impl testsmejrs-216/+0
2025-04-14Test that `Self` properly works in filtersmejrs-0/+29
2025-04-14Raise errors on bad rustc_on_unimplemented format strings againmejrs-10/+6
2025-04-14Disable usage on trait impls and aliasesmejrs-11/+7
2025-04-10Write the format string parserand split it from conditions parsermejrs-12/+16
2025-04-08UI tests: add missing diagnostic kinds where possibleVadim Petrochenkov-8/+8
2025-03-11Implement SliceIndex for ByteStrThalia Archibald-2/+4
2025-02-21Trim suggestion part before generating highlightsMichael Goulet-2/+2
2025-02-21More sophisticated span trimmingMichael Goulet-10/+6
2025-02-10Show diff suggestion format on verbose replacementEsteban Küber-6/+10
``` 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; | ```
2024-11-04Rollup merge of #132583 - mejrs:tuples, r=compiler-errorsMatthias Krüger-0/+96
Suggest creating unary tuples when types don't match a trait When you want to have a variadic function, a common workaround to implement this is to create a trait and then implement that trait for various tuples. For example in `pyo3` there exists ```rust /// Calls the object with only positional arguments. pub fn call1(&self, args: impl IntoPy<Py<PyTuple>>) -> PyResult<&PyAny> { ... } ``` with various impls like ```rust impl<A: IntoPy<PyObject> IntoPy<Py<PyAny>> for (A,) impl<A: IntoPy<PyObject, B: IntoPy<PyObject> IntoPy<Py<PyAny>> for (A, B) ... etc ``` This means that if you want to call the method with a single item you have to create a unary tuple, like `(x,)`, rather than just `x`. This PR implements a suggestion to do that, if applicable.
2024-11-04Suggest creating unary tuplesmejrs-0/+96
2024-11-02Trim output of E0277 in some casesEsteban Küber-4/+0
Remove default note for "trait is not implemented" in favor of the more colorful diff output from the previous commit. Removes duplicated output.
2024-11-02Add trait diff highlighting logic and use it in E0277Esteban Küber-4/+8
When a trait is not implemented for a type, but there *is* an `impl` for another type or different trait params, we format the output to use highlighting in the same way that E0308 does for types. The logic accounts for 3 cases: - When both the type and trait in the expected predicate and the candidate are different - When only the types are different - When only the trait generic params are different For each case, we use slightly different formatting and wording.
2024-10-29Remove detail from label/note that is already available in other noteEsteban Küber-2/+2
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-09-22Don't call const normalize in error reportingMichael Goulet-2/+2
2024-06-12Spell out other trait diagnosticAlex Macleod-18/+18
2024-03-27Use `TraitRef::to_string` sorting in favor of `TraitRef::ord`, as the latter ↵Oli Scherer-9/+9
compares `DefId`s which we need to avoid
2024-02-16[AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives许杰友 Jieyou Xu (Joe)-1/+1
2024-02-12Fix failing testShoyu Vanilla-1/+1
2024-02-12Fix failing testShoyu Vanilla-1/+1
2024-01-30Provide more context on derived obligation error primary labelEsteban Küber-2/+2
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-24Deduplicate more sized errors on call exprsEsteban Küber-58/+11
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-13Bless testsGeorge-lewis-0/+1
Update tests
2023-11-24Show number in error message even for one errorNilstrieb-4/+4
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-10-02Point out the actual mismatch errorMichael Goulet-0/+5
2023-10-02For a single impl candidate, try to unify it with error trait refMichael Goulet-2/+2
2023-09-10Point out if a local trait has no implementationsMichael Goulet-0/+30
2023-08-26More accurately point at argumentsEsteban Küber-4/+8
2023-06-27Don't sort strings right after we just sorted by typesMichael Goulet-12/+12
2023-04-12Tweak output for 'add line' suggestionEsteban Küber-1/+2
2023-01-11Move /src/test to /testsAlbert Larsan-0/+761