Skip to content

Commit cb4c521

Browse files
BoxyUwUcompiler-errors
authored andcommitted
line length limit
1 parent 5dbd029 commit cb4c521

File tree

1 file changed

+39
-19
lines changed

1 file changed

+39
-19
lines changed

Diff for: src/turbofishing-and-early-late-bound.md

+39-19
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
# Turbofishing's interactions with early/late bound parameters
22

3-
The early/late bound parameter distinction on functions introduces some complications when providing generic arguments to functions. This document discusses what those are and how they might interact with future changes to make more things late bound.
3+
The early/late bound parameter distinction on functions introduces some complications
4+
when providing generic arguments to functions. This document discusses what those are
5+
and how they might interact with future changes to make more things late bound.
46

57
## Can't turbofish generic arguments on functions sometimes
68

7-
When a function has any late bound lifetime parameters (be they explicitly defined or implicitly introduced via lifetime elision) we disallow specifying any lifetime arguments on the function. Sometimes this is a hard error other times it is a future compat lint ([`late_bound_lifetime_arguments`](https://github.com/rust-lang/rust/issues/42868)).
9+
When a function has any late bound lifetime parameters (be they explicitly defined or
10+
implicitly introduced via lifetime elision) we disallow specifying any lifetime arguments
11+
on the function. Sometimes this is a hard error other times it is a future compat lint
12+
([`late_bound_lifetime_arguments`](https://github.com/rust-lang/rust/issues/42868)).
813

914
```rust
1015
fn early<'a: 'a>(a: &'a ()) -> &'a () { a }
@@ -30,7 +35,10 @@ fn main() {
3035
}
3136
```
3237

33-
The justification for this is that late bound parameters are not present on the `FnDef` so the arguments to late bound parameters can't be present in the substs for the type. i.e. the `late` function in the above code snippet would not have any generic parameters on the `FnDef` zst:
38+
The justification for this is that late bound parameters are not present on the
39+
`FnDef` so the arguments to late bound parameters can't be present in the substs
40+
for the type. i.e. the `late` function in the above code snippet would not have
41+
any generic parameters on the `FnDef` zst:
3442
```rust
3543
// example desugaring of the `late` function and its zst + builtin Fn impl
3644
struct LateFnDef;
@@ -40,25 +48,38 @@ impl<'a> Fn<(&'a ())> for LateFnDef {
4048
}
4149
```
4250

43-
The cause for some situations giving future compat lints and others giving hard errors is a little arbitrary but explainable:
51+
The cause for some situations giving future compat lints and others giving hard errors
52+
is a little arbitrary but explainable:
4453
- It's always a hard error for method calls
45-
- It's only a hard error on paths to free functions if there is no unambiguous way to create the substs for the fndef from the lifetime arguments. (i.e. the amount of lifetimes provided must be exactly equal to the amount of early bound lifetimes or else it's a hard error)
54+
- It's only a hard error on paths to free functions if there is no unambiguous way to
55+
create the substs for the fndef from the lifetime arguments. (i.e. the amount of
56+
lifetimes provided must be exactly equal to the amount of early bound lifetimes or
57+
else it's a hard error)
4658

4759
## Back compat issues from turning early bound to late bound
4860

49-
Because of the previously mentioned restriction on turbofishing generic arguments, it is a breaking change to upgrade a lifetime from early bound to late bound as it can cause existing turbofishies to become hard errors/future compat lints.
61+
Because of the previously mentioned restriction on turbofishing generic arguments, it
62+
is a breaking change to upgrade a lifetime from early bound to late bound as it can cause
63+
existing turbofishies to become hard errors/future compat lints.
5064

51-
Many t-types members have expressed interest in wanting more parameters to be late bound. We cannot do so if making something late bound is going to break code that many would expect to work (judging by the future compat lint issue many people do expect to be able to turbofish late bound parameters).
65+
Many t-types members have expressed interest in wanting more parameters to be late bound.
66+
We cannot do so if making something late bound is going to break code that many would
67+
expect to work (judging by the future compat lint issue many people do expect to be able
68+
to turbofish late bound parameters).
5269

5370
## Interactions with late bound type/const parameters
5471

55-
If we were to make some type/const parameters late bound we would definitely not want to disallow turbofishing them as it presumably(?) would break a Tonne of code.
72+
If we were to make some type/const parameters late bound we would definitely not want
73+
to disallow turbofishing them as it presumably(?) would break a Tonne of code.
5674

57-
While lifetimes do differ from type/consts in some ways I(BoxyUwU) do not believe there is any justification for why it would make sense to allow turbofishing late bound type/const parameters but not late bound lifetimes.
75+
While lifetimes do differ from type/consts in some ways I(BoxyUwU) do not believe there
76+
is any justification for why it would make sense to allow turbofishing late bound
77+
type/const parameters but not late bound lifetimes.
5878

5979
## Removing the hard error/fcw
6080

61-
From reasons above it seems reasonable that we may want to remove the hard error and fcw (removing the errors/fcw is definitely a blocker for making more things late bound).
81+
From reasons above it seems reasonable that we may want to remove the hard error and fcw
82+
(removing the errors/fcw is definitely a blocker for making more things late bound).
6283

6384
example behaviour:
6485
```rust
@@ -77,7 +98,9 @@ fn main() {
7798
}
7899
````
79100

80-
one potential complication is that we would want a way to specify a generic argument to a function without having to specify arguments for all previous parameters. i.e. ideally you could write the following code somehow.
101+
one potential complication is that we would want a way to specify a generic argument
102+
to a function without having to specify arguments for all previous parameters. i.e.
103+
ideally you could write the following code somehow.
81104
```rust
82105
fn late<'a, 'b>(_: &'a (), _: &'b ()) {}
83106

@@ -90,11 +113,8 @@ fn main() {
90113
accepts_fn(f);
91114
}
92115
```
93-
Maybe we can just special case astconv for `_`/`'_` arguments for late bound parameters somehow and have it not mean the same thing as `_` for early bound parameters. Regardless I think we would need a solution that would allow writing the above code even if it was done by some new syntax such as havign to write `late::<k#no_argument, 'static>` (naturally `k#no_argument` would only make sense as an argument to late bound parameters).
94-
95-
96-
## Conclusion
97-
98-
Late bound params make turbofishing complicated. We currently have a hard error and a future compat lint that we might or might not want.
99-
100-
We don't have to decide on anything in this meeting when it comes to the error/fcw or whether we even want to make more things late bound. The primary purpose is to spread knowledge. I would still like to see what people think about removing the error and fcw though (but any decision about it will have a proper FCP).
116+
Maybe we can just special case astconv for `_`/`'_` arguments for late bound parameters somehow
117+
and have it not mean the same thing as `_` for early bound parameters. Regardless I think we
118+
would need a solution that would allow writing the above code even if it was done by some new
119+
syntax such as havign to write `late::<k#no_argument, 'static>` (naturally `k#no_argument`
120+
would only make sense as an argument to late bound parameters).

0 commit comments

Comments
 (0)