Skip to content
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

Change use of "UFCS" to "fully-qualified function call syntax" #3366

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions text/0132-ufcs.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@

# Summary

This RFC describes a variety of extensions to allow any method to be
used as first-class functions. The same extensions also allow for
trait methods without receivers to be invoked in a more natural
fashion.
This RFC describes the fully-qualified syntax for making function calls,
which was previously called Unambiguous or Universal Function Call Syntax
(UFCS). The [Rust Reference section on call expressions] provides
an overview of this syntax, and reasons for the change in terminology.

There are a variety of extensions to allow any method to be used as
first-class functions. The same extensions also allow for trait methods
without receivers to be invoked in a more natural fashion.
Comment on lines +7 to +14
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the structure of this entire paragraph doesn't seem necessary to add the explanatory note, and usually RFCs are preserved as close to as-written as reasonable. The intent is good overall with this PR but please favor additive over subtractive changes.


First, at present, the notation `path::method()` can be used to invoke
inherent methods on types. For example, `Vec::new()` is used to create
Expand Down Expand Up @@ -210,3 +214,6 @@ to try and change the question:
type parameter. But there exists a lot of precedent for the current
approach and hence I think this is likely a bad idea (not to mention
that it's a drastic change).


[Rust Reference section on call expressions]: https://doc.rust-lang.org/reference/expressions/call-expr.html#disambiguating-function-calls
12 changes: 6 additions & 6 deletions text/0255-object-safety.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ where a trait object is used with a generic call and would be something like
"type error: SomeTrait does not implement SomeTrait" - no indication that the
non-object-safe method were to blame, only a failure in trait matching.

Another advantage of this proposal is that it implies that all
method-calls can always be rewritten into an equivalent [UFCS]
call. This simplifies the "core language" and makes method dispatch
notation -- which involves some non-trivial inference -- into a kind
of "sugar" for the more explicit UFCS notation.
Another advantage of this proposal is that it implies that all method-calls
can always be rewritten into an equivalent fully-qualified function call
(see [RFC 132]). This simplifies the "core language" and makes method dispatch
notation -- which involves some non-trivial inference -- into a kind of
"sugar" for the more explicit fully-qualified notation.
Comment on lines +73 to +77
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, but is there a version that minimizes the diff?


# Detailed design

Expand Down Expand Up @@ -212,5 +212,5 @@ N/A
(2) specify that methods may include `where Self:Sized` to overcome
object safety restrictions.

[UFCS]: 0132-ufcs.md
[RFC 132]: 0132-ufcs.md
[RFC 546]: 0546-Self-not-sized-by-default.md