Allow associated const equality constraints with GCA - #159506
Conversation
|
|
| if !tcx.generics_of(item.def_id).is_own_empty() { | ||
| errors.push(AssocConstViolation::Generic); | ||
| } else if !is_type_const { | ||
| errors.push(AssocConstViolation::NonType); |
There was a problem hiding this comment.
Isn't NonType now dead code and can be removed?
There was a problem hiding this comment.
Thanks, removed here: b464ecb, we need this for mgca, reverted the removal
| .filter(|item| item.is_type() || item.is_type_const()) | ||
| // Only associated items that support equality constraints can | ||
| // be constrained in a trait object type via a binding. | ||
| .filter(|item| item.can_have_equality_constraint(tcx)) |
There was a problem hiding this comment.
Note that this change means that stabilizing mGCA will break stable code like tests/ui/type-alias/lack-of-wfcheck.rs.
There was a problem hiding this comment.
does that mean we can't stablize this? not sure how to go about this..
There was a problem hiding this comment.
this change is supposed to be for generic_const_args not min_generic_const_args since mgca doesn't support const items in the type system but full GCA does. once you change that this'll go back to mgca being backwards compatible but with GCA being backwards incompatible (which is OK)
There was a problem hiding this comment.
Ah! thanks, my bad 🥲 . Just made changes specific to GCA
| if !tcx.generics_of(item.def_id).is_own_empty() { | ||
| errors.push(AssocConstViolation::Generic); | ||
| } else if !is_type_const { | ||
| } else if !is_type_const && !tcx.features().generic_const_args() { |
There was a problem hiding this comment.
@fmease do you know if you added a test that type const FOO<const N: usize> makes a trait dyn incompatible? (because its a GAT)
regardless, @Shourya742 can you add a test that cosnt ASSOC<const N: usize>: usize makes a trait dyn incompatible under feature(generic_const_args)
|
Ah can you also add a variant of |
|
@rustbot author |
79271ed to
0e7d4e2
Compare
Added here: 0e7d4e2 |
|
|
||
| // * dyn incompatible due to GAT | ||
| // * `'a: 'static`, `String: Copy` and `[u8]: Sized` unsatisfied, `loop {}` diverging | ||
| type Several<'a> = dyn HasGenericAssocType<Type<'a, String, { loop {} }> = [u8]>; |
There was a problem hiding this comment.
can you split this into a separate test, it's also not actually showing an error right now
|
|
||
| type DynIncompat0 = dyn Sized; // `Sized` axiomatically dyn incompatible | ||
| // issue: <https://github.com/rust-lang/rust/issues/153731> | ||
| type DynIncompat1 = dyn HasAssocConst; |
There was a problem hiding this comment.
this part of the test would ideally be revisioned so that it shows the behaviour with and without generic_const_args enabled :3 (to demonstrate the breaking nature of stabilization)
There was a problem hiding this comment.
TIL, we have this pretty cool thing called revisions that helps feature gate compile tests, so I used it here. Added in 2191fc1.
0e7d4e2 to
2191fc1
Compare
|
@bors r+ |
…-non-typeconsts-in-GCA, r=BoxyUwU Allow associated const equality constraints with GCA closes: rust-lang/project-const-generics#77 r? @BoxyUwU
…-non-typeconsts-in-GCA, r=BoxyUwU Allow associated const equality constraints with GCA closes: rust-lang/project-const-generics#77 r? @BoxyUwU
…uwer Rollup of 17 pull requests Successful merges: - #159530 (Cap socket send length to c_int::MAX on Apple targets) - #159506 (Allow associated const equality constraints with GCA) - #160006 (Account for desugaring in method call move errors) - #160415 (Split `aarch64-apple{,-macos-26}` => `aarch64-apple{,-macos-26}-{1,2}` jobs) - #160464 (fix: Check the fallback map before queueing child in `visible_parent_map` breadth-first search) - #160555 (Split `apply_primary_terminator_effect`) - #160592 (Suggest if-let chain continuation on unclosed delimiter) - #160600 (Avoid the std DLL copy alongside rustc) - #160156 (check_consts: exhaustively match on CastKind) - #160211 (Rename `#[unroll]` => `#[rustc_unroll]` to mitigate nameres ambiguity) - #160304 (Add tests for fixed new solver issues) - #160398 (rustc_abi: Add `LayoutData::is_variant_uninhabited` method) - #160546 (Update error message in documentation comments) - #160568 (Use `VisitorResult` helper macros) - #160571 (Add regression test for array type recovery in generic arguments) - #160588 (add a test showing polonius alpha is not a subset of datalog polonius) - #160617 (Add a suggestion to MissingUnsafeOnExtern diagnostic)
Rollup merge of #159506 - bit-aloo:2026-07-14-dyn-compatible-non-typeconsts-in-GCA, r=BoxyUwU Allow associated const equality constraints with GCA closes: rust-lang/project-const-generics#77 r? @BoxyUwU
|
@rust-timer build e1373c7 |
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (e1373c7): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up. @rustbot label: -S-waiting-on-perf -perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)This perf run didn't have relevant results for this metric. CyclesResults (primary 2.3%, secondary -5.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 458.35s -> 474.78s (3.58%) |
View all comments
closes: rust-lang/project-const-generics#77
r? @BoxyUwU