diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-07-25 04:43:18 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-25 04:43:18 +0200 |
| commit | cfc5f25b3d7c2f9fa37d0165085cdd4120939716 (patch) | |
| tree | d0f2623102a192d2a45a1683529eb39405bb793b /src | |
| parent | e7d66eac5e8e8f60370c98d186aee9fa0ebd7845 (diff) | |
| parent | 7da751a108a31b52650d055202e89a15f43ce0e7 (diff) | |
| download | rust-cfc5f25b3d7c2f9fa37d0165085cdd4120939716.tar.gz rust-cfc5f25b3d7c2f9fa37d0165085cdd4120939716.zip | |
Rollup merge of #127054 - compiler-errors:bound-ordering, r=fmease
Reorder trait bound modifiers *after* `for<...>` binder in trait bounds This PR suggests changing the grammar of trait bounds from: ``` [CONSTNESS] [ASYNCNESS] [?] [BINDER] [TRAIT_PATH] const async ? for<'a> Sized ``` to ``` ([BINDER] [CONSTNESS] [ASYNCNESS] | [?]) [TRAIT_PATH] ``` i.e., either ``` ? Sized ``` or ``` for<'a> const async Sized ``` (but not both) ### Why? I think it's strange that the binder applies "more tightly" than the `?` trait polarity. This becomes even weirder when considering that we (or at least, I) want to have `async` trait bounds expressed like: ``` where T: for<'a> async Fn(&'a ()) -> i32, ``` and not: ``` where T: async for<'a> Fn(&'a ()) -> i32, ``` ### Fallout No crates on crater use this syntax, presumably because it's literally useless. This will require modifying the reference grammar, though. ### Alternatives If this is not desirable, then we can alternatively keep parsing `for<'a>` after the `?` but deprecate it with either an FCW (or an immediate hard error), and begin parsing `for<'a>` *before* the `?`.
Diffstat (limited to 'src')
| -rw-r--r-- | src/tools/rustfmt/tests/source/type.rs | 2 | ||||
| -rw-r--r-- | src/tools/rustfmt/tests/target/negative-bounds.rs | 6 | ||||
| -rw-r--r-- | src/tools/rustfmt/tests/target/type.rs | 2 | ||||
| -rw-r--r-- | src/tools/tidy/src/ui_tests.rs | 2 |
4 files changed, 1 insertions, 11 deletions
diff --git a/src/tools/rustfmt/tests/source/type.rs b/src/tools/rustfmt/tests/source/type.rs index 61ef73a3cab..7a232f85198 100644 --- a/src/tools/rustfmt/tests/source/type.rs +++ b/src/tools/rustfmt/tests/source/type.rs @@ -146,8 +146,6 @@ trait T: ~ const Super {} const fn not_quite_const<S: ~ const T>() -> i32 { <S as T>::CONST } -struct S<T:~ const ? Sized>(std::marker::PhantomData<T>); - impl ~ const T {} fn apit(_: impl ~ const T) {} diff --git a/src/tools/rustfmt/tests/target/negative-bounds.rs b/src/tools/rustfmt/tests/target/negative-bounds.rs index 4fb35cccf66..9fcb86ef4a4 100644 --- a/src/tools/rustfmt/tests/target/negative-bounds.rs +++ b/src/tools/rustfmt/tests/target/negative-bounds.rs @@ -3,9 +3,3 @@ where i32: !Copy, { } - -fn maybe_const_negative() -where - i32: ~const !Copy, -{ -} diff --git a/src/tools/rustfmt/tests/target/type.rs b/src/tools/rustfmt/tests/target/type.rs index c789ecb055a..325adb52f3f 100644 --- a/src/tools/rustfmt/tests/target/type.rs +++ b/src/tools/rustfmt/tests/target/type.rs @@ -153,8 +153,6 @@ const fn not_quite_const<S: ~const T>() -> i32 { <S as T>::CONST } -struct S<T: ~const ?Sized>(std::marker::PhantomData<T>); - impl ~const T {} fn apit(_: impl ~const T) {} diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index 5e6992038e3..0ae0356b2c4 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -16,7 +16,7 @@ use std::path::{Path, PathBuf}; const ENTRY_LIMIT: u32 = 901; // FIXME: The following limits should be reduced eventually. -const ISSUES_ENTRY_LIMIT: u32 = 1672; +const ISSUES_ENTRY_LIMIT: u32 = 1673; const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[ "rs", // test source files |
