Auto merge of #90207 - BoxyUwU:stabilise_cg_defaults, r=lcnr

Stabilise `feature(const_generics_defaults)`

`feature(const_generics_defaults)` is complete implementation wise and has a pretty extensive test suite so I think is ready for stabilisation.

needs stabilisation report and maybe an RFC 😅

r? `@lcnr`
cc `@rust-lang/project-const-generics`
This commit is contained in:
bors 2021-12-12 14:24:23 +00:00
commit 753e569c9c
94 changed files with 101 additions and 380 deletions

View File

@ -332,10 +332,7 @@ pub type GenericBounds = Vec<GenericBound>;
pub enum ParamKindOrd { pub enum ParamKindOrd {
Lifetime, Lifetime,
Type, Type,
// `unordered` is only `true` if `sess.unordered_const_ty_params()` Const,
// returns true. Specifically, if it's only `min_const_generics`, it will still require
// ordering consts after types.
Const { unordered: bool },
// `Infer` is not actually constructed directly from the AST, but is implicitly constructed // `Infer` is not actually constructed directly from the AST, but is implicitly constructed
// during HIR lowering, and `ParamKindOrd` will implicitly order inferred variables last. // during HIR lowering, and `ParamKindOrd` will implicitly order inferred variables last.
Infer, Infer,
@ -346,11 +343,7 @@ impl Ord for ParamKindOrd {
use ParamKindOrd::*; use ParamKindOrd::*;
let to_int = |v| match v { let to_int = |v| match v {
Lifetime => 0, Lifetime => 0,
Infer | Type | Const { unordered: true } => 1, Infer | Type | Const => 1,
// technically both consts should be ordered equally,
// but only one is ever encountered at a time, so this is
// fine.
Const { unordered: false } => 2,
}; };
to_int(*self).cmp(&to_int(*other)) to_int(*self).cmp(&to_int(*other))

View File

@ -894,7 +894,6 @@ impl<'a> AstValidator<'a> {
/// Checks that generic parameters are in the correct order, /// Checks that generic parameters are in the correct order,
/// which is lifetimes, then types and then consts. (`<'a, T, const N: usize>`) /// which is lifetimes, then types and then consts. (`<'a, T, const N: usize>`)
fn validate_generic_param_order( fn validate_generic_param_order(
sess: &Session,
handler: &rustc_errors::Handler, handler: &rustc_errors::Handler,
generics: &[GenericParam], generics: &[GenericParam],
span: Span, span: Span,
@ -911,8 +910,7 @@ fn validate_generic_param_order(
GenericParamKind::Type { default: _ } => (ParamKindOrd::Type, ident.to_string()), GenericParamKind::Type { default: _ } => (ParamKindOrd::Type, ident.to_string()),
GenericParamKind::Const { ref ty, kw_span: _, default: _ } => { GenericParamKind::Const { ref ty, kw_span: _, default: _ } => {
let ty = pprust::ty_to_string(ty); let ty = pprust::ty_to_string(ty);
let unordered = sess.features_untracked().unordered_const_ty_params(); (ParamKindOrd::Const, format!("const {}: {}", ident, ty))
(ParamKindOrd::Const { unordered }, format!("const {}: {}", ident, ty))
} }
}; };
param_idents.push((kind, ord_kind, bounds, idx, ident)); param_idents.push((kind, ord_kind, bounds, idx, ident));
@ -968,14 +966,7 @@ fn validate_generic_param_order(
); );
err.span_suggestion( err.span_suggestion(
span, span,
&format!( "reorder the parameters: lifetimes, then consts and types",
"reorder the parameters: lifetimes, {}",
if sess.features_untracked().unordered_const_ty_params() {
"then consts and types"
} else {
"then types, then consts"
}
),
ordered_params.clone(), ordered_params.clone(),
Applicability::MachineApplicable, Applicability::MachineApplicable,
); );
@ -1342,8 +1333,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
} }
fn visit_generics(&mut self, generics: &'a Generics) { fn visit_generics(&mut self, generics: &'a Generics) {
let cg_defaults = self.session.features_untracked().unordered_const_ty_params();
let mut prev_param_default = None; let mut prev_param_default = None;
for param in &generics.params { for param in &generics.params {
match param.kind { match param.kind {
@ -1358,12 +1347,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
span, span,
"generic parameters with a default must be trailing", "generic parameters with a default must be trailing",
); );
if matches!(param.kind, GenericParamKind::Const { .. }) && !cg_defaults {
err.note(
"using type defaults and const parameters \
in the same parameter list is currently not permitted",
);
}
err.emit(); err.emit();
break; break;
} }
@ -1371,12 +1354,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
} }
} }
validate_generic_param_order( validate_generic_param_order(self.err_handler(), &generics.params, generics.span);
self.session,
self.err_handler(),
&generics.params,
generics.span,
);
for predicate in &generics.where_clause.predicates { for predicate in &generics.where_clause.predicates {
if let WherePredicate::EqPredicate(ref predicate) = *predicate { if let WherePredicate::EqPredicate(ref predicate) = *predicate {

View File

@ -724,10 +724,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session) {
gate_all!(half_open_range_patterns, "half-open range patterns are unstable"); gate_all!(half_open_range_patterns, "half-open range patterns are unstable");
gate_all!(inline_const, "inline-const is experimental"); gate_all!(inline_const, "inline-const is experimental");
gate_all!(inline_const_pat, "inline-const in pattern position is experimental"); gate_all!(inline_const_pat, "inline-const in pattern position is experimental");
gate_all!(
const_generics_defaults,
"default values for const generic parameters are experimental"
);
if sess.parse_sess.span_diagnostic.err_count() == 0 { if sess.parse_sess.span_diagnostic.err_count() == 0 {
// Errors for `destructuring_assignment` can get quite noisy, especially where `_` is // Errors for `destructuring_assignment` can get quite noisy, especially where `_` is
// involved, so we only emit errors where there are no other parsing errors. // involved, so we only emit errors where there are no other parsing errors.

View File

@ -90,6 +90,8 @@ declare_features! (
(accepted, const_fn_union, "1.56.0", Some(51909), None), (accepted, const_fn_union, "1.56.0", Some(51909), None),
/// Allows unsizing coercions in `const fn`. /// Allows unsizing coercions in `const fn`.
(accepted, const_fn_unsize, "1.54.0", Some(64992), None), (accepted, const_fn_unsize, "1.54.0", Some(64992), None),
/// Allows const generics to have default values (e.g. `struct Foo<const N: usize = 3>(...);`).
(accepted, const_generics_defaults, "1.59.0", Some(44580), None),
/// Allows the use of `if` and `match` in constants. /// Allows the use of `if` and `match` in constants.
(accepted, const_if_match, "1.46.0", Some(49146), None), (accepted, const_if_match, "1.46.0", Some(49146), None),
/// Allows indexing into constant arrays. /// Allows indexing into constant arrays.

View File

@ -69,10 +69,6 @@ macro_rules! declare_features {
} }
} }
pub fn unordered_const_ty_params(&self) -> bool {
self.const_generics_defaults || self.generic_const_exprs || self.adt_const_params
}
/// Some features are known to be incomplete and using them is likely to have /// Some features are known to be incomplete and using them is likely to have
/// unanticipated results, such as compiler crashes. We warn the user about these /// unanticipated results, such as compiler crashes. We warn the user about these
/// to alert them. /// to alert them.
@ -334,8 +330,6 @@ declare_features! (
(active, const_fn_trait_bound, "1.53.0", Some(57563), None), (active, const_fn_trait_bound, "1.53.0", Some(57563), None),
/// Allows `for _ in _` loops in const contexts. /// Allows `for _ in _` loops in const contexts.
(active, const_for, "1.56.0", Some(87575), None), (active, const_for, "1.56.0", Some(87575), None),
/// Allows const generics to have default values (e.g. `struct Foo<const N: usize = 3>(...);`).
(active, const_generics_defaults, "1.51.0", Some(44580), None),
/// Allows argument and return position `impl Trait` in a `const fn`. /// Allows argument and return position `impl Trait` in a `const fn`.
(active, const_impl_trait, "1.48.0", Some(77463), None), (active, const_impl_trait, "1.48.0", Some(77463), None),
/// Allows using `&mut` in constant functions. /// Allows using `&mut` in constant functions.

View File

@ -325,13 +325,11 @@ impl GenericArg<'_> {
} }
} }
pub fn to_ord(&self, feats: &rustc_feature::Features) -> ast::ParamKindOrd { pub fn to_ord(&self) -> ast::ParamKindOrd {
match self { match self {
GenericArg::Lifetime(_) => ast::ParamKindOrd::Lifetime, GenericArg::Lifetime(_) => ast::ParamKindOrd::Lifetime,
GenericArg::Type(_) => ast::ParamKindOrd::Type, GenericArg::Type(_) => ast::ParamKindOrd::Type,
GenericArg::Const(_) => { GenericArg::Const(_) => ast::ParamKindOrd::Const,
ast::ParamKindOrd::Const { unordered: feats.unordered_const_ty_params() }
}
GenericArg::Infer(_) => ast::ParamKindOrd::Infer, GenericArg::Infer(_) => ast::ParamKindOrd::Infer,
} }
} }

View File

@ -24,13 +24,11 @@ impl GenericParamDefKind {
GenericParamDefKind::Const { .. } => "constant", GenericParamDefKind::Const { .. } => "constant",
} }
} }
pub fn to_ord(&self, tcx: TyCtxt<'_>) -> ast::ParamKindOrd { pub fn to_ord(&self) -> ast::ParamKindOrd {
match self { match self {
GenericParamDefKind::Lifetime => ast::ParamKindOrd::Lifetime, GenericParamDefKind::Lifetime => ast::ParamKindOrd::Lifetime,
GenericParamDefKind::Type { .. } => ast::ParamKindOrd::Type, GenericParamDefKind::Type { .. } => ast::ParamKindOrd::Type,
GenericParamDefKind::Const { .. } => { GenericParamDefKind::Const { .. } => ast::ParamKindOrd::Const,
ast::ParamKindOrd::Const { unordered: tcx.features().unordered_const_ty_params() }
}
} }
} }
} }

