Skip to content

Commit 0d54f57

Browse files
committed
impl review
1 parent a5a5ca0 commit 0d54f57

File tree

10 files changed

+26
-19
lines changed

10 files changed

+26
-19
lines changed

src/librustc_ast_passes/feature_gate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
530530
&self,
531531
|x: &Features| x.const_generics || x.min_const_generics,
532532
param.ident.span,
533-
sym::const_generics,
533+
sym::min_const_generics,
534534
"const generics are unstable"
535535
);
536536
}

src/librustc_parse/parser/generics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl<'a> Parser<'a> {
5454
self.expect(&token::Colon)?;
5555
let ty = self.parse_ty()?;
5656

57-
self.sess.gated_spans.gate(sym::const_generics, const_span.to(self.prev_token.span));
57+
self.sess.gated_spans.gate(sym::min_const_generics, const_span.to(self.prev_token.span));
5858

5959
Ok(GenericParam {
6060
ident,

src/librustc_typeck/collect/type_of.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,8 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
330330
let err = if tcx.features().min_const_generics {
331331
match ty.kind {
332332
ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Error(_) => None,
333+
ty::FnPtr(_) => Some("function pointers"),
334+
ty::RawPtr(_) => Some("raw pointers"),
333335
_ => {
334336
err_ty_str = format!("`{}`", ty);
335337
Some(err_ty_str.as_str())
@@ -352,7 +354,8 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
352354
);
353355

354356
if tcx.features().min_const_generics {
355-
err.note("the only supported types are integers, `bool` and `char`").emit()
357+
err.note("the only supported types are integers, `bool` and `char`")
358+
.note("more complex types are supported with `#[feature(const_generics)]`").emit()
356359
} else {
357360
err.emit();
358361
}

src/test/ui/const-generics/const-param-in-trait-ungated.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ error[E0658]: const generics are unstable
44
LL | trait Trait<const T: ()> {}
55
| ^
66
|
7-
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
8-
= help: add `#![feature(const_generics)]` to the crate attributes to enable
7+
= note: see issue #74878 <https://github.com/rust-lang/rust/issues/74878> for more information
8+
= help: add `#![feature(min_const_generics)]` to the crate attributes to enable
99

1010
error: aborting due to previous error
1111

src/test/ui/const-generics/const-param-type-depends-on-type-param-ungated.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ error[E0658]: const generics are unstable
1010
LL | struct B<T, const N: T>(PhantomData<[T; N]>);
1111
| ^
1212
|
13-
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
14-
= help: add `#![feature(const_generics)]` to the crate attributes to enable
13+
= note: see issue #74878 <https://github.com/rust-lang/rust/issues/74878> for more information
14+
= help: add `#![feature(min_const_generics)]` to the crate attributes to enable
1515

1616
error: aborting due to 2 previous errors
1717

src/test/ui/const-generics/issues/issue-60263.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ error[E0658]: const generics are unstable
44
LL | struct B<const I: u8>;
55
| ^
66
|
7-
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
8-
= help: add `#![feature(const_generics)]` to the crate attributes to enable
7+
= note: see issue #74878 <https://github.com/rust-lang/rust/issues/74878> for more information
8+
= help: add `#![feature(min_const_generics)]` to the crate attributes to enable
99

1010
error: aborting due to previous error
1111

src/test/ui/const-generics/min_const_generics/complex-types.stderr

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | struct Foo<const N: [u8; 0]>;
55
| ^^^^^^^
66
|
77
= note: the only supported types are integers, `bool` and `char`
8+
= note: more complex types are supported with `#[feature(const_generics)]`
89

910
error: using `()` as const generic parameters is forbidden
1011
--> $DIR/complex-types.rs:6:21
@@ -13,6 +14,7 @@ LL | struct Bar<const N: ()>;
1314
| ^^
1415
|
1516
= note: the only supported types are integers, `bool` and `char`
17+
= note: more complex types are supported with `#[feature(const_generics)]`
1618

1719
error: using `No` as const generic parameters is forbidden
1820
--> $DIR/complex-types.rs:12:21
@@ -21,6 +23,7 @@ LL | struct Fez<const N: No>;
2123
| ^^
2224
|
2325
= note: the only supported types are integers, `bool` and `char`
26+
= note: more complex types are supported with `#[feature(const_generics)]`
2427

2528
error: using `&'static u8` as const generic parameters is forbidden
2629
--> $DIR/complex-types.rs:15:21
@@ -29,6 +32,7 @@ LL | struct Faz<const N: &'static u8>;
2932
| ^^^^^^^^^^^
3033
|
3134
= note: the only supported types are integers, `bool` and `char`
35+
= note: more complex types are supported with `#[feature(const_generics)]`
3236

3337
error: aborting due to 4 previous errors
3438

src/test/ui/const-generics/min_const_generics/feature-gate-min_const_generics.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ error[E0658]: const generics are unstable
44
LL | fn test<const N: usize>() {}
55
| ^
66
|
7-
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
8-
= help: add `#![feature(const_generics)]` to the crate attributes to enable
7+
= note: see issue #74878 <https://github.com/rust-lang/rust/issues/74878> for more information
8+
= help: add `#![feature(min_const_generics)]` to the crate attributes to enable
99

1010
error: aborting due to previous error
1111

src/test/ui/feature-gates/feature-gate-const_generics-ptr.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ error[E0658]: const generics are unstable
44
LL | struct ConstFn<const F: fn()>;
55
| ^
66
|
7-
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
8-
= help: add `#![feature(const_generics)]` to the crate attributes to enable
7+
= note: see issue #74878 <https://github.com/rust-lang/rust/issues/74878> for more information
8+
= help: add `#![feature(min_const_generics)]` to the crate attributes to enable
99

1010
error[E0658]: const generics are unstable
1111
--> $DIR/feature-gate-const_generics-ptr.rs:5:23
1212
|
1313
LL | struct ConstPtr<const P: *const u32>;
1414
| ^
1515
|
16-
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
17-
= help: add `#![feature(const_generics)]` to the crate attributes to enable
16+
= note: see issue #74878 <https://github.com/rust-lang/rust/issues/74878> for more information
17+
= help: add `#![feature(min_const_generics)]` to the crate attributes to enable
1818

1919
error: using function pointers as const generic parameters is forbidden
2020
--> $DIR/feature-gate-const_generics-ptr.rs:1:25

src/test/ui/feature-gates/feature-gate-const_generics.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ error[E0658]: const generics are unstable
44
LL | fn foo<const X: ()>() {}
55
| ^
66
|
7-
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
8-
= help: add `#![feature(const_generics)]` to the crate attributes to enable
7+
= note: see issue #74878 <https://github.com/rust-lang/rust/issues/74878> for more information
8+
= help: add `#![feature(min_const_generics)]` to the crate attributes to enable
99

1010
error[E0658]: const generics are unstable
1111
--> $DIR/feature-gate-const_generics.rs:3:18
1212
|
1313
LL | struct Foo<const X: usize>([(); X]);
1414
| ^
1515
|
16-
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
17-
= help: add `#![feature(const_generics)]` to the crate attributes to enable
16+
= note: see issue #74878 <https://github.com/rust-lang/rust/issues/74878> for more information
17+
= help: add `#![feature(min_const_generics)]` to the crate attributes to enable
1818

1919
error: aborting due to 2 previous errors
2020

0 commit comments

Comments
 (0)