Commit 2c9087a
committed
Auto merge of rust-lang#117758 - Urgau:lint_pointer_trait_comparisons, r=davidtwco
Add lint against ambiguous wide pointer comparisons
This PR is the resolution of rust-lang#106447 decided in rust-lang#117717 by T-lang.
## `ambiguous_wide_pointer_comparisons`
*warn-by-default*
The `ambiguous_wide_pointer_comparisons` lint checks comparison of `*const/*mut ?Sized` as the operands.
### Example
```rust
let ab = (A, B);
let a = &ab.0 as *const dyn T;
let b = &ab.1 as *const dyn T;
let _ = a == b;
```
### Explanation
The comparison includes metadata which may not be expected.
-------
This PR also drops `clippy::vtable_address_comparisons` which is superseded by this one.
~~One thing: is the current naming right? `invalid` seems a bit too much.~~
Fixes rust-lang#117717File tree
6 files changed
+17
-1
lines changed- alloc/tests
- core/src
- ptr
6 files changed
+17
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1980 | 1980 | | |
1981 | 1981 | | |
1982 | 1982 | | |
1983 | | - | |
| 1983 | + | |
1984 | 1984 | | |
1985 | 1985 | | |
1986 | 1986 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
| 233 | + | |
233 | 234 | | |
234 | 235 | | |
235 | 236 | | |
236 | 237 | | |
237 | 238 | | |
238 | 239 | | |
239 | 240 | | |
| 241 | + | |
240 | 242 | | |
241 | 243 | | |
242 | 244 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1772 | 1772 | | |
1773 | 1773 | | |
1774 | 1774 | | |
| 1775 | + | |
1775 | 1776 | | |
1776 | 1777 | | |
1777 | 1778 | | |
| |||
1784 | 1785 | | |
1785 | 1786 | | |
1786 | 1787 | | |
| 1788 | + | |
1787 | 1789 | | |
1788 | 1790 | | |
1789 | 1791 | | |
| |||
1803 | 1805 | | |
1804 | 1806 | | |
1805 | 1807 | | |
| 1808 | + | |
1806 | 1809 | | |
1807 | 1810 | | |
1808 | 1811 | | |
1809 | 1812 | | |
1810 | 1813 | | |
| 1814 | + | |
1811 | 1815 | | |
1812 | 1816 | | |
1813 | 1817 | | |
1814 | 1818 | | |
1815 | 1819 | | |
| 1820 | + | |
1816 | 1821 | | |
1817 | 1822 | | |
1818 | 1823 | | |
1819 | 1824 | | |
1820 | 1825 | | |
| 1826 | + | |
1821 | 1827 | | |
1822 | 1828 | | |
1823 | 1829 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1897 | 1897 | | |
1898 | 1898 | | |
1899 | 1899 | | |
| 1900 | + | |
1900 | 1901 | | |
1901 | 1902 | | |
1902 | 1903 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2199 | 2199 | | |
2200 | 2200 | | |
2201 | 2201 | | |
| 2202 | + | |
2202 | 2203 | | |
2203 | 2204 | | |
2204 | 2205 | | |
| |||
2210 | 2211 | | |
2211 | 2212 | | |
2212 | 2213 | | |
| 2214 | + | |
2213 | 2215 | | |
2214 | 2216 | | |
2215 | 2217 | | |
| |||
2229 | 2231 | | |
2230 | 2232 | | |
2231 | 2233 | | |
| 2234 | + | |
2232 | 2235 | | |
2233 | 2236 | | |
2234 | 2237 | | |
2235 | 2238 | | |
2236 | 2239 | | |
| 2240 | + | |
2237 | 2241 | | |
2238 | 2242 | | |
2239 | 2243 | | |
2240 | 2244 | | |
2241 | 2245 | | |
| 2246 | + | |
2242 | 2247 | | |
2243 | 2248 | | |
2244 | 2249 | | |
2245 | 2250 | | |
2246 | 2251 | | |
| 2252 | + | |
2247 | 2253 | | |
2248 | 2254 | | |
2249 | 2255 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1791 | 1791 | | |
1792 | 1792 | | |
1793 | 1793 | | |
| 1794 | + | |
1794 | 1795 | | |
1795 | 1796 | | |
1796 | 1797 | | |
| |||
0 commit comments