-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
suggest removing &
when iterating over &<some iterator type>
#47744
Comments
&
when iterating over &<some iterator type>
cc @estebank |
@nikomatsakis Can I give it a shot? |
@ysiraichi feel free to do so! Also feel free to reach out either on gitter or on this issue for help. You'll have to look at |
That doesn't quite seem like enough -- the type might be an let x = &(1..2);
for y in x { ... } But indeed that is one of the tricky bits here: the place where the error is reported is rather 'divorced' from the original source code. We might be able to consult the |
The further removed the borrow is from the use location the less likely you're to be able to change it without breaking something else. If the type is copy or clone, I'd instead suggest using * instead. Also, I thought that even if it is a binding a ref or what have you, you can follow the Tys until you get to a TyAdt. |
@estebank I think we should literally look for the case where the for x in &vec to
Also, adding a |
…ebank Suggest removing `&`s This implements the error message discussed in rust-lang#47744. We check whether removing each `&` yields a type that satisfies the requested obligation. Also, it was created a new `NodeId` field in `ObligationCause` in order to iterate through the `&`s. The way it's implemented now, it iterates through the obligation snippet and counts the number of `&`. r? @estebank
Repro case for test. |
I started going
for constraint in &self.constraints {
then move to useenumerate
and forgot to remove the&
.I figuref that the error could say
maybe remove the &
, callingiter
and having&
doesn't make sense.The text was updated successfully, but these errors were encountered: