-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Revert "RFC to require impl MyStruct
to be nearby the definition of MyStruct
"
#735
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
See also this comment about some of the consequences of UFCS. |
Sounds good! |
I agree with the sentiment, however there remains some amount of impl work to be done before the arguments in the original RFC no longer apply, no? |
Yes, hopefully I'll get to it in the next couple of weeks (I already figured out the details). |
Does this mean that it will be possible to write something like pub struct SomeType { ... }
mod some_functionality {
use super::SomeType;
impl SomeType {
fn do_something(&self) { ... }
}
fn free_func() {
let s: SomeType = ...;
s.do_something();
}
} or maybe even pub struct SomeType { ... }
mod some_functionality {
use super::SomeType;
impl SomeType {
fn do_something(&self) { ... }
}
}
fn free_func() {
let s: SomeType = ...;
s.do_something();
} ? If so, it is great! It will help structuring programs immensely. |
@netvl Both work before UFCS if you remove the restriction. I had a PR doing this a while back, it required amending the RFC and I never got back to it. |
👍 but instead of deleting the original RFC, @eddyb can we have a new RFC that reverses the design? It can be pretty short. I'd prefer to leave the RFC for historical purposes. |
@brson I guess it could be something small explaining how UFCS allows resolution to ignore |
Merged. |
The "Revised UFCS proposal", PR #132, makes the restriction imposed by PR #155 unnecessary:
This applies to all non-trait
impl
s, and because<T>::item
has to be handled during type-checking, that removes any need to handleimpl
s (or treat them as modules, for that matter) in resolution, eliminatingall the issues #155 was trying to solve by being overly conservative.