You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: text/0000-default-type-parameter-fallback-take-two.md
+9-5Lines changed: 9 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -537,13 +537,17 @@ The following unresolved questions should be resolved prior to stabilization, bu
537
537
538
538
### Interaction with numerical fallback
539
539
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:
541
541
542
542
1. User fallback takes precedence over numerical fallback, always.
543
543
2. Numerical fallback takes precedence, always.
544
544
3. DWIM: User fallback takes preference, but if it fails we try numerical fallback.
545
545
4. Error on any ambiguity.
546
546
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
+
547
551
The two following examples show the consequences of each alternative, example 1:
548
552
549
553
```rust
@@ -552,6 +556,7 @@ fn foo<T=u64>(t: T) { ... }
552
556
// 2. `_` is `i32`
553
557
// 3. `_` is `u64`
554
558
// 4. Error.
559
+
// 5. Error.
555
560
fnmain() { foo::<_>(22) }
556
561
```
557
562
@@ -561,14 +566,13 @@ Example 2:
561
566
fnfoo<T=char>(t:T) { ... }
562
567
// 1. Error.
563
568
// 2. `_` is `i32`
564
-
// 3. `_` is `u64`
569
+
// 3. `_` is `i32`
565
570
// 4. Error.
571
+
// 5. `_` is `i32`.
566
572
fnmain() { foo::<_>(22) }
567
573
```
568
574
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.
0 commit comments