Autoref for temporaries in argument position
Nobody has claimed this yet.
- Dominant language
- Markdown
- Stars
- 6.6k
- Forks
- 1.7k
- Avg merge
- 16h 14m
- Merged PRs (30d)
- 1
Description
I often see code like (a + b).cmp(&(c + d)). Both the self argument and the first method argument of cmp are reference types, but only the self argument automatically gets a reference taken.
I suggest that function and method arguments should also automatically get their address taken, if and only if they are temporaries. Rvalue references are copied if they are Copy and thus are then temporaries and get their address taken automatically
So the above example could now be (a + b).cmp(c + d).
Things allowed under this scheme
(a + b).cmp(c + d)foo.cmp(&bar)foo.cmp(&vec[42])
Things not allowed under this scheme
foo.cmp(bar)ifbaris not a reference type or aCopytypefoo.cmp(vec[42])ifvec's elements are not references or aCopytype- e.g. if the vec elements are
i32this would be allowed, but not if they areString
- e.g. if the vec elements are
Locations where to apply autoref
- function arguments
- index op argument
- struct constructor field initialization expressions
- tuple field initialization expressions
- array element initialization expressions
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the issue's allowed and disallowed examples and the listed locations where autoref would apply. Determine the language-semantics and implementation entry points for argument, index, struct, tuple, and array initialization handling; done means the proposal has an agreed design and coverage for each stated case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100