Skip to content

Commit 92b7dd9

Browse files
committed
Add a fifth option to the integer fallback unresolved question.
1 parent 587b9bf commit 92b7dd9

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

text/0000-default-type-parameter-fallback-take-two.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -537,13 +537,17 @@ The following unresolved questions should be resolved prior to stabilization, bu
537537

538538
### Interaction with numerical fallback
539539

540-
There are multiple alternatives of what to do about the interaction of user fallback with numerical (and diverging) fallback. This was discussed at lenght in [this internals thread](https://internals.rust-lang.org/t/interaction-of-user-defined-and-integral-fallbacks-with-inference/2496). The options are:
540+
There are multiple alternatives of what to do about the interaction of user fallback with numerical (and diverging) fallback. This was discussed at lenght in [this internals thread](https://internals.rust-lang.org/t/interaction-of-user-defined-and-integral-fallbacks-with-inference/2496). The options were:
541541

542542
1. User fallback takes precedence over numerical fallback, always.
543543
2. Numerical fallback takes precedence, always.
544544
3. DWIM: User fallback takes preference, but if it fails we try numerical fallback.
545545
4. Error on any ambiguity.
546546

547+
And now a fifth option proposed by this RFC:
548+
549+
5. Error on conflicting numericals, whenever DWIM would prefer a user fallback we instead error.
550+
547551
The two following examples show the consequences of each alternative, example 1:
548552

549553
```rust
@@ -552,6 +556,7 @@ fn foo<T=u64>(t: T) { ... }
552556
// 2. `_` is `i32`
553557
// 3. `_` is `u64`
554558
// 4. Error.
559+
// 5. Error.
555560
fn main() { foo::<_>(22) }
556561
```
557562

@@ -561,14 +566,13 @@ Example 2:
561566
fn foo<T=char>(t: T) { ... }
562567
// 1. Error.
563568
// 2. `_` is `i32`
564-
// 3. `_` is `u64`
569+
// 3. `_` is `i32`
565570
// 4. Error.
571+
// 5. `_` is `i32`.
566572
fn main() { foo::<_>(22) }
567573
```
568574

569-
Option 3 gives the best results, but it may change the behaviour of existing code so it might have to be phased-in through the errors given by option 4. The consensus reached in the thread was for using option 4 to open the possibility of transitioning to 3, is that still a consensus? Taking option 3 at a point in the future will make code that works fine today possibly overflow. Even if this is done through epochs, it's still a considerable risk.
570-
571-
The decision seems to come down between complete backwards compatibility with option 2, complete forwards compatibility with option 4 or try to get the best behaviour now with option 3. If we want option 4 now is the best time, however without a plan to migrate to option 3 it would be difficult to justify that change. Perhaps if we see zero chance of behaviour change from option 3 in a crater run we can go straight to that.
575+
Option 3 gives the best results, but it may change the behaviour of existing code so it might have to be phased-in through the errors given by option 4 or 5. The consensus reached in the thread was for using option 4 to open the possibility of transitioning to 3, is that still a consensus? However option 4 seems overly restrictive, we could instead do option 5 for a smoother transition.
572576

573577
### Terminology and syntax
574578

0 commit comments

Comments
 (0)