summary refs log tree commit diff
path: root/src/test/ui/traits
AgeCommit message (Collapse)AuthorLines
2020-06-25Rollup merge of #73674 - estebank:op-trait-bound-suggestion, r=davidtwcoManish Goregaokar-0/+5
Tweak binop errors * Suggest potentially missing binop trait bound (fix #73416) * Use structured suggestion for dereference in binop
2020-06-24Suggest type param trait bound for binop only when appropriateEsteban Küber-1/+0
Verify that the binop trait *is* implemented for the types *if* all the involved type parameters are replaced with fresh inferred types. When this is the case, it means that the type parameter was indeed missing a trait bound. If this is not the case, provide a generic `note` refering to the type that doesn't implement the expected trait.
2020-06-23Tweak binop errorsEsteban Küber-0/+6
* Suggest potentially missing binop trait bound (fix #73416) * Use structured suggestion for dereference in binop
2020-06-20Rollup merge of #72456 - ldm0:dereftrait, r=estebankManish Goregaokar-0/+253
Try to suggest dereferences on trait selection failed Fixes #39029 Fixes #62530 This PR consists of two parts: 1. Decouple `Autoderef` with `FnCtxt` and move `Autoderef` to `librustc_trait_selection`. 2. Try to suggest dereferences when trait selection failed. The first is needed because: 1. For suggesting dereferences, the struct `Autoderef` should be used. But before this PR, it is placed in `librustc_typeck`, which depends on `librustc_trait_selection`. But trait selection error emitting happens in `librustc_trait_selection`, if we want to use `Autoderef` in it, dependency loop is inevitable. So I moved the `Autoderef` to `librustc_trait_selection`. 2. Before this PR, `FnCtxt` is coupled to `Autoderef`, and `FnCtxt` only exists in `librustc_typeck`. So decoupling is needed. After this PR, we can get suggestion like this: ``` error[E0277]: the trait bound `&Baz: Happy` is not satisfied --> $DIR/trait-suggest-deferences-multiple.rs:34:9 | LL | fn foo<T>(_: T) where T: Happy {} | ----- required by this bound in `foo` ... LL | foo(&baz); | ^^^^ | | | the trait `Happy` is not implemented for `&Baz` | help: consider adding dereference here: `&***baz` error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. ``` r? @estebank
2020-06-20Prevent incorrect help message for dereference suggestionDonough Liu-1/+67
2020-06-20Try to suggest dereferences when trait selection failed.Donough Liu-0/+187
2020-06-19Rollup merge of #73452 - matthewjasper:auto-rec, r=nikomatsakisManish Goregaokar-32/+44
Unify region variables when projecting associated types This is required to avoid cycles when evaluating auto trait predicates. Notably, this is required to be able add Chalk types to `CtxtInterners` for `cfg(parallel_compiler)`. r? @nikomatsakis
2020-06-19Rollup merge of #71420 - RalfJung:specialization-incomplete, r=matthewjasperManish Goregaokar-9/+57
Specialization is unsound As discussed in https://github.com/rust-lang/rust/issues/31844#issuecomment-617013949, it might be a good idea to warn users of specialization that the feature they are using is unsound. I also expanded the "incomplete feature" warning to link the user to the tracking issue.
2020-06-17Unify region variables when projecting associated typesmatthewjasper-32/+44
This is required to avoid cycles when evaluating auto trait predicates.
2020-06-16warn against 'specialization' featureRalf Jung-9/+57
2020-06-15Only display other method receiver candidates if they actually applyAaron Hill-7/+0
Previously, we would suggest `Box<Self>` as a valid receiver, even if method resolution only succeeded due to an autoderef (e.g. to `&self`)
2020-06-15Rollup merge of #72556 - matthew-mcallister:trait-alias-inherent-impl, ↵Ralf Jung-0/+33
r=estebank Fix trait alias inherent impl resolution Fixes #60021 and fixes #72415. Obviously, the fix was very easy, but getting started with the testing and debugging rust compiler was an interesting experience. Now I can cross it off my bucket list!
2020-05-28Account for `Self` as a type paramEsteban Küber-0/+72
2020-05-27review comments: change wording and visual outputEsteban Küber-8/+6
2020-05-27Modify wordingEsteban Küber-3/+6
2020-05-27review commentsEsteban Küber-2/+2
2020-05-27Tweak output for mismatched impl itemEsteban Küber-1/+39
Detect type parameter that might require lifetime constraint. Do not name `ReVar`s in expected/found output. Reword text suggesting to check the lifetimes.
2020-05-27Name `RegionKind::ReVar` lifetimes in diagnosticsEsteban Küber-1/+1
2020-05-27Fix spacing of expected/found notes without a labelEsteban Küber-2/+2
2020-05-24Fix trait alias inherent impl resolutionMatthew McAllister-0/+33
Fixes #60021 and #72415.
2020-05-22Rollup merge of #71829 - kper:issue71136, r=matthewjasperRalf Jung-0/+21
Fix suggestion to borrow in struct The corresponding issue is #71136. The compiler suggests that borrowing `the_foos` might solve the problem. This is obviously incorrect. ``` struct Foo(u8); #[derive(Clone)] struct FooHolster { the_foos: Vec<Foo>, } ``` I propose as fix to check if there is any colon in the span. However, there might a case where `my_method(B { a: 1, b : foo })` would be appropriate to show a suggestion for `&B ...`. To fix that too, we can simply check if there is a bracket in the span. This is only possible because both spans are different. Issue's span: `the_foos: Vec<Foo>` other's span: `B { a : 1, b : foo }`
2020-05-03Adding new test #71136Kevin Per-0/+21
2020-04-26Use Cell::take in a couple placesThinkChaos-2/+2
2020-04-24Rollup merge of #71235 - estebank:lt-sugg-2, r=ecstatic-morseDylan DPC-1/+1
Tweak `'static` suggestion code Fix #71196.
2020-04-23fix error code for E0751YI-15/+15
2020-04-22Sort `MultiSpan`s on creationEsteban Küber-1/+1
2020-04-18Add label to item source of bound obligationEsteban Küber-1/+1
2020-04-18Do not emit note for projected derived obligationsEsteban Küber-1/+0
2020-04-18Remove `AssocTypeBound` and propagate bound `Span`sEsteban Küber-15/+11
2020-04-18Maintain chain of derived obligationsEsteban Küber-0/+5
When evaluating the derived obligations from super traits, maintain a reference to the original obligation in order to give more actionable context in the output.
2020-04-14Rename AssocKind::Method to AssocKind::FnRustin-Liu-2/+2
Rename fn_has_self_argument to fn_has_self_parameter Rename AssocItemKind::Method to AssocItemKind::Fn Refine has_no_input_arg Refine has_no_input_arg Revert has_no_input_arg Refine suggestion_descr Move as_def_kind into AssocKind Signed-off-by: Rustin-Liu <rustin.liu@gmail.com> Fix tidy check issue Signed-off-by: Rustin-Liu <rustin.liu@gmail.com>
2020-04-11rustc: Add a warning count upon completionRoccoDev-1/+1
2020-04-08Small tweaks to required bound spanEsteban Küber-25/+25
2020-04-08Use `PredicateObligation`s instead of `Predicate`sEsteban Küber-17/+26
Keep more information about trait binding failures.
2020-04-05"cannot resolve" → "cannot satisfy"Esteban Küber-1/+1
2020-04-03Rollup merge of #70741 - DutchGhost:test-59023, r=CentrilMazdak Farrokhzad-0/+17
Add test for #59023 Adds a test for https://github.com/rust-lang/rust/issues/59023 Closes https://github.com/rust-lang/rust/issues/59023
2020-04-03Add test for #59023DutchGhost-0/+17
2020-04-02tests: remove ignore directives from tests that mention core/alloc/std spans.Eduard-Mihai Burtescu-18/+9
2020-03-29Tweak `suggest_constraining_type_param`Esteban Küber-24/+18
Some of the bound restriction structured suggestions were incorrect while others had subpar output.
2020-03-26add test for negative specializes negativeNiko Matsakis-0/+13
2020-03-26move stderr file tooNiko Matsakis-0/+12
2020-03-26give the negative-impls-builtin test a more sensible nameNiko Matsakis-0/+0
2020-03-26comment the `typeck-negative-impls-builtin` testNiko Matsakis-0/+3
2020-03-26move feature-gate-negative-impls test to traits/negative-implsNiko Matsakis-0/+3
2020-03-26introduce `negative_impls` feature gate and documentNiko Matsakis-18/+47
They used to be covered by `optin_builtin_traits` but negative impls are now applicable to all traits, not just auto traits. This also adds docs in the unstable book for the current state of auto traits.
2020-03-26make a custom error for overlap with negative implsNiko Matsakis-47/+43
2020-03-26permit negative impls for non-auto traitsNiko Matsakis-7/+253
2020-03-23Rollup merge of #69942 - estebank:sized-verbose-sugg, r=matthewjasperMazdak Farrokhzad-8/+8
Increase verbosity when suggesting subtle code changes Do not suggest changes that are actually quite small inline, to minimize the likelihood of confusion. Fix #69243.
2020-03-23Rollup merge of #70227 - LeSeulArtichaut:typo-def, r=CentrilMazdak Farrokhzad-6/+5
Only display definition when suggesting a typo Closes #70206 r? @Centril
2020-03-22Use more targetted span for error labelEsteban Küber-4/+4