Don't abort early when collecting const generics
This commit is contained in:
parent
2a1b6c52d3
commit
425fb58cac
@ -1053,12 +1053,13 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty
|
||||
);
|
||||
}
|
||||
|
||||
// Emit an error, but skip the parameter rather than aborting to
|
||||
// continue to get other errors.
|
||||
tcx.sess.struct_span_err(
|
||||
param.span,
|
||||
"const generics in any position are currently unsupported",
|
||||
).emit();
|
||||
tcx.sess.abort_if_errors();
|
||||
bug!();
|
||||
None
|
||||
}
|
||||
_ => None,
|
||||
}),
|
||||
|
@ -8,6 +8,7 @@ fn foo<const X: (), T>(_: T) {
|
||||
|
||||
fn bar<const X: (), 'a>(_: &'a ()) {
|
||||
//~^ ERROR lifetime parameters must be declared prior to const parameters
|
||||
//~^^ ERROR const generics in any position are currently unsupported
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -22,5 +22,11 @@ error: const generics in any position are currently unsupported
|
||||
LL | fn foo<const X: (), T>(_: T) {
|
||||
| ^
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: const generics in any position are currently unsupported
|
||||
--> $DIR/const-param-before-other-params.rs:9:14
|
||||
|
|
||||
LL | fn bar<const X: (), 'a>(_: &'a ()) {
|
||||
| ^
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
@ -2,5 +2,6 @@ fn foo<const X: ()>() {} //~ ERROR const generics are unstable
|
||||
//~^ const generics in any position are currently unsupported
|
||||
|
||||
struct Foo<const X: usize>([(); X]); //~ ERROR const generics are unstable
|
||||
//~^ const generics in any position are currently unsupported
|
||||
|
||||
fn main() {}
|
||||
|
@ -20,6 +20,12 @@ error: const generics in any position are currently unsupported
|
||||
LL | fn foo<const X: ()>() {} //~ ERROR const generics are unstable
|
||||
| ^
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: const generics in any position are currently unsupported
|
||||
--> $DIR/feature-gate-const_generics.rs:4:18
|
||||
|
|
||||
LL | struct Foo<const X: usize>([(); X]); //~ ERROR const generics are unstable
|
||||
| ^
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
Loading…
x
Reference in New Issue
Block a user