]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #79606 - ThePuzzlemaker:issue-79458-fix, r=scottmcm
authorbors <bors@rust-lang.org>
Wed, 2 Dec 2020 07:37:40 +0000 (07:37 +0000)
committerbors <bors@rust-lang.org>
Wed, 2 Dec 2020 07:37:40 +0000 (07:37 +0000)
Do not show negative polarity trait implementations in diagnostic messages for similar implementations

This fixes #79458.

Previously, this code:
```rust
#[derive(Clone)]
struct Foo<'a, T> {
    x: &'a mut T,
}
```
would have suggested that `<&mut T as Clone>` was an implementation that was found. This is due to the fact that the standard library now has `impl<'_, T> !Clone for &'_ mut T`, and explicit negative polarity implementations were not filtered out in diagnostic output when suggesting similar implementations.

This PR fixes this issue by filtering out negative polarity trait implementations in `find_similar_impl_candidates` within `rustc_trait_selection::traits::error_reporting::InferCtxtPrivExt<'tcx>`. It also adds a UI regression test for this issue and fixes UI tests that had incorrectly been modified to expect the invalid output.

r? `@scottmcm`


Trivial merge