Skip to content

Commit 0c28e02

Browse files
committed
feature(const_generics) -> feature(const_param_types)
1 parent c0e853f commit 0c28e02

File tree

574 files changed

+849
-4305
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

574 files changed

+849
-4305
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ pub type GenericBounds = Vec<GenericBound>;
332332
pub enum ParamKindOrd {
333333
Lifetime,
334334
Type,
335-
// `unordered` is only `true` if `sess.has_features().const_generics`
335+
// `unordered` is only `true` if `sess.has_features().const_generics_defaults`
336336
// is active. Specifically, if it's only `min_const_generics`, it will still require
337337
// ordering consts after types.
338338
Const { unordered: bool },

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session) {
687687
gate_all!(trait_alias, "trait aliases are experimental");
688688
gate_all!(associated_type_bounds, "associated type bounds are unstable");
689689
gate_all!(crate_visibility_modifier, "`crate` visibility modifier is experimental");
690-
gate_all!(const_generics, "const generics are unstable");
691690
gate_all!(decl_macro, "`macro` is experimental");
692691
gate_all!(box_patterns, "box pattern syntax is experimental");
693692
gate_all!(exclusive_range_pattern, "exclusive range pattern syntax is experimental");

compiler/rustc_error_codes/src/error_codes/E0671.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ Const parameters cannot depend on type parameters.
44
The following is therefore invalid:
55

66
```compile_fail,E0770
7-
#![feature(const_generics)]
8-
97
fn const_id<T, const N: T>() -> T { // error
108
N
119
}

compiler/rustc_error_codes/src/error_codes/E0741.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ A non-structural-match type was used as the type of a const generic parameter.
33
Erroneous code example:
44

55
```compile_fail,E0741
6-
#![feature(const_generics)]
6+
#![feature(const_param_types)]
77
88
struct A;
99
@@ -16,7 +16,7 @@ may be used as the types of const generic parameters.
1616
To fix the previous code example, we derive `PartialEq` and `Eq`:
1717

1818
```
19-
#![feature(const_generics)]
19+
#![feature(const_param_types)]
2020
2121
#[derive(PartialEq, Eq)] // We derive both traits here.
2222
struct A;

compiler/rustc_error_codes/src/error_codes/E0770.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ The type of a const parameter references other generic parameters.
33
Erroneous code example:
44

55
```compile_fail,E0770
6-
#![feature(const_generics)]
76
fn foo<T, const N: T>() {} // error!
87
```
98

compiler/rustc_error_codes/src/error_codes/E0771.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ allowed.
44
Erroneous code example:
55

66
```compile_fail,E0771
7-
#![feature(const_generics)]
7+
#![feature(const_param_types)]
88
99
fn function_with_str<'a, const STRING: &'a str>() {} // error!
1010
```
@@ -13,7 +13,7 @@ To fix this issue, the lifetime in the const generic need to be changed to
1313
`'static`:
1414

1515
```
16-
#![feature(const_generics)]
16+
#![feature(const_param_types)]
1717
1818
fn function_with_str<const STRING: &'static str>() {} // ok!
1919
```

compiler/rustc_feature/src/accepted.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ declare_features! (
273273
/// Allows patterns with concurrent by-move and by-ref bindings.
274274
/// For example, you can write `Foo(a, ref b)` where `a` is by-move and `b` is by-ref.
275275
(accepted, move_ref_pattern, "1.49.0", Some(68354), None),
276-
/// The smallest useful subset of `const_generics`.
276+
/// The smallest useful subset of const generics.
277277
(accepted, min_const_generics, "1.51.0", Some(74878), None),
278278
/// The `unsafe_op_in_unsafe_fn` lint (allowed by default): no longer treat an unsafe function as an unsafe block.
279279
(accepted, unsafe_block_in_unsafe_fn, "1.52.0", Some(71668), None),

compiler/rustc_feature/src/active.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ macro_rules! declare_features {
7171
}
7272

7373
pub fn unordered_const_ty_params(&self) -> bool {
74-
self.const_generics || self.const_generics_defaults
74+
self.const_generics_defaults
7575
}
7676

7777
/// Some features are known to be incomplete and using them is likely to have
@@ -453,9 +453,6 @@ declare_features! (
453453
/// Allows using `#[ffi_returns_twice]` on foreign functions.
454454
(active, ffi_returns_twice, "1.34.0", Some(58314), None),
455455

456-
/// Allows const generic types (e.g. `struct Foo<const N: usize>(...);`).
457-
(incomplete, const_generics, "1.34.0", Some(44580), None),
458-
459456
/// Allows using `#[optimize(X)]`.
460457
(active, optimize_attribute, "1.34.0", Some(54882), None),
461458

@@ -676,6 +673,9 @@ declare_features! (
676673
/// Allows non-trivial generic constants which have to have wfness manually propagated to callers
677674
(incomplete, generic_const_exprs, "1.56.0", Some(76560), None),
678675

676+
/// Allows additional const parameter types, such as `&'static str` or user defined types
677+
(incomplete, const_param_types, "1.56.0", Some(44580), None),
678+
679679
// -------------------------------------------------------------------------
680680
// feature-group-end: actual feature gates
681681
// -------------------------------------------------------------------------

compiler/rustc_feature/src/removed.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ declare_features! (
102102
(removed, extern_in_paths, "1.33.0", Some(55600), None,
103103
Some("subsumed by `::foo::bar` paths")),
104104
(removed, quote, "1.33.0", Some(29601), None, None),
105+
/// Allows const generic types (e.g. `struct Foo<const N: usize>(...);`).
106+
(removed, const_generics, "1.34.0", Some(44580), None,
107+
Some("removed in favor of `#![feature(const_param_types]` and `#![feature(generic_const_exprs)]`")),
105108
/// Allows `[x; N]` where `x` is a constant (RFC 2203).
106109
(removed, const_in_array_repeat_expressions, "1.37.0", Some(49147), None,
107110
Some("removed due to causing promotable bugs")),

compiler/rustc_infer/src/infer/combine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> {
202202
/// A good example of this is the following:
203203
///
204204
/// ```rust
205-
/// #![feature(const_generics)]
205+
/// #![feature(generic_const_exprs)]
206206
///
207207
/// fn bind<const N: usize>(value: [u8; N]) -> [u8; 3 + 4] {
208208
/// todo!()

0 commit comments

Comments
 (0)