`multiple_supertrait_upcastable` lint is maybe overzealous for auto traits
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code:
#![feature(multiple_supertrait_upcastable)]
#![warn(multiple_supertrait_upcastable)]
pub trait Foo: Send + Sync {}
I expected to see this happen: Send and Sync are auto traits, and thus do not (currently) take any extra space in the vtable for dyn Foo[^1], so the multiple_supertrait_upcastable lint should not fire. (similarly if Foo had one auto and one non-auto supertrait).
Instead, this happened: The multiple_supertrait_upcastable lint fires, since Foo has multiple supertraits (Send and Sync) (playground).
Tracking issue for multiple_supertrait_upcastable: #150833
This could be determined to not be a false positive, as the diagnostic is technically correct. However, the reason for the lint when it was introduced was:
To support upcasting with multiple supertraits, we need to store multiple vtables and
this can result in extra space overhead, even if no code actually uses upcasting. This
lint allows users to identify when such scenarios occur and to decide whether the
additional overhead is justified
Under that reasoning, I think Foo should not be linted on.
There could also be an argument for not linting on empty non-auto supertraits, but that is less convincing IMO.
non-auto supertraits
There could also be an argument for not linting on Bar below, as Super1 and Super2 also do not take any extra vtable space. However, this is less convincing IMO, since they could semver-compatibly get new items with default implementations that would give them vtable entries, whereas auto traits like Send/Sync cannot (currently).
pub trait Super1 {} // empty
pub trait Super2 {} // empty
pub trait Bar: Super1 + Super2 { /* ... */ }
Meta
rustc --version --verbose:
rustc 1.95.0-nightly (d940e5684 2026-01-19)
binary: rustc
commit-hash: d940e56841ddcc05671ead99290e35ff2e98369f
commit-date: 2026-01-19
host: x86_64-unknown-linux-gnu
release: 1.95.0-nightly
LLVM version: 21.1.8
(no backtrace)
[^1]: upcasting dyn Foo to dyn Send just re-uses the vtable since it has a common prefix of drop_in_place, size, align
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the multiple_supertrait_upcastable warning with the Foo: Send + Sync example from the issue, then read the lint's implementation and the tracking issue #150833. Done means reaching and testing a decision about whether combinations containing auto traits should avoid this warning, including the mixed auto/non-auto case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100