mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-04 01:42:54 +03:00
d37afad0cc
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`