-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[NLL] A rejects-valid (a NLL regression) #48180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I believe this is a duplicate of #48129 |
Reduced example: #![feature(nll)]
use std::ops::{ShrAssign, AddAssign};
trait HasTrailingZeros {
#[inline(always)]
fn trailing_zeros(self) -> u32;
}
impl HasTrailingZeros for u32 {
#[inline(always)]
fn trailing_zeros(self) -> u32 { self.trailing_zeros() }
}
fn gcd<T>(mut u: T, mut v: T) -> T
where T: Copy +
ShrAssign<u32> +
HasTrailingZeros {
v >>= v.trailing_zeros();
v
}
// Not necessary for repro, but useful for comparison to #48129
fn add_self<T>(mut v: T) -> T
where T: AddAssign + Copy + AddAssign {
v += v;
v
}
fn main() {
println!("{}", gcd(20u32, 10u32));
} The MIR generated by `gcd` MIR
`add_self` example
so I'm going to close this. @leonardo-m feel free to reopen if you disagree 😄. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code compiles and runs correctly if I don't use the NLL feature:
With the NLL feature it gives (it used to compile with NLL):
The text was updated successfully, but these errors were encountered: