@@ -1782,13 +1782,20 @@ pub(crate) enum InvalidNanComparisonsSuggestion {
1782
1782
#[derive(LintDiagnostic)]
1783
1783
pub(crate) enum AmbiguousWidePointerComparisons<'a> {
1784
1784
#[diag(lint_ambiguous_wide_pointer_comparisons)]
1785
- Spanful {
1785
+ SpanfulEq {
1786
1786
#[subdiagnostic]
1787
1787
addr_suggestion: AmbiguousWidePointerComparisonsAddrSuggestion<'a>,
1788
1788
#[subdiagnostic]
1789
1789
addr_metadata_suggestion: Option<AmbiguousWidePointerComparisonsAddrMetadataSuggestion<'a>>,
1790
1790
},
1791
1791
#[diag(lint_ambiguous_wide_pointer_comparisons)]
1792
+ SpanfulCmp {
1793
+ #[subdiagnostic]
1794
+ cast_suggestion: AmbiguousWidePointerComparisonsCastSuggestion<'a>,
1795
+ #[subdiagnostic]
1796
+ expect_suggestion: AmbiguousWidePointerComparisonsExpectSuggestion<'a>,
1797
+ },
1798
+ #[diag(lint_ambiguous_wide_pointer_comparisons)]
1792
1799
#[help(lint_addr_metadata_suggestion)]
1793
1800
#[help(lint_addr_suggestion)]
1794
1801
Spanless,
@@ -1816,48 +1823,67 @@ pub(crate) struct AmbiguousWidePointerComparisonsAddrMetadataSuggestion<'a> {
1816
1823
}
1817
1824
1818
1825
#[derive(Subdiagnostic)]
1819
- pub(crate) enum AmbiguousWidePointerComparisonsAddrSuggestion<'a> {
1820
- #[multipart_suggestion(
1821
- lint_addr_suggestion,
1822
- style = "verbose",
1823
- // FIXME(#53934): make machine-applicable again
1824
- applicability = "maybe-incorrect"
1825
- )]
1826
- AddrEq {
1827
- ne: &'a str,
1828
- deref_left: &'a str,
1829
- deref_right: &'a str,
1830
- l_modifiers: &'a str,
1831
- r_modifiers: &'a str,
1832
- #[suggestion_part(code = "{ne}std::ptr::addr_eq({deref_left}")]
1833
- left: Span,
1834
- #[suggestion_part(code = "{l_modifiers}, {deref_right}")]
1835
- middle: Span,
1836
- #[suggestion_part(code = "{r_modifiers})")]
1837
- right: Span,
1838
- },
1839
- #[multipart_suggestion(
1840
- lint_addr_suggestion,
1841
- style = "verbose",
1842
- // FIXME(#53934): make machine-applicable again
1843
- applicability = "maybe-incorrect"
1826
+ #[multipart_suggestion(
1827
+ lint_addr_suggestion,
1828
+ style = "verbose",
1829
+ // FIXME(#53934): make machine-applicable again
1830
+ applicability = "maybe-incorrect"
1831
+ )]
1832
+ pub(crate) struct AmbiguousWidePointerComparisonsAddrSuggestion<'a> {
1833
+ pub(crate) ne: &'a str,
1834
+ pub(crate) deref_left: &'a str,
1835
+ pub(crate) deref_right: &'a str,
1836
+ pub(crate) l_modifiers: &'a str,
1837
+ pub(crate) r_modifiers: &'a str,
1838
+ #[suggestion_part(code = "{ne}std::ptr::addr_eq({deref_left}")]
1839
+ pub(crate) left: Span,
1840
+ #[suggestion_part(code = "{l_modifiers}, {deref_right}")]
1841
+ pub(crate) middle: Span,
1842
+ #[suggestion_part(code = "{r_modifiers})")]
1843
+ pub(crate) right: Span,
1844
+ }
1845
+
1846
+ #[derive(Subdiagnostic)]
1847
+ #[multipart_suggestion(
1848
+ lint_cast_suggestion,
1849
+ style = "verbose",
1850
+ // FIXME(#53934): make machine-applicable again
1851
+ applicability = "maybe-incorrect"
1852
+ )]
1853
+ pub(crate) struct AmbiguousWidePointerComparisonsCastSuggestion<'a> {
1854
+ pub(crate) deref_left: &'a str,
1855
+ pub(crate) deref_right: &'a str,
1856
+ pub(crate) paren_left: &'a str,
1857
+ pub(crate) paren_right: &'a str,
1858
+ pub(crate) l_modifiers: &'a str,
1859
+ pub(crate) r_modifiers: &'a str,
1860
+ #[suggestion_part(code = "({deref_left}")]
1861
+ pub(crate) left_before: Option<Span>,
1862
+ #[suggestion_part(code = "{l_modifiers}{paren_left}.cast::<()>()")]
1863
+ pub(crate) left_after: Span,
1864
+ #[suggestion_part(code = "({deref_right}")]
1865
+ pub(crate) right_before: Option<Span>,
1866
+ #[suggestion_part(code = "{r_modifiers}{paren_right}.cast::<()>()")]
1867
+ pub(crate) right_after: Span,
1868
+ }
1869
+
1870
+ #[derive(Subdiagnostic)]
1871
+ #[multipart_suggestion(
1872
+ lint_expect_suggestion,
1873
+ style = "verbose",
1874
+ // FIXME(#53934): make machine-applicable again
1875
+ applicability = "maybe-incorrect"
1876
+ )]
1877
+ pub(crate) struct AmbiguousWidePointerComparisonsExpectSuggestion<'a> {
1878
+ pub(crate) paren_left: &'a str,
1879
+ pub(crate) paren_right: &'a str,
1880
+ // FIXME(#127436): Adjust once resolved
1881
+ #[suggestion_part(
1882
+ code = r#"{{ #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] {paren_left}"#
1844
1883
)]
1845
- Cast {
1846
- deref_left: &'a str,
1847
- deref_right: &'a str,
1848
- paren_left: &'a str,
1849
- paren_right: &'a str,
1850
- l_modifiers: &'a str,
1851
- r_modifiers: &'a str,
1852
- #[suggestion_part(code = "({deref_left}")]
1853
- left_before: Option<Span>,
1854
- #[suggestion_part(code = "{l_modifiers}{paren_left}.cast::<()>()")]
1855
- left_after: Span,
1856
- #[suggestion_part(code = "({deref_right}")]
1857
- right_before: Option<Span>,
1858
- #[suggestion_part(code = "{r_modifiers}{paren_right}.cast::<()>()")]
1859
- right_after: Span,
1860
- },
1884
+ pub(crate) before: Span,
1885
+ #[suggestion_part(code = "{paren_right} }}")]
1886
+ pub(crate) after: Span,
1861
1887
}
1862
1888
1863
1889
#[derive(LintDiagnostic)]
0 commit comments