about summary refs log tree commit diff
path: root/src/test/ui/derives
AgeCommit message (Collapse)AuthorLines
2023-01-11Move /src/test to /testsAlbert Larsan-2416/+0
2022-12-13Make some diagnostics not depend on the source of what they reference being ↵Oli Scherer-20/+4
available
2022-10-24Port `dead_code` lints to be translatable.Charles Lew-2/+2
2022-10-01bless ui testsMaybe Waffle-11/+11
2022-08-21Adjust messages, address some nitsMichael Goulet-3/+3
2022-08-18Reword "Required because of the requirements on the impl of ..."Andy Wang-3/+3
2022-08-01Don't derive `PartialEq::ne`.Nicholas Nethercote-112/+7
Currently we skip deriving `PartialEq::ne` for C-like (fieldless) enums and empty structs, thus reyling on the default `ne`. This behaviour is unnecessarily conservative, because the `PartialEq` docs say this: > Implementations must ensure that eq and ne are consistent with each other: > > `a != b` if and only if `!(a == b)` (ensured by the default > implementation). This means that the default implementation (`!(a == b)`) is always good enough. So this commit changes things such that `ne` is never derived. The motivation for this change is that not deriving `ne` reduces compile times and binary sizes. Observable behaviour may change if a user has defined a type `A` with an inconsistent `PartialEq` and then defines a type `B` that contains an `A` and also derives `PartialEq`. Such code is already buggy and preserving bug-for-bug compatibility isn't necessary. Two side-effects of the change: - There is only one error message produced for types where `PartialEq` cannot be derived, instead of two. - For coverage reports, some warnings about generated `ne` methods not being executed have disappeared. Both side-effects seem fine, and possibly preferable.
2022-07-26Remove erroneous E0133 code from an error message.Nicholas Nethercote-8/+8
This error message is about `derive` and `packed`, but E0133 is for "Unsafe code was used outside of an unsafe function or block".
2022-07-25Improve error messages involving `derive` and `packed`.Nicholas Nethercote-46/+60
There are two errors involving `derive` and `packed`. ``` `#[derive]` can't be derived on a `#[repr(packed)]` struct with type or const parameters `#[derive]` can't be derived on a `#[repr(packed)]` struct that does not derive Copy ``` The second one overstates things. It is possible to use derive on a repr(packed) struct that doesn't derive Copy in two cases. - If all the fields within the struct meet the required alignment: 1 for `repr(packed)`, or `N` for `repr(packed(N))`. - If `Default` is the only trait derived. This commit improves things in a few ways. - Changes the errors to say `$TRAIT can't be derived on this ...`. This is more accurate, because it's just $TRAIT and *this* packed struct that are a problem, not *all* derived traits on *all* packed structs. - Adds more details to the "ERROR" lines in the test case, enough to distinguish between the two error messages. - Adds more cases to the test case that don't cause errors, e.g. `Default` derives. - Uses a wider variety of builtin traits in the test case, for better coverage.
2022-07-07Track implicit `Sized` obligations in type paramsEsteban Küber-6/+6
Suggest adding a `?Sized` bound if appropriate on E0599 by inspecting the HIR Generics. (Fix #98539)
2022-07-01Auto merge of #93967 - cjgillot:short-struct-span, r=petrochenkovbors-20/+20
Shorten def_span for more items. The `def_span` query only returns the signature span for functions. Struct/enum/union definitions can also have a very long body. This PR shortens the associated span.
2022-07-01Shorten def_span for more items.Camille GILLOT-20/+20
2022-07-01Auto merge of #98402 - cjgillot:undead, r=michaelwoeristerbors-9/+9
Rewrite dead-code pass to avoid fetching HIR. This allows to get a more uniform handling of spans, and to simplify the grouping of diagnostics for variants and fields.
2022-06-25Rollup merge of #98298 - TaKO8Ki:point-to-type-param-definition, ↵Matthias Krüger-6/+6
r=compiler-errors Point to type parameter definition when not finding variant, method and associated item fixes #77391
2022-06-22Uniform spans in dead code lint.Camille GILLOT-9/+9
2022-06-22point to type param definition when not finding variant, method and assoc typeTakayuki Maeda-6/+6
use `def_ident_span` , `body_owner_def_id` instead of `in_progress_typeck_results`, `guess_head_span` use `body_id.owner` directly add description to label
2022-06-22Auto merge of #97853 - TaKO8Ki:emit-only-one-note-per-unused-struct-field, ↵bors-15/+61
r=estebank Collapse multiple dead code warnings into a single diagnostic closes #97643
2022-06-19Be more specific for what lifetimes are not allowed onMichael Goulet-1/+1
2022-06-19collapse dead code warnings into a single diagnosticTakayuki Maeda-39/+40
add comments in `store_dead_field_or_variant` support multiple log level add a item ident label fix ui tests fix a ui test fix a rustdoc ui test use let chain refactor: remove `store_dead_field_or_variant` fix a tiny bug
2022-06-19emit only one note per unused struct fieldTakayuki Maeda-0/+45
2022-06-16 fix one more case of trailing spaceklensy-3/+3
2022-06-03Rollup merge of #97471 - estebank:prohibit-generics, r=cjgillotDylan DPC-3/+11
Provide more context when denying invalid type params
2022-06-02don't use a `span_note` for ignored implslcnr-18/+3
2022-06-01Make output more specificEsteban Küber-3/+6
2022-06-01Fix testEsteban Küber-0/+5
2022-05-27Modify `derive(Debug)` to use `Self` in struct literal to avoid redundant errorEsteban Küber-12/+3
#97343
2022-05-27Add test for #97343Esteban Küber-0/+30
2022-04-14make unaligned_reference warning visible in future compat reportRalf Jung-0/+64
2022-04-05Suggest derivable trait on E0277ohno418-0/+108
2022-04-03Improve method name suggestionsOliver Downard-1/+1
Attempts to improve method name suggestions when a matching method name is not found. The approach taken is use the Levenshtein distance and account for substrings having a high distance but can sometimes be very close to the intended method (eg. empty vs is_empty).
2022-03-24Properly track `ImplObligation`sEsteban Kuber-4/+5
Instead of probing for all possible impls that could have caused an `ImplObligation`, keep track of its `DefId` and obligation spans for accurate error reporting. Follow up to #89580. Addresses #89418. Remove some unnecessary clones. Tweak output for auto trait impl obligations.
2022-02-16Make implementation genericLucas Kent-4/+4
2022-02-16Suggest deriving required supertraitsLucas Kent-0/+113
2022-01-15Use span of ignored impls for explanatory noteFabian Wolff-12/+15
2022-01-11Annotate dead code lint with notes about ignored derived implsFabian Wolff-0/+18
2021-12-23Rollup merge of #91544 - rukai:91492, r=wesleywiserMatthias Krüger-0/+79
Fix duplicate derive clone suggestion closes https://github.com/rust-lang/rust/issues/91492 The addition of: ```rust derives.sort(); derives.dedup(); ``` is what actually solves the problem. The rest is just cleanup. I want to improve the diagnostic message to provide the suggestion as a proper diff but ran into some problems, so I'll attempt that again in a follow up PR.
2021-12-10update testsEllen-2/+0
2021-12-05Fix duplicate derive clone suggestionLucas Kent-0/+79
2021-12-03Update invalid crate attributes, add help messageTom Farmer-1/+101
tidy run update invalid crate attributes, improve error update test outputs de-capitalise error update tests Update invalid crate attributes, add help message Update - generate span without using BytePos Add correct dependancies Update - generate suggestion without BytePos Tidy run update tests Generate Suggestion without BytePos Add all builtin attributes add err builtin inner attr at top of crate fix tests add err builtin inner attr at top of crate tidy fix add err builtin inner attr at top of crate
2021-11-20Point at `impl` blocks when they introduce unmet obligationsEsteban Kuber-3/+7
Group obligations by `impl` block that introduced them.
2021-11-20Do not mention associated items when they introduce an obligationEsteban Kuber-95/+0
2021-11-20Point at source of trait bound obligations in more placesEsteban Kuber-8/+8
Be more thorough in using `ItemObligation` and `BindingObligation` when evaluating obligations so that we can point at trait bounds that introduced unfulfilled obligations. We no longer incorrectly point at unrelated trait bounds (`substs-ppaux.verbose.stderr`). In particular, we now point at trait bounds on method calls. We no longer point at "obvious" obligation sources (we no longer have a note pointing at `Trait` saying "required by a bound in `Trait`", like in `associated-types-no-suitable-supertrait*`). Address part of #89418.
2021-11-13Fix handling of substitutions and binders when deciding whether to suggest ↵Jakob Degen-3/+3
references When suggesting references, substitutions were being forgotten and some types were misused. This led to at least one ICE and other incorrectly emitted diagnostics. This has been fixed; in some cases this leads to diagnostics changing, and tests have been adjusted.
2021-10-19Revert "Rollup merge of #86011 - tlyu:correct-sized-bound-spans, r=estebank"Yuki Okushi-4/+4
This reverts commit 36a1076d24697621a3bb67ef654b4eb79647aa54, reversing changes made to e1e9319d93aea755c444c8f8ff863b0936d7a4b6.
2021-10-08update ui test expectationsTaylor Yu-4/+4
2021-10-05Consider unfulfilled obligations in binop errorsEsteban Kuber-10/+90
When encountering a binop where the types would have been accepted, if all the predicates had been fulfilled, include information about the predicates and suggest appropriate `#[derive]`s if possible. Point at trait(s) that needs to be `impl`emented.
2021-09-27better suggestionsTakayuki Maeda-12/+18
2021-09-16Remove unnecessary labelEsteban Kuber-20/+5
2021-09-16Point at call span that introduced obligation for the argEsteban Kuber-17/+35
2021-09-09Ignore automatically derived impls of `Clone` and `Debug` in dead code analysisFabian Wolff-0/+83