Code does not compile due to ignored trait implementation
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
A recent update of wide broke (https://github.com/Lokathor/wide/issues/303#issuecomment-5141894529) some code that compiled before.
The latest version (1.6.0) changes the way traits are implemented for SIMD types, and reduces to the following code that should work but instead gives a compile error:
use std::ops::Add;
pub struct Type;
impl Add for Type {
type Output = Self;
fn add(self, _: Type) -> Self::Output {
unimplemented!()
}
}
impl<Rhs> Add<&Rhs> for Type
where
Self: Add<Rhs, Output = Self>,
{
type Output = Self;
fn add(self, _: &Rhs) -> Self::Output {
unimplemented!()
}
}
trait T<'s> {}
fn test<'s>(_x: impl T<'s>) {
let _ = Type + Type;
}
I expected to see this happen: Code compiles.
Instead, it does not compile and gives this error:
> cargo check
Checking tt v0.1.0 (/tmp/philae/tt)
error[E0275]: overflow evaluating the requirement `Type: Add<&_>`
╭▸ src/lib.rs:26:18
│
26 │ let _ = Type + Type;
│ ━
│
╰ help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`tt`)
note: required for `Type` to implement `Add<&&_>`
╭▸ src/lib.rs:13:11
│
13 │ impl<Rhs> Add<&Rhs> for Type
│ ━━━━━━━━━ ━━━━
14 │ where
15 │ Self: Add<Rhs, Output = Self>,
│ ───────────── unsatisfied trait bound introduced here
├ note: 126 redundant requirements hidden
├ note: required for `Type` to implement `Add<&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&_>`
├ note: the full name for the type has been written to '/tmp/philae/tt/target/debug/deps/tt-d36a269beefb58bc.long-type-7391855843772083704.txt'
╰ note: consider using `--verbose` to print the full type name to the console
For more information about this error, try `rustc --explain E0275`.
error: could not compile `tt` (lib) due to 1 previous error
All of the changes below make the code compile:
- Dropping the
Add<&Rhs>trait implementation. - Removing the unused
_xargument. - Changing the
_x: impl T<'s>to_x: impl T<'static>. - Removing the
Output = Selfbound in the implementation ofAdd<&Rhs>. - Changing
Rhsinimpl<Rhs> Add<&Rhs> for Typeto a specific type.
Meta
The bug is there both on (yesterdays) stable, nightly, and also those from ~2 months ago (the last time I ran rustup update before yesterday).
rustc 1.99.0-nightly (1a833e165 2026-07-29)
binary: rustc
commit-hash: 1a833e16546c2eb012758ddd499964fd8afee29e
commit-date: 2026-07-29
host: x86_64-unknown-linux-gnu
release: 1.99.0-nightly
LLVM version: 22.1.8
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 with the reduced Rust example in the issue and run cargo check to reproduce the E0275 overflow. Investigate the trait obligations created by the generic Add<&Rhs> implementation and lifetime parameter, then confirm the original example compiles without the listed workarounds and add a regression test where appropriate.
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
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100