Files
rust/tests/ui/generic-const-items
Jonathan Brouwer 388032363d Rollup merge of #152385 - LaneAsade:gate-type-const-defaults, r=BoxyUwU
Feature gate for defaulted associated type_consts with associated_type_defaults

*[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/pull/152385)*

This PR for issue rust-lang/rust#130288 extends a feature gate that was already present for defaulted associated types to defaulted type consts under associated_type_defaults.

Code added:
```
if ctxt == AssocCtxt::Trait && rhs.is_some() {
                    gate!(
                        &self,
                        associated_type_defaults,
                        i.span,
                        "associated type defaults are unstable"
                    );
                }
```

Error produced:
```
error[E0658]: associated type defaults are unstable
  --> $DIR/type-const-associated-default.rs:4:5
   |
LL |     type const N: usize = 10;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #29661 <https://github.com/rust-lang/rust/issues/29661> for more information
   = help: add `#![feature(associated_type_defaults)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

warning: the feature `min_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
  --> $DIR/type-const-associated-default.rs:1:12
   |
LL | #![feature(min_generic_const_args)]
   |            ^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information
   = note: `#[warn(incomplete_features)]` on by default

error: aborting due to 1 previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0658`.

```
Thanks to @BoxyUwU for the guidance on this issue.
2026-02-22 20:14:23 +01:00
..
2025-11-08 07:37:15 +01:00