View File

@ -5,7 +5,7 @@ use rustc_ast::{
self as ast, Attribute, GenericBounds, GenericParam, GenericParamKind, WhereClause, self as ast, Attribute, GenericBounds, GenericParam, GenericParamKind, WhereClause,
}; };
use rustc_errors::PResult; use rustc_errors::PResult;
use rustc_span::symbol::{kw, sym}; use rustc_span::symbol::kw;
impl<'a> Parser<'a> { impl<'a> Parser<'a> {
/// Parses bounds of a lifetime parameter `BOUND + BOUND + BOUND`, possibly with trailing `+`. /// Parses bounds of a lifetime parameter `BOUND + BOUND + BOUND`, possibly with trailing `+`.
@ -59,19 +59,8 @@ impl<'a> Parser<'a> {
self.expect(&token::Colon)?; self.expect(&token::Colon)?;
let ty = self.parse_ty()?; let ty = self.parse_ty()?;
// Parse optional const generics default value, taking care of feature gating the spans // Parse optional const generics default value.
// with the unstable syntax mechanism. let default = if self.eat(&token::Eq) { Some(self.parse_const_arg()?) } else { None };
let default = if self.eat(&token::Eq) {
// The gated span goes from the `=` to the end of the const argument that follows (and
// which could be a block expression).
let start = self.prev_token.span;
let const_arg = self.parse_const_arg()?;
let span = start.to(const_arg.value.span);
self.sess.gated_spans.gate(sym::const_generics_defaults, span);
Some(const_arg)
} else {
None
};
Ok(GenericParam { Ok(GenericParam {
ident, ident,

View File

@ -131,8 +131,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
_ => {} _ => {}
} }
let kind_ord = param.kind.to_ord(tcx); let kind_ord = param.kind.to_ord();
let arg_ord = arg.to_ord(tcx.features()); let arg_ord = arg.to_ord();
// This note is only true when generic parameters are strictly ordered by their kind. // This note is only true when generic parameters are strictly ordered by their kind.
if possible_ordering_error && kind_ord.cmp(&arg_ord) != core::cmp::Ordering::Equal { if possible_ordering_error && kind_ord.cmp(&arg_ord) != core::cmp::Ordering::Equal {
@ -298,26 +298,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
.params .params
.clone() .clone()
.into_iter() .into_iter()
.map(|param| { .map(|param| (param.kind.to_ord(), param))
(
match param.kind {
GenericParamDefKind::Lifetime => {
ParamKindOrd::Lifetime
}
GenericParamDefKind::Type { .. } => {
ParamKindOrd::Type
}
GenericParamDefKind::Const { .. } => {
ParamKindOrd::Const {
unordered: tcx
.features()
.unordered_const_ty_params(),
}
}
},
param,
)
})
.collect::<Vec<(ParamKindOrd, GenericParamDef)>>(); .collect::<Vec<(ParamKindOrd, GenericParamDef)>>();
param_types_present.sort_by_key(|(ord, _)| *ord); param_types_present.sort_by_key(|(ord, _)| *ord);
let (mut param_types_present, ordered_params): ( let (mut param_types_present, ordered_params): (
@ -330,16 +311,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
tcx, tcx,
arg, arg,
param, param,
!args_iter.clone().is_sorted_by_key(|arg| match arg { !args_iter.clone().is_sorted_by_key(|arg| arg.to_ord()),
GenericArg::Lifetime(_) => ParamKindOrd::Lifetime,
GenericArg::Type(_) => ParamKindOrd::Type,
GenericArg::Const(_) => ParamKindOrd::Const {
unordered: tcx
.features()
.unordered_const_ty_params(),
},
GenericArg::Infer(_) => ParamKindOrd::Infer,
}),
Some(&format!( Some(&format!(
"reorder the arguments: {}: `<{}>`", "reorder the arguments: {}: `<{}>`",
param_types_present param_types_present

View File

@ -697,7 +697,6 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) {
hir::GenericParamKind::Lifetime { .. } | hir::GenericParamKind::Type { .. } => (), hir::GenericParamKind::Lifetime { .. } | hir::GenericParamKind::Type { .. } => (),
// Const parameters are well formed if their type is structural match. // Const parameters are well formed if their type is structural match.
// FIXME(const_generics_defaults): we also need to check that the `default` is wf.
hir::GenericParamKind::Const { ty: hir_ty, default: _ } => { hir::GenericParamKind::Const { ty: hir_ty, default: _ } => {
let ty = tcx.type_of(tcx.hir().local_def_id(param.hir_id)); let ty = tcx.type_of(tcx.hir().local_def_id(param.hir_id));

View File

@ -1,5 +1,5 @@
// revisions: cfail // revisions: cfail
#![feature(generic_const_exprs, adt_const_params, const_generics_defaults)] #![feature(generic_const_exprs, adt_const_params)]
#![allow(incomplete_features)] #![allow(incomplete_features)]
// regression test for #77650 // regression test for #77650
struct C<T, const N: core::num::NonZeroUsize>([T; N.get()]) struct C<T, const N: core::num::NonZeroUsize>([T; N.get()])

View File

@ -1,5 +1,4 @@
#![crate_name = "foo"] #![crate_name = "foo"]
#![feature(const_generics_defaults)]
// @has foo/struct.Foo.html '//pre[@class="rust struct"]' \ // @has foo/struct.Foo.html '//pre[@class="rust struct"]' \
// 'pub struct Foo<const M: usize = 10_usize, const N: usize = M, T = i32>(_);' // 'pub struct Foo<const M: usize = 10_usize, const N: usize = M, T = i32>(_);'

View File

@ -1,30 +0,0 @@
error: type parameters must be declared prior to const parameters
--> $DIR/argument_order.rs:4:28
|
LL | struct Bad<const N: usize, T> {
| -----------------^- help: reorder the parameters: lifetimes, then types, then consts: `<T, const N: usize>`
error: lifetime parameters must be declared prior to const parameters
--> $DIR/argument_order.rs:10:32
|
LL | struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> {
| -----------------^^-----^^-------------------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T, U, const N: usize, const M: usize>`
error: type parameters must be declared prior to const parameters
--> $DIR/argument_order.rs:10:36
|
LL | struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> {
| ---------------------^----------------------^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T, U, const N: usize, const M: usize>`
error[E0747]: lifetime provided when a type was expected
--> $DIR/argument_order.rs:18:23
|
LL | let _: AlsoBad<7, 'static, u32, 'static, 17, u16>;
| ^^^^^^^
|
= note: lifetime arguments must be provided before type arguments
= help: reorder the arguments: lifetimes, then types, then consts: `<'a, 'b, T, U, N, M>`
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0747`.

View File

@ -1,15 +1,10 @@
// revisions: full min
#![cfg_attr(full, feature(const_generics_defaults))]
struct Bad<const N: usize, T> { struct Bad<const N: usize, T> {
//[min]~^ ERROR type parameters must be declared prior to const parameters
arr: [u8; { N }], arr: [u8; { N }],
another: T, another: T,
} }
struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> { struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> {
//~^ ERROR lifetime parameters must be declared prior //~^ ERROR lifetime parameters must be declared prior
//[min]~^^ ERROR type parameters must be declared prior to const parameters
a: &'a T, a: &'a T,
b: &'b U, b: &'b U,
} }

View File

@ -1,11 +1,11 @@
error: lifetime parameters must be declared prior to const parameters error: lifetime parameters must be declared prior to const parameters
--> $DIR/argument_order.rs:10:32 --> $DIR/argument_order.rs:6:32
| |
LL | struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> { LL | struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> {
| -----------------^^-----^^-------------------- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, const N: usize, T, const M: usize, U>` | -----------------^^-----^^-------------------- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, const N: usize, T, const M: usize, U>`
error[E0747]: lifetime provided when a type was expected error[E0747]: lifetime provided when a type was expected
--> $DIR/argument_order.rs:18:23 --> $DIR/argument_order.rs:13:23
| |
LL | let _: AlsoBad<7, 'static, u32, 'static, 17, u16>; LL | let _: AlsoBad<7, 'static, u32, 'static, 17, u16>;
| ^^^^^^^ | ^^^^^^^

View File

@ -3,9 +3,6 @@ error[E0747]: constant provided when a type was expected
| |
LL | fn foo<const N: usize>() -> Array<N, ()> { LL | fn foo<const N: usize>() -> Array<N, ()> {
| ^ | ^
|
= note: type arguments must be provided before constant arguments
= help: reorder the arguments: types, then consts: `<T, N>`
error: aborting due to previous error error: aborting due to previous error

View File

@ -1,14 +0,0 @@
error: lifetime parameters must be declared prior to const parameters
--> $DIR/const-param-before-other-params.rs:5:21
|
LL | fn bar<const X: u8, 'a>(_: &'a ()) {
| --------------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, const X: u8>`
error: type parameters must be declared prior to const parameters
--> $DIR/const-param-before-other-params.rs:9:21
|
LL | fn foo<const X: u8, T>(_: &T) {}
| --------------^- help: reorder the parameters: lifetimes, then types, then consts: `<T, const X: u8>`
error: aborting due to 2 previous errors

View File

@ -1,12 +1,7 @@
// revisions: full min
#![cfg_attr(full, feature(const_generics_defaults))]
#![cfg_attr(full, allow(incomplete_features))]
fn bar<const X: u8, 'a>(_: &'a ()) { fn bar<const X: u8, 'a>(_: &'a ()) {
//~^ ERROR lifetime parameters must be declared prior to const parameters //~^ ERROR lifetime parameters must be declared prior to const parameters
} }
fn foo<const X: u8, T>(_: &T) {} fn foo<const X: u8, T>(_: &T) {}
//[min]~^ ERROR type parameters must be declared prior to const parameters
fn main() {} fn main() {}

View File

@ -1,5 +1,5 @@
error: lifetime parameters must be declared prior to const parameters error: lifetime parameters must be declared prior to const parameters
--> $DIR/const-param-before-other-params.rs:5:21 --> $DIR/const-param-before-other-params.rs:1:21
| |
LL | fn bar<const X: u8, 'a>(_: &'a ()) { LL | fn bar<const X: u8, 'a>(_: &'a ()) {
| --------------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, const X: u8>` | --------------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, const X: u8>`

View File

@ -1,5 +1,3 @@
#![feature(const_generics_defaults)]
pub struct Defaulted<const N: usize=3>; pub struct Defaulted<const N: usize=3>;
impl Defaulted { impl Defaulted {
pub fn new() -> Self { pub fn new() -> Self {

View File

@ -1,5 +1,5 @@
error: generic parameters may not be used in const operations error: generic parameters may not be used in const operations
--> $DIR/complex-generic-default-expr.rs:7:47 --> $DIR/complex-generic-default-expr.rs:6:47
| |
LL | struct Foo<const N: usize, const M: usize = { N + 1 }>; LL | struct Foo<const N: usize, const M: usize = { N + 1 }>;
| ^ cannot perform const operation using `N` | ^ cannot perform const operation using `N`
@ -8,7 +8,7 @@ LL | struct Foo<const N: usize, const M: usize = { N + 1 }>;
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations error: generic parameters may not be used in const operations
--> $DIR/complex-generic-default-expr.rs:10:62 --> $DIR/complex-generic-default-expr.rs:9:62
| |
LL | struct Bar<T, const TYPE_SIZE: usize = { std::mem::size_of::<T>() }>(T); LL | struct Bar<T, const TYPE_SIZE: usize = { std::mem::size_of::<T>() }>(T);
| ^ cannot perform const operation using `T` | ^ cannot perform const operation using `T`

View File

@ -1,8 +1,7 @@
// revisions: full min // revisions: full min
//[full] check-pass //[full] check-pass
#![cfg_attr(full, feature(generic_const_exprs))] #![cfg_attr(full, feature(generic_const_exprs))]
#![feature(const_generics_defaults)] #![cfg_attr(full, allow(incomplete_features))]
#![allow(incomplete_features)]
struct Foo<const N: usize, const M: usize = { N + 1 }>; struct Foo<const N: usize, const M: usize = { N + 1 }>;
//[min]~^ ERROR generic parameters may not be used in const operations //[min]~^ ERROR generic parameters may not be used in const operations

View File

@ -1,12 +1,8 @@
// [full] run-pass // run-pass
// revisions: full min
// Checks a complicated usage of unordered params // Checks a complicated usage of unordered params
#![cfg_attr(full, feature(const_generics_defaults))]
#![cfg_attr(full, allow(incomplete_features))]
#![allow(dead_code)] #![allow(dead_code)]
struct NestedArrays<'a, const N: usize, A: 'a, const M: usize, T:'a =u32> { struct NestedArrays<'a, const N: usize, A: 'a, const M: usize, T:'a =u32> {
//[min]~^ ERROR type parameters must be declared prior to const parameters
args: &'a [&'a [T; M]; N], args: &'a [&'a [T; M]; N],
specifier: A, specifier: A,
} }

View File

@ -1,6 +1,4 @@
// run-pass // run-pass
#![feature(const_generics_defaults)]
pub struct ConstDefault<const N: usize = 3>; pub struct ConstDefault<const N: usize = 3>;
impl<const N: usize> ConstDefault<N> { impl<const N: usize> ConstDefault<N> {

View File

@ -1,5 +1,4 @@
// run-pass // run-pass
#![feature(const_generics_defaults)]
struct Foo<const N: usize, const M: usize = N>([u8; N], [u8; M]); struct Foo<const N: usize, const M: usize = N>([u8; N], [u8; M]);
fn foo<const N: usize>() -> Foo<N> { fn foo<const N: usize>() -> Foo<N> {

View File

@ -1,5 +1,4 @@
// run-pass // run-pass
#![feature(const_generics_defaults)]
struct Foo<const N: usize, T = [u8; N]>(T); struct Foo<const N: usize, T = [u8; N]>(T);
impl<const N: usize> Foo<N> { impl<const N: usize> Foo<N> {

View File

@ -1,6 +1,5 @@
// run-pass // run-pass
#![feature(staged_api)] #![feature(staged_api)]
#![feature(const_generics_defaults)]
#![allow(incomplete_features)] #![allow(incomplete_features)]
// FIXME(const_generics_defaults): It seems like we aren't testing the right thing here, // FIXME(const_generics_defaults): It seems like we aren't testing the right thing here,
// I would assume that we want the attributes to apply to the const parameter defaults // I would assume that we want the attributes to apply to the const parameter defaults

View File

@ -1,5 +1,3 @@
#![feature(const_generics_defaults)]
struct Struct<const N: usize = { Self; 10 }>; struct Struct<const N: usize = { Self; 10 }>;
//~^ ERROR generic parameters cannot use `Self` in their defaults [E0735] //~^ ERROR generic parameters cannot use `Self` in their defaults [E0735]

View File

@ -1,17 +1,17 @@
error[E0735]: generic parameters cannot use `Self` in their defaults error[E0735]: generic parameters cannot use `Self` in their defaults
--> $DIR/default-const-param-cannot-reference-self.rs:3:34 --> $DIR/default-const-param-cannot-reference-self.rs:1:34
| |
LL | struct Struct<const N: usize = { Self; 10 }>; LL | struct Struct<const N: usize = { Self; 10 }>;
| ^^^^ `Self` in generic parameter default | ^^^^ `Self` in generic parameter default
error[E0735]: generic parameters cannot use `Self` in their defaults error[E0735]: generic parameters cannot use `Self` in their defaults
--> $DIR/default-const-param-cannot-reference-self.rs:6:30 --> $DIR/default-const-param-cannot-reference-self.rs:4:30
| |
LL | enum Enum<const N: usize = { Self; 10 }> { } LL | enum Enum<const N: usize = { Self; 10 }> { }
| ^^^^ `Self` in generic parameter default | ^^^^ `Self` in generic parameter default
error[E0735]: generic parameters cannot use `Self` in their defaults error[E0735]: generic parameters cannot use `Self` in their defaults
--> $DIR/default-const-param-cannot-reference-self.rs:9:32 --> $DIR/default-const-param-cannot-reference-self.rs:7:32
| |
LL | union Union<const N: usize = { Self; 10 }> { not_empty: () } LL | union Union<const N: usize = { Self; 10 }> { not_empty: () }
| ^^^^ `Self` in generic parameter default | ^^^^ `Self` in generic parameter default

View File

@ -1,5 +1,3 @@
#![feature(const_generics_defaults)]
struct Foo<const N: usize>; struct Foo<const N: usize>;
impl<const N: usize = 1> Foo<N> {} impl<const N: usize = 1> Foo<N> {}

View File

@ -1,5 +1,5 @@
error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
--> $DIR/default-on-impl.rs:5:12 --> $DIR/default-on-impl.rs:3:12
| |
LL | impl<const N: usize = 1> Foo<N> {} LL | impl<const N: usize = 1> Foo<N> {}
| ^ | ^

View File

@ -1,4 +1,3 @@
#![feature(const_generics_defaults)]
struct Foo<const N: u8 = { 255 + 1 }>; struct Foo<const N: u8 = { 255 + 1 }>;
//~^ ERROR evaluation of constant value failed //~^ ERROR evaluation of constant value failed
fn main() {} fn main() {}

View File

@ -1,5 +1,5 @@
error[E0080]: evaluation of constant value failed error[E0080]: evaluation of constant value failed
--> $DIR/default-param-wf-concrete.rs:2:28 --> $DIR/default-param-wf-concrete.rs:1:28
| |
LL | struct Foo<const N: u8 = { 255 + 1 }>; LL | struct Foo<const N: u8 = { 255 + 1 }>;
| ^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow | ^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow

View File

@ -1,5 +1,3 @@
#![feature(const_generics_defaults)]
// test that defaulted const params are not used to help type inference // test that defaulted const params are not used to help type inference
struct Foo<const N: u32 = 2>; struct Foo<const N: u32 = 2>;

View File

@ -1,5 +1,5 @@
error[E0282]: type annotations needed for `Foo<{_: u32}>` error[E0282]: type annotations needed for `Foo<{_: u32}>`
--> $DIR/doesnt_infer.rs:13:15 --> $DIR/doesnt_infer.rs:11:15
| |
LL | let foo = Foo::foo(); LL | let foo = Foo::foo();
| --- ^^^^^^^^ cannot infer the value of const parameter `N` | --- ^^^^^^^^ cannot infer the value of const parameter `N`

View File

@ -1,7 +1,5 @@
// aux-build:const_defaulty.rs // aux-build:const_defaulty.rs
// check-pass // check-pass
#![feature(const_generics_defaults)]
extern crate const_defaulty; extern crate const_defaulty;
use const_defaulty::Defaulted; use const_defaulty::Defaulted;

View File

@ -1,5 +1,3 @@
#![feature(const_generics_defaults)]
struct Foo<const N: usize = M, const M: usize = 10>; struct Foo<const N: usize = M, const M: usize = 10>;
//~^ ERROR generic parameters with a default cannot use forward declared identifiers //~^ ERROR generic parameters with a default cannot use forward declared identifiers

View File

@ -1,23 +1,23 @@
error[E0128]: generic parameters with a default cannot use forward declared identifiers error[E0128]: generic parameters with a default cannot use forward declared identifiers
--> $DIR/forward-declared.rs:3:29 --> $DIR/forward-declared.rs:1:29
| |
LL | struct Foo<const N: usize = M, const M: usize = 10>; LL | struct Foo<const N: usize = M, const M: usize = 10>;
| ^ defaulted generic parameters cannot be forward declared | ^ defaulted generic parameters cannot be forward declared
error[E0128]: generic parameters with a default cannot use forward declared identifiers error[E0128]: generic parameters with a default cannot use forward declared identifiers
--> $DIR/forward-declared.rs:6:27 --> $DIR/forward-declared.rs:4:27
| |
LL | enum Bar<const N: usize = M, const M: usize = 10> {} LL | enum Bar<const N: usize = M, const M: usize = 10> {}
| ^ defaulted generic parameters cannot be forward declared | ^ defaulted generic parameters cannot be forward declared
error[E0128]: generic parameters with a default cannot use forward declared identifiers error[E0128]: generic parameters with a default cannot use forward declared identifiers
--> $DIR/forward-declared.rs:9:30 --> $DIR/forward-declared.rs:7:30
| |
LL | struct Foo2<const N: usize = N>; LL | struct Foo2<const N: usize = N>;
| ^ defaulted generic parameters cannot be forward declared | ^ defaulted generic parameters cannot be forward declared
error[E0128]: generic parameters with a default cannot use forward declared identifiers error[E0128]: generic parameters with a default cannot use forward declared identifiers
--> $DIR/forward-declared.rs:12:28 --> $DIR/forward-declared.rs:10:28
| |
LL | enum Bar2<const N: usize = N> {} LL | enum Bar2<const N: usize = N> {}
| ^ defaulted generic parameters cannot be forward declared | ^ defaulted generic parameters cannot be forward declared

View File

@ -1,4 +1,4 @@
#![feature(generic_const_exprs, const_generics_defaults)] #![feature(generic_const_exprs)]
#![allow(incomplete_features)] #![allow(incomplete_features)]
struct Foo<const N: usize, const M: usize = { N + 1 }>; struct Foo<const N: usize, const M: usize = { N + 1 }>;

View File

@ -1,4 +1,4 @@
#![feature(generic_const_exprs, const_generics_defaults)] #![feature(generic_const_exprs)]
#![allow(incomplete_features)] #![allow(incomplete_features)]
struct Foo<const N: usize, const M: usize = { N + 1 }>; struct Foo<const N: usize, const M: usize = { N + 1 }>;

View File

@ -1,4 +1,4 @@
#![feature(generic_const_exprs, const_generics_defaults)] #![feature(generic_const_exprs)]
#![allow(incomplete_features)] #![allow(incomplete_features)]
pub struct Foo<const N: usize, const M: usize = { N + 1 }>; pub struct Foo<const N: usize, const M: usize = { N + 1 }>;

View File

@ -1,14 +0,0 @@
error: lifetime parameters must be declared prior to const parameters
--> $DIR/intermixed-lifetime.rs:5:28
|
LL | struct Foo<const N: usize, 'a, T = u32>(&'a (), T);
| -----------------^^---------- help: reorder the parameters: lifetimes, then consts and types: `<'a, const N: usize, T = u32>`
error: lifetime parameters must be declared prior to type parameters
--> $DIR/intermixed-lifetime.rs:8:37
|
LL | struct Bar<const N: usize, T = u32, 'a>(&'a (), T);
| --------------------------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, const N: usize, T = u32>`
error: aborting due to 2 previous errors

View File

@ -1,6 +1,4 @@
// Checks that lifetimes cannot be interspersed between consts and types. // Checks that lifetimes cannot be interspersed between consts and types.
// revisions: full min
#![feature(const_generics_defaults)]
struct Foo<const N: usize, 'a, T = u32>(&'a (), T); struct Foo<const N: usize, 'a, T = u32>(&'a (), T);
//~^ Error lifetime parameters must be declared prior to const parameters //~^ Error lifetime parameters must be declared prior to const parameters

View File

@ -1,11 +1,11 @@
error: lifetime parameters must be declared prior to const parameters error: lifetime parameters must be declared prior to const parameters
--> $DIR/intermixed-lifetime.rs:5:28 --> $DIR/intermixed-lifetime.rs:3:28
| |
LL | struct Foo<const N: usize, 'a, T = u32>(&'a (), T); LL | struct Foo<const N: usize, 'a, T = u32>(&'a (), T);
| -----------------^^---------- help: reorder the parameters: lifetimes, then consts and types: `<'a, const N: usize, T = u32>` | -----------------^^---------- help: reorder the parameters: lifetimes, then consts and types: `<'a, const N: usize, T = u32>`
error: lifetime parameters must be declared prior to type parameters error: lifetime parameters must be declared prior to type parameters
--> $DIR/intermixed-lifetime.rs:8:37 --> $DIR/intermixed-lifetime.rs:6:37
| |
LL | struct Bar<const N: usize, T = u32, 'a>(&'a (), T); LL | struct Bar<const N: usize, T = u32, 'a>(&'a (), T);
| --------------------------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, const N: usize, T = u32>` | --------------------------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, const N: usize, T = u32>`

View File

@ -1,5 +1,3 @@
#![feature(const_generics_defaults)]
pub struct Example<const N: usize=13>; pub struct Example<const N: usize=13>;
pub struct Example2<T=u32, const N: usize=13>(T); pub struct Example2<T=u32, const N: usize=13>(T);
pub struct Example3<const N: usize=13, T=u32>(T); pub struct Example3<const N: usize=13, T=u32>(T);

View File

@ -1,5 +1,5 @@
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/mismatch.rs:9:28 --> $DIR/mismatch.rs:7:28
| |
LL | let e: Example::<13> = (); LL | let e: Example::<13> = ();
| ------------- ^^ expected struct `Example`, found `()` | ------------- ^^ expected struct `Example`, found `()`
@ -10,7 +10,7 @@ LL | let e: Example::<13> = ();
found unit type `()` found unit type `()`
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/mismatch.rs:12:34 --> $DIR/mismatch.rs:10:34
| |
LL | let e: Example2::<u32, 13> = (); LL | let e: Example2::<u32, 13> = ();
| ------------------- ^^ expected struct `Example2`, found `()` | ------------------- ^^ expected struct `Example2`, found `()`
@ -21,7 +21,7 @@ LL | let e: Example2::<u32, 13> = ();
found unit type `()` found unit type `()`
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/mismatch.rs:15:34 --> $DIR/mismatch.rs:13:34
| |
LL | let e: Example3::<13, u32> = (); LL | let e: Example3::<13, u32> = ();
| ------------------- ^^ expected struct `Example3`, found `()` | ------------------- ^^ expected struct `Example3`, found `()`
@ -32,7 +32,7 @@ LL | let e: Example3::<13, u32> = ();
found unit type `()` found unit type `()`
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/mismatch.rs:18:28 --> $DIR/mismatch.rs:16:28
| |
LL | let e: Example3::<7> = (); LL | let e: Example3::<7> = ();
| ------------- ^^ expected struct `Example3`, found `()` | ------------- ^^ expected struct `Example3`, found `()`
@ -43,7 +43,7 @@ LL | let e: Example3::<7> = ();
found unit type `()` found unit type `()`
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/mismatch.rs:21:28 --> $DIR/mismatch.rs:19:28
| |
LL | let e: Example4::<7> = (); LL | let e: Example4::<7> = ();
| ------------- ^^ expected struct `Example4`, found `()` | ------------- ^^ expected struct `Example4`, found `()`

View File

@ -1,8 +0,0 @@
error: type parameters must be declared prior to const parameters
--> $DIR/needs-feature.rs:7:26
|
LL | struct A<const N: usize, T=u32>(T);
| -----------------^----- help: reorder the parameters: lifetimes, then types, then consts: `<T = u32, const N: usize>`
error: aborting due to previous error

View File

@ -1,12 +0,0 @@
//[full] run-pass
// Verifies that having generic parameters after constants is not permitted without the
// `const_generics_defaults` feature.
// revisions: min full
#![cfg_attr(full, feature(const_generics_defaults))]
struct A<const N: usize, T=u32>(T);
//[min]~^ ERROR type parameters must be declared prior
fn main() {
let _: A<3> = A(0);
}

View File

@ -1,4 +1,3 @@
#![feature(const_generics_defaults)]
struct Foo<const M: usize = 10, 'a>(&'a u32); struct Foo<const M: usize = 10, 'a>(&'a u32);
//~^ Error lifetime parameters must be declared prior to const parameters //~^ Error lifetime parameters must be declared prior to const parameters

View File

@ -1,5 +1,5 @@
error: lifetime parameters must be declared prior to const parameters error: lifetime parameters must be declared prior to const parameters
--> $DIR/param-order-err-pretty-prints-default.rs:2:33 --> $DIR/param-order-err-pretty-prints-default.rs:1:33
| |
LL | struct Foo<const M: usize = 10, 'a>(&'a u32); LL | struct Foo<const M: usize = 10, 'a>(&'a u32);
| ----------------------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, const M: usize = 10>` | ----------------------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, const M: usize = 10>`

View File

@ -3,7 +3,6 @@
// compile-flags: -Z unpretty=expanded // compile-flags: -Z unpretty=expanded
#![crate_type = "lib"] #![crate_type = "lib"]
#![feature(const_generics_defaults)]
trait Foo<const KIND: bool = true> {} trait Foo<const KIND: bool = true> {}

View File

@ -5,7 +5,6 @@
// compile-flags: -Z unpretty=expanded // compile-flags: -Z unpretty=expanded
#![crate_type = "lib"] #![crate_type = "lib"]
#![feature(const_generics_defaults)]
#[prelude_import] #[prelude_import]
use ::std::prelude::rust_2015::*; use ::std::prelude::rust_2015::*;
#[macro_use] #[macro_use]

View File

@ -2,8 +2,6 @@
// run-pass // run-pass
#![feature(const_generics_defaults)]
#[repr(C)] #[repr(C)]
pub struct Loaf<T: Sized, const N: usize = 1> { pub struct Loaf<T: Sized, const N: usize = 1> {
head: [T; N], head: [T; N],

View File

@ -1,6 +1,4 @@
// run-pass // run-pass
#![feature(const_generics_defaults)]
struct Uwu<const N: u32 = 1, const M: u32 = N>; struct Uwu<const N: u32 = 1, const M: u32 = N>;
trait Trait {} trait Trait {}

View File

@ -1,5 +1,3 @@
#![feature(const_generics_defaults)]
struct Uwu<const N: u32 = 1, const M: u32 = N>; struct Uwu<const N: u32 = 1, const M: u32 = N>;
trait Trait {} trait Trait {}

View File

@ -1,5 +1,5 @@
error[E0277]: the trait bound `Uwu<10_u32, 12_u32>: Trait` is not satisfied error[E0277]: the trait bound `Uwu<10_u32, 12_u32>: Trait` is not satisfied
--> $DIR/rp_impl_trait_fail.rs:8:14 --> $DIR/rp_impl_trait_fail.rs:6:14
| |
LL | fn rawr() -> impl Trait { LL | fn rawr() -> impl Trait {
| ^^^^^^^^^^ the trait `Trait` is not implemented for `Uwu<10_u32, 12_u32>` | ^^^^^^^^^^ the trait `Trait` is not implemented for `Uwu<10_u32, 12_u32>`
@ -8,7 +8,7 @@ LL | fn rawr() -> impl Trait {
<Uwu<N> as Trait> <Uwu<N> as Trait>
error[E0277]: the trait bound `u32: Traitor<N, N>` is not satisfied error[E0277]: the trait bound `u32: Traitor<N, N>` is not satisfied
--> $DIR/rp_impl_trait_fail.rs:19:26 --> $DIR/rp_impl_trait_fail.rs:17:26
| |
LL | fn uwu<const N: u8>() -> impl Traitor<N> { LL | fn uwu<const N: u8>() -> impl Traitor<N> {
| ^^^^^^^^^^^^^^^ the trait `Traitor<N, N>` is not implemented for `u32` | ^^^^^^^^^^^^^^^ the trait `Traitor<N, N>` is not implemented for `u32`
@ -17,7 +17,7 @@ LL | fn uwu<const N: u8>() -> impl Traitor<N> {
<u32 as Traitor<N, 2_u8>> <u32 as Traitor<N, 2_u8>>
error[E0277]: the trait bound `u64: Traitor<1_u8, 1_u8>` is not satisfied error[E0277]: the trait bound `u64: Traitor<1_u8, 1_u8>` is not satisfied
--> $DIR/rp_impl_trait_fail.rs:24:13 --> $DIR/rp_impl_trait_fail.rs:22:13
| |
LL | fn owo() -> impl Traitor { LL | fn owo() -> impl Traitor {
| ^^^^^^^^^^^^ the trait `Traitor<1_u8, 1_u8>` is not implemented for `u64` | ^^^^^^^^^^^^ the trait `Traitor<1_u8, 1_u8>` is not implemented for `u64`

View File

@ -1,6 +1,5 @@
// run-pass // run-pass
// Checks that type param defaults are allowed after const params. // Checks that type param defaults are allowed after const params.
#![feature(const_generics_defaults)]
#![allow(dead_code)] #![allow(dead_code)]
struct FixedOutput<'a, const N: usize, T=u32> { struct FixedOutput<'a, const N: usize, T=u32> {

View File

@ -1,6 +1,4 @@
// run-pass // run-pass
#![feature(const_generics_defaults)]
trait Trait<const N: u8 = 12> { trait Trait<const N: u8 = 12> {
fn uwu(&self) -> u8 { fn uwu(&self) -> u8 {
N N

View File

@ -1,5 +1,3 @@
#![feature(const_generics_defaults)]
trait Trait<const N: u8 = 12> { trait Trait<const N: u8 = 12> {
fn uwu(&self) -> u8 { fn uwu(&self) -> u8 {
N N

View File

@ -1,5 +1,5 @@
error[E0277]: the trait bound `u32: Trait` is not satisfied error[E0277]: the trait bound `u32: Trait` is not satisfied
--> $DIR/trait_objects_fail.rs:28:9 --> $DIR/trait_objects_fail.rs:26:9
| |
LL | foo(&10_u32); LL | foo(&10_u32);
| --- ^^^^^^^ the trait `Trait` is not implemented for `u32` | --- ^^^^^^^ the trait `Trait` is not implemented for `u32`
@ -11,7 +11,7 @@ LL | foo(&10_u32);
= note: required for the cast to the object type `dyn Trait` = note: required for the cast to the object type `dyn Trait`
error[E0277]: the trait bound `bool: Traitor<{_: u8}, {_: u8}>` is not satisfied error[E0277]: the trait bound `bool: Traitor<{_: u8}, {_: u8}>` is not satisfied
--> $DIR/trait_objects_fail.rs:30:9 --> $DIR/trait_objects_fail.rs:28:9
| |
LL | bar(&true); LL | bar(&true);
| --- ^^^^^ the trait `Traitor<{_: u8}, {_: u8}>` is not implemented for `bool` | --- ^^^^^ the trait `Traitor<{_: u8}, {_: u8}>` is not implemented for `bool`

View File

@ -1,6 +1,4 @@
// check-pass // check-pass
#![feature(const_generics_defaults)]
struct N; struct N;
struct Foo<const N: usize = 1, T = N>(T); struct Foo<const N: usize = 1, T = N>(T);

View File

@ -1,5 +1,3 @@
#![feature(const_generics_defaults)]
struct Ooopsies<const N: u8 = { u8::MAX + 1 }>; struct Ooopsies<const N: u8 = { u8::MAX + 1 }>;
//~^ error: evaluation of constant value failed //~^ error: evaluation of constant value failed

View File

@ -1,11 +1,11 @@
error[E0080]: evaluation of constant value failed error[E0080]: evaluation of constant value failed
--> $DIR/wfness.rs:3:33 --> $DIR/wfness.rs:1:33
| |
LL | struct Ooopsies<const N: u8 = { u8::MAX + 1 }>; LL | struct Ooopsies<const N: u8 = { u8::MAX + 1 }>;
| ^^^^^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow | ^^^^^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow
error[E0277]: the trait bound `(): Trait<2_u8>` is not satisfied error[E0277]: the trait bound `(): Trait<2_u8>` is not satisfied
--> $DIR/wfness.rs:8:47 --> $DIR/wfness.rs:6:47
| |
LL | struct WhereClause<const N: u8 = 2> where (): Trait<N>; LL | struct WhereClause<const N: u8 = 2> where (): Trait<N>;
| ^^^^^^^^ the trait `Trait<2_u8>` is not implemented for `()` | ^^^^^^^^ the trait `Trait<2_u8>` is not implemented for `()`
@ -14,7 +14,7 @@ LL | struct WhereClause<const N: u8 = 2> where (): Trait<N>;
<() as Trait<3_u8>> <() as Trait<3_u8>>
error[E0277]: the trait bound `(): Trait<1_u8>` is not satisfied error[E0277]: the trait bound `(): Trait<1_u8>` is not satisfied
--> $DIR/wfness.rs:16:13 --> $DIR/wfness.rs:14:13
| |
LL | fn foo() -> DependentDefaultWfness { LL | fn foo() -> DependentDefaultWfness {
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait<1_u8>` is not implemented for `()` | ^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait<1_u8>` is not implemented for `()`
@ -22,7 +22,7 @@ LL | fn foo() -> DependentDefaultWfness {
= help: the following implementations were found: = help: the following implementations were found:
<() as Trait<3_u8>> <() as Trait<3_u8>>
note: required by a bound in `WhereClause` note: required by a bound in `WhereClause`
--> $DIR/wfness.rs:8:47 --> $DIR/wfness.rs:6:47
| |
LL | struct WhereClause<const N: u8 = 2> where (): Trait<N>; LL | struct WhereClause<const N: u8 = 2> where (): Trait<N>;
| ^^^^^^^^ required by this bound in `WhereClause` | ^^^^^^^^ required by this bound in `WhereClause`

View File

@ -1,5 +1,3 @@
#![feature(const_generics_defaults)]
struct A<T = u32, const N: usize> { struct A<T = u32, const N: usize> {
//~^ ERROR generic parameters with a default must be trailing //~^ ERROR generic parameters with a default must be trailing
arg: T, arg: T,

View File

@ -1,11 +1,11 @@
error: generic parameters with a default must be trailing error: generic parameters with a default must be trailing
--> $DIR/wrong-order.rs:3:10 --> $DIR/wrong-order.rs:1:10
| |
LL | struct A<T = u32, const N: usize> { LL | struct A<T = u32, const N: usize> {
| ^ | ^
error: generic parameters with a default must be trailing error: generic parameters with a default must be trailing
--> $DIR/wrong-order.rs:8:18 --> $DIR/wrong-order.rs:6:18
| |
LL | struct Foo<const N: u8 = 3, T>(T); LL | struct Foo<const N: u8 = 3, T>(T);
| ^ | ^

View File

@ -1,5 +1,5 @@
// check-pass // check-pass
#![feature(generic_const_exprs, const_generics_defaults)] #![feature(generic_const_exprs)]
#![allow(incomplete_features)] #![allow(incomplete_features)]
struct Foo<const N: usize, const M: usize = { N + 1 }>; struct Foo<const N: usize, const M: usize = { N + 1 }>;
struct Bar<const N: usize>(Foo<N, 3>); struct Bar<const N: usize>(Foo<N, 3>);

View File

@ -1,4 +1,4 @@
#![feature(adt_const_params, const_generics_defaults)] #![feature(adt_const_params)]
#![allow(incomplete_features)] #![allow(incomplete_features)]
#[derive(PartialEq, Eq)] #[derive(PartialEq, Eq)]

View File

@ -1,6 +1,5 @@
#![crate_type = "lib"] #![crate_type = "lib"]
#![feature(const_generics_defaults)] #![allow(dead_code)]
#![allow(incomplete_features, dead_code)]
struct Both<const N: usize=3, T> { struct Both<const N: usize=3, T> {
//~^ ERROR: generic parameters with a default must be //~^ ERROR: generic parameters with a default must be

View File

@ -1,5 +1,5 @@
error: generic parameters with a default must be trailing error: generic parameters with a default must be trailing
--> $DIR/const_default_first.rs:5:19 --> $DIR/const_default_first.rs:4:19
| |
LL | struct Both<const N: usize=3, T> { LL | struct Both<const N: usize=3, T> {
| ^ | ^

View File

@ -1,5 +1,4 @@
#![crate_type = "lib"] #![crate_type = "lib"]
#![feature(const_generics_defaults)]
fn foo<const SIZE: usize = 5usize>() {} fn foo<const SIZE: usize = 5usize>() {}
//~^ ERROR defaults for const parameters are //~^ ERROR defaults for const parameters are

View File

@ -1,5 +1,5 @@
error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
--> $DIR/default_function_param.rs:4:14 --> $DIR/default_function_param.rs:3:14
| |
LL | fn foo<const SIZE: usize = 5usize>() {} LL | fn foo<const SIZE: usize = 5usize>() {}
| ^^^^ | ^^^^

View File

@ -1,4 +1,4 @@
// check-pass
trait Foo<const KIND: bool = true> {} trait Foo<const KIND: bool = true> {}
//~^ ERROR default values for const generic parameters are experimental
fn main() {} fn main() {}

View File

@ -1,12 +0,0 @@
error[E0658]: default values for const generic parameters are experimental
--> $DIR/default_trait_param.rs:1:28
|
LL | trait Foo<const KIND: bool = true> {}
| ^^^^^^
|
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
= help: add `#![feature(const_generics_defaults)]` to the crate attributes to enable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.

View File

@ -1,5 +1,4 @@
// run-pass // run-pass
#![feature(const_generics_defaults)]
#![allow(dead_code)] #![allow(dead_code)]
struct Both<T=u32, const N: usize=3> { struct Both<T=u32, const N: usize=3> {

View File

@ -3,8 +3,6 @@ error: generic parameters with a default must be trailing
| |
LL | struct Bar<T = [u8; N], const N: usize>(T); LL | struct Bar<T = [u8; N], const N: usize>(T);
| ^ | ^
|
= note: using type defaults and const parameters in the same parameter list is currently not permitted
error: generic parameters may not be used in const operations error: generic parameters may not be used in const operations
--> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:5:44 --> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:5:44

View File

@ -1,11 +1,6 @@
// [full] run-pass // run-pass
// revisions: full min
// Verifies that having generic parameters after constants is permitted // Verifies that having generic parameters after constants is permitted
#![cfg_attr(full, feature(const_generics_defaults))]
#![cfg_attr(full, allow(incomplete_features))]
#[allow(dead_code)] #[allow(dead_code)]
struct A<const N: usize, T>(T); struct A<const N: usize, T>(T);
//[min]~^ ERROR type parameters must be declared prior to const parameters
fn main() {} fn main() {}

View File

@ -1,6 +1,4 @@
// check-pass // check-pass
#![feature(const_generics_defaults)]
#[derive(Clone, PartialEq, Debug)] #[derive(Clone, PartialEq, Debug)]
struct Example<T, const N: usize = 1usize>([T; N]); struct Example<T, const N: usize = 1usize>([T; N]);

View File

@ -1,9 +0,0 @@
#[cfg(FALSE)]
struct A<const N: usize = 3>;
//~^ ERROR default values for const generic parameters are experimental
#[cfg(FALSE)]
fn foo<const B: bool = false>() {}
//~^ ERROR default values for const generic parameters are experimental
fn main() {}

View File

@ -1,21 +0,0 @@
error[E0658]: default values for const generic parameters are experimental
--> $DIR/feature-gate-const_generics_defaults.rs:2:25
|
LL | struct A<const N: usize = 3>;
| ^^^
|
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
= help: add `#![feature(const_generics_defaults)]` to the crate attributes to enable
error[E0658]: default values for const generic parameters are experimental
--> $DIR/feature-gate-const_generics_defaults.rs:6:22
|
LL | fn foo<const B: bool = false>() {}
| ^^^^^^^
|
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
= help: add `#![feature(const_generics_defaults)]` to the crate attributes to enable
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`.

View File

@ -1,8 +1,7 @@
#![allow(dead_code)] #![allow(dead_code)]
#![feature(const_generics_defaults)]
// This test checks that generic parameter re-ordering diagnostic suggestions mention that // This test checks that generic parameter re-ordering diagnostic suggestions mention that
// consts come after types and lifetimes when the `const_generics_defaults` feature is enabled. // consts come after types and lifetimes.
// We cannot run rustfix on this test because of the above const generics warning. // We cannot run rustfix on this test because of the above const generics warning.
struct A; struct A;

View File

@ -1,5 +1,5 @@
error: lifetime parameters must be declared prior to type parameters error: lifetime parameters must be declared prior to type parameters
--> $DIR/issue-59508-1.rs:11:25 --> $DIR/issue-59508-1.rs:10:25
| |
LL | pub fn do_things<T, 'a, 'b: 'a>() { LL | pub fn do_things<T, 'a, 'b: 'a>() {
| ----^^--^^----- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b: 'a, T>` | ----^^--^^----- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b: 'a, T>`

View File

@ -2,7 +2,7 @@ error: lifetime parameters must be declared prior to type parameters
--> $DIR/issue-59508.rs:10:25 --> $DIR/issue-59508.rs:10:25
| |
LL | pub fn do_things<T, 'a, 'b: 'a>() { LL | pub fn do_things<T, 'a, 'b: 'a>() {
| ----^^--^^----- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b: 'a, T>` | ----^^--^^----- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b: 'a, T>`
error: aborting due to previous error error: aborting due to previous error

View File

@ -2,25 +2,25 @@ error: lifetime parameters must be declared prior to type parameters
--> $DIR/lifetime-before-type-params.rs:2:13 --> $DIR/lifetime-before-type-params.rs:2:13
| |
LL | fn first<T, 'a, 'b>() {} LL | fn first<T, 'a, 'b>() {}
| ----^^--^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>` | ----^^--^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, T>`
error: lifetime parameters must be declared prior to type parameters error: lifetime parameters must be declared prior to type parameters
--> $DIR/lifetime-before-type-params.rs:4:18 --> $DIR/lifetime-before-type-params.rs:4:18
| |
LL | fn second<'a, T, 'b>() {} LL | fn second<'a, T, 'b>() {}
| --------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>` | --------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, T>`
error: lifetime parameters must be declared prior to type parameters error: lifetime parameters must be declared prior to type parameters
--> $DIR/lifetime-before-type-params.rs:6:16 --> $DIR/lifetime-before-type-params.rs:6:16
| |
LL | fn third<T, U, 'a>() {} LL | fn third<T, U, 'a>() {}
| -------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T, U>` | -------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, T, U>`
error: lifetime parameters must be declared prior to type parameters error: lifetime parameters must be declared prior to type parameters
--> $DIR/lifetime-before-type-params.rs:8:18 --> $DIR/lifetime-before-type-params.rs:8:18
| |
LL | fn fourth<'a, T, 'b, U, 'c, V>() {} LL | fn fourth<'a, T, 'b, U, 'c, V>() {}
| --------^^-----^^---- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, 'c, T, U, V>` | --------^^-----^^---- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, 'c, T, U, V>`
error: aborting due to 4 previous errors error: aborting due to 4 previous errors

View File

@ -2,7 +2,7 @@ error: lifetime parameters must be declared prior to type parameters
--> $DIR/issue-80512-param-reordering-with-defaults.rs:3:18 --> $DIR/issue-80512-param-reordering-with-defaults.rs:3:18
| |
LL | struct S<T = (), 'a>(&'a T); LL | struct S<T = (), 'a>(&'a T);
| ---------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T = ()>` | ---------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, T = ()>`
error: aborting due to previous error error: aborting due to previous error

View File

@ -1,6 +1,3 @@
#![allow(incomplete_features)]
#![feature(const_generics_defaults)]
struct X<const N: u8>(); struct X<const N: u8>();
impl X<N> {} impl X<N> {}

View File

@ -1,5 +1,5 @@
error[E0412]: cannot find type `N` in this scope error[E0412]: cannot find type `N` in this scope
--> $DIR/missing-type-parameter2.rs:6:8 --> $DIR/missing-type-parameter2.rs:3:8
| |
LL | struct X<const N: u8>(); LL | struct X<const N: u8>();
| ------------------------ similarly named struct `X` defined here | ------------------------ similarly named struct `X` defined here
@ -17,7 +17,7 @@ LL | impl<N> X<N> {}
| +++ | +++
error[E0412]: cannot find type `N` in this scope error[E0412]: cannot find type `N` in this scope
--> $DIR/missing-type-parameter2.rs:9:28 --> $DIR/missing-type-parameter2.rs:6:28
| |
LL | impl<T, const A: u8 = 2> X<N> {} LL | impl<T, const A: u8 = 2> X<N> {}
| - ^ | - ^
@ -34,7 +34,7 @@ LL | impl<T, const A: u8 = 2, N> X<N> {}
| +++ | +++
error[E0412]: cannot find type `T` in this scope error[E0412]: cannot find type `T` in this scope
--> $DIR/missing-type-parameter2.rs:14:20 --> $DIR/missing-type-parameter2.rs:11:20
| |
LL | struct X<const N: u8>(); LL | struct X<const N: u8>();
| ------------------------ similarly named struct `X` defined here | ------------------------ similarly named struct `X` defined here
@ -52,7 +52,7 @@ LL | fn foo<T>(_: T) where T: Send {}
| +++ | +++
error[E0412]: cannot find type `T` in this scope error[E0412]: cannot find type `T` in this scope
--> $DIR/missing-type-parameter2.rs:14:11 --> $DIR/missing-type-parameter2.rs:11:11
| |
LL | struct X<const N: u8>(); LL | struct X<const N: u8>();
| ------------------------ similarly named struct `X` defined here | ------------------------ similarly named struct `X` defined here
@ -70,7 +70,7 @@ LL | fn foo<T>(_: T) where T: Send {}
| +++ | +++
error[E0412]: cannot find type `A` in this scope error[E0412]: cannot find type `A` in this scope
--> $DIR/missing-type-parameter2.rs:18:24 --> $DIR/missing-type-parameter2.rs:15:24
| |
LL | struct X<const N: u8>(); LL | struct X<const N: u8>();
| ------------------------ similarly named struct `X` defined here | ------------------------ similarly named struct `X` defined here
@ -88,7 +88,7 @@ LL | fn bar<const N: u8, A>(_: A) {}
| +++ | +++
error[E0747]: unresolved item provided when a constant was expected error[E0747]: unresolved item provided when a constant was expected
--> $DIR/missing-type-parameter2.rs:6:8 --> $DIR/missing-type-parameter2.rs:3:8
| |
LL | impl X<N> {} LL | impl X<N> {}
| ^ | ^
@ -99,13 +99,13 @@ LL | impl X<{ N }> {}
| + + | + +
error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
--> $DIR/missing-type-parameter2.rs:9:15 --> $DIR/missing-type-parameter2.rs:6:15
| |
LL | impl<T, const A: u8 = 2> X<N> {} LL | impl<T, const A: u8 = 2> X<N> {}
| ^ | ^
error[E0747]: unresolved item provided when a constant was expected error[E0747]: unresolved item provided when a constant was expected
--> $DIR/missing-type-parameter2.rs:9:28 --> $DIR/missing-type-parameter2.rs:6:28
| |
LL | impl<T, const A: u8 = 2> X<N> {} LL | impl<T, const A: u8 = 2> X<N> {}
| ^ | ^

View File

@ -2,7 +2,7 @@ error: lifetime parameters must be declared prior to type parameters
--> $DIR/issue-14303-enum.rs:1:15 --> $DIR/issue-14303-enum.rs:1:15
| |
LL | enum X<'a, T, 'b> { LL | enum X<'a, T, 'b> {
| --------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>` | --------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, T>`
error: aborting due to previous error error: aborting due to previous error

View File

@ -2,7 +2,7 @@ error: lifetime parameters must be declared prior to type parameters
--> $DIR/issue-14303-fn-def.rs:1:15 --> $DIR/issue-14303-fn-def.rs:1:15
| |
LL | fn foo<'a, T, 'b>(x: &'a T) {} LL | fn foo<'a, T, 'b>(x: &'a T) {}
| --------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>` | --------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, T>`
error: aborting due to previous error error: aborting due to previous error

View File

@ -2,7 +2,7 @@ error: lifetime parameters must be declared prior to type parameters
--> $DIR/issue-14303-impl.rs:3:13 --> $DIR/issue-14303-impl.rs:3:13
| |
LL | impl<'a, T, 'b> X<T> {} LL | impl<'a, T, 'b> X<T> {}
| --------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>` | --------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, T>`
error: aborting due to previous error error: aborting due to previous error

View File

@ -2,7 +2,7 @@ error: lifetime parameters must be declared prior to type parameters
--> $DIR/issue-14303-struct.rs:1:17 --> $DIR/issue-14303-struct.rs:1:17
| |
LL | struct X<'a, T, 'b> { LL | struct X<'a, T, 'b> {
| --------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>` | --------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, T>`
error: aborting due to previous error error: aborting due to previous error

View File

@ -2,7 +2,7 @@ error: lifetime parameters must be declared prior to type parameters
--> $DIR/issue-14303-trait.rs:1:18 --> $DIR/issue-14303-trait.rs:1:18
| |
LL | trait Foo<'a, T, 'b> {} LL | trait Foo<'a, T, 'b> {}
| --------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>` | --------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, T>`
error: aborting due to previous error error: aborting due to previous error

View File

@ -2,25 +2,25 @@ error: lifetime parameters must be declared prior to type parameters
--> $DIR/suggest-move-lifetimes.rs:1:13 --> $DIR/suggest-move-lifetimes.rs:1:13
| |
LL | struct A<T, 'a> { LL | struct A<T, 'a> {
| ----^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T>` | ----^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, T>`
error: lifetime parameters must be declared prior to type parameters error: lifetime parameters must be declared prior to type parameters
--> $DIR/suggest-move-lifetimes.rs:5:13 --> $DIR/suggest-move-lifetimes.rs:5:13
| |
LL | struct B<T, 'a, U> { LL | struct B<T, 'a, U> {
| ----^^---- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T, U>` | ----^^---- help: reorder the parameters: lifetimes, then consts and types: `<'a, T, U>`
error: lifetime parameters must be declared prior to type parameters error: lifetime parameters must be declared prior to type parameters
--> $DIR/suggest-move-lifetimes.rs:10:16 --> $DIR/suggest-move-lifetimes.rs:10:16
| |
LL | struct C<T, U, 'a> { LL | struct C<T, U, 'a> {
| -------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T, U>` | -------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, T, U>`
error: lifetime parameters must be declared prior to type parameters error: lifetime parameters must be declared prior to type parameters
--> $DIR/suggest-move-lifetimes.rs:15:16 --> $DIR/suggest-move-lifetimes.rs:15:16
| |
LL | struct D<T, U, 'a, 'b, V, 'c> { LL | struct D<T, U, 'a, 'b, V, 'c> {
| -------^^--^^-----^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, 'c, T, U, V>` | -------^^--^^-----^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, 'c, T, U, V>`
error: aborting due to 4 previous errors error: aborting due to 4 previous errors

View File

@ -1,5 +1,4 @@
#![warn(clippy::trailing_empty_array)] #![warn(clippy::trailing_empty_array)]
#![feature(const_generics_defaults)]
// Do lint: // Do lint:

View File

@ -1,5 +1,5 @@
error: trailing zero-sized array in a struct which is not marked with a `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute
--> $DIR/trailing_empty_array.rs:6:1 --> $DIR/trailing_empty_array.rs:5:1
| |
LL | / struct RarelyUseful { LL | / struct RarelyUseful {
LL | | field: i32, LL | | field: i32,
@ -11,7 +11,7 @@ LL | | }
= help: consider annotating `RarelyUseful` with `#[repr(C)]` or another `repr` attribute = help: consider annotating `RarelyUseful` with `#[repr(C)]` or another `repr` attribute
error: trailing zero-sized array in a struct which is not marked with a `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute
--> $DIR/trailing_empty_array.rs:11:1 --> $DIR/trailing_empty_array.rs:10:1
| |
LL | / struct OnlyField { LL | / struct OnlyField {
LL | | first_and_last: [usize; 0], LL | | first_and_last: [usize; 0],
@ -21,7 +21,7 @@ LL | | }
= help: consider annotating `OnlyField` with `#[repr(C)]` or another `repr` attribute = help: consider annotating `OnlyField` with `#[repr(C)]` or another `repr` attribute
error: trailing zero-sized array in a struct which is not marked with a `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute
--> $DIR/trailing_empty_array.rs:15:1 --> $DIR/trailing_empty_array.rs:14:1
| |
LL | / struct GenericArrayType<T> { LL | / struct GenericArrayType<T> {
LL | | field: i32, LL | | field: i32,
@ -32,7 +32,7 @@ LL | | }
= help: consider annotating `GenericArrayType` with `#[repr(C)]` or another `repr` attribute = help: consider annotating `GenericArrayType` with `#[repr(C)]` or another `repr` attribute
error: trailing zero-sized array in a struct which is not marked with a `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute
--> $DIR/trailing_empty_array.rs:21:1 --> $DIR/trailing_empty_array.rs:20:1
| |
LL | / struct OnlyAnotherAttribute { LL | / struct OnlyAnotherAttribute {
LL | | field: i32, LL | | field: i32,
@ -43,7 +43,7 @@ LL | | }
= help: consider annotating `OnlyAnotherAttribute` with `#[repr(C)]` or another `repr` attribute = help: consider annotating `OnlyAnotherAttribute` with `#[repr(C)]` or another `repr` attribute
error: trailing zero-sized array in a struct which is not marked with a `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute
--> $DIR/trailing_empty_array.rs:27:1 --> $DIR/trailing_empty_array.rs:26:1
| |
LL | / struct OnlyADeriveAttribute { LL | / struct OnlyADeriveAttribute {
LL | | field: i32, LL | | field: i32,
@ -54,7 +54,7 @@ LL | | }
= help: consider annotating `OnlyADeriveAttribute` with `#[repr(C)]` or another `repr` attribute = help: consider annotating `OnlyADeriveAttribute` with `#[repr(C)]` or another `repr` attribute
error: trailing zero-sized array in a struct which is not marked with a `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute
--> $DIR/trailing_empty_array.rs:33:1 --> $DIR/trailing_empty_array.rs:32:1
| |
LL | / struct ZeroSizedWithConst { LL | / struct ZeroSizedWithConst {
LL | | field: i32, LL | | field: i32,
@ -65,7 +65,7 @@ LL | | }
= help: consider annotating `ZeroSizedWithConst` with `#[repr(C)]` or another `repr` attribute = help: consider annotating `ZeroSizedWithConst` with `#[repr(C)]` or another `repr` attribute
error: trailing zero-sized array in a struct which is not marked with a `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute
--> $DIR/trailing_empty_array.rs:42:1 --> $DIR/trailing_empty_array.rs:41:1
| |
LL | / struct ZeroSizedWithConstFunction { LL | / struct ZeroSizedWithConstFunction {
LL | | field: i32, LL | | field: i32,
@ -76,7 +76,7 @@ LL | | }
= help: consider annotating `ZeroSizedWithConstFunction` with `#[repr(C)]` or another `repr` attribute = help: consider annotating `ZeroSizedWithConstFunction` with `#[repr(C)]` or another `repr` attribute
error: trailing zero-sized array in a struct which is not marked with a `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute
--> $DIR/trailing_empty_array.rs:50:1 --> $DIR/trailing_empty_array.rs:49:1
| |
LL | / struct ZeroSizedWithConstFunction2 { LL | / struct ZeroSizedWithConstFunction2 {
LL | | field: i32, LL | | field: i32,
@ -87,7 +87,7 @@ LL | | }
= help: consider annotating `ZeroSizedWithConstFunction2` with `#[repr(C)]` or another `repr` attribute = help: consider annotating `ZeroSizedWithConstFunction2` with `#[repr(C)]` or another `repr` attribute
error: trailing zero-sized array in a struct which is not marked with a `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute
--> $DIR/trailing_empty_array.rs:55:1 --> $DIR/trailing_empty_array.rs:54:1
| |
LL | struct ZeroSizedArrayWrapper([usize; 0]); LL | struct ZeroSizedArrayWrapper([usize; 0]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -95,7 +95,7 @@ LL | struct ZeroSizedArrayWrapper([usize; 0]);
= help: consider annotating `ZeroSizedArrayWrapper` with `#[repr(C)]` or another `repr` attribute = help: consider annotating `ZeroSizedArrayWrapper` with `#[repr(C)]` or another `repr` attribute
error: trailing zero-sized array in a struct which is not marked with a `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute
--> $DIR/trailing_empty_array.rs:57:1 --> $DIR/trailing_empty_array.rs:56:1
| |
LL | struct TupleStruct(i32, [usize; 0]); LL | struct TupleStruct(i32, [usize; 0]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -103,7 +103,7 @@ LL | struct TupleStruct(i32, [usize; 0]);
= help: consider annotating `TupleStruct` with `#[repr(C)]` or another `repr` attribute = help: consider annotating `TupleStruct` with `#[repr(C)]` or another `repr` attribute
error: trailing zero-sized array in a struct which is not marked with a `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute
--> $DIR/trailing_empty_array.rs:59:1 --> $DIR/trailing_empty_array.rs:58:1
| |
LL | / struct LotsOfFields { LL | / struct LotsOfFields {
LL | | f1: u32, LL | | f1: u32,