Skip to content

Commit 4747cbb

Browse files
committed
allow unordered const/ty params if any cg feature is active
1 parent 0c28e02 commit 4747cbb

File tree

4 files changed

+4
-6
lines changed

4 files changed

+4
-6
lines changed

Diff for: compiler/rustc_ast/src/ast.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,8 @@ pub type GenericBounds = Vec<GenericBound>;
332332
pub enum ParamKindOrd {
333333
Lifetime,
334334
Type,
335-
// `unordered` is only `true` if `sess.has_features().const_generics_defaults`
336-
// is active. Specifically, if it's only `min_const_generics`, it will still require
335+
// `unordered` is only `true` if `sess.unordered_const_ty_params()`
336+
// returns true. Specifically, if it's only `min_const_generics`, it will still require
337337
// ordering consts after types.
338338
Const { unordered: bool },
339339
// `Infer` is not actually constructed directly from the AST, but is implicitly constructed

Diff for: compiler/rustc_ast_passes/src/ast_validation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1351,7 +1351,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
13511351
}
13521352

13531353
fn visit_generics(&mut self, generics: &'a Generics) {
1354-
let cg_defaults = self.session.features_untracked().const_generics_defaults;
1354+
let cg_defaults = self.session.features_untracked().unordered_const_ty_params();
13551355

13561356
let mut prev_param_default = None;
13571357
for param in &generics.params {

Diff for: compiler/rustc_feature/src/active.rs

+1-1
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_defaults
74+
self.const_generics_defaults || self.generic_const_exprs || self.const_param_types
7575
}
7676

7777
/// Some features are known to be incomplete and using them is likely to have

Diff for: src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.full.stderr

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ error: generic parameters with a default must be trailing
33
|
44
LL | struct Bar<T = [u8; N], const N: usize>(T);
55
| ^
6-
|
7-
= note: using type defaults and const parameters in the same parameter list is currently not permitted
86

97
error[E0128]: generic parameters with a default cannot use forward declared identifiers
108
--> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:8:21

0 commit comments

Comments
 (0)