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-const-trait-impls.md
+3-5Lines changed: 3 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -873,7 +873,7 @@ This can be achieved across an edition by having some intermediate syntax like p
873
873
874
874
Then in the following edition, we can forbid the `#[next_const]` attribute and just make it the default.
875
875
876
-
The disadvantage of this is that by default, it creates stricter bounds than desired.
876
+
The disadvantage of this is that sometimes, it creates stricter bounds than desired.
877
877
878
878
```rust
879
879
constfnfoo<T:Foo>() {
@@ -884,15 +884,13 @@ const fn foo<T: Foo>() {
884
884
compiles today, and allows all types that implement `Foo`, irrespective of the constness of the impl.
885
885
With the opt-out scheme that would still compile, but suddenly require callers to provide a const impl.
886
886
887
-
The safe default (and the one folks are used to for a few years now on stable), is that trait bounds just work, you just
888
-
can't call methods on them.
889
-
This is both useful in
887
+
The alternative proposed above (and the one folks are used to for a few years now on stable), is that trait bounds mean the same on all functions, you just can't call methods on them in `const fn`.
890
888
891
889
* nudging function authors to using the minimal necessary bounds to get their function
892
890
body to compile and thus requiring as little as possible from their callers,
893
891
* ensuring our implementation is correct by default.
894
892
895
-
The implementation correctness argument is partially due to our history with `?const`(see https://github.com/rust-lang/rust/issues/83452 for where we got it wrong and thus decided to stop using opt-out), and partially with our history with `?` bounds not being great either (https://github.com/rust-lang/rust/issues/135229, https://github.com/rust-lang/rust/pull/132209). An opt-in is much easier to make sound and keep sound.
893
+
The implementation correctness argument is partially due to our history with `cosnt fn` trait bounds (see https://github.com/rust-lang/rust/issues/83452 for where we got "reject all trait bounds" wrong and thus decided to stop using opt-out), and partially with our history with `?` bounds not being great either (https://github.com/rust-lang/rust/issues/135229, https://github.com/rust-lang/rust/pull/132209). An opt-in is much easier to make sound and keep sound.
896
894
897
895
To get more capabilities, you add more syntax. Thus the opt-out approach was not taken.
0 commit comments