Skip to content

Commit 08984a6

Browse files
committed
Add a compatibility clause for UFCS method calls
1 parent cb7becf commit 08984a6

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

active/0000-enum-namespacing.md

+26
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,32 @@ This should not affect much if any code in practice, as Rust's naming
254254
conventions state that variants should be capitalized and method names should
255255
not.
256256

257+
## With other post-1.0 work
258+
259+
Part of the UFCS work will (or at least discussed) allowing this:
260+
```
261+
trait Foo {
262+
fn Baz();
263+
}
264+
265+
enum Bar {
266+
Baz,
267+
}
268+
269+
impl Foo for Bar {
270+
fn Baz() {}
271+
}
272+
273+
fn main() {
274+
Bar::Baz(); // instead of Foo::<for Bar>::Baz()
275+
}
276+
```
277+
If this is implemented before namespaced enums, we must add a restriction,
278+
similar to the one for intrinsic methods, that prohibits something like
279+
`Foo::Baz` from being called as in the above example. Note that the trait may
280+
be implemented for `Bar` without any problems, and the method may be called via
281+
the long form. It's just `Bar::Baz()` that must be disallowed.
282+
257283
## Later
258284

259285
The compiler's resolve stage will be altered in two ways. It will place an

0 commit comments

Comments
 (0)