-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Simplify unstable methods list #128549
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
Simplify unstable methods list #128549
Conversation
This PR is not intended to make any functional difference, but it replaces a reference with an owned Vec for a slight code simplification. This will become more useful in subsequent work towards arbitrary self types.
r? @davidtwco rustbot has assigned @davidtwco. Use |
The commit in this PR is also the first commit in #128548. r? @wesleywiser |
@@ -1093,7 +1086,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { | |||
&self, | |||
step: &CandidateStep<'tcx>, | |||
self_ty: Ty<'tcx>, | |||
unstable_candidates: Option<&mut Vec<(Candidate<'tcx>, Symbol)>>, | |||
unstable_candidates: &mut Option<Vec<(Candidate<'tcx>, Symbol)>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you invert this?
I think Option<&mut T>
is generally preferred over &mut Option<T>
, unless you intend to modify the value of the Option
itself. Passing &mut Option<T>
implies the wrong intention with this IMO, since passing in unstable_candidates
indicates that that the caller wants unstable candidates recorded -- I don't expect the callee to ever, e.g., set *unstable_candiates = Some(vec![])
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough - I'll close this PR.
It happens to simplify some of the subsequent work on arbitrary self types, but I'll find another way to do it. Most likely I'll make a newtype wrapper for this Option
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, I don't mind the other half of this PR, i.e. passing Option<Vec<..>>
at the top level of pick -- I don't necessarily see why these had to change from Option<&mut Vec<>>
to &mut Option<Vec<>>
as a consequence though?
This PR is not intended to make any functional difference, but it replaces a reference with an owned
Vec
for a slight code simplification. This will become more useful in subsequent work towards arbitrary self types, RFC 3519 (#44874).