mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
Rollup merge of #85896 - BoxyUwU:remove-fixme-fwd-declared-const-default, r=petrochenkov
Add test for forward declared const param defaults
This commit is contained in:
commit
7ee817e4c4
@ -450,7 +450,7 @@ impl<'a> Resolver<'a> {
|
||||
err.span_label(shadowed_binding_span, msg);
|
||||
err
|
||||
}
|
||||
ResolutionError::ForwardDeclaredTyParam => {
|
||||
ResolutionError::ForwardDeclaredGenericParam => {
|
||||
let mut err = struct_span_err!(
|
||||
self.session,
|
||||
span,
|
||||
|
@ -242,7 +242,7 @@ enum ResolutionError<'a> {
|
||||
shadowed_binding_span: Span,
|
||||
},
|
||||
/// Error E0128: generic parameters with a default cannot use forward-declared identifiers.
|
||||
ForwardDeclaredTyParam, // FIXME(const_generics_defaults)
|
||||
ForwardDeclaredGenericParam,
|
||||
/// ERROR E0770: the type of const parameters must not depend on other generic parameters.
|
||||
ParamInTyOfConstParam(Symbol),
|
||||
/// generic parameters must not be used inside const evaluations.
|
||||
@ -2608,7 +2608,7 @@ impl<'a> Resolver<'a> {
|
||||
let res_error = if rib_ident.name == kw::SelfUpper {
|
||||
ResolutionError::SelfInTyParamDefault
|
||||
} else {
|
||||
ResolutionError::ForwardDeclaredTyParam
|
||||
ResolutionError::ForwardDeclaredGenericParam
|
||||
};
|
||||
self.report_error(span, res_error);
|
||||
}
|
||||
|
15
src/test/ui/const-generics/defaults/forward-declared.rs
Normal file
15
src/test/ui/const-generics/defaults/forward-declared.rs
Normal file
@ -0,0 +1,15 @@
|
||||
#![feature(const_generics_defaults)]
|
||||
|
||||
struct Foo<const N: usize = M, const M: usize = 10>;
|
||||
//~^ ERROR generic parameters with a default cannot use forward declared identifiers
|
||||
|
||||
enum Bar<const N: usize = M, const M: usize = 10> {}
|
||||
//~^ ERROR generic parameters with a default cannot use forward declared identifiers
|
||||
|
||||
struct Foo2<const N: usize = N>;
|
||||
//~^ ERROR generic parameters with a default cannot use forward declared identifiers
|
||||
|
||||
enum Bar2<const N: usize = N> {}
|
||||
//~^ ERROR generic parameters with a default cannot use forward declared identifiers
|
||||
|
||||
fn main() {}
|
27
src/test/ui/const-generics/defaults/forward-declared.stderr
Normal file
27
src/test/ui/const-generics/defaults/forward-declared.stderr
Normal file
@ -0,0 +1,27 @@
|
||||
error[E0128]: generic parameters with a default cannot use forward declared identifiers
|
||||
--> $DIR/forward-declared.rs:3:29
|
||||
|
|
||||
LL | struct Foo<const N: usize = M, const M: usize = 10>;
|
||||
| ^ defaulted generic parameters cannot be forward declared
|
||||
|
||||
error[E0128]: generic parameters with a default cannot use forward declared identifiers
|
||||
--> $DIR/forward-declared.rs:6:27
|
||||
|
|
||||
LL | enum Bar<const N: usize = M, const M: usize = 10> {}
|
||||
| ^ defaulted generic parameters cannot be forward declared
|
||||
|
||||
error[E0128]: generic parameters with a default cannot use forward declared identifiers
|
||||
--> $DIR/forward-declared.rs:9:30
|
||||
|
|
||||
LL | struct Foo2<const N: usize = N>;
|
||||
| ^ defaulted generic parameters cannot be forward declared
|
||||
|
||||
error[E0128]: generic parameters with a default cannot use forward declared identifiers
|
||||
--> $DIR/forward-declared.rs:12:28
|
||||
|
|
||||
LL | enum Bar2<const N: usize = N> {}
|
||||
| ^ defaulted generic parameters cannot be forward declared
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0128`.
|
Loading…
Reference in New Issue
Block a user