Overflow evaluation when using a wrapper function
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code:
pub struct AdditiveShare<T>(T);
pub trait SharedValue {}
pub trait IntoIteratorB {
fn into_iter_b(&self) {}
}
impl <'a, T> IntoIteratorB for &'a AdditiveShare<T>
where
&'a T: IntoIteratorB,
T: SharedValue,
{}
fn addition<'a, T>(x: &'a AdditiveShare<T>)
where
&'a T: IntoIteratorB,
T: SharedValue,
{
addition_circuit(x);
}
fn addition_circuit<'a, T>(x: &'a AdditiveShare<T>)
where
&'a T: IntoIteratorB,
T: SharedValue,
{
x.into_iter_b();
}
impl SharedValue for u32{}
impl<'a> IntoIteratorB for &'a u32{
fn into_iter_b(&self){}
}
fn main ()
{
let u=AdditiveShare(0u32);
(&u).into_iter_b();
println!("Hello, world!");
}
I expected to see this happen: that it would compile
Instead, this happened: error[E0275]: overflow evaluating the requirement &AdditiveShare<_>: IntoIteratorB
Interestingly, commenting out the wrapper function does not result in a compilation error:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=887c6cfabce6e3eb64b561d278f28807
however, this does:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=d3d7e05d015b3eb397eb8fe5b7433f6a
It might be related to #39959, however this code works when commenting out the wrapper function.
Meta
rustc --version --verbose:
rustc 1.75.0-nightly (fdaaaf9f9 2023-11-08)
binary: rustc
commit-hash: fdaaaf9f923281ab98b865259aa40fbf93d72c7a
commit-date: 2023-11-08
host: aarch64-apple-darwin
release: 1.75.0-nightly
LLVM version: 17.0.4
Backtrace
<backtrace>
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 supplied Rust examples and comparing the Playground links with and without the wrapper function. The report names no repository file or test; done means the demonstrated program no longer produces overflow evaluating the IntoIteratorB requirement, with regression coverage added in the appropriate compiler test area.
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
- 30/100